Changeset 155116 in webkit


Ignore:
Timestamp:
Sep 5, 2013, 7:45:58 AM (11 years ago)
Author:
Antti Koivisto
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r155113 r155116  
     12013-09-05  Antti Koivisto  <antti@apple.com>
     2
     3        Call createTextRenderersForSiblingsAfterAttachIfNeeded only for the attach root
     4        https://bugs.webkit.org/show_bug.cgi?id=120770
     5
     6        Reviewed by Andreas Kling.
     7
     8        There is no need to call this during recursive attach as siblings are going to be attached normally anyway.
     9        Move call sites to attach roots only.
     10
     11        * style/StyleResolveTree.cpp:
     12        (WebCore::Style::createTextRenderersForSiblingsAfterAttachIfNeeded):
     13       
     14            Factor to take reference and do the inital tests itself.
     15
     16        (WebCore::Style::createTextRendererIfNeeded):
     17        (WebCore::Style::updateTextRendererAfterContentChange):
     18        (WebCore::Style::attachChildren):
     19       
     20            Also tightened the condition where previously attached children may be encountered.
     21
     22        (WebCore::Style::attachRenderTree):
     23        (WebCore::Style::resolveLocal):
     24        (WebCore::Style::updateTextStyle):
     25        (WebCore::Style::reattachRenderTree):
     26
    1272013-09-05  Enrique Ocaña González  <eocanha@igalia.com>
    228
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r155074 r155116  
    281281}
    282282
    283 static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node* sibling)
    284 {
    285     ASSERT(sibling->previousSibling());
    286     ASSERT(sibling->previousSibling()->renderer());
    287     ASSERT(!sibling->renderer());
    288     ASSERT(sibling->attached());
     283static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node& node)
     284{
     285    if (!node.renderer())
     286        return;
    289287    // If this node got a renderer it may be the previousRenderer() of sibling text nodes and thus affect the
    290288    // result of Text::textRendererIsNeeded() for those nodes.
    291     for (; sibling; sibling = sibling->nextSibling()) {
     289    for (Node* sibling = node.nextSibling(); sibling; sibling = sibling->nextSibling()) {
    292290        if (sibling->renderer())
    293291            break;
     
    296294        if (!sibling->isTextNode())
    297295            continue;
    298         ASSERT(!sibling->renderer());
    299296        attachTextRenderer(*toText(sibling));
    300297        // If we again decided not to create a renderer for next, we can bail out the loop,
     
    386383    newRenderer->setStyle(style.release());
    387384    parentRenderer->addChild(newRenderer, nextRenderer);
    388 
    389     Node* sibling = textNode.nextSibling();
    390     if (sibling && !sibling->renderer() && sibling->attached())
    391         createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
    392385}
    393386
     
    415408    if (!textRenderer) {
    416409        attachTextRenderer(textNode);
     410        createTextRenderersForSiblingsAfterAttachIfNeeded(textNode);
    417411        return;
    418412    }
     
    426420}
    427421
    428 #ifndef NDEBUG
    429 static bool childAttachedAllowedWhenAttachingChildren(ContainerNode& node)
    430 {
    431     if (node.isShadowRoot())
    432         return true;
    433     if (node.isInsertionPoint())
    434         return true;
    435     if (node.isElementNode() && toElement(&node)->shadowRoot())
    436         return true;
    437     return false;
    438 }
    439 #endif
    440 
    441422static void attachChildren(ContainerNode& current)
    442423{
    443424    for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
    444         ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
     425        ASSERT(!child->attached() || current.shadowRoot());
    445426        if (child->attached())
    446427            continue;
     
    494475
    495476    attachChildren(current);
    496 
    497     Node* sibling = current.nextSibling();
    498     if (current.renderer() && sibling && !sibling->renderer() && sibling->attached())
    499         createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
    500477
    501478    current.setAttached(true);
     
    613590            detachRenderTree(current, ReattachDetach);
    614591        attachRenderTree(current, newStyle.get());
     592        createTextRenderersForSiblingsAfterAttachIfNeeded(current);
     593
    615594        return Detach;
    616595    }
     
    653632    if (renderer)
    654633        renderer->setText(text.dataImpl());
    655     else
     634    else {
    656635        attachTextRenderer(text);
     636        createTextRenderersForSiblingsAfterAttachIfNeeded(text);
     637    }
    657638    text.clearNeedsStyleRecalc();
    658639}
     
    837818{
    838819    attachRenderTree(element, nullptr);
     820    createTextRenderersForSiblingsAfterAttachIfNeeded(element);
    839821}
    840822
     
    853835    if (current.attached())
    854836        detachRenderTree(current, ReattachDetach);
    855     attachRenderTree(current, nullptr);
    856 }
    857 
    858 }
    859 }
     837    attachRenderTree(current);
     838}
     839
     840}
     841}
Note: See TracChangeset for help on using the changeset viewer.