Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: Source/WebCore/rendering/CounterNode.cpp

Issue 7601020: Merge 92630 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/CounterNode.cpp
===================================================================
--- Source/WebCore/rendering/CounterNode.cpp (revision 92662)
+++ Source/WebCore/rendering/CounterNode.cpp (working copy)
@@ -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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698