Title: [155116] trunk/Source/WebCore
Revision
155116
Author
[email protected]
Date
2013-09-05 07:45:58 -0700 (Thu, 05 Sep 2013)

Log Message

Call createTextRenderersForSiblingsAfterAttachIfNeeded only for the attach root
https://bugs.webkit.org/show_bug.cgi?id=120770

Reviewed by Andreas Kling.

There is no need to call this during recursive attach as siblings are going to be attached normally anyway.
Move call sites to attach roots only.

* style/StyleResolveTree.cpp:
(WebCore::Style::createTextRenderersForSiblingsAfterAttachIfNeeded):
        
    Factor to take reference and do the inital tests itself.

(WebCore::Style::createTextRendererIfNeeded):
(WebCore::Style::updateTextRendererAfterContentChange):
(WebCore::Style::attachChildren):
        
    Also tightened the condition where previously attached children may be encountered.

(WebCore::Style::attachRenderTree):
(WebCore::Style::resolveLocal):
(WebCore::Style::updateTextStyle):
(WebCore::Style::reattachRenderTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155115 => 155116)


--- trunk/Source/WebCore/ChangeLog	2013-09-05 14:31:30 UTC (rev 155115)
+++ trunk/Source/WebCore/ChangeLog	2013-09-05 14:45:58 UTC (rev 155116)
@@ -1,3 +1,29 @@
+2013-09-05  Antti Koivisto  <[email protected]>
+
+        Call createTextRenderersForSiblingsAfterAttachIfNeeded only for the attach root
+        https://bugs.webkit.org/show_bug.cgi?id=120770
+
+        Reviewed by Andreas Kling.
+
+        There is no need to call this during recursive attach as siblings are going to be attached normally anyway.
+        Move call sites to attach roots only.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::createTextRenderersForSiblingsAfterAttachIfNeeded):
+        
+            Factor to take reference and do the inital tests itself.
+
+        (WebCore::Style::createTextRendererIfNeeded):
+        (WebCore::Style::updateTextRendererAfterContentChange):
+        (WebCore::Style::attachChildren):
+        
+            Also tightened the condition where previously attached children may be encountered.
+
+        (WebCore::Style::attachRenderTree):
+        (WebCore::Style::resolveLocal):
+        (WebCore::Style::updateTextStyle):
+        (WebCore::Style::reattachRenderTree):
+
 2013-09-05  Enrique Ocaña González  <[email protected]>
 
         [GTK] Assertion fails when the mouse pointer is styled with a custom cursor

Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (155115 => 155116)


--- trunk/Source/WebCore/style/StyleResolveTree.cpp	2013-09-05 14:31:30 UTC (rev 155115)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp	2013-09-05 14:45:58 UTC (rev 155116)
@@ -280,22 +280,19 @@
     return 0;
 }
 
-static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node* sibling)
+static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node& node)
 {
-    ASSERT(sibling->previousSibling());
-    ASSERT(sibling->previousSibling()->renderer());
-    ASSERT(!sibling->renderer());
-    ASSERT(sibling->attached());
+    if (!node.renderer())
+        return;
     // If this node got a renderer it may be the previousRenderer() of sibling text nodes and thus affect the
     // result of Text::textRendererIsNeeded() for those nodes.
-    for (; sibling; sibling = sibling->nextSibling()) {
+    for (Node* sibling = node.nextSibling(); sibling; sibling = sibling->nextSibling()) {
         if (sibling->renderer())
             break;
         if (!sibling->attached())
             break; // Assume this means none of the following siblings are attached.
         if (!sibling->isTextNode())
             continue;
-        ASSERT(!sibling->renderer());
         attachTextRenderer(*toText(sibling));
         // If we again decided not to create a renderer for next, we can bail out the loop,
         // because it won't affect the result of Text::textRendererIsNeeded() for the rest
@@ -385,10 +382,6 @@
     // Parent takes care of the animations, no need to call setAnimatableStyle.
     newRenderer->setStyle(style.release());
     parentRenderer->addChild(newRenderer, nextRenderer);
-
-    Node* sibling = textNode.nextSibling();
-    if (sibling && !sibling->renderer() && sibling->attached())
-        createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
 }
 
 void attachTextRenderer(Text& textNode)
@@ -414,6 +407,7 @@
     RenderText* textRenderer = toRenderText(textNode.renderer());
     if (!textRenderer) {
         attachTextRenderer(textNode);
+        createTextRenderersForSiblingsAfterAttachIfNeeded(textNode);
         return;
     }
     RenderObject* parentRenderer = NodeRenderingTraversal::parent(&textNode)->renderer();
@@ -425,23 +419,10 @@
     textRenderer->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData);
 }
 
-#ifndef NDEBUG
-static bool childAttachedAllowedWhenAttachingChildren(ContainerNode& node)
-{
-    if (node.isShadowRoot())
-        return true;
-    if (node.isInsertionPoint())
-        return true;
-    if (node.isElementNode() && toElement(&node)->shadowRoot())
-        return true;
-    return false;
-}
-#endif
-
 static void attachChildren(ContainerNode& current)
 {
     for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
-        ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
+        ASSERT(!child->attached() || current.shadowRoot());
         if (child->attached())
             continue;
         if (child->isTextNode()) {
@@ -494,10 +475,6 @@
 
     attachChildren(current);
 
-    Node* sibling = current.nextSibling();
-    if (current.renderer() && sibling && !sibling->renderer() && sibling->attached())
-        createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
-
     current.setAttached(true);
     current.clearNeedsStyleRecalc();
 
@@ -612,6 +589,8 @@
         if (current.attached())
             detachRenderTree(current, ReattachDetach);
         attachRenderTree(current, newStyle.get());
+        createTextRenderersForSiblingsAfterAttachIfNeeded(current);
+
         return Detach;
     }
 
@@ -652,8 +631,10 @@
         return;
     if (renderer)
         renderer->setText(text.dataImpl());
-    else
+    else {
         attachTextRenderer(text);
+        createTextRenderersForSiblingsAfterAttachIfNeeded(text);
+    }
     text.clearNeedsStyleRecalc();
 }
 
@@ -836,6 +817,7 @@
 void attachRenderTree(Element& element)
 {
     attachRenderTree(element, nullptr);
+    createTextRenderersForSiblingsAfterAttachIfNeeded(element);
 }
 
 void detachRenderTree(Element& element)
@@ -852,7 +834,7 @@
 {
     if (current.attached())
         detachRenderTree(current, ReattachDetach);
-    attachRenderTree(current, nullptr);
+    attachRenderTree(current);
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to