Title: [250128] trunk/Source/WebCore
Revision
250128
Author
za...@apple.com
Date
2019-09-20 06:36:00 -0700 (Fri, 20 Sep 2019)

Log Message

[LFC] Introduce LayoutContext class
https://bugs.webkit.org/show_bug.cgi?id=202026
<rdar://problem/55546622>

Reviewed by Antti Koivisto.

Move context related functionality from LayoutState to LayoutContext.
To initiate a layout, create a LayoutContext, pass the current LayoutState object in and call layout().

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::layoutOutOfFlowContent):
* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::createFormattingStateForFormattingRootIfNeeded):
(WebCore::Layout::LayoutState::updateLayout): Deleted.
(WebCore::Layout::LayoutState::layoutFormattingContextSubtree): Deleted.
(WebCore::Layout::LayoutState::styleChanged): Deleted.
(WebCore::Layout::LayoutState::markNeedsUpdate): Deleted.
(WebCore::Layout::LayoutState::createFormattingContext): Deleted.
(WebCore::Layout::LayoutState::run): Deleted.
* layout/LayoutState.h:
(WebCore::Layout::LayoutState::hasFormattingState const):
(WebCore::Layout::LayoutState::setQuirksMode):
(WebCore::Layout::LayoutState::inNoQuirksMode const):
(WebCore::Layout::LayoutState::updateAll): Deleted.
* layout/Verification.cpp:
(WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree):
(WebCore::Layout::LayoutState::verifyAndOutputMismatchingLayoutTree const): Deleted.
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
* layout/blockformatting/BlockInvalidation.cpp:
(WebCore::Layout::computeUpdateType):
(WebCore::Layout::computeUpdateTypeForAncestor):
(WebCore::Layout::BlockInvalidation::invalidate):
* layout/blockformatting/BlockInvalidation.h:
* layout/displaytree/DisplayBox.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
(WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot):
* layout/inlineformatting/InlineInvalidation.cpp:
(WebCore::Layout::InlineInvalidation::invalidate):
* layout/inlineformatting/InlineInvalidation.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::printLayoutTreeForLiveDocuments):
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::layoutTableCellBox):
(WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns):
* layout/tableformatting/TableInvalidation.cpp:
(WebCore::Layout::TableInvalidation::invalidate):
* layout/tableformatting/TableInvalidation.h:
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250127 => 250128)


--- trunk/Source/WebCore/ChangeLog	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/ChangeLog	2019-09-20 13:36:00 UTC (rev 250128)
@@ -1,3 +1,64 @@
+2019-09-20  Zalan Bujtas  <za...@apple.com>
+
+        [LFC] Introduce LayoutContext class
+        https://bugs.webkit.org/show_bug.cgi?id=202026
+        <rdar://problem/55546622>
+
+        Reviewed by Antti Koivisto.
+
+        Move context related functionality from LayoutState to LayoutContext.
+        To initiate a layout, create a LayoutContext, pass the current LayoutState object in and call layout().  
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::layoutOutOfFlowContent):
+        * layout/FormattingContext.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+        * layout/LayoutState.cpp:
+        (WebCore::Layout::LayoutState::createFormattingStateForFormattingRootIfNeeded):
+        (WebCore::Layout::LayoutState::updateLayout): Deleted.
+        (WebCore::Layout::LayoutState::layoutFormattingContextSubtree): Deleted.
+        (WebCore::Layout::LayoutState::styleChanged): Deleted.
+        (WebCore::Layout::LayoutState::markNeedsUpdate): Deleted.
+        (WebCore::Layout::LayoutState::createFormattingContext): Deleted.
+        (WebCore::Layout::LayoutState::run): Deleted.
+        * layout/LayoutState.h:
+        (WebCore::Layout::LayoutState::hasFormattingState const):
+        (WebCore::Layout::LayoutState::setQuirksMode):
+        (WebCore::Layout::LayoutState::inNoQuirksMode const):
+        (WebCore::Layout::LayoutState::updateAll): Deleted.
+        * layout/Verification.cpp:
+        (WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree):
+        (WebCore::Layout::LayoutState::verifyAndOutputMismatchingLayoutTree const): Deleted.
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
+        * layout/blockformatting/BlockInvalidation.cpp:
+        (WebCore::Layout::computeUpdateType):
+        (WebCore::Layout::computeUpdateTypeForAncestor):
+        (WebCore::Layout::BlockInvalidation::invalidate):
+        * layout/blockformatting/BlockInvalidation.h:
+        * layout/displaytree/DisplayBox.h:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
+        (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot):
+        * layout/inlineformatting/InlineInvalidation.cpp:
+        (WebCore::Layout::InlineInvalidation::invalidate):
+        * layout/inlineformatting/InlineInvalidation.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::printLayoutTreeForLiveDocuments):
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::layoutTableCellBox):
+        (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns):
+        * layout/tableformatting/TableInvalidation.cpp:
+        (WebCore::Layout::TableInvalidation::invalidate):
+        * layout/tableformatting/TableInvalidation.h:
+        * page/FrameViewLayoutContext.cpp:
+        (WebCore::layoutUsingFormattingContext):
+
 2019-09-19  Joonghun Park  <pjh0...@gmail.com>
 
         Unreviewed. Fix Build error below since r248879.

Modified: trunk/Source/WebCore/Sources.txt (250127 => 250128)


--- trunk/Source/WebCore/Sources.txt	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/Sources.txt	2019-09-20 13:36:00 UTC (rev 250128)
@@ -1401,6 +1401,7 @@
 layout/FormattingContextGeometry.cpp
 layout/FormattingContextQuirks.cpp
 layout/FormattingState.cpp
