Title: [108548] trunk
Revision
108548
Author
[email protected]
Date
2012-02-22 13:56:33 -0800 (Wed, 22 Feb 2012)

Log Message

Crash from empty anonymous block preceding :before content
https://bugs.webkit.org/show_bug.cgi?id=78250

Patch by Ken Buchanan <[email protected]> on 2012-02-22
Reviewed by David Hyatt.

Source/WebCore:

RenderListMarkers getting removed from the tree in updateMarkerLocation()
can leave parent anonymous blocks behind with no children. This was
confusing updateBeforeAfterContent() because it does not expect
an empty block to precede :before content renderers.

Fix is to remove the anonymous block if it will lose all of its children.

* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateMarkerLocation):

LayoutTests:

Test exercises a crashing condition from extra :before content being
created after a RenderListMarker in an anonymous block has been moved.

Also rebasing some tests that had extraneous anonymous blocks in their
render tree dumps.

* fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash-expected.txt: Added
* fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash.html: Added
* platform/chromium-win/editing/execCommand/create-list-with-hr-expected.txt:
* platform/gtk/editing/execCommand/create-list-with-hr-expected.txt:
* platform/mac/editing/execCommand/create-list-with-hr-expected.txt:
* platform/qt/editing/execCommand/create-list-with-hr-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (108547 => 108548)


--- trunk/LayoutTests/ChangeLog	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/LayoutTests/ChangeLog	2012-02-22 21:56:33 UTC (rev 108548)
@@ -1,3 +1,23 @@
+2012-02-22  Ken Buchanan  <[email protected]>
+
+        Crash from empty anonymous block preceding :before content
+        https://bugs.webkit.org/show_bug.cgi?id=78250
+
+        Reviewed by David Hyatt.
+
+        Test exercises a crashing condition from extra :before content being
+        created after a RenderListMarker in an anonymous block has been moved.
+
+        Also rebasing some tests that had extraneous anonymous blocks in their
+        render tree dumps.
+
+        * fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash-expected.txt: Added
+        * fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash.html: Added
+        * platform/chromium-win/editing/execCommand/create-list-with-hr-expected.txt:
+        * platform/gtk/editing/execCommand/create-list-with-hr-expected.txt:
+        * platform/mac/editing/execCommand/create-list-with-hr-expected.txt:
+        * platform/qt/editing/execCommand/create-list-with-hr-expected.txt:
+
 2012-02-22  Abhishek Arya  <[email protected]>
 
         Crash due to accessing removed parent lineboxes when clearing view selection.

Added: trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash-expected.txt (0 => 108548)


--- trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash-expected.txt	2012-02-22 21:56:33 UTC (rev 108548)
@@ -0,0 +1,2 @@
+PASS if no assert or crash on debug
+

Added: trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash.html (0 => 108548)


--- trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/before-content-with-list-marker-in-anon-block-crash.html	2012-02-22 21:56:33 UTC (rev 108548)
@@ -0,0 +1,41 @@
+<style>
+.c9::before { float: right; content: counter(section); }
+.c9 { display: list-item; }
+.c19 { display: table-row; }
+.c19:nth-child(even) { position: fixed; }
+</style>
+<script>
+var nodes = Array();
+function runTest() {
+    firstDiv = document.createElement('div');
+    document.documentElement.appendChild(firstDiv);
+
+    secondDiv = document.createElement('div');
+    document.documentElement.appendChild(secondDiv);
+
+    childDivListItem = document.createElement('div');
+    childDivListItem.setAttribute('class', 'c9');
+    document.documentElement.appendChild(childDivListItem);
+
+    citeNode = document.createElement('cite');
+    citeNode.setAttribute('class', 'c19');
+    document.documentElement.appendChild(citeNode);
+
+    parentDivListItem = document.createElement('div');
+    parentDivListItem.setAttribute('class', 'c9');
+    
+    citeNode.appendChild(parentDivListItem);
+
+    document.body.offsetTop;
+    parentDivListItem.appendChild(childDivListItem);
+    document.body.offsetTop;
+    secondDiv.setAttribute('class', 'c1');
+    document.body.offsetTop;
+    firstDiv.setAttribute('class', 'c1');
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+}
+window._onload_ = runTest;
+</script>
+PASS if no assert or crash on debug

Modified: trunk/LayoutTests/platform/chromium-win/editing/execCommand/create-list-with-hr-expected.txt (108547 => 108548)


