Changeset 156904 in webkit


Ignore:
Timestamp:
Oct 4, 2013 12:22:38 PM (11 years ago)
Author:
Antti Koivisto
Message:

Tighten markContainingBlocksForLayout
https://bugs.webkit.org/show_bug.cgi?id=122326

Reviewed by Anders Carlsson.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r156903 r156904  
     12013-10-04  Antti Koivisto  <antti@apple.com>
     2
     3        Tighten markContainingBlocksForLayout
     4        https://bugs.webkit.org/show_bug.cgi?id=122326
     5
     6        Reviewed by Anders Carlsson.
     7
    182013-10-04  Andreas Kling  <akling@apple.com>
    29
  • trunk/Source/WebCore/page/FrameView.cpp

    r156876 r156904  
    24032403}
    24042404
    2405 void FrameView::scheduleRelayoutOfSubtree(RenderObject& newRelayoutRoot)
     2405void FrameView::scheduleRelayoutOfSubtree(RenderElement& newRelayoutRoot)
    24062406{
    24072407    ASSERT(renderView());
     
    33863386    parentView->layout(allowSubtree);
    33873387
    3388     RenderObject* root = m_layoutRoot ? m_layoutRoot : frame().document()->renderView();
     3388    RenderElement* root = m_layoutRoot ? m_layoutRoot : frame().document()->renderView();
    33893389    ASSERT_UNUSED(root, !root->needsLayout());
    33903390
  • trunk/Source/WebCore/page/FrameView.h

    r156871 r156904  
    107107    void layoutTimerFired(Timer<FrameView>*);
    108108    void scheduleRelayout();
    109     void scheduleRelayoutOfSubtree(RenderObject&);
     109    void scheduleRelayoutOfSubtree(RenderElement&);
    110110    void unscheduleRelayout();
    111111    bool layoutPending() const;
     
    568568    Timer<FrameView> m_layoutTimer;
    569569    bool m_delayedLayout;
    570     RenderObject* m_layoutRoot;
     570    RenderElement* m_layoutRoot;
    571571   
    572572    bool m_layoutSchedulingEnabled;
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r156876 r156904  
    596596}
    597597
    598 static inline bool objectIsRelayoutBoundary(const RenderObject* object)
     598static inline bool objectIsRelayoutBoundary(const RenderElement* object)
    599599{
    600600    // FIXME: In future it may be possible to broaden these conditions in order to improve performance.
     601    if (object->isRenderView())
     602        return true;
     603
    601604    if (object->isTextControl())
    602605        return true;
     
    635638}
    636639
    637 void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderObject* newRoot)
     640static void scheduleRelayoutForSubtree(RenderElement& renderer)
     641{
     642    if (!renderer.isRenderView()) {
     643        if (!renderer.isRooted())
     644            return;
     645        renderer.view().frameView().scheduleRelayoutOfSubtree(renderer);
     646        return;
     647    }
     648    toRenderView(renderer).frameView().scheduleRelayout();
     649}
     650
     651void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderElement* newRoot)
    638652{
    639653    ASSERT(!scheduleRelayout || !newRoot);
    640654    ASSERT(!isSetNeedsLayoutForbidden());
    641655
    642     RenderElement* object = container();
    643     RenderObject* last = this;
     656    RenderElement* ancestor = container();
    644657
    645658    bool simplifiedNormalFlowLayout = needsSimplifiedNormalFlowLayout() && !selfNeedsLayout() && !normalChildNeedsLayout();
    646 
    647     while (object) {
     659    bool hasOutOfFlowPosition = !isText() && style()->hasOutOfFlowPosition();
     660
     661    while (ancestor) {
    648662#ifndef NDEBUG
    649663        // FIXME: Remove this once we remove the special cases for counters, quotes and mathml
    650664        // calling setNeedsLayout during preferred width computation.
    651         SetLayoutNeededForbiddenScope layoutForbiddenScope(object, isSetNeedsLayoutForbidden());
     665        SetLayoutNeededForbiddenScope layoutForbiddenScope(ancestor, isSetNeedsLayoutForbidden());
    652666#endif
    653667        // Don't mark the outermost object of an unrooted subtree. That object will be
    654668        // marked when the subtree is added to the document.
    655         RenderElement* container = object->container();
    656         if (!container && !object->isRenderView())
     669        RenderElement* container = ancestor->container();
     670        if (!container && !ancestor->isRenderView())
    657671            return;
    658         if (!last->isText() && last->style()->hasOutOfFlowPosition()) {
    659             bool willSkipRelativelyPositionedInlines = !object->isRenderBlock() || object->isAnonymousBlock();
     672        if (hasOutOfFlowPosition) {
     673            bool willSkipRelativelyPositionedInlines = !ancestor->isRenderBlock() || ancestor->isAnonymousBlock();
    660674            // Skip relatively positioned inlines and anonymous blocks to get to the enclosing RenderBlock.
    661             while (object && (!object->isRenderBlock() || object->isAnonymousBlock()))
    662                 object = object->container();
    663             if (!object || object->posChildNeedsLayout())
     675            while (ancestor && (!ancestor->isRenderBlock() || ancestor->isAnonymousBlock()))
     676                ancestor = ancestor->container();
     677            if (!ancestor || ancestor->posChildNeedsLayout())
    664678                return;
    665679            if (willSkipRelativelyPositionedInlines)
    666                 container = object->container();
    667             object->setPosChildNeedsLayoutBit(true);
     680                container = ancestor->container();
     681            ancestor->setPosChildNeedsLayoutBit(true);
    668682            simplifiedNormalFlowLayout = true;
    669             ASSERT(!object->isSetNeedsLayoutForbidden());
    670683        } else if (simplifiedNormalFlowLayout) {
    671             if (object->needsSimplifiedNormalFlowLayout())
     684            if (ancestor->needsSimplifiedNormalFlowLayout())
    672685                return;
    673             object->setNeedsSimplifiedNormalFlowLayoutBit(true);
    674             ASSERT(!object->isSetNeedsLayoutForbidden());
     686            ancestor->setNeedsSimplifiedNormalFlowLayoutBit(true);
    675687        } else {
    676             if (object->normalChildNeedsLayout())
     688            if (ancestor->normalChildNeedsLayout())
    677689                return;
    678             object->setNormalChildNeedsLayoutBit(true);
    679             ASSERT(!object->isSetNeedsLayoutForbidden());
    680         }
    681 
    682         if (object == newRoot)
     690            ancestor->setNormalChildNeedsLayoutBit(true);
     691        }
     692        ASSERT(!ancestor->isSetNeedsLayoutForbidden());
     693
     694        if (ancestor == newRoot)
    683695            return;
    684696
    685         last = object;
    686         if (scheduleRelayout && objectIsRelayoutBoundary(last))
     697        if (scheduleRelayout && objectIsRelayoutBoundary(ancestor))
    687698            break;
    688         object = container;
    689     }
    690 
    691     if (scheduleRelayout)
    692         last->scheduleRelayout();
     699
     700        hasOutOfFlowPosition = ancestor->style()->hasOutOfFlowPosition();
     701        ancestor = container;
     702    }
     703
     704    if (scheduleRelayout && ancestor)
     705        scheduleRelayoutForSubtree(*ancestor);
    693706}
    694707
     
    22052218}
    22062219
    2207 void RenderObject::scheduleRelayout()
    2208 {
    2209     if (isRenderView())
    2210         toRenderView(*this).frameView().scheduleRelayout();
    2211     else {
    2212         if (isRooted())
    2213             view().frameView().scheduleRelayoutOfSubtree(*this);
    2214     }
    2215 }
    2216 
    22172220void RenderObject::layout()
    22182221{
  • trunk/Source/WebCore/rendering/RenderObject.h

    r156876 r156904  
    617617    RenderBoxModelObject* offsetParent() const;
    618618
    619     void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0);
     619    void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderElement* newRoot = 0);
    620620    void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
    621621    void clearNeedsLayout();
     
    653653    void setHasTransform(bool b = true) { m_bitfields.setHasTransform(b); }
    654654    void setHasReflection(bool b = true) { m_bitfields.setHasReflection(b); }
    655 
    656     void scheduleRelayout();
    657655
    658656    virtual void paint(PaintInfo&, const LayoutPoint&);
Note: See TracChangeset for help on using the changeset viewer.