+layout/LayoutContext.cpp
 layout/LayoutPhase.cpp
 layout/LayoutState.cpp
 layout/LayoutUnits.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (250127 => 250128)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-09-20 13:36:00 UTC (rev 250128)
@@ -2002,6 +2002,7 @@
 		6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
 		6F0CD695229ED32700C5994E /* InlineLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F0CD694229ED32700C5994E /* InlineLine.h */; };
 		6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26BB6B23343E5B002F2BEA /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F3E1F622136142000A65A08 /* FloatBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F3E1F612136141700A65A08 /* FloatBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C4208C2956002F29AB /* LayoutState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F7CA3CA208C2B2E002F29AB /* InlineFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9157,6 +9158,8 @@
 		6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
 		6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
 		6F25B200220A85AB0000011B /* InlineFormattingContextLineLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContextLineLayout.cpp; sourceTree = "<group>"; };
+		6F26BB6923343E5A002F2BEA /* LayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContext.cpp; sourceTree = "<group>"; };
+		6F26BB6B23343E5B002F2BEA /* LayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContext.h; sourceTree = "<group>"; };
 		6F35EFAF2187CBD50044E0F4 /* InlineFormattingContextGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContextGeometry.cpp; sourceTree = "<group>"; };
 		6F3E1F5F2136141700A65A08 /* FloatBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FloatBox.cpp; sourceTree = "<group>"; };
 		6F3E1F612136141700A65A08 /* FloatBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; };
@@ -16417,6 +16420,8 @@
 				115CFA75208AFE30001E6991 /* FormattingState.cpp */,
 				115CFA74208AFE30001E6991 /* FormattingState.h */,
 				115F7805209CBCBD00739C13 /* Invalidation.h */,
+				6F26BB6923343E5A002F2BEA /* LayoutContext.cpp */,
+				6F26BB6B23343E5B002F2BEA /* LayoutContext.h */,
 				6F4A5BD522F9F16B00A80F25 /* LayoutPhase.cpp */,
 				6FEFE81D22F9D22A00114927 /* LayoutPhase.h */,
 				6F7CA3C5208C2956002F29AB /* LayoutState.cpp */,
@@ -30693,6 +30698,7 @@
 				115CFA97208B952B001E6991 /* LayoutBox.h in Headers */,
 				11310CF620BA4A560065A8D0 /* LayoutChildIterator.h in Headers */,
 				1199FA46208E35A3002358CC /* LayoutContainer.h in Headers */,
+				6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */,
 				11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */,
 				11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */,
 				931D72F615FE695300C4C07E /* LayoutMilestone.h in Headers */,

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -32,6 +32,7 @@
 #include "FormattingState.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
+#include "LayoutContext.h"
 #include "LayoutDescendantIterator.h"
 #include "LayoutState.h"
 #include "Logging.h"
@@ -158,9 +159,10 @@
         computeBorderAndPadding(*outOfFlowBox);
         computeOutOfFlowHorizontalGeometry(*outOfFlowBox);
         if (is<Container>(*outOfFlowBox)) {
-            auto formattingContext = layoutState().createFormattingContext(downcast<Container>(*outOfFlowBox));
+            auto& outOfFlowRootContainer = downcast<Container>(*outOfFlowBox);
+            auto formattingContext = LayoutContext::createFormattingContext(outOfFlowRootContainer, layoutState());
             formattingContext->layoutInFlowContent();
-            computeOutOfFlowVerticalGeometry(*outOfFlowBox);
+            computeOutOfFlowVerticalGeometry(outOfFlowRootContainer);
             formattingContext->layoutOutOfFlowContent();            
         } else
             computeOutOfFlowVerticalGeometry(*outOfFlowBox);

Modified: trunk/Source/WebCore/layout/FormattingContext.h (250127 => 250128)


--- trunk/Source/WebCore/layout/FormattingContext.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -29,6 +29,7 @@
 
 #include "DisplayBox.h"
 #include "LayoutBox.h"
+#include "LayoutContainer.h"
 #include "LayoutState.h"
 #include <wtf/IsoMalloc.h>
 #include <wtf/WeakPtr.h>

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -258,7 +258,7 @@
         auto& formattingStateForRoot = layoutState().createFormattingStateForFormattingRootIfNeeded(root);
         auto precomputedIntrinsicWidthConstraints = formattingStateForRoot.intrinsicWidthConstraints();
         if (!precomputedIntrinsicWidthConstraints)
-            intrinsicWidthConstraints = layoutState().createFormattingContext(root)->computedIntrinsicWidthConstraints();
+            intrinsicWidthConstraints = LayoutContext::createFormattingContext(root, layoutState())->computedIntrinsicWidthConstraints();
         else
             intrinsicWidthConstraints = *precomputedIntrinsicWidthConstraints;
     }

