⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 251638 in webkit


Ignore:
Timestamp:
Oct 26, 2019, 12:16:18 PM (7 years ago)
Author:
Alan Bujtas
Message:

[LFC] Do not layout on every paint frame.
https://bugs.webkit.org/show_bug.cgi?id=203462
<rdar://problem/56646779>

Reviewed by Antti Koivisto.

This is in preparation for being able to run layout benchmarks.

  • layout/LayoutContext.cpp:

(WebCore::Layout::LayoutContext::runLayoutAndVerify):
(WebCore::Layout::LayoutContext::paint):
(WebCore::Layout::LayoutContext::runLayoutAndPaint): Deleted.

  • layout/LayoutContext.h:
  • layout/LayoutState.cpp:

(WebCore::Layout::LayoutState::LayoutState):

  • layout/LayoutState.h:
  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::printLayoutTreeForLiveDocuments):

  • page/FrameView.cpp:

(WebCore::FrameView::paintContents):

  • page/FrameViewLayoutContext.cpp:

(WebCore::FrameViewLayoutContext::layoutUsingFormattingContext):
(WebCore::FrameViewLayoutContext::layout):
(WebCore::layoutUsingFormattingContext): Deleted.

  • page/FrameViewLayoutContext.h:

(WebCore::FrameViewLayoutContext::initialLayoutState const):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251637 r251638  
     12019-10-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Do not layout on every paint frame.
     4        https://bugs.webkit.org/show_bug.cgi?id=203462
     5        <rdar://problem/56646779>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This is in preparation for being able to run layout benchmarks.
     10
     11        * layout/LayoutContext.cpp:
     12        (WebCore::Layout::LayoutContext::runLayoutAndVerify):
     13        (WebCore::Layout::LayoutContext::paint):
     14        (WebCore::Layout::LayoutContext::runLayoutAndPaint): Deleted.
     15        * layout/LayoutContext.h:
     16        * layout/LayoutState.cpp:
     17        (WebCore::Layout::LayoutState::LayoutState):
     18        * layout/LayoutState.h:
     19        * layout/layouttree/LayoutTreeBuilder.cpp:
     20        (WebCore::Layout::printLayoutTreeForLiveDocuments):
     21        * page/FrameView.cpp:
     22        (WebCore::FrameView::paintContents):
     23        * page/FrameViewLayoutContext.cpp:
     24        (WebCore::FrameViewLayoutContext::layoutUsingFormattingContext):
     25        (WebCore::FrameViewLayoutContext::layout):
     26        (WebCore::layoutUsingFormattingContext): Deleted.
     27        * page/FrameViewLayoutContext.h:
     28        (WebCore::FrameViewLayoutContext::initialLayoutState const):
     29
    1302019-10-26  Rob Buis  <rbuis@igalia.com>
    231
  • trunk/Source/WebCore/layout/LayoutContext.cpp

    r250769 r251638  
    162162}
    163163
    164 void LayoutContext::runLayoutAndVerify(const RenderView& renderView)
     164std::unique_ptr<LayoutState> LayoutContext::runLayoutAndVerify(const RenderView& renderView)
    165165{
    166     auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
    167     auto layoutState = LayoutState { *initialContainingBlock };
    168     initializeLayoutState(layoutState, renderView);
    169     runLayout(layoutState);
    170     LayoutContext::verifyAndOutputMismatchingLayoutTree(layoutState, renderView);
     166    auto layoutState = makeUnique<LayoutState>(TreeBuilder::createLayoutTree(renderView));
     167    initializeLayoutState(*layoutState, renderView);
     168    runLayout(*layoutState);
     169    LayoutContext::verifyAndOutputMismatchingLayoutTree(*layoutState, renderView);
     170    return layoutState;
    171171}
    172172
    173 void LayoutContext::runLayoutAndPaint(const RenderView& renderView, GraphicsContext& context)
     173void LayoutContext::paint(const LayoutState& layoutState, GraphicsContext& context)
    174174{
    175     auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
    176     auto layoutState = LayoutState { *initialContainingBlock };
    177     initializeLayoutState(layoutState, renderView);
    178     runLayout(layoutState);
    179175    Display::Painter::paint(layoutState, context);
    180176}
  • trunk/Source/WebCore/layout/LayoutContext.h

    r251590 r251638  
    5555public:
    5656    // FIXME: These are temporary entry points for LFC layout.
    57     static void runLayoutAndVerify(const RenderView&);
    58     static void runLayoutAndPaint(const RenderView&, GraphicsContext&);
     57    static std::unique_ptr<LayoutState> runLayoutAndVerify(const RenderView&);
     58    static void paint(const LayoutState&, GraphicsContext&);
    5959
    6060    LayoutContext(LayoutState&);
  • trunk/Source/WebCore/layout/LayoutState.cpp

    r251484 r251638  
    3939WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
    4040
    41 LayoutState::LayoutState(const Container& root)
    42     : m_root(makeWeakPtr(root))
     41LayoutState::LayoutState(std::unique_ptr<Container> root)
     42    : m_root(WTFMove(root))
    4343{
    4444    // It makes absolutely no sense to construct a dedicated layout state for a non-formatting context root (it would be a no-op).
    45     ASSERT(root.establishesFormattingContext());
     45    ASSERT(m_root->establishesFormattingContext());
    4646}
    4747
  • trunk/Source/WebCore/layout/LayoutState.h

    r251484 r251638  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
     30#include "LayoutContainer.h"
    3031#include <wtf/HashMap.h>
    3132#include <wtf/HashSet.h>
     
    4243
    4344class Box;
    44 class Container;
    4545class FormattingContext;
    4646class FormattingState;
     
    4949    WTF_MAKE_ISO_ALLOCATED(LayoutState);
    5050public:
    51     LayoutState(const Container& root);
     51    LayoutState(std::unique_ptr<Container> root);
    5252    ~LayoutState();
    5353
     
    7575
    7676private:
    77     WeakPtr<const Container> m_root;
     77    // FIXME: Figure out the ownership model for the layout tree.
     78    std::unique_ptr<Container> m_root;
    7879    HashMap<const Container*, std::unique_ptr<FormattingState>> m_formattingStates;
    7980#ifndef NDEBUG
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r251484 r251638  
    402402        // FIXME: Need to find a way to output geometry without layout context.
    403403        auto& renderView = *document->renderView();
    404         auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
    405         auto layoutState = LayoutState { *initialContainingBlock };
     404        auto layoutState = LayoutState { TreeBuilder::createLayoutTree(renderView) };
    406405        layoutState.setQuirksMode(renderView.document().inLimitedQuirksMode() ? LayoutState::QuirksMode::Limited : (renderView.document().inQuirksMode() ? LayoutState::QuirksMode::Yes : LayoutState::QuirksMode::No));
    407406        LayoutContext(layoutState).layout();
    408         showLayoutTree(*initialContainingBlock, &layoutState);
     407        showLayoutTree(layoutState.root(), &layoutState);
    409408    }
    410409}
  • trunk/Source/WebCore/page/FrameView.cpp

    r251567 r251638  
    41814181#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    41824182    if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextEnabled()) {
    4183         Layout::LayoutContext::runLayoutAndPaint(*renderView, context);
     4183        if (auto* layoutState = layoutContext().initialLayoutState())
     4184            Layout::LayoutContext::paint(*layoutState, context);
    41844185        return;
    41854186    }
  • trunk/Source/WebCore/page/FrameViewLayoutContext.cpp

    r251605 r251638  
    4242#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    4343#include "LayoutContext.h"
     44#include "LayoutState.h"
    4445#endif
    4546
     
    5152
    5253#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    53 static void layoutUsingFormattingContext(const RenderView& renderView)
     54void FrameViewLayoutContext::layoutUsingFormattingContext()
    5455{
    5556    if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextEnabled())
    5657        return;
    57     Layout::LayoutContext::runLayoutAndVerify(renderView);
     58    m_initialLayoutState = Layout::LayoutContext::runLayoutAndVerify(*renderView());
    5859}
    5960#endif
     
    205206        layoutRoot->layout();
    206207#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    207         layoutUsingFormattingContext(*renderView());
     208        layoutUsingFormattingContext();
    208209#endif
    209210        ++m_layoutCount;
  • trunk/Source/WebCore/page/FrameViewLayoutContext.h

    r245868 r251638  
    4343class RenderLayoutState;
    4444class RenderView;
     45#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     46namespace Layout {
     47class LayoutState;
     48}
     49#endif
    4550   
    4651class FrameViewLayoutContext {
     
    111116    using LayoutStateStack = Vector<std::unique_ptr<RenderLayoutState>>;
    112117
     118#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     119    const Layout::LayoutState* initialLayoutState() const { return m_initialLayoutState.get(); }
     120#endif
     121
    113122private:
    114123    friend class LayoutScope;
     
    151160    void disablePaintOffsetCache() { m_paintOffsetCacheDisableCount++; }
    152161    void enablePaintOffsetCache() { ASSERT(m_paintOffsetCacheDisableCount > 0); m_paintOffsetCacheDisableCount--; }
     162#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     163    void layoutUsingFormattingContext();
     164#endif
    153165
    154166    Frame& frame() const;
     
    176188    unsigned m_paintOffsetCacheDisableCount { 0 };
    177189    LayoutStateStack m_layoutStateStack;
     190#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     191    std::unique_ptr<Layout::LayoutState> m_initialLayoutState;
     192#endif
    178193};
    179194
Note: See TracChangeset for help on using the changeset viewer.