WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jul 2008 03:43:36 +0000 (03:43 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jul 2008 03:43:36 +0000 (03:43 +0000)
2008-07-23  Beth Dakin  <bdakin@apple.com>

        Reviewed by Dan Bernstein.

        Fix for <rdar://problem/5997215> display: table-row-group
        for :before content causes a crash

        The actual bug fix here is to ddd the generated content container
        as a child before adding any of the generated content to the
        container. There are two correctness fixes as well that deal with
        style changes and correctly.

        This patch also makes Node::diff() a static function.

        * dom/Node.cpp:
        (WebCore::Node::diff):
        * dom/Node.h:
        (WebCore::Node::):
        (WebCore::Node::recalcStyle):
        * rendering/RenderContainer.cpp:
        (WebCore::findBeforeAfterParent):
        (WebCore::RenderContainer::updateBeforeAfterContentForContainer):
        * svg/SVGUseElement.cpp:
        (WebCore::SVGUseElement::recalcStyle):

LayoutTests:

2008-07-23  Beth Dakin  <bdakin@apple.com>

        Reviewed by Dan Bernstein.

        Tests for <rdar://problem/5997215> display: table-row-group
        for :before content causes a crash

        * fast/css-generated-content/table-row-group-to-inline.html: Added.
        * fast/css-generated-content/table-row-group-with-before.html: Added.
        * fast/css-generated-content/table-row-with-before.html: Added.
        * fast/css-generated-content/table-with-before.html: Added.
        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.checksum: Added.
        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png: Added.
        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt: Added.
        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.checksum: Added.
        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png: Added.
        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.txt: Added.
        * platform/mac/fast/css-generated-content/table-row-with-before-expected.checksum: Added.
        * platform/mac/fast/css-generated-content/table-row-with-before-expected.png: Added.
        * platform/mac/fast/css-generated-content/table-row-with-before-expected.txt: Added.
        * platform/mac/fast/css-generated-content/table-with-before-expected.checksum: Added.
        * platform/mac/fast/css-generated-content/table-with-before-expected.png: Added.
        * platform/mac/fast/css-generated-content/table-with-before-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35318 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-generated-content/table-row-group-to-inline.html [new file with mode: 0644]
LayoutTests/fast/css-generated-content/table-row-group-with-before.html [new file with mode: 0644]
LayoutTests/fast/css-generated-content/table-row-with-before.html [new file with mode: 0644]
LayoutTests/fast/css-generated-content/table-with-before.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/rendering/RenderContainer.cpp
WebCore/svg/SVGUseElement.cpp

index f566caa0fbe49c597241a554d7d035a352f53a12..05920be9507d9f66b7f2cb291398715b0f75278d 100644 (file)
@@ -1,3 +1,27 @@
+2008-07-23  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Tests for <rdar://problem/5997215> display: table-row-group 
+        for :before content causes a crash
+
+        * fast/css-generated-content/table-row-group-to-inline.html: Added.
+        * fast/css-generated-content/table-row-group-with-before.html: Added.
+        * fast/css-generated-content/table-row-with-before.html: Added.
+        * fast/css-generated-content/table-with-before.html: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.checksum: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.checksum: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png: Added.
+        * platform/mac/fast/css-generated-content/table-row-group-with-before-expected.txt: Added.
+        * platform/mac/fast/css-generated-content/table-row-with-before-expected.checksum: Added.
+        * platform/mac/fast/css-generated-content/table-row-with-before-expected.png: Added.
+        * platform/mac/fast/css-generated-content/table-row-with-before-expected.txt: Added.
+        * platform/mac/fast/css-generated-content/table-with-before-expected.checksum: Added.
+        * platform/mac/fast/css-generated-content/table-with-before-expected.png: Added.
+        * platform/mac/fast/css-generated-content/table-with-before-expected.txt: Added.
+
 2008-07-23  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Geoff Garen.
diff --git a/LayoutTests/fast/css-generated-content/table-row-group-to-inline.html b/LayoutTests/fast/css-generated-content/table-row-group-to-inline.html
new file mode 100644 (file)
index 0000000..e7a68f5
--- /dev/null
@@ -0,0 +1,21 @@
+<style>
+.first:before {
+    display: table-row-group;
+    content: "hello";
+}
+
+.second:before {
+    display: inline;
+    content: "hello";
+}
+</style>
+<span>This test passes if it does not crash, and if we successfully destroy the table-section generated content.</span>
+<br/>
+<ul>
+<li class="first" id="me">test</li>
+</ul>
+
+<script>
+    var thing = document.getElementById("me");
+    thing.className = "second";
+</script>
diff --git a/LayoutTests/fast/css-generated-content/table-row-group-with-before.html b/LayoutTests/fast/css-generated-content/table-row-group-with-before.html
new file mode 100644 (file)
index 0000000..d300b69
--- /dev/null
@@ -0,0 +1,11 @@
+<style>
+li:before {
+    display: table-row-group;
+    content: "hello";
+}
+</style>
+<span>This test passes if it does not crash.</span>
+<br/>
+<ul>
+<li>test</li>
+</ul>
diff --git a/LayoutTests/fast/css-generated-content/table-row-with-before.html b/LayoutTests/fast/css-generated-content/table-row-with-before.html
new file mode 100644 (file)
index 0000000..b50bef3
--- /dev/null
@@ -0,0 +1,11 @@
+<style>
+li:before {
+    display: table-row;
+    content: "hello";
+}
+</style>
+<span>This test passes if it does not crash.</span>
+<br/>
+<ul>
+<li>test</li>
+</ul>
diff --git a/LayoutTests/fast/css-generated-content/table-with-before.html b/LayoutTests/fast/css-generated-content/table-with-before.html
new file mode 100644 (file)
index 0000000..5e0eb4a
--- /dev/null
@@ -0,0 +1,11 @@
+<style>
+li:before {
+    display: table;
+    content: "hello";
+}
+</style>
+<span>This test passes if it does not crash.</span>
+<br/>
+<ul>
+<li>test</li>
+</ul>
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.checksum b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.checksum
new file mode 100644 (file)
index 0000000..16f6dc9
--- /dev/null
@@ -0,0 +1 @@
+fae95b5097c0a14780934de1ba50c740
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png
new file mode 100644 (file)
index 0000000..2d4fe4b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt
new file mode 100644 (file)
index 0000000..d023f3a
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderInline {SPAN} at (0,0) size 638x18
+          RenderText {#text} at (0,0) size 638x18
+            text run at (0,0) width 638: "This test passes if it does not crash, and if we successfully destroy the table-section generated content."
+        RenderText {#text} at (638,0) size 4x18
+          text run at (638,0) width 4: " "
+        RenderBR {BR} at (642,14) size 0x0
+      RenderBlock {UL} at (0,34) size 784x36
+        RenderListItem {LI} at (40,0) size 744x36
+          RenderBlock (anonymous) at (0,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+            RenderInline (generated) at (0,0) size 31x18
+              RenderText at (0,0) size 31x18
+                text run at (0,0) width 31: "hello"
+          RenderTable at (0,18) size 0x0
+          RenderBlock (anonymous) at (0,18) size 744x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "test"
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.checksum b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.checksum
new file mode 100644 (file)
index 0000000..64f7c4f
--- /dev/null
@@ -0,0 +1 @@
+7cc6ec31a80164e7c2d1fbca3b99ca11
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png
new file mode 100644 (file)
index 0000000..8ca5100
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.txt b/LayoutTests/platform/mac/fast/css-generated-content/table-row-group-with-before-expected.txt
new file mode 100644 (file)
index 0000000..24fc484
--- /dev/null
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderInline {SPAN} at (0,0) size 220x18
+          RenderText {#text} at (0,0) size 220x18
+            text run at (0,0) width 220: "This test passes if it does not crash."
+        RenderText {#text} at (220,0) size 4x18
+          text run at (220,0) width 4: " "
+        RenderBR {BR} at (224,14) size 0x0
+      RenderBlock {UL} at (0,34) size 784x54
+        RenderListItem {LI} at (40,0) size 744x54
+          RenderBlock (anonymous) at (0,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+          RenderTable at (0,18) size 31x18
+            RenderTableSection (anonymous) at (0,0) size 31x18
+              RenderTableRow (anonymous) at (0,0) size 31x18
+                RenderTableCell (anonymous) at (0,0) size 31x18 [r=0 c=0 rs=1 cs=1]
+                  RenderText at (0,0) size 31x18
+                    text run at (0,0) width 31: "hello"
+          RenderBlock (anonymous) at (0,36) size 744x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "test"
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.checksum b/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.checksum
new file mode 100644 (file)
index 0000000..64f7c4f
--- /dev/null
@@ -0,0 +1 @@
+7cc6ec31a80164e7c2d1fbca3b99ca11
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.png b/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.png
new file mode 100644 (file)
index 0000000..8ca5100
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.txt b/LayoutTests/platform/mac/fast/css-generated-content/table-row-with-before-expected.txt
new file mode 100644 (file)
index 0000000..24fc484
--- /dev/null
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderInline {SPAN} at (0,0) size 220x18
+          RenderText {#text} at (0,0) size 220x18
+            text run at (0,0) width 220: "This test passes if it does not crash."
+        RenderText {#text} at (220,0) size 4x18
+          text run at (220,0) width 4: " "
+        RenderBR {BR} at (224,14) size 0x0
+      RenderBlock {UL} at (0,34) size 784x54
+        RenderListItem {LI} at (40,0) size 744x54
+          RenderBlock (anonymous) at (0,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+          RenderTable at (0,18) size 31x18
+            RenderTableSection (anonymous) at (0,0) size 31x18
+              RenderTableRow (anonymous) at (0,0) size 31x18
+                RenderTableCell (anonymous) at (0,0) size 31x18 [r=0 c=0 rs=1 cs=1]
+                  RenderText at (0,0) size 31x18
+                    text run at (0,0) width 31: "hello"
+          RenderBlock (anonymous) at (0,36) size 744x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "test"
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.checksum b/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.checksum
new file mode 100644 (file)
index 0000000..64f7c4f
--- /dev/null
@@ -0,0 +1 @@
+7cc6ec31a80164e7c2d1fbca3b99ca11
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.png b/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.png
new file mode 100644 (file)
index 0000000..8ca5100
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.txt b/LayoutTests/platform/mac/fast/css-generated-content/table-with-before-expected.txt
new file mode 100644 (file)
index 0000000..24fc484
--- /dev/null
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderInline {SPAN} at (0,0) size 220x18
+          RenderText {#text} at (0,0) size 220x18
+            text run at (0,0) width 220: "This test passes if it does not crash."
+        RenderText {#text} at (220,0) size 4x18
+          text run at (220,0) width 4: " "
+        RenderBR {BR} at (224,14) size 0x0
+      RenderBlock {UL} at (0,34) size 784x54
+        RenderListItem {LI} at (40,0) size 744x54
+          RenderBlock (anonymous) at (0,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+          RenderTable at (0,18) size 31x18
+            RenderTableSection (anonymous) at (0,0) size 31x18
+              RenderTableRow (anonymous) at (0,0) size 31x18
+                RenderTableCell (anonymous) at (0,0) size 31x18 [r=0 c=0 rs=1 cs=1]
+                  RenderText at (0,0) size 31x18
+                    text run at (0,0) width 31: "hello"
+          RenderBlock (anonymous) at (0,36) size 744x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "test"
index 4bd2571b098471b59f5c44acc93144637b778097..0c59a39cafaa54a11d92fff54536148c9aacd2a2 100644 (file)
@@ -1,3 +1,28 @@
+2008-07-23  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for <rdar://problem/5997215> display: table-row-group 
+        for :before content causes a crash
+        The actual bug fix here is to ddd the generated content container 
+        as a child before adding any of the generated content to the 
+        container. There are two correctness fixes as well that deal with 
+        style changes and correctly.
+
+        This patch also makes Node::diff() a static function.
+
+        * dom/Node.cpp:
+        (WebCore::Node::diff):
+        * dom/Node.h:
+        (WebCore::Node::):
+        (WebCore::Node::recalcStyle):
+        * rendering/RenderContainer.cpp:
+        (WebCore::findBeforeAfterParent):
+        (WebCore::RenderContainer::updateBeforeAfterContentForContainer):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::recalcStyle):
+
 2008-07-23  Timothy Hatcher  <timothy@apple.com>
 
         Updates the elements DOM tree when nodes are added or removed from
index bbeba949892252e6d32cb708466241a368d6a33f..b5fdead6bb4a3979c0e3b196072e6178fab4967f 100644 (file)
@@ -112,6 +112,50 @@ void Node::stopIgnoringLeaks()
 #endif
 }
 
+Node::StyleChange Node::diff( RenderStyle *s1, RenderStyle *s2 )
+{
+    // FIXME: The behavior of this function is just totally wrong.  It doesn't handle
+    // explicit inheritance of non-inherited properties and so you end up not re-resolving
+    // style in cases where you need to.
+    StyleChange ch = NoInherit;
+    EDisplay display1 = s1 ? s1->display() : NONE;
+    bool fl1 = s1 && s1->hasPseudoStyle(RenderStyle::FIRST_LETTER);
+    EDisplay display2 = s2 ? s2->display() : NONE;
+    bool fl2 = s2 && s2->hasPseudoStyle(RenderStyle::FIRST_LETTER);
+        
+    if (display1 != display2 || fl1 != fl2 || (s1 && s2 && !s1->contentDataEquivalent(s2)))
+        ch = Detach;
+    else if (!s1 || !s2)
+        ch = Inherit;
+    else if (*s1 == *s2)
+        ch = NoChange;
+    else if (s1->inheritedNotEqual(s2))
+        ch = Inherit;
+    
+    // If the pseudoStyles have changed, we want any StyleChange that is not NoChange
+    // because setStyle will do the right thing with anything else.
+    if (ch == NoChange && s1->hasPseudoStyle(RenderStyle::BEFORE)) {
+        RenderStyle* ps2 = s2->getPseudoStyle(RenderStyle::BEFORE);
+        if (!ps2)
+            ch = NoInherit;
+        else {
+            RenderStyle* ps1 = s1->getPseudoStyle(RenderStyle::BEFORE);
+            ch = ps1 && *ps1 == *ps2 ? NoChange : NoInherit;
+        }
+    }
+    if (ch == NoChange && s1->hasPseudoStyle(RenderStyle::AFTER)) {
+        RenderStyle* ps2 = s2->getPseudoStyle(RenderStyle::AFTER);
+        if (!ps2)
+            ch = NoInherit;
+        else {
+            RenderStyle* ps1 = s1->getPseudoStyle(RenderStyle::AFTER);
+            ch = ps2 && *ps1 == *ps2 ? NoChange : NoInherit;
+        }
+    }
+    
+    return ch;
+}
+
 Node::Node(Document *doc)
     : m_document(doc),
       m_previous(0),
@@ -792,50 +836,6 @@ bool Node::childAllowed(Node* newChild)
     return childTypeAllowed(newChild->nodeType());
 }
 
-Node::StyleChange Node::diff( RenderStyle *s1, RenderStyle *s2 ) const
-{
-    // FIXME: The behavior of this function is just totally wrong.  It doesn't handle
-    // explicit inheritance of non-inherited properties and so you end up not re-resolving
-    // style in cases where you need to.
-    StyleChange ch = NoInherit;
-    EDisplay display1 = s1 ? s1->display() : NONE;
-    bool fl1 = s1 && s1->hasPseudoStyle(RenderStyle::FIRST_LETTER);
-    EDisplay display2 = s2 ? s2->display() : NONE;
-    bool fl2 = s2 && s2->hasPseudoStyle(RenderStyle::FIRST_LETTER);
-        
-    if (display1 != display2 || fl1 != fl2 || (s1 && s2 && !s1->contentDataEquivalent(s2)))
-        ch = Detach;
-    else if (!s1 || !s2)
-        ch = Inherit;
-    else if (*s1 == *s2)
-        ch = NoChange;
-    else if (s1->inheritedNotEqual(s2))
-        ch = Inherit;
-    
-    // If the pseudoStyles have changed, we want any StyleChange that is not NoChange
-    // because setStyle will do the right thing with anything else.
-    if (ch == NoChange && s1->hasPseudoStyle(RenderStyle::BEFORE)) {
-        RenderStyle* ps2 = s2->getPseudoStyle(RenderStyle::BEFORE);
-        if (!ps2)
-            ch = NoInherit;
-        else {
-            RenderStyle* ps1 = s1->getPseudoStyle(RenderStyle::BEFORE);
-            ch = ps1 && *ps1 == *ps2 ? NoChange : NoInherit;
-        }
-    }
-    if (ch == NoChange && s1->hasPseudoStyle(RenderStyle::AFTER)) {
-        RenderStyle* ps2 = s2->getPseudoStyle(RenderStyle::AFTER);
-        if (!ps2)
-            ch = NoInherit;
-        else {
-            RenderStyle* ps1 = s1->getPseudoStyle(RenderStyle::AFTER);
-            ch = ps2 && *ps1 == *ps2 ? NoChange : NoInherit;
-        }
-    }
-    
-    return ch;
-}
-
 void Node::attach()
 {
     ASSERT(!attached());
index 67d9d77c11bc505f7fed9edef4bf730dd8e86aa2..8d6bab2c329797974240a0540a53b7dcaaa6fc07 100644 (file)
@@ -96,6 +96,9 @@ public:
     static void startIgnoringLeaks();
     static void stopIgnoringLeaks();
 
+    enum StyleChange { NoChange, NoInherit, Inherit, Detach, Force };    
+    static StyleChange diff(RenderStyle*, RenderStyle*);
+
     Node(Document*);
     virtual ~Node();
 
@@ -293,9 +296,7 @@ public:
     virtual bool shouldUseInputMethod() const;
     virtual IntRect getRect() const;
 
-    enum StyleChange { NoChange, NoInherit, Inherit, Detach, Force };
     virtual void recalcStyle(StyleChange = NoChange) { }
-    StyleChange diff(RenderStyle*, RenderStyle*) const;
 
     unsigned nodeIndex() const;
 
index 79e02688782745facb423bbce8ca7ed6f0321382..63b35dd9cd4d726d5f8e0b3ca9a1818d19a25808 100644 (file)
@@ -243,6 +243,18 @@ void RenderContainer::updateBeforeAfterContent(RenderStyle::PseudoId type)
     updateBeforeAfterContentForContainer(type, this);
 }
 
+static RenderObject* findBeforeAfterParent(RenderObject* object)
+{
+    // Only table parts need to search for the :before or :after parent
+    if (!(object->isTable() || object->isTableSection() || object->isTableRow()))
+        return object;
+
+    RenderObject* beforeAfterParent = object;
+    while (beforeAfterParent && !(beforeAfterParent->isText() || beforeAfterParent->isImage()))
+        beforeAfterParent = beforeAfterParent->firstChild();
+    return beforeAfterParent;
+}
+
 void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId type, RenderContainer* styledObject)
 {
     // In CSS2, before/after pseudo-content cannot nest.  Check this first.
@@ -271,7 +283,7 @@ void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId
     // If we don't want generated content any longer, or if we have generated content, but it's no longer
     // identical to the new content data we want to build render objects for, then we nuke all
     // of the old generated content.
-    if (!newContentWanted || (oldContentPresent && !child->style()->contentDataEquivalent(pseudoElementStyle))) {
+    if (!newContentWanted || (oldContentPresent && Node::diff(child->style(), pseudoElementStyle) == Node::Detach)) {
         // Nuke the child. 
         if (child && child->style()->styleType() == type) {
             oldContentPresent = false;
@@ -300,9 +312,13 @@ void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId
             // style information with the new pseudo-element style.
             child->setStyle(pseudoElementStyle);
 
+            RenderObject* beforeAfterParent = findBeforeAfterParent(child);
+            if (!beforeAfterParent)
+                return;
+
             // Note that if we ever support additional types of generated content (which should be way off
             // in the future), this code will need to be patched.
-            for (RenderObject* genChild = child->firstChild(); genChild; genChild = genChild->nextSibling()) {
+            for (RenderObject* genChild = beforeAfterParent->firstChild(); genChild; genChild = genChild->nextSibling()) {
                 if (genChild->isText())
                     // Generated text content is a child whose style also needs to be set to the pseudo-element style.
                     genChild->setStyle(pseudoElementStyle);
@@ -357,15 +373,11 @@ void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId
                 // to find the original content properly.
                 generatedContentContainer = RenderObject::createObject(document(), pseudoElementStyle);
                 generatedContentContainer->setStyle(pseudoElementStyle);
+                addChild(generatedContentContainer, insertBefore);
             }
             generatedContentContainer->addChild(renderer);
         }
     }
-
-    // Add the pseudo after we've installed all our content so that addChild will be able to find the text
-    // inside the inline for e.g., first-letter styling.
-    if (generatedContentContainer)
-        addChild(generatedContentContainer, insertBefore);
 }
 
 bool RenderContainer::isAfterContent(RenderObject* child) const
index d61060b4f10458fc06800d1abbfc373e6b2b7dd4..f5a68d2f584c061c7a0ff6e0494509c4d8e04c1f 100644 (file)
@@ -169,7 +169,7 @@ void SVGUseElement::recalcStyle(StyleChange change)
     // as the shadow tree root element has no (direct) parent node. Yes, shadow trees are tricky.
     if (change >= Inherit || m_shadowTreeRootElement->changed()) {
         RenderStyle* newStyle = document()->styleSelector()->styleForElement(m_shadowTreeRootElement.get());
-        StyleChange ch = m_shadowTreeRootElement->diff(m_shadowTreeRootElement->renderStyle(), newStyle);
+        StyleChange ch = Node::diff(m_shadowTreeRootElement->renderStyle(), newStyle);
         if (ch == Detach) {
             ASSERT(m_shadowTreeRootElement->attached());
             m_shadowTreeRootElement->detach();