--- trunk/LayoutTests/platform/chromium-win/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/LayoutTests/platform/chromium-win/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:56:33 UTC (rev 108548)
@@ -21,7 +21,6 @@
       RenderBlock {DIV} at (0,56) size 784x30
         RenderBlock {UL} at (0,0) size 784x30
           RenderListItem {LI} at (40,0) size 744x30
-            RenderBlock (anonymous) at (0,0) size 744x0
             RenderBlock {HR} at (0,0) size 744x2 [border: (1px inset #000000)]
             RenderBlock (anonymous) at (0,10) size 744x20
               RenderListMarker at (-18,0) size 7x19: bullet

Modified: trunk/LayoutTests/platform/gtk/editing/execCommand/create-list-with-hr-expected.txt (108547 => 108548)


--- trunk/LayoutTests/platform/gtk/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/LayoutTests/platform/gtk/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:56:33 UTC (rev 108548)
@@ -21,7 +21,6 @@
       RenderBlock {DIV} at (0,52) size 784x28
         RenderBlock {UL} at (0,0) size 784x28
           RenderListItem {LI} at (40,0) size 744x28
-            RenderBlock (anonymous) at (0,0) size 744x0
             RenderBlock {HR} at (0,0) size 744x2 [border: (1px inset #000000)]
             RenderBlock (anonymous) at (0,10) size 744x18
               RenderListMarker at (-17,0) size 7x17: bullet

Modified: trunk/LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.txt (108547 => 108548)


--- trunk/LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:56:33 UTC (rev 108548)
@@ -21,7 +21,6 @@
       RenderBlock {DIV} at (0,52) size 784x28
         RenderBlock {UL} at (0,0) size 784x28
           RenderListItem {LI} at (40,0) size 744x28
-            RenderBlock (anonymous) at (0,0) size 744x0
             RenderBlock {HR} at (0,0) size 744x2 [border: (1px inset #000000)]
             RenderBlock (anonymous) at (0,10) size 744x18
               RenderListMarker at (-17,0) size 7x18: bullet

Modified: trunk/LayoutTests/platform/qt/editing/execCommand/create-list-with-hr-expected.txt (108547 => 108548)


--- trunk/LayoutTests/platform/qt/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/LayoutTests/platform/qt/editing/execCommand/create-list-with-hr-expected.txt	2012-02-22 21:56:33 UTC (rev 108548)
@@ -21,7 +21,6 @@
       RenderBlock {DIV} at (0,58) size 784x31
         RenderBlock {UL} at (0,0) size 784x31
           RenderListItem {LI} at (40,0) size 744x31
-            RenderBlock (anonymous) at (0,0) size 744x0
             RenderBlock {HR} at (0,0) size 744x2 [border: (1px inset #000000)]
             RenderBlock (anonymous) at (0,10) size 744x21
               RenderListMarker at (-18,0) size 7x21: bullet

Modified: trunk/Source/WebCore/ChangeLog (108547 => 108548)


--- trunk/Source/WebCore/ChangeLog	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/Source/WebCore/ChangeLog	2012-02-22 21:56:33 UTC (rev 108548)
@@ -1,3 +1,20 @@
+2012-02-22  Ken Buchanan  <[email protected]>
+
+        Crash from empty anonymous block preceding :before content
+        https://bugs.webkit.org/show_bug.cgi?id=78250
+
+        Reviewed by David Hyatt.
+
+        RenderListMarkers getting removed from the tree in updateMarkerLocation()
+        can leave parent anonymous blocks behind with no children. This was
+        confusing updateBeforeAfterContent() because it does not expect
+        an empty block to precede :before content renderers.
+
+        Fix is to remove the anonymous block if it will lose all of its children.
+
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::updateMarkerLocation):
+
 2012-02-22  Abhishek Arya  <[email protected]>
 
         Crash due to accessing removed parent lineboxes when clearing view selection.

Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (108547 => 108548)


--- trunk/Source/WebCore/rendering/RenderListItem.cpp	2012-02-22 21:33:33 UTC (rev 108547)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp	2012-02-22 21:56:33 UTC (rev 108548)
@@ -247,6 +247,9 @@
             LayoutStateDisabler layoutStateDisabler(view());
             updateFirstLetter();
             m_marker->remove();
+            // If markerPar is an anonymous block that will lose all its children, destroy it
+            if (markerPar && (markerPar != lineBoxParent) && markerPar->isAnonymousBlock() && !(toRenderBlock(markerPar)->firstChild()))
+                markerPar->destroy();
             if (!lineBoxParent)
                 lineBoxParent = this;
             lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to