Changeset 223569 in webkit


Ignore:
Timestamp:
Oct 17, 2017 1:09:15 PM (7 years ago)
Author:
Alan Bujtas
Message:

[FrameView::layout cleanup] Subtree should read subtreeLayout.
https://bugs.webkit.org/show_bug.cgi?id=178401

Reviewed by Simon Fraser.

Rename some variables to improve readability.

No change in functionality.

  • page/FrameView.cpp:

(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree):
(WebCore::FrameView::reset):
(WebCore::FrameView::willDestroyRenderTree):
(WebCore::FrameView::didDestroyRenderTree):
(WebCore::FrameView::calculateScrollbarModesForLayout):
(WebCore::FrameView::layout):
(WebCore::FrameView::convertSubtreeLayoutToFullLayout):
(WebCore::FrameView::scheduleRelayout):
(WebCore::FrameView::scheduleRelayoutOfSubtree):
(WebCore::FrameView::needsLayout const):
(WebCore::FrameView::autoSizeIfEnabled):

  • page/FrameView.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223567 r223569  
     12017-10-17  Zalan Bujtas  <zalan@apple.com>
     2
     3        [FrameView::layout cleanup] Subtree should read subtreeLayout.
     4        https://bugs.webkit.org/show_bug.cgi?id=178401
     5
     6        Reviewed by Simon Fraser.
     7
     8        Rename some variables to improve readability.
     9
     10        No change in functionality.
     11
     12        * page/FrameView.cpp:
     13        (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
     14        (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
     15        (WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree):
     16        (WebCore::FrameView::reset):
     17        (WebCore::FrameView::willDestroyRenderTree):
     18        (WebCore::FrameView::didDestroyRenderTree):
     19        (WebCore::FrameView::calculateScrollbarModesForLayout):
     20        (WebCore::FrameView::layout):
     21        (WebCore::FrameView::convertSubtreeLayoutToFullLayout):
     22        (WebCore::FrameView::scheduleRelayout):
     23        (WebCore::FrameView::scheduleRelayoutOfSubtree):
     24        (WebCore::FrameView::needsLayout const):
     25        (WebCore::FrameView::autoSizeIfEnabled):
     26        * page/FrameView.h:
     27
    1282017-10-16  Dean Jackson  <dino@apple.com>
    229
  • trunk/Source/WebCore/dom/Document.cpp

    r223514 r223569  
    20692069            }
    20702070           
    2071             if (currRenderer == frameView->layoutRoot())
     2071            if (currRenderer == frameView->subtreeLayoutRoot())
    20722072                break;
    20732073        }
  • trunk/Source/WebCore/page/FrameView.cpp

    r223551 r223569  
    167167public:
    168168    SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
    169         : m_layoutRoot(subtreeLayoutRoot)
     169        : m_subtreeLayoutRoot(subtreeLayoutRoot)
    170170    {
    171         if (m_layoutRoot) {
    172             RenderView& view = m_layoutRoot->view();
    173             view.pushLayoutState(*m_layoutRoot);
     171        if (m_subtreeLayoutRoot) {
     172            RenderView& view = m_subtreeLayoutRoot->view();
     173            view.pushLayoutState(*m_subtreeLayoutRoot);
    174174            if (shouldDisableLayoutStateForSubtree()) {
    175175                view.disableLayoutState();
     
    181181    ~SubtreeLayoutStateMaintainer()
    182182    {
    183         if (m_layoutRoot) {
    184             RenderView& view = m_layoutRoot->view();
    185             view.popLayoutState(*m_layoutRoot);
     183        if (m_subtreeLayoutRoot) {
     184            RenderView& view = m_subtreeLayoutRoot->view();
     185            view.popLayoutState(*m_subtreeLayoutRoot);
    186186            if (m_didDisableLayoutState)
    187187                view.enableLayoutState();
     
    191191    bool shouldDisableLayoutStateForSubtree()
    192192    {
    193         for (auto* renderer = m_layoutRoot; renderer; renderer = renderer->container()) {
     193        for (auto* renderer = m_subtreeLayoutRoot; renderer; renderer = renderer->container()) {
    194194            if (renderer->hasTransform() || renderer->hasReflection())
    195195                return true;
     
    199199   
    200200private:
    201     RenderElement* m_layoutRoot { nullptr };
     201    RenderElement* m_subtreeLayoutRoot { nullptr };
    202202    bool m_didDisableLayoutState { false };
    203203};
     
    337337    m_contentIsOpaque = false;
    338338    m_layoutTimer.stop();
    339     m_layoutRoot = nullptr;
     339    m_subtreeLayoutRoot = nullptr;
    340340    m_delayedLayout = false;
    341341    m_needsFullRepaint = true;
     
    656656{
    657657    detachCustomScrollbars();
    658     m_layoutRoot = nullptr;
     658    m_subtreeLayoutRoot = nullptr;
    659659}
    660660
    661661void FrameView::didDestroyRenderTree()
    662662{
    663     ASSERT(!m_layoutRoot);
     663    ASSERT(!m_subtreeLayoutRoot);
    664664    ASSERT(m_widgetsInRenderTree.isEmpty());
    665665
     
    829829    }
    830830   
    831     if (m_layoutRoot)
     831    if (m_subtreeLayoutRoot)
    832832        return;
    833833   
     
    13231323#endif
    13241324
    1325 void FrameView::layout(bool allowSubtree)
     1325void FrameView::layout(bool allowSubtreeLayout)
    13261326{
    13271327    ASSERT_WITH_SECURITY_IMPLICATION(!frame().document()->inRenderTreeUpdate());
    13281328
    1329     LOG(Layout, "FrameView %p (%dx%d) layout, main frameview %d, allowSubtree=%d", this, size().width(), size().height(), frame().isMainFrame(), allowSubtree);
     1329    LOG(Layout, "FrameView %p (%dx%d) layout, main frameview %d, allowSubtreeLayout=%d", this, size().width(), size().height(), frame().isMainFrame(), allowSubtreeLayout);
    13301330    if (isInRenderTreeLayout()) {
    13311331        LOG(Layout, "  in layout, bailing");
     
    13551355            m_frameFlatteningViewSizeForMediaQuery = ScrollView::layoutSize();
    13561356        }
    1357         startLayoutAtMainFrameViewIfNeeded(allowSubtree);
    1358         RenderElement* root = m_layoutRoot ? m_layoutRoot : frame().document()->renderView();
    1359         if (!root || !root->needsLayout())
     1357        startLayoutAtMainFrameViewIfNeeded(allowSubtreeLayout);
     1358        auto* layoutRoot = m_subtreeLayoutRoot ? m_subtreeLayoutRoot : frame().document()->renderView();
     1359        if (!layoutRoot || !layoutRoot->needsLayout())
    13601360            return;
    13611361    }
     
    13651365#if PLATFORM(IOS)
    13661366    if (updateFixedPositionLayoutRect())
    1367         allowSubtree = false;
     1367        allowSubtreeLayout = false;
    13681368#endif
    13691369
     
    13801380    AnimationUpdateBlock animationUpdateBlock(&frame().animation());
    13811381   
    1382     if (!allowSubtree && m_layoutRoot)
     1382    if (!allowSubtreeLayout && m_subtreeLayoutRoot)
    13831383        convertSubtreeLayoutToFullLayout();
    13841384
     
    13881388    Document& document = *frame().document();
    13891389    ASSERT(document.pageCacheState() == Document::NotInPageCache);
    1390     RenderElement* root = nullptr;
     1390    RenderElement* layoutRoot = nullptr;
    13911391    RenderLayer* layer = nullptr;
    1392     bool subtree = false;
     1392    bool isSubtreeLayout = false;
    13931393
    13941394    {
     
    14301430        autoSizeIfEnabled();
    14311431
    1432         root = m_layoutRoot ? m_layoutRoot : document.renderView();
    1433         if (!root)
     1432        layoutRoot = m_subtreeLayoutRoot ? m_subtreeLayoutRoot : document.renderView();
     1433        if (!layoutRoot)
    14341434            return;
    1435         subtree = m_layoutRoot;
    1436 
    1437         if (!m_layoutRoot) {
     1435        isSubtreeLayout = m_subtreeLayoutRoot;
     1436
     1437        if (!isSubtreeLayout) {
    14381438            auto* body = document.bodyOrFrameset();
    14391439            if (body && body->renderer()) {
     
    14521452        }
    14531453
    1454         m_needsFullRepaint = !subtree && (m_firstLayout || downcast<RenderView>(*root).printing());
    1455 
    1456         if (!subtree) {
     1454        m_needsFullRepaint = !isSubtreeLayout && (m_firstLayout || downcast<RenderView>(*layoutRoot).printing());
     1455
     1456        if (!isSubtreeLayout) {
    14571457            ScrollbarMode hMode;
    14581458            ScrollbarMode vMode;   
     
    14661466                    m_firstLayoutCallbackPending = true;
    14671467                    m_lastViewportSize = sizeForResizeEvent();
    1468                     m_lastZoomFactor = root->style().zoom();
     1468                    m_lastZoomFactor = layoutRoot->style().zoom();
    14691469
    14701470                    // Set the initial vMode to AlwaysOn if we're auto.
     
    15031503        }
    15041504
    1505         layer = root->enclosingLayer();
    1506         SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(m_layoutRoot);
    1507 
    1508         RenderView::RepaintRegionAccumulator repaintRegionAccumulator(&root->view());
     1505        ASSERT(allowSubtreeLayout || !isSubtreeLayout);
     1506        layer = layoutRoot->enclosingLayer();
     1507        SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(m_subtreeLayoutRoot);
     1508
     1509        RenderView::RepaintRegionAccumulator repaintRegionAccumulator(&layoutRoot->view());
    15091510
    15101511        ASSERT(m_layoutPhase == InPreLayout);
     
    15151516        ASSERT(m_layoutPhase == InRenderTreeLayout);
    15161517#ifndef NDEBUG
    1517         RenderTreeNeedsLayoutChecker checker(*root);
     1518        RenderTreeNeedsLayoutChecker checker(*layoutRoot);
    15181519#endif
    1519         root->layout();
     1520        layoutRoot->layout();
    15201521
    15211522#if ENABLE(TEXT_AUTOSIZING)
    1522         applyTextSizingIfNeeded(*root);
     1523        applyTextSizingIfNeeded(*layoutRoot);
    15231524#endif
    15241525
    15251526        ASSERT(m_layoutPhase == InRenderTreeLayout);
    1526         m_layoutRoot = nullptr;
     1527        m_subtreeLayoutRoot = nullptr;
    15271528        // Close block here to end the scope of changeSchedulingEnabled and SubtreeLayoutStateMaintainer.
    15281529    }
     
    15321533    bool neededFullRepaint = m_needsFullRepaint;
    15331534
    1534     if (!subtree && !downcast<RenderView>(*root).printing()) {
     1535    if (!isSubtreeLayout && !downcast<RenderView>(*layoutRoot).printing()) {
    15351536        adjustViewSize();
    15361537        // FIXME: Firing media query callbacks synchronously on nested frames could produced a detached FrameView here by
     
    15461547    // Now update the positions of all layers.
    15471548    if (m_needsFullRepaint)
    1548         root->view().repaintRootContents();
    1549 
    1550     root->view().releaseProtectedRenderWidgets();
    1551 
    1552     ASSERT(!root->needsLayout());
    1553 
    1554     layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, subtree, m_needsFullRepaint));
     1549        layoutRoot->view().repaintRootContents();
     1550
     1551    layoutRoot->view().releaseProtectedRenderWidgets();
     1552
     1553    ASSERT(!layoutRoot->needsLayout());
     1554
     1555    layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, isSubtreeLayout, m_needsFullRepaint));
    15551556
    15561557    updateCompositingLayersAfterLayout();
     
    15611562
    15621563#if PLATFORM(COCOA) || PLATFORM(WIN) || PLATFORM(GTK)
    1563     if (AXObjectCache* cache = root->document().existingAXObjectCache())
    1564         cache->postNotification(root, AXObjectCache::AXLayoutComplete);
     1564    if (AXObjectCache* cache = layoutRoot->document().existingAXObjectCache())
     1565        cache->postNotification(layoutRoot, AXObjectCache::AXLayoutComplete);
    15651566#endif
    15661567
     
    16051606    }
    16061607
    1607     InspectorInstrumentation::didLayout(cookie, *root);
     1608    InspectorInstrumentation::didLayout(cookie, *layoutRoot);
    16081609    DebugPageOverlays::didLayout(frame());
    16091610
     
    30403041void FrameView::convertSubtreeLayoutToFullLayout()
    30413042{
    3042     ASSERT(m_layoutRoot);
    3043     m_layoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No);
    3044     m_layoutRoot = nullptr;
     3043    ASSERT(m_subtreeLayoutRoot);
     3044    m_subtreeLayoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No);
     3045    m_subtreeLayoutRoot = nullptr;
    30453046}
    30463047
     
    30603061    ASSERT(frame().view() == this);
    30613062
    3062     if (m_layoutRoot)
     3063    if (m_subtreeLayoutRoot)
    30633064        convertSubtreeLayoutToFullLayout();
    30643065    if (!m_layoutSchedulingEnabled)
     
    31093110    ASSERT(frame().view() == this);
    31103111
    3111     // When m_layoutRoot is already set, ignore the renderView's needsLayout bit
    3112     // since we need to resolve the conflict between the m_layoutRoot and newRelayoutRoot layouts.
    3113     if (renderView.needsLayout() && !m_layoutRoot) {
    3114         m_layoutRoot = &newRelayoutRoot;
     3112    // When m_subtreeLayoutRoot is already set, ignore the renderView's needsLayout bit
     3113    // since we need to resolve the conflict between the m_subtreeLayoutRoot and newRelayoutRoot layouts.
     3114    if (renderView.needsLayout() && !m_subtreeLayoutRoot) {
     3115        m_subtreeLayoutRoot = &newRelayoutRoot;
    31153116        convertSubtreeLayoutToFullLayout();
    31163117        return;
     
    31203121        Seconds delay = renderView.document().minimumLayoutDelay();
    31213122        ASSERT(!newRelayoutRoot.container() || is<RenderView>(newRelayoutRoot.container()) || !newRelayoutRoot.container()->needsLayout());
    3122         m_layoutRoot = &newRelayoutRoot;
     3123        m_subtreeLayoutRoot = &newRelayoutRoot;
    31233124        InspectorInstrumentation::didInvalidateLayout(frame());
    31243125        m_delayedLayout = delay.value();
     
    31273128    }
    31283129
    3129     if (m_layoutRoot == &newRelayoutRoot)
    3130         return;
    3131 
    3132     if (!m_layoutRoot) {
     3130    if (m_subtreeLayoutRoot == &newRelayoutRoot)
     3131        return;
     3132
     3133    if (!m_subtreeLayoutRoot) {
    31333134        // We already have a pending (full) layout. Just mark the subtree for layout.
    31343135        newRelayoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
     
    31373138    }
    31383139
    3139     if (isObjectAncestorContainerOf(m_layoutRoot, &newRelayoutRoot)) {
     3140    if (isObjectAncestorContainerOf(m_subtreeLayoutRoot, &newRelayoutRoot)) {
    31403141        // Keep the current root.
    3141         newRelayoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No, m_layoutRoot);
    3142         ASSERT(!m_layoutRoot->container() || is<RenderView>(m_layoutRoot->container()) || !m_layoutRoot->container()->needsLayout());
    3143         return;
    3144     }
    3145 
    3146     if (isObjectAncestorContainerOf(&newRelayoutRoot, m_layoutRoot)) {
     3142        newRelayoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No, m_subtreeLayoutRoot);
     3143        ASSERT(!m_subtreeLayoutRoot->container() || is<RenderView>(m_subtreeLayoutRoot->container()) || !m_subtreeLayoutRoot->container()->needsLayout());
     3144        return;
     3145    }
     3146
     3147    if (isObjectAncestorContainerOf(&newRelayoutRoot, m_subtreeLayoutRoot)) {
    31473148        // Re-root at newRelayoutRoot.
    3148         m_layoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No, &newRelayoutRoot);
    3149         m_layoutRoot = &newRelayoutRoot;
    3150         ASSERT(!m_layoutRoot->container() || is<RenderView>(m_layoutRoot->container()) || !m_layoutRoot->container()->needsLayout());
     3149        m_subtreeLayoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No, &newRelayoutRoot);
     3150        m_subtreeLayoutRoot = &newRelayoutRoot;
     3151        ASSERT(!m_subtreeLayoutRoot->container() || is<RenderView>(m_subtreeLayoutRoot->container()) || !m_subtreeLayoutRoot->container()->needsLayout());
    31513152        InspectorInstrumentation::didInvalidateLayout(frame());
    31523153        return;
     
    31713172    return layoutPending()
    31723173        || (renderView && renderView->needsLayout())
    3173         || m_layoutRoot
     3174        || m_subtreeLayoutRoot
    31743175        || (m_deferSetNeedsLayoutCount && m_setNeedsLayoutWasDeferred);
    31753176}
     
    36893690    LOG(Layout, "FrameView %p autoSizeIfEnabled", this);
    36903691    SetForScope<bool> changeInAutoSize(m_inAutoSize, true);
    3691     if (m_layoutRoot)
     3692    if (m_subtreeLayoutRoot)
    36923693        convertSubtreeLayoutToFullLayout();
    36933694    // Start from the minimum size and allow it to grow.
  • trunk/Source/WebCore/page/FrameView.h

    r223432 r223569  
    117117    bool inPaintableState() { return m_layoutPhase != InRenderTreeLayout && m_layoutPhase != InViewSizeAdjust && m_layoutPhase != InPostLayout; }
    118118
    119     RenderElement* layoutRoot() const { return m_layoutRoot; }
    120     void clearLayoutRoot() { m_layoutRoot = nullptr; }
     119    RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot; }
     120    void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot = nullptr; }
    121121    int layoutCount() const { return m_layoutCount; }
    122122
     
    800800    Timer m_layoutTimer;
    801801    bool m_delayedLayout;
    802     RenderElement* m_layoutRoot { nullptr };
     802    RenderElement* m_subtreeLayoutRoot { nullptr };
    803803
    804804    LayoutPhase m_layoutPhase;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r223389 r223569  
    22972297
    22982298    // If layout is limited to a subtree, the subtree root's logical width does not change.
    2299     if (element() && !view().frameView().layoutPending() && view().frameView().layoutRoot() == this)
     2299    if (element() && !view().frameView().layoutPending() && view().frameView().subtreeLayoutRoot() == this)
    23002300        return;
    23012301
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r223514 r223569  
    10971097}
    10981098
    1099 inline void RenderElement::clearLayoutRootIfNeeded() const
     1099inline void RenderElement::clearSubtreeLayoutRootIfNeeded() const
    11001100{
    11011101    if (renderTreeBeingDestroyed())
    11021102        return;
    11031103
    1104     if (view().frameView().layoutRoot() != this)
     1104    if (view().frameView().subtreeLayoutRoot() != this)
    11051105        return;
    11061106
     
    11121112    // the layout root is still set to |this|. Make sure to clear it
    11131113    // since we are getting destroyed.
    1114     view().frameView().clearLayoutRoot();
     1114    view().frameView().clearSubtreeLayoutRoot();
    11151115}
    11161116
     
    11291129    RenderObject::willBeDestroyed();
    11301130
    1131     clearLayoutRootIfNeeded();
     1131    clearSubtreeLayoutRootIfNeeded();
    11321132
    11331133    if (hasInitializedStyle()) {
  • trunk/Source/WebCore/rendering/RenderElement.h

    r223194 r223569  
    324324    bool getTrailingCorner(FloatPoint& output, bool& insideFixed) const;
    325325
    326     void clearLayoutRootIfNeeded() const;
     326    void clearSubtreeLayoutRootIfNeeded() const;
    327327   
    328328    bool shouldWillChangeCreateStackingContext() const;
Note: See TracChangeset for help on using the changeset viewer.