Copied: trunk/Source/WebCore/layout/LayoutContext.cpp (from rev 250127, trunk/Source/WebCore/layout/LayoutState.cpp) (0 => 250128)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LayoutContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BlockFormattingContext.h"
+#include "BlockFormattingState.h"
+#include "BlockInvalidation.h"
+#include "DisplayBox.h"
+#include "InlineFormattingContext.h"
+#include "InlineFormattingState.h"
+#include "InlineInvalidation.h"
+#include "Invalidation.h"
+#include "LayoutBox.h"
+#include "LayoutContainer.h"
+#include "LayoutPhase.h"
+#include "LayoutTreeBuilder.h"
+#include "RenderView.h"
+#include "TableFormattingContext.h"
+#include "TableFormattingState.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutContext);
+
+LayoutContext::LayoutContext(LayoutState& layoutState)
+    : m_layoutState(layoutState)
+{
+}
+
+void LayoutContext::layout()
+{
+    PhaseScope scope(Phase::Type::Layout);
+
+    ASSERT(!m_formattingContextRootListForLayout.isEmpty());
+    for (auto* layoutRoot : m_formattingContextRootListForLayout)
+        layoutFormattingContextSubtree(*layoutRoot);
+    m_formattingContextRootListForLayout.clear();
+}
+
+void LayoutContext::layoutFormattingContextSubtree(const Container& layoutRoot)
+{
+    RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
+    auto formattingContext = createFormattingContext(layoutRoot, layoutState());
+    formattingContext->layoutInFlowContent();
+    formattingContext->layoutOutOfFlowContent();
+}
+
+void LayoutContext::styleChanged(const Box& layoutBox, StyleDiff styleDiff)
+{
+    PhaseScope scope(Phase::Type::Invalidation);
+
+    auto& formattingState = layoutState().formattingStateForBox(layoutBox);
+    const Container* invalidationRoot = nullptr;
+    if (is<BlockFormattingState>(formattingState))
+        invalidationRoot = BlockInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<BlockFormattingState>(formattingState)).root;
+    else if (is<InlineFormattingState>(formattingState))
+        invalidationRoot = InlineInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<InlineFormattingState>(formattingState)).root;
+    else
+        ASSERT_NOT_IMPLEMENTED_YET();
+    ASSERT(invalidationRoot);
+    m_formattingContextRootListForLayout.addVoid(invalidationRoot);
+}
+
+void LayoutContext::markNeedsUpdate(const Box& layoutBox, OptionSet<UpdateType>)
+{
+    // FIXME: This should trigger proper invalidation instead of just adding the formatting context root to the dirty list. 
+    m_formattingContextRootListForLayout.addVoid(&(layoutBox.isInitialContainingBlock() ? downcast<Container>(layoutBox) : layoutBox.formattingContextRoot()));
+}
+
+std::unique_ptr<FormattingContext> LayoutContext::createFormattingContext(const Container& formattingContextRoot, LayoutState& layoutState)
+{
+    ASSERT(formattingContextRoot.establishesFormattingContext());
+    if (formattingContextRoot.establishesInlineFormattingContext()) {
+        auto& inlineFormattingState = downcast<InlineFormattingState>(layoutState.createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
+        return makeUnique<InlineFormattingContext>(formattingContextRoot, inlineFormattingState);
+    }
+
+    if (formattingContextRoot.establishesBlockFormattingContext()) {
+        ASSERT(formattingContextRoot.establishesBlockFormattingContextOnly());
+        auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
+        return makeUnique<BlockFormattingContext>(formattingContextRoot, blockFormattingState);
+    }
+
+    if (formattingContextRoot.establishesTableFormattingContext()) {
+        auto& tableFormattingState = downcast<TableFormattingState>(layoutState.createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
+        return makeUnique<TableFormattingContext>(formattingContextRoot, tableFormattingState);
+    }
+
+    CRASH();
+}
+
+void LayoutContext::run(const RenderView& renderView)
+{
+    auto quirksMode = [&] {
+        auto& document = renderView.document();
+        if (document.inLimitedQuirksMode())
+            return LayoutState::QuirksMode::Limited;
+        if (document.inQuirksMode())
+            return LayoutState::QuirksMode::Yes;
+        return LayoutState::QuirksMode::No;
+    };
+
+    auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
+
+    auto layoutState = LayoutState { };
+    layoutState.setQuirksMode(quirksMode());
+    layoutState.createFormattingStateForFormattingRootIfNeeded(*initialContainingBlock);
+
+    auto layoutContext = LayoutContext(layoutState);
+
+    auto& displayBox = layoutState.displayBoxForLayoutBox(*initialContainingBlock);
+    displayBox.setHorizontalMargin({ });
+    displayBox.setHorizontalComputedMargin({ });
+    displayBox.setVerticalMargin({ });
+    displayBox.setBorder({ });
+    displayBox.setPadding({ });
+    displayBox.setTopLeft({ });
+    displayBox.setContentBoxHeight(LayoutUnit(initialContainingBlock->style().logicalHeight().value()));
+    displayBox.setContentBoxWidth(LayoutUnit(initialContainingBlock->style().logicalWidth().value()));
+
+    // Not efficient, but this is temporary anyway.
+    // Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).
+    for (auto& descendant : descendantsOfType<Box>(*initialContainingBlock)) {
+        if (!descendant.isOutOfFlowPositioned())
+            continue;
+        auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(descendant.formattingContextRoot());
+        formattingState.addOutOfFlowBox(descendant);
+    }
+    layoutContext.markNeedsUpdate(*initialContainingBlock);
+    layoutContext.layout();
+    LayoutContext::verifyAndOutputMismatchingLayoutTree(layoutState, renderView, *initialContainingBlock);
+}
+
+}
+}
+
+#endif

Copied: trunk/Source/WebCore/layout/LayoutContext.h (from rev 250127, trunk/Source/WebCore/layout/LayoutState.h) (0 => 250128)


