Title: [106852] trunk
Revision
106852
Author
[email protected]
Date
2012-02-06 14:30:09 -0800 (Mon, 06 Feb 2012)

Log Message

Source/WebCore: Add RefPtrs for parent and sibling counter nodes
https://bugs.webkit.org/show_bug.cgi?id=75212

Reviewed by Adam Barth.

Test: fast/css/counters/reparent-table-children-with-counters-crash.html

* rendering/RenderCounter.cpp:
(WebCore::findPlaceForCounter):
(WebCore::makeCounterNode):
(WebCore::updateCounters):

LayoutTests: Test for crash when counter nodes are reparented outside of tables
https://bugs.webkit.org/show_bug.cgi?id=75212

Reviewed by Adam Barth.

* fast/css/counters/reparent-table-children-with-counters-crash-expected.txt: Added.
* fast/css/counters/reparent-table-children-with-counters-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106851 => 106852)


--- trunk/LayoutTests/ChangeLog	2012-02-06 22:26:29 UTC (rev 106851)
+++ trunk/LayoutTests/ChangeLog	2012-02-06 22:30:09 UTC (rev 106852)
@@ -1,3 +1,13 @@
+2012-02-06  Cris Neckar  <[email protected]>
+
+        Test for crash when counter nodes are reparented outside of tables
+        https://bugs.webkit.org/show_bug.cgi?id=75212
+
+        Reviewed by Adam Barth.
+
+        * fast/css/counters/reparent-table-children-with-counters-crash-expected.txt: Added.
+        * fast/css/counters/reparent-table-children-with-counters-crash.html: Added.
+
 2012-02-06  Adam Barth  <[email protected]>
 
         According to the flakiness dashboard, these tests do appear to be

Added: trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash-expected.txt (0 => 106852)


--- trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash-expected.txt	2012-02-06 22:30:09 UTC (rev 106852)
@@ -0,0 +1,2 @@
+PASS: Reparenting nodes outside of table body does not trigger crash.
+

Added: trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash.html (0 => 106852)


--- trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/reparent-table-children-with-counters-crash.html	2012-02-06 22:30:09 UTC (rev 106852)
@@ -0,0 +1,18 @@
+<html>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+</script>
+<table>
+    <tbody>
+        <td style="counter-increment: list-item"></td>
+    </tbody>
+    <ol><ol>
+    </ol></ol>
+    <td>PASS: Reparenting nodes outside of table body does not trigger crash.</td>
+    <li></li>
+</table>
+<table>
+    <td style="counter-increment: list-item"></td>
+</table>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (106851 => 106852)


--- trunk/Source/WebCore/ChangeLog	2012-02-06 22:26:29 UTC (rev 106851)
+++ trunk/Source/WebCore/ChangeLog	2012-02-06 22:30:09 UTC (rev 106852)
@@ -1,3 +1,17 @@
+2012-02-06  Cris Neckar  <[email protected]>
+
+        Add RefPtrs for parent and sibling counter nodes
+        https://bugs.webkit.org/show_bug.cgi?id=75212
+
+        Reviewed by Adam Barth.
+
+        Test: fast/css/counters/reparent-table-children-with-counters-crash.html
+
+        * rendering/RenderCounter.cpp:
+        (WebCore::findPlaceForCounter):
+        (WebCore::makeCounterNode):
+        (WebCore::updateCounters):
+
 2012-02-06  Kalev Lember  <[email protected]>
 
         [GTK] Add missing pango include dir to fix build

Modified: trunk/Source/WebCore/rendering/RenderCounter.cpp (106851 => 106852)


--- trunk/Source/WebCore/rendering/RenderCounter.cpp	2012-02-06 22:26:29 UTC (rev 106851)
+++ trunk/Source/WebCore/rendering/RenderCounter.cpp	2012-02-06 22:30:09 UTC (rev 106852)
@@ -301,7 +301,7 @@
 // reset node.
 // - Non-reset CounterNodes cannot have descendants.
 
-static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& identifier, bool isReset, CounterNode*& parent, CounterNode*& previousSibling)
+static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& previousSibling)
 {
     // We cannot stop searching for counters with the same identifier before we also
     // check this renderer, because it may affect the positioning in the tree of our counter.
@@ -346,7 +346,9 @@
                     if (!isReset || !areRenderersElementsSiblings(currentRenderer, counterOwner)) {
                         // If the node we are placing is not reset or we have found a counter that is attached
                         // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node.
-                        ASSERT(currentCounter->parent() == previousSiblingProtector->parent());
+                        if (currentCounter->parent() != previousSiblingProtector->parent())
+                            return false;
+
                         parent = currentCounter->parent();
                         previousSibling = previousSiblingProtector.get();
                         return true;
@@ -428,11 +430,11 @@
     if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter)
         return 0;
 
-    CounterNode* newParent = 0;
-    CounterNode* newPreviousSibling = 0;
+    RefPtr<CounterNode> newParent = 0;
+    RefPtr<CounterNode> newPreviousSibling = 0;
     RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value);
     if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousSibling))
-        newParent->insertAfter(newNode.get(), newPreviousSibling, identifier);
+        newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifier);
     CounterMap* nodeMap;
     if (object->hasCounterNodeMap())
         nodeMap = counterMaps().get(object);
@@ -628,8 +630,8 @@
             makeCounterNode(renderer, AtomicString(it->first.get()), false);
             continue;
         }
-        CounterNode* newParent = 0;
-        CounterNode* newPreviousSibling;
+        RefPtr<CounterNode> newParent = 0;
+        RefPtr<CounterNode> newPreviousSibling = 0;
         
         findPlaceForCounter(renderer, AtomicString(it->first.get()), node->hasResetType(), newParent, newPreviousSibling);
         if (node != counterMap->get(it->first.get()))
@@ -640,7 +642,7 @@
         if (parent)
             parent->removeChild(node.get());
         if (newParent)
-            newParent->insertAfter(node.get(), newPreviousSibling, it->first.get());
+            newParent->insertAfter(node.get(), newPreviousSibling.get(), it->first.get());
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to