Changeset 154873 in webkit


Ignore:
Timestamp:
Aug 30, 2013, 5:33:15 AM (12 years ago)
Author:
Antti Koivisto
Message:

Remove AttachContext
https://bugs.webkit.org/show_bug.cgi?id=120518

Reviewed by Andreas Kling.

This type is not useful anymore. Just pass the precomputed style to attachRenderTree and reattach-or-not flag to detachRenderTree.

  • style/StyleResolveTree.cpp:

(WebCore::Style::createRendererIfNeeded):
(WebCore::Style::attachChildren):
(WebCore::Style::attachShadowRoot):
(WebCore::Style::attachRenderTree):
(WebCore::Style::detachChildren):
(WebCore::Style::detachShadowRoot):
(WebCore::Style::detachRenderTree):
(WebCore::Style::reattachRenderTree):
(WebCore::Style::resolveLocal):

  • style/StyleResolveTree.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r154871 r154873  
     12013-08-30  Antti Koivisto  <antti@apple.com>
     2
     3        Remove AttachContext
     4        https://bugs.webkit.org/show_bug.cgi?id=120518
     5
     6        Reviewed by Andreas Kling.
     7
     8        This type is not useful anymore. Just pass the precomputed style to attachRenderTree and reattach-or-not flag to detachRenderTree.
     9
     10        * style/StyleResolveTree.cpp:
     11        (WebCore::Style::createRendererIfNeeded):
     12        (WebCore::Style::attachChildren):
     13        (WebCore::Style::attachShadowRoot):
     14        (WebCore::Style::attachRenderTree):
     15        (WebCore::Style::detachChildren):
     16        (WebCore::Style::detachShadowRoot):
     17        (WebCore::Style::detachRenderTree):
     18        (WebCore::Style::reattachRenderTree):
     19        (WebCore::Style::resolveLocal):
     20        * style/StyleResolveTree.h:
     21
    1222013-08-30  Commit Queue  <commit-queue@webkit.org>
    223
  • TabularUnified trunk/Source/WebCore/dom/Element.cpp

    r154835 r154873  
    13761376void Element::lazyReattach(ShouldSetAttached shouldSetAttached)
    13771377{
    1378     Style::AttachContext context;
    1379     context.performingReattach = true;
    1380 
    13811378    if (attached())
    1382         Style::detachRenderTree(this, context);
     1379        Style::detachRenderTreeInReattachMode(this);
    13831380    lazyAttach(shouldSetAttached);
    13841381}
  • TabularUnified trunk/Source/WebCore/style/StyleResolveTree.cpp

    r154820 r154873  
    5555namespace Style {
    5656
     57enum DetachType { NormalDetach, ReattachDetach };
     58
     59static void attachRenderTree(Element*, RenderStyle* resolvedStyle);
     60static void detachRenderTree(Element*, DetachType);
     61
    5762Change determineChange(const RenderStyle* s1, const RenderStyle* s2, Settings* settings)
    5863{
     
    189194#endif
    190195
    191 static void createRendererIfNeeded(Element& element, const AttachContext& context)
     196static void createRendererIfNeeded(Element& element, RenderStyle* resolvedStyle)
    192197{
    193198    ASSERT(!element.renderer());
     
    196201    ContainerNode* renderingParentNode = NodeRenderingTraversal::parent(&element);
    197202
    198     RefPtr<RenderStyle> style = context.resolvedStyle;
     203    RefPtr<RenderStyle> style = resolvedStyle;
    199204
    200205    element.setIsInsideRegion(false);
     
    432437#endif
    433438
    434 static void attachChildren(ContainerNode& current, const AttachContext& context)
    435 {
    436     AttachContext childrenContext(context);
    437     childrenContext.resolvedStyle = 0;
    438 
     439static void attachChildren(ContainerNode& current)
     440{
    439441    for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
    440442        ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
     
    446448        }
    447449        if (child->isElementNode())
    448             attachRenderTree(toElement(child), childrenContext);
    449     }
    450 }
    451 
    452 static void attachShadowRoot(ShadowRoot& shadowRoot, const AttachContext& context)
     450            attachRenderTree(toElement(child), nullptr);
     451    }
     452}
     453
     454static void attachShadowRoot(ShadowRoot& shadowRoot)
    453455{
    454456    if (shadowRoot.attached())
     
    457459    styleResolver.pushParentShadowRoot(&shadowRoot);
    458460
    459     attachChildren(shadowRoot, context);
     461    attachChildren(shadowRoot);
    460462
    461463    styleResolver.popParentShadowRoot(&shadowRoot);
     
    465467}
    466468
    467 void attachRenderTree(Element* current, const AttachContext& context)
     469static void attachRenderTree(Element* current, RenderStyle* resolvedStyle)
    468470{
    469471    PostAttachCallbackDisabler callbackDisabler(current);
     
    473475        current->willAttachRenderers();
    474476
    475     createRendererIfNeeded(*current, context);
     477    createRendererIfNeeded(*current, resolvedStyle);
    476478
    477479    if (current->parentElement() && current->parentElement()->isInCanvasSubtree())
     
    485487    if (ShadowRoot* shadowRoot = current->shadowRoot()) {
    486488        parentPusher.push();
    487         attachShadowRoot(*shadowRoot, context);
     489        attachShadowRoot(*shadowRoot);
    488490    } else if (current->firstChild())
    489491        parentPusher.push();
    490492
    491     attachChildren(*current, context);
     493    attachChildren(*current);
    492494
    493495    Node* sibling = current->nextSibling();
     
    511513}
    512514
    513 static void detachChildren(ContainerNode& current, const AttachContext& context)
    514 {
    515     AttachContext childrenContext(context);
    516     childrenContext.resolvedStyle = 0;
    517 
     515static void detachChildren(ContainerNode& current, DetachType detachType)
     516{
    518517    for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
    519518        if (child->isTextNode()) {
     
    522521        }
    523522        if (child->isElementNode())
    524             detachRenderTree(toElement(child), childrenContext);
     523            detachRenderTree(toElement(child), detachType);
    525524    }
    526525    current.clearChildNeedsStyleRecalc();
    527526}
    528527
    529 static void detachShadowRoot(ShadowRoot& shadowRoot, const AttachContext& context)
     528static void detachShadowRoot(ShadowRoot& shadowRoot, DetachType detachType)
    530529{
    531530    if (!shadowRoot.attached())
    532531        return;
    533     detachChildren(shadowRoot, context);
     532    detachChildren(shadowRoot, detachType);
    534533
    535534    shadowRoot.setAttached(false);
    536535}
    537536
    538 void detachRenderTree(Element* current, const AttachContext& context)
     537static void detachRenderTree(Element* current, DetachType detachType)
    539538{
    540539    WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
     
    547546    // Do not remove the element's hovered and active status
    548547    // if performing a reattach.
    549     if (!context.performingReattach)
     548    if (detachType != ReattachDetach)
    550549        current->clearHoverAndActiveStatusBeforeDetachingRenderer();
    551550
    552551    if (ShadowRoot* shadowRoot = current->shadowRoot())
    553         detachShadowRoot(*shadowRoot, context);
    554 
    555     detachChildren(*current, context);
     552        detachShadowRoot(*shadowRoot, detachType);
     553
     554    detachChildren(*current, detachType);
    556555
    557556    if (current->renderer())
     
    563562    if (current->hasCustomStyleResolveCallbacks())
    564563        current->didDetachRenderers();
    565 }
    566 
    567 void reattachRenderTree(Element* current, const AttachContext& context)
    568 {
    569     AttachContext reattachContext(context);
    570     reattachContext.performingReattach = true;
    571 
    572     if (current->attached())
    573         detachRenderTree(current, reattachContext);
    574 
    575     attachRenderTree(current, reattachContext);
    576564}
    577565
     
    622610    }
    623611    if (localChange == Detach) {
    624         AttachContext reattachContext;
    625         reattachContext.resolvedStyle = newStyle.get();
    626         reattachRenderTree(current, reattachContext);
     612        if (current->attached())
     613            detachRenderTree(current, ReattachDetach);
     614        attachRenderTree(current, newStyle.get());
    627615        return Detach;
    628616    }
     
    845833}
    846834
    847 }
    848 }
     835void attachRenderTree(Element* element)
     836{
     837    attachRenderTree(element, nullptr);
     838}
     839
     840void detachRenderTree(Element* element)
     841{
     842    detachRenderTree(element, NormalDetach);
     843}
     844
     845void detachRenderTreeInReattachMode(Element* element)
     846{
     847    detachRenderTree(element, ReattachDetach);
     848}
     849
     850void reattachRenderTree(Element* current)
     851{
     852    if (current->attached())
     853        detachRenderTree(current, ReattachDetach);
     854    attachRenderTree(current, nullptr);
     855}
     856
     857}
     858}
  • TabularUnified trunk/Source/WebCore/style/StyleResolveTree.h

    r154738 r154873  
    4242void resolveTree(Document*, Change);
    4343
    44 struct AttachContext {
    45     RenderStyle* resolvedStyle;
    46     bool performingReattach;
    47 
    48     AttachContext() : resolvedStyle(0), performingReattach(false) { }
    49 };
    50 void attachRenderTree(Element*, const AttachContext& = AttachContext());
    51 void detachRenderTree(Element*, const AttachContext& = AttachContext());
    52 void reattachRenderTree(Element*, const AttachContext& = AttachContext());
     44void attachRenderTree(Element*);
     45void detachRenderTree(Element*);
     46void reattachRenderTree(Element*);
     47// FIXME: This is only used for "lazy reattach" for shadow trees.
     48void detachRenderTreeInReattachMode(Element*);
    5349
    5450void attachTextRenderer(Text&);
Note: See TracChangeset for help on using the changeset viewer.