--- trunk/Source/WebCore/layout/LayoutContext.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/LayoutContext.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "LayoutContainer.h"
+#include "LayoutState.h"
+#include <wtf/HashSet.h>
+#include <wtf/IsoMalloc.h>
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+
+class RenderView;
+
+namespace Layout {
+
+enum class StyleDiff;
+class Box;
+class FormattingContext;
+
+// LayoutContext is the entry point for layout.
+// LayoutContext::layout() generates the display tree for the root container's subtree (it does not run layout on the root though).
+// Note, while the initial containing block is entry point for the initial layout, it does not necessarily need to be the entry point of any
+// subsequent layouts (subtree layout). A non-initial, subtree layout could be initiated on multiple formatting contexts.
+// Each formatting context has an entry point for layout, which potenitally means multiple entry points per layout frame.
+// LayoutState holds the formatting states. They cache formatting context specific data to enable performant incremental layouts.
+class LayoutContext {
+    WTF_MAKE_ISO_ALLOCATED(LayoutContext);
+public:
+    // FIXME: This is a temporary entry point for LFC layout.
+    static void run(const RenderView&);
+
+    LayoutContext(LayoutState&);
+    void layout();
+
+    enum class UpdateType {
+        Overflow = 1 << 0,
+        Position = 1 << 1,
+        Size     = 1 << 2
+    };
+    static constexpr OptionSet<UpdateType> updateAll() { return { UpdateType::Overflow, UpdateType::Position, UpdateType::Size }; }
+    void markNeedsUpdate(const Box&, OptionSet<UpdateType> = updateAll());
+    bool needsUpdate(const Box&) const;
+
+    void styleChanged(const Box&, StyleDiff);
+
+    static std::unique_ptr<FormattingContext> createFormattingContext(const Container& formattingContextRoot, LayoutState&);
+
+    // For testing purposes only
+    static void verifyAndOutputMismatchingLayoutTree(const LayoutState&, const RenderView&, const Container& initialContainingBlock);
+
+private:
+    void layoutFormattingContextSubtree(const Container&);
+    LayoutState& layoutState() { return m_layoutState; }
+
+    LayoutState& m_layoutState;
+    HashSet<const Container*> m_formattingContextRootListForLayout;
+};
+
+}
+}
+#endif

Modified: trunk/Source/WebCore/layout/LayoutState.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/LayoutState.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/LayoutState.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -28,21 +28,9 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#include "BlockFormattingContext.h"
-#include "BlockFormattingState.h"
-#include "BlockInvalidation.h"
 #include "DisplayBox.h"
-#include "InlineFormattingContext.h"
-#include "InlineFormattingState.h"
-#include "InlineInvalidation.h"
-#include "Invalidation.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutPhase.h"
-#include "LayoutTreeBuilder.h"
-#include "RenderView.h"
-#include "TableFormattingContext.h"
-#include "TableFormattingState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -50,24 +38,6 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
 
-void LayoutState::updateLayout()
-{
-    PhaseScope scope(Phase::Type::Layout);
-
-    ASSERT(!m_formattingContextRootListForLayout.isEmpty());
-    for (auto* layoutRoot : m_formattingContextRootListForLayout)
-        layoutFormattingContextSubtree(*layoutRoot);
-    m_formattingContextRootListForLayout.clear();
-}
-
-void LayoutState::layoutFormattingContextSubtree(const Container& layoutRoot)
-{
-    RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
-    auto formattingContext = createFormattingContext(layoutRoot);
-    formattingContext->layoutInFlowContent();
-    formattingContext->layoutOutOfFlowContent();
-}
-
 Display::Box& LayoutState::displayBoxForLayoutBox(const Box& layoutBox) const
 {
     return *m_layoutToDisplayBox.ensure(&layoutBox, [&layoutBox] {
@@ -75,28 +45,6 @@
     }).iterator->value;
 }
 
-void LayoutState::styleChanged(const Box& layoutBox, StyleDiff styleDiff)
-{
-    PhaseScope scope(Phase::Type::Invalidation);
-
-    auto& formattingState = formattingStateForBox(layoutBox);
-    const Container* invalidationRoot = nullptr;
-    if (is<BlockFormattingState>(formattingState))
-        invalidationRoot = BlockInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<BlockFormattingState>(formattingState)).root;
-    else if (is<InlineFormattingState>(formattingState))
-        invalidationRoot = InlineInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<InlineFormattingState>(formattingState)).root;
-    else
-        ASSERT_NOT_IMPLEMENTED_YET();
-    ASSERT(invalidationRoot);
-    m_formattingContextRootListForLayout.addVoid(invalidationRoot);
-}
-
-void LayoutState::markNeedsUpdate(const Box& layoutBox, OptionSet<UpdateType>)
-{
-    // FIXME: This should trigger proper invalidation instead of just adding the formatting context root to the dirty list. 
-    m_formattingContextRootListForLayout.addVoid(&(layoutBox.isInitialContainingBlock() ? downcast<Container>(layoutBox) : layoutBox.formattingContextRoot()));
-}
-
 FormattingState& LayoutState::formattingStateForBox(const Box& layoutBox) const
 {
     auto& root = layoutBox.formattingContextRoot();
@@ -111,40 +59,40 @@
     return *m_formattingStates.get(&formattingRoot);
 }
 
