2010-12-17 Carol Szabo <carol.szabo@nokia.com>
authorcarol.szabo@nokia.com <carol.szabo@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Dec 2010 21:39:19 +0000 (21:39 +0000)
committercarol.szabo@nokia.com <carol.szabo@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Dec 2010 21:39:19 +0000 (21:39 +0000)
        Reviewed by Darin Adler.

        A corrupted counter tree is created when renderers are added to the
        tree bypassing RenderObject::addChild
        https://bugs.webkit.org/show_bug.cgi?id=51270

        This patch replaces the hack introduced for fixing bug 43812
        with code that addresses the underlying problem for that bug.
        No new layout tests provided as there is no identified scenario when
        visible behavior would be different, the internal datastructures
        are maintained properly through this fix so the previous hack
        introduced for bug 43812 is now removed. The fact that the
        layout test introduced for 43812 continues to pass is proof that the
        code works.

        * rendering/RenderCounter.cpp:
        (WebCore::findPlaceForCounter):
          Removed hack.
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::addChild):
          Moved call to counter nodes updater to lower level
          functions to avoid bypass.
        * rendering/RenderObjectChildList.cpp:
        (WebCore::RenderObjectChildList::appendChildNode):
        (WebCore::RenderObjectChildList::insertChildNode):
          Changed to update the values of the counters that
          may be inserted in the tree.

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

WebCore/ChangeLog
WebCore/rendering/RenderCounter.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObjectChildList.cpp

index 3816965..a7c4e73 100644 (file)
@@ -1,3 +1,33 @@
+2010-12-17  Carol Szabo  <carol.szabo@nokia.com>
+
+        Reviewed by Darin Adler.
+
+        A corrupted counter tree is created when renderers are added to the
+        tree bypassing RenderObject::addChild
+        https://bugs.webkit.org/show_bug.cgi?id=51270
+
+        This patch replaces the hack introduced for fixing bug 43812
+        with code that addresses the underlying problem for that bug.
+        No new layout tests provided as there is no identified scenario when
+        visible behavior would be different, the internal datastructures
+        are maintained properly through this fix so the previous hack
+        introduced for bug 43812 is now removed. The fact that the 
+        layout test introduced for 43812 continues to pass is proof that the
+        code works.
+
+        * rendering/RenderCounter.cpp:
+        (WebCore::findPlaceForCounter):
+          Removed hack.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::addChild):
+          Moved call to counter nodes updater to lower level
+          functions to avoid bypass.
+        * rendering/RenderObjectChildList.cpp:
+        (WebCore::RenderObjectChildList::appendChildNode):
+        (WebCore::RenderObjectChildList::insertChildNode):
+          Changed to update the values of the counters that
+          may be inserted in the tree.
+
 2010-12-17  Shimeng (Simon) Wang  <swang@google.com>
 
         Reviewed by Steve Block.
index c357be1..7e10440 100644 (file)
@@ -136,11 +136,6 @@ static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString&
     RenderObject* currentRenderer = counterOwner->previousInPreOrder();
     previousSibling = 0;
     while (currentRenderer) {
-        // A sibling without a parent means that the counter node tree was not constructed correctly so we stop
-        // traversing. In the future RenderCounter should handle RenderObjects that are not connected to the
-        // render tree at counter node creation. See bug 43812.
-        if (previousSibling && !previousSibling->parent())
-            return false;
         CounterNode* currentCounter = makeCounterNode(currentRenderer, identifier, false);
         if (searchEndRenderer == currentRenderer) {
             // We may be at the end of our search.
index 3930910..d27a780 100644 (file)
@@ -315,7 +315,6 @@ void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild)
         // Just add it...
         children->insertChildNode(this, newChild, beforeChild);
     }
-    RenderCounter::rendererSubtreeAttached(newChild);
     if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) {
         RefPtr<StringImpl> textToTransform = toRenderText(newChild)->originalText();
         if (textToTransform)
index c7c8e44..fed5a2e 100644 (file)
@@ -174,6 +174,7 @@ void RenderObjectChildList::appendChildNode(RenderObject* owner, RenderObject* n
             owner->dirtyLinesFromChangedChild(newChild);
     }
 
+    RenderCounter::rendererSubtreeAttached(newChild);
     newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy.
     if (!owner->normalChildNeedsLayout())
         owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
@@ -233,6 +234,7 @@ void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c
             owner->dirtyLinesFromChangedChild(child);
     }
 
+    RenderCounter::rendererSubtreeAttached(child);
     child->setNeedsLayoutAndPrefWidthsRecalc();
     if (!owner->normalChildNeedsLayout())
         owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.