Changeset 223649 in webkit


Ignore:
Timestamp:
Oct 18, 2017 7:22:45 PM (6 years ago)
Author:
Alan Bujtas
Message:

[FrameView::layout cleanup] Group related pre-layout code to improve readability
https://bugs.webkit.org/show_bug.cgi?id=178496
<rdar://problem/35065718>

Reviewed by Simon Fraser.

Early returns/asserts/member variable resets etc.

Covered by existing tests.

  • page/FrameView.cpp:

(WebCore::FrameView::layout):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223644 r223649  
     12017-10-18  Zalan Bujtas  <zalan@apple.com>
     2
     3        [FrameView::layout cleanup] Group related pre-layout code to improve readability
     4        https://bugs.webkit.org/show_bug.cgi?id=178496
     5        <rdar://problem/35065718>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Early returns/asserts/member variable resets etc.
     10
     11        Covered by existing tests.
     12
     13        * page/FrameView.cpp:
     14        (WebCore::FrameView::layout):
     15
    1162017-10-17  Jiewen Tan  <jiewen_tan@apple.com>
    217
  • trunk/Source/WebCore/page/FrameView.cpp

    r223633 r223649  
    13501350    LOG(Layout, "FrameView %p (%dx%d) layout, main frameview %d, allowSubtreeLayout=%d", this, size().width(), size().height(), frame().isMainFrame(), allowSubtreeLayout);
    13511351    if (isInRenderTreeLayout()) {
    1352         LOG(Layout, "  in layout, bailing");
     1352        LOG(Layout, "  in render tree layout, bailing");
    13531353        return;
    13541354    }
    13551355
    13561356    if (layoutDisallowed()) {
    1357         LOG(Layout, "  layout is disallowed, bailing");
    1358         return;
    1359     }
    1360 
     1357        LOG(Layout, "  is disallowed, bailing");
     1358        return;
     1359    }
     1360    ASSERT(!isPainting());
     1361    if (isPainting()) {
     1362        LOG(Layout, "  in painting, bailing");
     1363        return;
     1364    }
     1365
     1366    ASSERT(frame().view() == this);
     1367    ASSERT(frame().document());
     1368    ASSERT(frame().document()->pageCacheState() == Document::NotInPageCache);
    13611369    // Protect the view from being deleted during layout (in recalcStyle).
    13621370    Ref<FrameView> protectedThis(*this);
     1371    TraceScope tracingScope(LayoutStart, LayoutEnd);
     1372    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(frame());
     1373    AnimationUpdateBlock animationUpdateBlock(&frame().animation());
    13631374
    13641375    // Many of the tasks performed during layout can cause this function to be re-entered,
    13651376    // so save the layout phase now and restore it on exit.
    13661377    SetForScope<LayoutPhase> layoutPhaseRestorer(m_layoutPhase, InPreLayout);
    1367 
    13681378    // Every scroll that happens during layout is programmatic.
    13691379    SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
    1370    
    1371     TraceScope tracingScope(LayoutStart, LayoutEnd);
    1372 
    1373     if (handleLayoutWithFrameFlatteningIfNeeded(allowSubtreeLayout))
    1374         return;
    1375 
     1380
     1381    m_layoutTimer.stop();
     1382    m_delayedLayout = false;
     1383    m_setNeedsLayoutWasDeferred = false;
     1384    if (!allowSubtreeLayout && m_subtreeLayoutRoot)
     1385        convertSubtreeLayoutToFullLayout();
    13761386#if PLATFORM(IOS)
    13771387    if (updateFixedPositionLayoutRect())
     
    13791389#endif
    13801390
    1381     m_layoutTimer.stop();
    1382     m_delayedLayout = false;
    1383     m_setNeedsLayoutWasDeferred = false;
    1384    
    1385     // we shouldn't enter layout() while painting
    1386     ASSERT(!isPainting());
    1387     if (isPainting())
    1388         return;
    1389 
    1390     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(frame());
    1391     AnimationUpdateBlock animationUpdateBlock(&frame().animation());
    1392    
    1393     if (!allowSubtreeLayout && m_subtreeLayoutRoot)
    1394         convertSubtreeLayoutToFullLayout();
    1395 
    1396     ASSERT(frame().view() == this);
    1397     ASSERT(frame().document());
     1391    if (handleLayoutWithFrameFlatteningIfNeeded(allowSubtreeLayout))
     1392        return;
    13981393
    13991394    Document& document = *frame().document();
    1400     ASSERT(document.pageCacheState() == Document::NotInPageCache);
    14011395    RenderElement* layoutRoot = nullptr;
    1402     RenderLayer* layer = nullptr;
    14031396    bool isSubtreeLayout = false;
    1404 
    14051397    {
    14061398        SetForScope<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
     
    14941486
    14951487        ASSERT(allowSubtreeLayout || !isSubtreeLayout);
    1496         layer = layoutRoot->enclosingLayer();
     1488        ASSERT(m_layoutPhase == InPreLayout);
     1489
     1490        forceLayoutParentViewIfNeeded();
     1491
    14971492        SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(m_subtreeLayoutRoot);
    1498 
    14991493        RenderView::RepaintRegionAccumulator repaintRegionAccumulator(&layoutRoot->view());
    1500 
    1501         ASSERT(m_layoutPhase == InPreLayout);
    1502         m_layoutPhase = InRenderTreeLayout;
    1503 
    1504         forceLayoutParentViewIfNeeded();
    1505 
    1506         ASSERT(m_layoutPhase == InRenderTreeLayout);
    15071494#ifndef NDEBUG
    15081495        RenderTreeNeedsLayoutChecker checker(*layoutRoot);
    15091496#endif
     1497        m_layoutPhase = InRenderTreeLayout;
    15101498        layoutRoot->layout();
     1499        ASSERT(m_layoutPhase == InRenderTreeLayout);
    15111500
    15121501#if ENABLE(TEXT_AUTOSIZING)
    15131502        applyTextSizingIfNeeded(*layoutRoot);
    15141503#endif
    1515 
    1516         ASSERT(m_layoutPhase == InRenderTreeLayout);
    15171504        m_subtreeLayoutRoot = nullptr;
    15181505        // Close block here to end the scope of changeSchedulingEnabled and SubtreeLayoutStateMaintainer.
     
    15361523
    15371524    ASSERT(!layoutRoot->needsLayout());
    1538 
    1539     layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, isSubtreeLayout, m_needsFullRepaint));
     1525    auto* layoutRootEnclosingLayer = layoutRoot->enclosingLayer();
     1526    layoutRootEnclosingLayer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layoutRootEnclosingLayer, isSubtreeLayout, m_needsFullRepaint));
    15401527
    15411528    updateCompositingLayersAfterLayout();
Note: See TracChangeset for help on using the changeset viewer.