-FormattingState& LayoutState::createFormattingStateForFormattingRootIfNeeded(const Container& formattingRoot)
+FormattingState& LayoutState::createFormattingStateForFormattingRootIfNeeded(const Container& formattingContextRoot)
 {
-    ASSERT(formattingRoot.establishesFormattingContext());
+    ASSERT(formattingContextRoot.establishesFormattingContext());
 
-    if (formattingRoot.establishesInlineFormattingContext()) {
-        return *m_formattingStates.ensure(&formattingRoot, [&] {
+    if (formattingContextRoot.establishesInlineFormattingContext()) {
+        return *m_formattingStates.ensure(&formattingContextRoot, [&] {
 
             // If the block container box that initiates this inline formatting context also establishes a block context, the floats outside of the formatting root
             // should not interfere with the content inside.
             // <div style="float: left"></div><div style="overflow: hidden"> <- is a non-intrusive float, because overflow: hidden triggers new block formatting context.</div>
-            if (formattingRoot.establishesBlockFormattingContext())
-                return makeUnique<InlineFormattingState>(FloatingState::create(*this, formattingRoot), *this);
+            if (formattingContextRoot.establishesBlockFormattingContext())
+                return makeUnique<InlineFormattingState>(FloatingState::create(*this, formattingContextRoot), *this);
 
             // Otherwise, the formatting context inherits the floats from the parent formatting context.
             // Find the formatting state in which this formatting root lives, not the one it creates and use its floating state.
-            auto& parentFormattingState = createFormattingStateForFormattingRootIfNeeded(formattingRoot.formattingContextRoot()); 
+            auto& parentFormattingState = createFormattingStateForFormattingRootIfNeeded(formattingContextRoot.formattingContextRoot()); 
             auto& parentFloatingState = parentFormattingState.floatingState();
             return makeUnique<InlineFormattingState>(parentFloatingState, *this);
         }).iterator->value;
     }
 
-    if (formattingRoot.establishesBlockFormattingContext()) {
-        return *m_formattingStates.ensure(&formattingRoot, [&] {
+    if (formattingContextRoot.establishesBlockFormattingContext()) {
+        return *m_formattingStates.ensure(&formattingContextRoot, [&] {
 
             // Block formatting context always establishes a new floating state.
-            return makeUnique<BlockFormattingState>(FloatingState::create(*this, formattingRoot), *this);
+            return makeUnique<BlockFormattingState>(FloatingState::create(*this, formattingContextRoot), *this);
         }).iterator->value;
     }
 
-    if (formattingRoot.establishesTableFormattingContext()) {
-        return *m_formattingStates.ensure(&formattingRoot, [&] {
+    if (formattingContextRoot.establishesTableFormattingContext()) {
+        return *m_formattingStates.ensure(&formattingContextRoot, [&] {
 
             // Table formatting context always establishes a new floating state -and it stays empty.
-            return makeUnique<TableFormattingState>(FloatingState::create(*this, formattingRoot), *this);
+            return makeUnique<TableFormattingState>(FloatingState::create(*this, formattingContextRoot), *this);
         }).iterator->value;
     }
 
@@ -151,68 +99,7 @@
     CRASH();
 }
 
-std::unique_ptr<FormattingContext> LayoutState::createFormattingContext(const Container& formattingContextRoot)
-{
-    ASSERT(formattingContextRoot.establishesFormattingContext());
-    if (formattingContextRoot.establishesInlineFormattingContext()) {
-        auto& inlineFormattingState = downcast<InlineFormattingState>(createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
-        return makeUnique<InlineFormattingContext>(formattingContextRoot, inlineFormattingState);
-    }
-
-    if (formattingContextRoot.establishesBlockFormattingContext()) {
-        ASSERT(formattingContextRoot.establishesBlockFormattingContextOnly());
-        auto& blockFormattingState = downcast<BlockFormattingState>(createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
-        return makeUnique<BlockFormattingContext>(formattingContextRoot, blockFormattingState);
-    }
-
-    if (formattingContextRoot.establishesTableFormattingContext()) {
-        auto& tableFormattingState = downcast<TableFormattingState>(createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
-        return makeUnique<TableFormattingContext>(formattingContextRoot, tableFormattingState);
-    }
-
-    CRASH();
 }
-
-void LayoutState::run(const RenderView& renderView)
-{
-    auto layoutState = LayoutState { };
-
-    auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
-    layoutState.createFormattingStateForFormattingRootIfNeeded(*initialContainingBlock);
-
-    auto& displayBox = layoutState.displayBoxForLayoutBox(*initialContainingBlock);
-    displayBox.setHorizontalMargin({ });
-    displayBox.setHorizontalComputedMargin({ });
-    displayBox.setVerticalMargin({ });
-    displayBox.setBorder({ });
-    displayBox.setPadding({ });
-    displayBox.setTopLeft({ });
-    displayBox.setContentBoxHeight(LayoutUnit(initialContainingBlock->style().logicalHeight().value()));
-    displayBox.setContentBoxWidth(LayoutUnit(initialContainingBlock->style().logicalWidth().value()));
-
-    // Not efficient, but this is temporary anyway.
-    // Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).
-    for (auto& descendant : descendantsOfType<Box>(*initialContainingBlock)) {
-        if (!descendant.isOutOfFlowPositioned())
-            continue;
-        auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(descendant.formattingContextRoot());
-        formattingState.addOutOfFlowBox(descendant);
-    }
-    auto quirksMode = [&] {
-        auto& document = renderView.document();
-        if (document.inLimitedQuirksMode())
-            return QuirksMode::Limited;
-        if (document.inQuirksMode())
-            return QuirksMode::Yes;
-        return QuirksMode::No;
-    };
-    layoutState.setQuirksMode(quirksMode());
-    layoutState.markNeedsUpdate(*initialContainingBlock);
-    layoutState.updateLayout();
-    layoutState.verifyAndOutputMismatchingLayoutTree(renderView, *initialContainingBlock);
 }
 
-}
-}
-
 #endif

Modified: trunk/Source/WebCore/layout/LayoutState.h (250127 => 250128)


--- trunk/Source/WebCore/layout/LayoutState.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/LayoutState.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -27,12 +27,9 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#include "LayoutContainer.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/IsoMalloc.h>
-#include <wtf/OptionSet.h>
-#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -44,43 +41,20 @@
 
 namespace Layout {
 
-enum class StyleDiff;
 class Box;
+class Container;
 class FormattingContext;
 class FormattingState;
 
-// LayoutState is the entry point for layout. It takes the initial containing block which acts as the root of the layout context.
-// LayoutState::layout() generates the display tree for the root container's subtree (it does not run layout on the root though).
-// Note, while the initial containing block is entry point for the initial layout, it does not necessarily need to be the entry point of any
-// subsequent layouts (subtree layout). A non-initial, subtree layout could be initiated on multiple formatting contexts.
-// Each formatting context has an entry point for layout, which potenitally means multiple entry points per layout frame.
-// LayoutState also holds the formatting states. They cache formatting context specific data to enable performant incremental layouts.
 class LayoutState {
     WTF_MAKE_ISO_ALLOCATED(LayoutState);
 public:
-    // FIXME: This is a temporary entry point for LFC layout.
-    static void run(const RenderView&);
 
-    void updateLayout();
-    void styleChanged(const Box&, StyleDiff);
-    enum class QuirksMode { No, Limited, Yes };
-    void setQuirksMode(QuirksMode quirksMode) { m_quirksMode = quirksMode; }
-
-    enum class UpdateType {
-        Overflow = 1 << 0,
-        Position = 1 << 1,
-        Size     = 1 << 2
-    };
-    static constexpr OptionSet<UpdateType> updateAll() { return { UpdateType::Overflow, UpdateType::Position, UpdateType::Size }; }
-    void markNeedsUpdate(const Box&, OptionSet<UpdateType> = updateAll());
-    bool needsUpdate(const Box&) const;
-
+    FormattingState& createFormattingStateForFormattingRootIfNeeded(const Container& formattingContextRoot);
+    FormattingState& establishedFormattingState(const Container& formattingRoot) const;
     FormattingState& formattingStateForBox(const Box&) const;
-    FormattingState& establishedFormattingState(const Container& formattingRoot) const;
     bool hasFormattingState(const Container& formattingRoot) const { return m_formattingStates.contains(&formattingRoot); }
-    FormattingState& createFormattingStateForFormattingRootIfNeeded(const Container& formattingRoot);
 
-    std::unique_ptr<FormattingContext> createFormattingContext(const Container& formattingContextRoot);
 #ifndef NDEBUG
     void registerFormattingContext(const FormattingContext&);
     void deregisterFormattingContext(const FormattingContext& formattingContext) { m_formattingContextList.remove(&formattingContext); }
@@ -89,16 +63,13 @@
     Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const;
     bool hasDisplayBox(const Box& layoutBox) const { return m_layoutToDisplayBox.contains(&layoutBox); }
 
+    enum class QuirksMode { No, Limited, Yes };
+    void setQuirksMode(QuirksMode quirksMode) { m_quirksMode = quirksMode; }
     bool inQuirksMode() const { return m_quirksMode == QuirksMode::Yes; }
     bool inLimitedQuirksMode() const { return m_quirksMode == QuirksMode::Limited; }
     bool inNoQuirksMode() const { return m_quirksMode == QuirksMode::No; }
-    // For testing purposes only
-    void verifyAndOutputMismatchingLayoutTree(const RenderView&, const Container& initialContainingBlock) const;
 
 private:
-    void layoutFormattingContextSubtree(const Container&);
-
-    HashSet<const Container*> m_formattingContextRootListForLayout;
     HashMap<const Container*, std::unique_ptr<FormattingState>> m_formattingStates;
 #ifndef NDEBUG
     HashSet<const FormattingContext*> m_formattingContextList;

Modified: trunk/Source/WebCore/layout/Verification.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/Verification.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/Verification.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -29,9 +29,11 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "DisplayBox.h"
+#include "InlineFormattingState.h"
 #include "InlineTextBox.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
+#include "LayoutContext.h"
 #include "LayoutTreeBuilder.h"
 #include "RenderBox.h"
 #include "RenderInline.h"
@@ -318,15 +320,15 @@
     return mismtachingGeometry;
 }
 
-void LayoutState::verifyAndOutputMismatchingLayoutTree(const RenderView& renderView, const Container& initialContainingBlock) const
+void LayoutContext::verifyAndOutputMismatchingLayoutTree(const LayoutState& layoutState, const RenderView& renderView, const Container& initialContainingBlock)
 {
     TextStream stream;
-    auto mismatchingGeometry = verifyAndOutputSubtree(stream, *this, renderView, initialContainingBlock);
+    auto mismatchingGeometry = verifyAndOutputSubtree(stream, layoutState, renderView, initialContainingBlock);
     if (!mismatchingGeometry)
         return;
 #if ENABLE(TREE_DEBUGGING)
     showRenderTree(&renderView);
-    showLayoutTree(initialContainingBlock, this);
+    showLayoutTree(initialContainingBlock, &layoutState);
 #endif
     WTFLogAlways("%s", stream.release().utf8().data());
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -166,10 +166,11 @@
     computeStaticHorizontalPosition(layoutBox);
     if (is<Container>(layoutBox)) {
         // Swich over to the new formatting context (the one that the root creates).
-        auto formattingContext = layoutState().createFormattingContext(downcast<Container>(layoutBox));
+        auto& rootContainer = downcast<Container>(layoutBox);
+        auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState());
         formattingContext->layoutInFlowContent();
         // Come back and finalize the root's geometry.
-        computeHeightAndMargin(layoutBox);
+        computeHeightAndMargin(rootContainer);
         // Now that we computed the root's height, we can go back and layout the out-of-flow content.
         formattingContext->layoutOutOfFlowContent();
     } else

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -323,7 +323,7 @@
         }
 
         if (layoutBox.establishesFormattingContext() && is<Container>(layoutBox))
-            return layoutState().createFormattingContext(downcast<Container>(layoutBox))->computedIntrinsicWidthConstraints();
+            return LayoutContext::createFormattingContext(downcast<Container>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
 
         if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
             return { };

Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -32,7 +32,6 @@
 #include "Invalidation.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -48,25 +47,24 @@
     return true;
 }
 
-static OptionSet<LayoutState::UpdateType> computeUpdateType(const Box&, StyleDiff, BlockFormattingState&)
+static OptionSet<LayoutContext::UpdateType> computeUpdateType(const Box&, StyleDiff, BlockFormattingState&)
 {
-    return LayoutState::updateAll();
+    return LayoutContext::updateAll();
 }
 
-static OptionSet<LayoutState::UpdateType> computeUpdateTypeForAncestor(const Container&, StyleDiff, BlockFormattingState&)
+static OptionSet<LayoutContext::UpdateType> computeUpdateTypeForAncestor(const Container&, StyleDiff, BlockFormattingState&)
 {
-    return LayoutState::updateAll();
+    return LayoutContext::updateAll();
 }
 
-InvalidationResult BlockInvalidation::invalidate(const Box& layoutBox, StyleDiff styleDiff, LayoutState& layoutState,
-    BlockFormattingState& formattingState)
+InvalidationResult BlockInvalidation::invalidate(const Box& layoutBox, StyleDiff styleDiff, LayoutContext& layoutContext, BlockFormattingState& formattingState)
 {
     // Invalidate this box and the containing block chain all the way up to the formatting context root (and beyond if needed).
-    layoutState.markNeedsUpdate(layoutBox, computeUpdateType(layoutBox, styleDiff, formattingState));
+    layoutContext.markNeedsUpdate(layoutBox, computeUpdateType(layoutBox, styleDiff, formattingState));
     for (auto* containingBlock = layoutBox.containingBlock(); containingBlock; containingBlock = containingBlock->containingBlock()) {
         if (containingBlock->establishesFormattingContext() && invalidationStopsAtFormattingContextBoundary(*containingBlock, layoutBox, styleDiff))
             return { containingBlock };
-        layoutState.markNeedsUpdate(*containingBlock, computeUpdateTypeForAncestor(*containingBlock, styleDiff, formattingState));
+        layoutContext.markNeedsUpdate(*containingBlock, computeUpdateTypeForAncestor(*containingBlock, styleDiff, formattingState));
     }
     // Invalidation always stops at the initial containing block.
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h (250127 => 250128)


--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -37,7 +37,7 @@
 class BlockFormattingState;
 class Container;
 struct InvalidationResult;
-class LayoutState;
+class LayoutContext;
 enum class StyleDiff;
 
 // This class implements box invalidation for block formatting context.
@@ -44,7 +44,7 @@
 class BlockInvalidation {
     WTF_MAKE_ISO_ALLOCATED(BlockInvalidation);
 public:
-    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutState&, BlockFormattingState&);
+    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutContext&, BlockFormattingState&);
 };
 
 }

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (250127 => 250128)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -43,6 +43,7 @@
 class FormattingContext;
 class FloatingContext;
 class InlineFormattingContext;
+class LayoutContext;
 class LayoutState;
 class TableFormattingContext;
 }
@@ -58,6 +59,8 @@
     friend class Layout::FormattingContext;
     friend class Layout::FloatingContext;
     friend class Layout::InlineFormattingContext;
+    // This is temporary and should be removed when LayoutContext::run is no longer needed.
+    friend class Layout::LayoutContext;
     friend class Layout::LayoutState;
     friend class Layout::TableFormattingContext;
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -33,6 +33,7 @@
 #include "InlineTextItem.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
+#include "LayoutContext.h"
 #include "LayoutState.h"
 #include "Logging.h"
 #include "Textutil.h"
@@ -175,7 +176,7 @@
     if (auto fixedWidth = geometry().fixedValue(formattingRoot.style().logicalWidth()))
         constraints = { *fixedWidth, *fixedWidth };
     else if (is<Container>(formattingRoot))
-        constraints = layoutState().createFormattingContext(downcast<Container>(formattingRoot))->computedIntrinsicWidthConstraints();
+        constraints = LayoutContext::createFormattingContext(downcast<Container>(formattingRoot), layoutState())->computedIntrinsicWidthConstraints();
     constraints = geometry().constrainByMinMaxWidth(formattingRoot, constraints);
     constraints.expand(geometryForBox(formattingRoot).horizontalMarginBorderAndPadding());
     formattingState().setIntrinsicWidthConstraintsForBox(formattingRoot, constraints);
@@ -237,10 +238,11 @@
     formattingState().displayBox(root).setTopLeft({ 0, 0 });
     // Swich over to the new formatting context (the one that the root creates).
     if (is<Container>(root)) {
-        auto formattingContext = layoutState().createFormattingContext(downcast<Container>(root));
+        auto& rootContainer = downcast<Container>(root);
+        auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState());
         formattingContext->layoutInFlowContent();
         // Come back and finalize the root's height and margin.
-        computeHeightAndMargin(root);
+        computeHeightAndMargin(rootContainer);
         // Now that we computed the root's height, we can go back and layout the out-of-flow content.
         formattingContext->layoutOutOfFlowContent();
     } else

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -31,7 +31,7 @@
 #include "InlineFormattingState.h"
 #include "Invalidation.h"
 #include "LayoutBox.h"
-#include "LayoutState.h"
+#include "LayoutContext.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -39,9 +39,9 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(InlineInvalidation);
 
-InvalidationResult InlineInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutState& layoutState, InlineFormattingState&)
+InvalidationResult InlineInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutContext& layoutContext, InlineFormattingState&)
 {
-    layoutState.markNeedsUpdate(layoutBox);
+    layoutContext.markNeedsUpdate(layoutBox);
     return { nullptr };
 }
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h (250127 => 250128)


--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -37,7 +37,7 @@
 class Container;
 class InlineFormattingState;
 struct InvalidationResult;
-class LayoutState;
+class LayoutContext;
 enum class StyleDiff;
 
 // This class implements box invalidation for inline formatting context.
@@ -44,7 +44,7 @@
 class InlineInvalidation {
     WTF_MAKE_ISO_ALLOCATED(InlineInvalidation);
 public:
-    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutState&, InlineFormattingState&);
+    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutContext&, InlineFormattingState&);
 };
 
 }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -35,6 +35,7 @@
 #include "LayoutBox.h"
 #include "LayoutChildIterator.h"
 #include "LayoutContainer.h"
+#include "LayoutContext.h"
 #include "LayoutDescendantIterator.h"
 #include "LayoutPhase.h"
 #include "LayoutState.h"
@@ -367,7 +368,7 @@
         auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView);
         auto layoutState = LayoutState { };
         layoutState.setQuirksMode(renderView.document().inLimitedQuirksMode() ? LayoutState::QuirksMode::Limited : (renderView.document().inQuirksMode() ? LayoutState::QuirksMode::Yes : LayoutState::QuirksMode::No));
