Child not placed correctly when beforeChild (table part)
authorinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Sep 2011 20:17:53 +0000 (20:17 +0000)
committerinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Sep 2011 20:17:53 +0000 (20:17 +0000)
has both :before, :after content.
https://bugs.webkit.org/show_bug.cgi?id=67656

Reviewed by James Robinson.

Source/WebCore:

Tests: fast/table/table-cell-before-after-content-around-table-block.html
       fast/table/table-cell-before-after-content-around-table-row.html
       fast/table/table-cell-before-after-content-around-table.html
       fast/table/table-row-before-after-content-around-block.html
       fast/table/table-row-before-after-content-around-table.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
1. Use the new helper functions findAfterContentRenderer,
   anonymousContainer.
2. Rename anonymousChild to better name - beforeChildAnonymousContainer.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::addChild):
When adding a new child, if beforeChild is a table part(
Table/TableSection/TableRow), we need to check if both
:before, :after content are shoved in one of the anonymous child.
If yes, we need to split the :before, :after content before adding
newChild. Easiest approach is to destroy the :before content, then add
the newChild and then call updateBeforeAfterContent to recreate the
:before content.
* rendering/RenderObject.h:
(WebCore::RenderObject::findBeforeContentRenderer): same as
beforePseudoElementRenderer, but ignores text childs since they are
sequentially added.
(WebCore::RenderObject::findAfterContentRenderer): same.
(WebCore::RenderObject::anonymousContainer):
(WebCore::objectIsRelayoutBoundary):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::addChild): use the new helpers and functionally
correct functions - findAfterContentRenderer, anonymousContainer. previous
implementation was wrong since it would not go inside, if :after content
is embedded deeper than one level.
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::addChild): same.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addChild): same.

LayoutTests:

