Title: [103376] branches/safari-534.54-branch/Source/WebCore
Revision
103376
Author
lforsch...@apple.com
Date
2011-12-20 17:40:35 -0800 (Tue, 20 Dec 2011)

Log Message

Merged r92630.

Modified Paths

Diff

Modified: branches/safari-534.54-branch/Source/WebCore/ChangeLog (103375 => 103376)


--- branches/safari-534.54-branch/Source/WebCore/ChangeLog	2011-12-21 01:37:16 UTC (rev 103375)
+++ branches/safari-534.54-branch/Source/WebCore/ChangeLog	2011-12-21 01:40:35 UTC (rev 103376)
@@ -1,5 +1,21 @@
 2011-12-20  Lucas Forschler  <lforsch...@apple.com>
 
+    Merge 92630
+
+    2011-08-08  Cris Neckar  <c...@chromium.org>
+
+            Remove counter nodes from the tree and fix-up children when they are removed from the counter map.
+            https://bugs.webkit.org/show_bug.cgi?id=65346
+
+            Reviewed by Adam Barth.
+
+            Covered by existing CSS counter tests.
+
+            * rendering/CounterNode.cpp:
+            (WebCore::CounterNode::~CounterNode):
+
+2011-12-20  Lucas Forschler  <lforsch...@apple.com>
+
     Merge 92347
 
     2011-08-03  Kent Tamura  <tk...@chromium.org>

Modified: branches/safari-534.54-branch/Source/WebCore/rendering/CounterNode.cpp (103375 => 103376)


--- branches/safari-534.54-branch/Source/WebCore/rendering/CounterNode.cpp	2011-12-21 01:37:16 UTC (rev 103375)
+++ branches/safari-534.54-branch/Source/WebCore/rendering/CounterNode.cpp	2011-12-21 01:40:35 UTC (rev 103376)
@@ -44,6 +44,49 @@
 
 CounterNode::~CounterNode()
 {
+    // Ideally this would be an assert and this would never be reached. In reality this happens a lot
+    // so we need to handle these cases. The node is still connected to the tree so we need to detach it.
+    if (m_parent || m_previousSibling || m_nextSibling || m_firstChild || m_lastChild) {
+        CounterNode* oldParent = 0;
+        CounterNode* oldPreviousSibling = 0;
+        // Instead of calling removeChild() we do this safely as the tree is likely broken if we get here.
+        if (m_parent) {
+            if (m_parent->m_firstChild == this)
+                m_parent->m_firstChild = m_nextSibling;
+            if (m_parent->m_lastChild == this)
+                m_parent->m_lastChild = m_previousSibling;
+            oldParent = m_parent;
+            m_parent = 0;
+        }
+        if (m_previousSibling) {
+            if (m_previousSibling->m_nextSibling == this)
+                m_previousSibling->m_nextSibling = m_nextSibling;
+            oldPreviousSibling = m_previousSibling;
+            m_previousSibling = 0;
+        }
+        if (m_nextSibling) {
+            if (m_nextSibling->m_previousSibling == this)
+                m_nextSibling->m_previousSibling = oldPreviousSibling;
+            m_nextSibling = 0;
+        }
+        if (m_firstChild) {
+            // The node's children are reparented to the old parent.
+            for (CounterNode* child = m_firstChild; child; ) {
+                CounterNode* nextChild = child->m_nextSibling;
+                CounterNode* nextSibling = 0;
+                child->m_parent = oldParent;
+                if (oldPreviousSibling) {
+                    nextSibling = oldPreviousSibling->m_nextSibling;
+                    child->m_previousSibling = oldPreviousSibling;
+                    oldPreviousSibling->m_nextSibling = child;
+                    child->m_nextSibling = nextSibling;
+                    nextSibling->m_previousSibling = child;
+                    oldPreviousSibling = child;
+                }
+                child = nextChild;
+            }
+        }
+    }
     resetRenderers();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to