-        layoutState.updateLayout();
+        LayoutContext(layoutState).layout();
         showLayoutTree(*initialContainingBlock, &layoutState);
     }
 }

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -97,7 +97,7 @@
 
     ASSERT(cellLayoutBox.establishesBlockFormattingContext());
     if (is<Container>(cellLayoutBox))
-        layoutState().createFormattingContext(downcast<Container>(cellLayoutBox))->layoutInFlowContent();
+        LayoutContext::createFormattingContext(downcast<Container>(cellLayoutBox), layoutState())->layoutInFlowContent();
     cellDisplayBox.setVerticalMargin({ { }, { } });
     cellDisplayBox.setContentBoxHeight(geometry().tableCellHeightAndMargin(cellLayoutBox).height);
     // FIXME: Check what to do with out-of-flow content.
@@ -196,7 +196,7 @@
         if (!intrinsicWidth) {
             intrinsicWidth = IntrinsicWidthConstraints { };
             if (is<Container>(tableCellBox))
-                intrinsicWidth = layoutState().createFormattingContext(downcast<Container>(tableCellBox))->computedIntrinsicWidthConstraints();
+                intrinsicWidth = LayoutContext::createFormattingContext(downcast<Container>(tableCellBox), layoutState())->computedIntrinsicWidthConstraints();
             intrinsicWidth = geometry().constrainByMinMaxWidth(tableCellBox, *intrinsicWidth);
             auto border = geometry().computedBorder(tableCellBox);
             auto padding = *geometry().computedPadding(tableCellBox, UsedHorizontalValues { UsedHorizontalValues::Constraints { { }, { } } });

Modified: trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp (250127 => 250128)


--- trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/tableformatting/TableInvalidation.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -30,7 +30,6 @@
 
 #include "Invalidation.h"
 #include "LayoutBox.h"
-#include "LayoutState.h"
 #include "TableFormattingState.h"
 #include <wtf/IsoMallocInlines.h>
 
@@ -39,9 +38,9 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(TableInvalidation);
 
-InvalidationResult TableInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutState& layoutState, TableFormattingState&)
+InvalidationResult TableInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutContext& layoutContext, TableFormattingState&)
 {
-    layoutState.markNeedsUpdate(layoutBox);
+    layoutContext.markNeedsUpdate(layoutBox);
     return { nullptr };
 }
 