* fast/table/table-cell-before-after-content-around-table-block-expected.png: Added.
* fast/table/table-cell-before-after-content-around-table-block-expected.txt: Added.
* fast/table/table-cell-before-after-content-around-table-block.html: Added.
* fast/table/table-cell-before-after-content-around-table-expected.png: Added.
* fast/table/table-cell-before-after-content-around-table-expected.txt: Added.
* fast/table/table-cell-before-after-content-around-table-row-expected.png: Added.
* fast/table/table-cell-before-after-content-around-table-row-expected.txt: Added.
* fast/table/table-cell-before-after-content-around-table-row.html: Added.
* fast/table/table-cell-before-after-content-around-table.html: Added.
* fast/table/table-row-before-after-content-around-block-expected.png: Added.
* fast/table/table-row-before-after-content-around-block-expected.txt: Added.
* fast/table/table-row-before-after-content-around-block.html: Added.
* fast/table/table-row-before-after-content-around-table-expected.png: Added.
* fast/table/table-row-before-after-content-around-table-expected.txt: Added.
* fast/table/table-row-before-after-content-around-table.html: Added.

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.png [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-block.html [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.png [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.png [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table-row.html [new file with mode: 0644]
LayoutTests/fast/table/table-cell-before-after-content-around-table.html [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-block-expected.png [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-block-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-block.html [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-table-expected.png [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-table-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/table-row-before-after-content-around-table.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableSection.cpp

index 269f074..aa51554 100644 (file)
@@ -1,3 +1,27 @@
+2011-09-16  Abhishek Arya  <inferno@chromium.org>
+
+        Child not placed correctly when beforeChild (table part)
+        has both :before, :after content.
+        https://bugs.webkit.org/show_bug.cgi?id=67656
+
+        Reviewed by James Robinson.
+
+        * fast/table/table-cell-before-after-content-around-table-block-expected.png: Added.
+        * fast/table/table-cell-before-after-content-around-table-block-expected.txt: Added.
+        * fast/table/table-cell-before-after-content-around-table-block.html: Added.
+        * fast/table/table-cell-before-after-content-around-table-expected.png: Added.
+        * fast/table/table-cell-before-after-content-around-table-expected.txt: Added.
+        * fast/table/table-cell-before-after-content-around-table-row-expected.png: Added.
+        * fast/table/table-cell-before-after-content-around-table-row-expected.txt: Added.
+        * fast/table/table-cell-before-after-content-around-table-row.html: Added.
+        * fast/table/table-cell-before-after-content-around-table.html: Added.
+        * fast/table/table-row-before-after-content-around-block-expected.png: Added.
+        * fast/table/table-row-before-after-content-around-block-expected.txt: Added.
+        * fast/table/table-row-before-after-content-around-block.html: Added.
+        * fast/table/table-row-before-after-content-around-table-expected.png: Added.
+        * fast/table/table-row-before-after-content-around-table-expected.txt: Added.
+        * fast/table/table-row-before-after-content-around-table.html: Added.
+
 2011-09-19  Tom Sepez  <tsepez@chromium.org>
 
         Fix xssauditor bypass with unterminated closing tag by making the HTMLSourceTracker
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.png b/LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.png
new file mode 100644 (file)
index 0000000..88cd4b0
Binary files /dev/null and b/LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.png differ
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.txt b/LayoutTests/fast/table/table-cell-before-after-content-around-table-block-expected.txt
new file mode 100644 (file)
index 0000000..160e6d5
--- /dev/null
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x64
+  RenderBlock {HTML} at (0,0) size 800x64
+    RenderBody {BODY} at (8,8) size 784x48 [color=#0000FF]
+      RenderBlock {DIV} at (0,0) size 784x48
+        RenderTable at (0,0) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [color=#0000FF] [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "ABCD"
+        RenderBlock {DIV} at (0,16) size 784x16
+          RenderText {#text} at (0,0) size 64x16
+            text run at (0,0) width 64: "1234"
+        RenderTable at (0,32) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [color=#0000FF] [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "EFGH"
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-block.html b/LayoutTests/fast/table/table-cell-before-after-content-around-table-block.html
new file mode 100644 (file)
index 0000000..799538d
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>\r
+<!-- Test passes if you see three blue boxes in three seperate rows. -->\r
+<html style="font: 1em/1 Ahem, sans-serif;">\r
+<style type="text/css">\r
+.container:before {\r
+    content: "ABCD";\r
+    display: table-cell;\r
+}\r
+\r
+.container:after {\r
+    content: "EFGH";\r
+    display: table-cell;\r
+}\r
+\r
+</style>\r
+</head>\r
+<body>\r
+<div class="container">\r
+<div style="display: block">1234</div>\r
+</div>\r
+<script>\r
+document.body.offsetTop;\r
+document.body.style.color = 'blue';\r
+</script>\r
+</html>\r
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.png b/LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.png
new file mode 100644 (file)
index 0000000..88cd4b0
Binary files /dev/null and b/LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.png differ
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.txt b/LayoutTests/fast/table/table-cell-before-after-content-around-table-expected.txt
new file mode 100644 (file)
index 0000000..455a554
--- /dev/null
@@ -0,0 +1,24 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x64
+  RenderBlock {HTML} at (0,0) size 800x64
+    RenderBody {BODY} at (8,8) size 784x48 [color=#0000FF]
+      RenderBlock {DIV} at (0,0) size 784x48
+        RenderTable at (0,0) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [color=#0000FF] [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "ABCD"
+        RenderTable {DIV} at (0,16) size 64x16
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (0,0) size 64x16
+                  text run at (0,0) width 64: "1234"
+        RenderTable at (0,32) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [color=#0000FF] [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "EFGH"
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.png b/LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.png
new file mode 100644 (file)
index 0000000..88cd4b0
Binary files /dev/null and b/LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.png differ
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.txt b/LayoutTests/fast/table/table-cell-before-after-content-around-table-row-expected.txt
new file mode 100644 (file)
index 0000000..741ae0c
--- /dev/null
@@ -0,0 +1,19 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x64
+  RenderBlock {HTML} at (0,0) size 800x64
+    RenderBody {BODY} at (8,8) size 784x48 [color=#0000FF]
+      RenderTable {DIV} at (0,0) size 64x48
+        RenderTableSection (anonymous) at (0,0) size 64x48
+          RenderTableRow (anonymous) at (0,0) size 64x16
+            RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+              RenderText at (0,0) size 64x16
+                text run at (0,0) width 64: "ABCD"
+          RenderTableRow {DIV} at (0,16) size 64x16
+            RenderTableCell (anonymous) at (0,16) size 64x16 [r=1 c=0 rs=1 cs=1]
+              RenderText {#text} at (0,0) size 64x16
+                text run at (0,0) width 64: "1234"
+          RenderTableRow (anonymous) at (0,32) size 64x16
+            RenderTableCell (anonymous) at (0,32) size 64x16 [r=2 c=0 rs=1 cs=1]
+              RenderText at (0,0) size 64x16
+                text run at (0,0) width 64: "EFGH"
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table-row.html b/LayoutTests/fast/table/table-cell-before-after-content-around-table-row.html
new file mode 100644 (file)
index 0000000..b320128
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>\r
+<!-- Test passes if you see three blue boxes in three seperate rows. -->\r
+<html style="font: 1em/1 Ahem, sans-serif;">\r
+<style type="text/css">\r
+.container:before {\r
+    content: "ABCD";\r
+    display: table-cell;\r
+}\r
+\r
+.container:after {\r
+    content: "EFGH";\r
+    display: table-cell;\r
+}\r
+\r
+</style>\r
+</head>\r
+<body>\r
+<div class="container" style="display:table">\r
+<div style="display:table-row">1234</div>\r
+</div>\r
+<script>\r
+document.body.offsetTop;\r
+document.body.style.color = 'blue';\r
+</script>\r
+</html>\r
diff --git a/LayoutTests/fast/table/table-cell-before-after-content-around-table.html b/LayoutTests/fast/table/table-cell-before-after-content-around-table.html
new file mode 100644 (file)
index 0000000..d077335
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>\r
+<!-- Test passes if you see three blue boxes in three seperate rows. -->\r
+<html style="font: 1em/1 Ahem, sans-serif;">\r
+<style type="text/css">\r
+.container:before {\r
+    content: "ABCD";\r
+    display: table-cell;\r
+}\r
+\r
+.container:after {\r
+    content: "EFGH";\r
+    display: table-cell;\r
+}\r
+\r
+</style>\r
+</head>\r
+<body>\r
+<div class="container">\r
+<div style="display: table">1234</div>\r
+</div>\r
+<script>\r
+document.body.offsetTop;\r
+document.body.style.color = 'blue';\r
+</script>\r
+</body>\r
+</html>\r
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-block-expected.png b/LayoutTests/fast/table/table-row-before-after-content-around-block-expected.png
new file mode 100644 (file)
index 0000000..88cd4b0
Binary files /dev/null and b/LayoutTests/fast/table/table-row-before-after-content-around-block-expected.png differ
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-block-expected.txt b/LayoutTests/fast/table/table-row-before-after-content-around-block-expected.txt
new file mode 100644 (file)
index 0000000..2207597
--- /dev/null
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x64
+  RenderBlock {HTML} at (0,0) size 800x64
+    RenderBody {BODY} at (8,8) size 784x48 [color=#0000FF]
+      RenderBlock {DIV} at (0,0) size 784x48
+        RenderTable at (0,0) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16 [color=#0000FF]
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "ABCD"
+        RenderBlock {DIV} at (0,16) size 784x16
+          RenderText {#text} at (0,0) size 64x16
+            text run at (0,0) width 64: "1234"
+        RenderTable at (0,32) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16 [color=#0000FF]
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "EFGH"
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-block.html b/LayoutTests/fast/table/table-row-before-after-content-around-block.html
new file mode 100644 (file)
index 0000000..06a6474
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<!-- Test passes if you see three blue boxes in three seperate rows. -->
+<html style="font: 1em/1 Ahem, sans-serif;">
+<style type="text/css">
+.container:before 
+{
+    content: "ABCD";
+    display: table-row;
+}
+
+.container:after 
+{
+    content: "EFGH";
+    display: table-row;
+}
+
+</style>
+</head>
+<body>
+<div class="container">
+<div style="display: block">1234</div>
+</div>
+<script>
+document.body.offsetTop;
+document.body.style.color = 'blue';
+</script>
+</html>
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-table-expected.png b/LayoutTests/fast/table/table-row-before-after-content-around-table-expected.png
new file mode 100644 (file)
index 0000000..88cd4b0
Binary files /dev/null and b/LayoutTests/fast/table/table-row-before-after-content-around-table-expected.png differ
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-table-expected.txt b/LayoutTests/fast/table/table-row-before-after-content-around-table-expected.txt
new file mode 100644 (file)
index 0000000..d6f631a
--- /dev/null
@@ -0,0 +1,24 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x64
+  RenderBlock {HTML} at (0,0) size 800x64
+    RenderBody {BODY} at (8,8) size 784x48 [color=#0000FF]
+      RenderBlock {DIV} at (0,0) size 784x48
+        RenderTable at (0,0) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16 [color=#0000FF]
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "ABCD"
+        RenderTable {DIV} at (0,16) size 64x16
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (0,0) size 64x16
+                  text run at (0,0) width 64: "1234"
+        RenderTable at (0,32) size 64x16 [color=#000000]
+          RenderTableSection (anonymous) at (0,0) size 64x16
+            RenderTableRow (anonymous) at (0,0) size 64x16 [color=#0000FF]
+              RenderTableCell (anonymous) at (0,0) size 64x16 [r=0 c=0 rs=1 cs=1]
+                RenderText at (0,0) size 64x16
+                  text run at (0,0) width 64: "EFGH"
diff --git a/LayoutTests/fast/table/table-row-before-after-content-around-table.html b/LayoutTests/fast/table/table-row-before-after-content-around-table.html
new file mode 100644 (file)
index 0000000..bf4b15d
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<!-- Test passes if you see three blue boxes in three seperate rows. -->
+<html style="font: 1em/1 Ahem, sans-serif;">
+<style type="text/css">
+.container:before 
+{
+    content: "ABCD";
+    display: table-row;
+}
+
+.container:after 
+{
+    content: "EFGH";
+    display: table-row;
+}
+
+</style>
+</head>
+<body>
+<div class="container">
+<div style="display: table">1234</div>
+</div>
+<script>
+document.body.offsetTop;
+document.body.style.color = 'blue';
+</script>
+</html>
index f3e4ea9..e3d4761 100644 (file)
@@ -1,3 +1,48 @@
+2011-09-16  Abhishek Arya  <inferno@chromium.org>
+
+        Child not placed correctly when beforeChild (table part)
+        has both :before, :after content.
+        https://bugs.webkit.org/show_bug.cgi?id=67656
+
+        Reviewed by James Robinson.
+
+        Tests: fast/table/table-cell-before-after-content-around-table-block.html
+               fast/table/table-cell-before-after-content-around-table-row.html
+               fast/table/table-cell-before-after-content-around-table.html
+               fast/table/table-row-before-after-content-around-block.html
+               fast/table/table-row-before-after-content-around-table.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
+        1. Use the new helper functions findAfterContentRenderer,
+           anonymousContainer.
+        2. Rename anonymousChild to better name - beforeChildAnonymousContainer.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::addChild):
+        When adding a new child, if beforeChild is a table part(
+        Table/TableSection/TableRow), we need to check if both
+        :before, :after content are shoved in one of the anonymous child.
+        If yes, we need to split the :before, :after content before adding
+        newChild. Easiest approach is to destroy the :before content, then add
+        the newChild and then call updateBeforeAfterContent to recreate the
+        :before content.   
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::findBeforeContentRenderer): same as
+        beforePseudoElementRenderer, but ignores text childs since they are
+        sequentially added.
+        (WebCore::RenderObject::findAfterContentRenderer): same.
+        (WebCore::RenderObject::anonymousContainer):
+        (WebCore::objectIsRelayoutBoundary):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::addChild): use the new helpers and functionally
+        correct functions - findAfterContentRenderer, anonymousContainer. previous
+        implementation was wrong since it would not go inside, if :after content
+        is embedded deeper than one level.
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::addChild): same.
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::addChild): same.
+
 2011-09-19  Robert Kroeger  <rjkroege@chromium.org>
 
         [chromium] Gesture recognizer fires taptype only every other touch
index 2ad3880..3aa675a 100644 (file)
@@ -668,26 +668,17 @@ RenderBlock* RenderBlock::columnsBlockForSpanningElement(RenderObject* newChild)
 void RenderBlock::addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild)
 {
     // Make sure we don't append things after :after-generated content if we have it.
-    if (!beforeChild) {
-        RenderObject* lastRenderer = lastChild();
-        while (lastRenderer && lastRenderer->isAnonymous() && !isAfterContent(lastRenderer))
-            lastRenderer = lastRenderer->lastChild();
-        if (lastRenderer && isAfterContent(lastRenderer))
-            beforeChild = lastRenderer;
-    }
+    if (!beforeChild)
+        beforeChild = findAfterContentRenderer();
 
     // If the requested beforeChild is not one of our children, then this is because
     // there is an anonymous container within this object that contains the beforeChild.
     if (beforeChild && beforeChild->parent() != this) {
-        RenderObject* anonymousChild = beforeChild->parent();
-        ASSERT(anonymousChild);
-
-        while (anonymousChild->parent() != this)
-            anonymousChild = anonymousChild->parent();
-
-        ASSERT(anonymousChild->isAnonymous());
+        RenderObject* beforeChildAnonymousContainer = anonymousContainer(beforeChild);
+        ASSERT(beforeChildAnonymousContainer);
+        ASSERT(beforeChildAnonymousContainer->isAnonymous());
 
-        if (anonymousChild->isAnonymousBlock()) {
+        if (beforeChildAnonymousContainer->isAnonymousBlock()) {
             // Insert the child into the anonymous block box instead of here.
             if (newChild->isInline() || beforeChild->parent()->firstChild() != beforeChild)
                 beforeChild->parent()->addChild(newChild, beforeChild);
@@ -696,19 +687,19 @@ void RenderBlock::addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild,
             return;
         }
 
-        ASSERT(anonymousChild->isTable());
+        ASSERT(beforeChildAnonymousContainer->isTable());
         if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
                 || (newChild->isRenderBlock() && newChild->style()->display() == TABLE_CAPTION)
                 || newChild->isTableSection()
                 || newChild->isTableRow()
                 || newChild->isTableCell()) {
             // Insert into the anonymous table.
-            anonymousChild->addChild(newChild, beforeChild);
+            beforeChildAnonymousContainer->addChild(newChild, beforeChild);
             return;
         }
 
         // Go on to insert before the anonymous table.
-        beforeChild = anonymousChild;
+        beforeChild = beforeChildAnonymousContainer;
     }
 
     // Check for a spanning element in columns.
index 126923d..375895a 100644 (file)
@@ -282,6 +282,17 @@ void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
     if (!children)
         return;
 
+    RenderObject* beforeContent = 0;
+    bool beforeChildHasBeforeAndAfterContent = false;
+    if (beforeChild && (beforeChild->isTable() || beforeChild->isTableSection() || beforeChild->isTableRow())) {
+        beforeContent = beforeChild->findBeforeContentRenderer();
+        RenderObject* afterContent = beforeChild->findAfterContentRenderer();
+        if (beforeContent && afterContent) {
+            beforeChildHasBeforeAndAfterContent = true;
+            beforeContent->destroy();
+        }
+    }
+
     bool needsTable = false;
 
     if (newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
@@ -320,11 +331,15 @@ void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
         // Just add it...
         children->insertChildNode(this, newChild, beforeChild);
     }
+
     if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) {
         RefPtr<StringImpl> textToTransform = toRenderText(newChild)->originalText();
         if (textToTransform)
             toRenderText(newChild)->setText(textToTransform.release(), true);
     }
+
+    if (beforeChildHasBeforeAndAfterContent)
+        children->updateBeforeAfterContent(this, BEFORE);
 }
 
 void RenderObject::removeChild(RenderObject* oldChild)
index bfaa695..3bd2457 100644 (file)
@@ -337,6 +337,28 @@ public:
     static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
     static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
 
+    inline RenderObject* findBeforeContentRenderer() const
+    {
+        RenderObject* renderer = beforePseudoElementRenderer();
+        return isBeforeContent(renderer) ? renderer : 0;
+    }
+
+    inline RenderObject* findAfterContentRenderer() const
+    {
+        RenderObject* renderer = afterPseudoElementRenderer();
+        return isAfterContent(renderer) ? renderer : 0;
+    }
+
+    inline RenderObject* anonymousContainer(RenderObject* child)
+    {
+         RenderObject* container = child;
+         while (container->parent() != this)
+             container = container->parent();
+
+         ASSERT(container->isAnonymous());
+         return container;
+    }
+
     bool childrenInline() const { return m_childrenInline; }
     void setChildrenInline(bool b = true) { m_childrenInline = b; }
     bool hasColumns() const { return m_hasColumns; }
index fc44605..dee57d8 100644 (file)
@@ -107,8 +107,10 @@ static inline void resetSectionPointerIfNotBefore(RenderTableSection*& ptr, Rend
 void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild)
 {
     // Make sure we don't append things after :after-generated content if we have it.
-    if (!beforeChild && isAfterContent(lastChild()))
-        beforeChild = lastChild();
+    if (!beforeChild) {
+        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
+            beforeChild = anonymousContainer(afterContentRenderer);
+    }
 
     bool wrapInAnonymousSection = !child->isPositioned();
 
index c705348..082eef4 100644 (file)
@@ -83,8 +83,10 @@ void RenderTableRow::styleDidChange(StyleDifference diff, const RenderStyle* old
 void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
 {
     // Make sure we don't append things after :after-generated content if we have it.
-    if (!beforeChild && isAfterContent(lastChild()))
-        beforeChild = lastChild();
+    if (!beforeChild) {
+        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
+            beforeChild = anonymousContainer(afterContentRenderer);
+    }
 
     if (!child->isTableCell()) {
         RenderObject* last = beforeChild;
index dc44094..af32d5b 100644 (file)
@@ -98,8 +98,10 @@ void RenderTableSection::willBeDestroyed()
 void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild)
 {
     // Make sure we don't append things after :after-generated content if we have it.
-    if (!beforeChild && isAfterContent(lastChild()))
-        beforeChild = lastChild();
+    if (!beforeChild) {
+        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
+            beforeChild = anonymousContainer(afterContentRenderer);
+    }
 
     if (!child->isTableRow()) {
         RenderObject* last = beforeChild;