Modified: trunk/Source/WebCore/layout/tableformatting/TableInvalidation.h (250127 => 250128)


--- trunk/Source/WebCore/layout/tableformatting/TableInvalidation.h	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/layout/tableformatting/TableInvalidation.h	2019-09-20 13:36:00 UTC (rev 250128)
@@ -36,7 +36,7 @@
 class Box;
 class TableFormattingState;
 struct InvalidationResult;
-class LayoutState;
+class LayoutContext;
 enum class StyleDiff;
 
 // This class implements box invalidation for table formatting context.
@@ -43,7 +43,7 @@
 class TableInvalidation {
     WTF_MAKE_ISO_ALLOCATED(TableInvalidation);
 public:
-    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutState&, TableFormattingState&);
+    static InvalidationResult invalidate(const Box&, StyleDiff, LayoutContext&, TableFormattingState&);
 };
 
 }

Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (250127 => 250128)


--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2019-09-20 11:00:53 UTC (rev 250127)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2019-09-20 13:36:00 UTC (rev 250128)
@@ -40,7 +40,7 @@
 #include "ScriptDisallowedScope.h"
 #include "Settings.h"
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "LayoutState.h"
+#include "LayoutContext.h"
 #endif
 
 #include <wtf/SetForScope.h>
@@ -54,7 +54,7 @@
 {
     if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextEnabled())
         return;
-    Layout::LayoutState::run(renderView);
+    Layout::LayoutContext::run(renderView);
 } 
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to