Title: [238995] trunk/Source/WebCore
Revision
238995
Author
an...@apple.com
Date
2018-12-07 16:26:34 -0800 (Fri, 07 Dec 2018)

Log Message

[LFC] Rename LayoutFormattingState files to LayoutState
https://bugs.webkit.org/show_bug.cgi?id=192520

Reviewed by Zalan Bujtas.

Match the class name.

* layout/FormattingContext.cpp:
* layout/FormattingContextQuirks.cpp:
* layout/FormattingState.h:
* layout/LayoutFormattingState.cpp: Removed.
* layout/LayoutFormattingState.h: Removed.
* layout/LayoutState.cpp: Copied from Source/WebCore/layout/LayoutFormattingState.cpp.
* layout/LayoutState.h: Copied from Source/WebCore/layout/LayoutFormattingState.h.
* layout/Verification.cpp:
* layout/blockformatting/BlockFormattingContext.cpp:
* layout/blockformatting/BlockFormattingContextQuirks.cpp:
* layout/blockformatting/BlockInvalidation.cpp:
* layout/floats/FloatAvoider.cpp:
* layout/floats/FloatingContext.cpp:
* layout/floats/FloatingState.cpp:
* layout/inlineformatting/InlineFormattingContext.cpp:
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
* layout/inlineformatting/InlineInvalidation.cpp:
* layout/layouttree/LayoutTreeBuilder.cpp:
* page/FrameViewLayoutContext.cpp:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238994 => 238995)


--- trunk/Source/WebCore/ChangeLog	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/ChangeLog	2018-12-08 00:26:34 UTC (rev 238995)
@@ -1,3 +1,32 @@
+2018-12-07  Antti Koivisto  <an...@apple.com>
+
+        [LFC] Rename LayoutFormattingState files to LayoutState
+        https://bugs.webkit.org/show_bug.cgi?id=192520
+
+        Reviewed by Zalan Bujtas.
+
+        Match the class name.
+
+        * layout/FormattingContext.cpp:
+        * layout/FormattingContextQuirks.cpp:
+        * layout/FormattingState.h:
+        * layout/LayoutFormattingState.cpp: Removed.
+        * layout/LayoutFormattingState.h: Removed.
+        * layout/LayoutState.cpp: Copied from Source/WebCore/layout/LayoutFormattingState.cpp.
+        * layout/LayoutState.h: Copied from Source/WebCore/layout/LayoutFormattingState.h.
+        * layout/Verification.cpp:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+        * layout/blockformatting/BlockInvalidation.cpp:
+        * layout/floats/FloatAvoider.cpp:
+        * layout/floats/FloatingContext.cpp:
+        * layout/floats/FloatingState.cpp:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        * layout/inlineformatting/InlineInvalidation.cpp:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        * page/FrameViewLayoutContext.cpp:
+
 2018-12-07  Justin Michaud  <justin_mich...@apple.com>
 
         CSS Painting API code cleanup

Modified: trunk/Source/WebCore/Sources.txt (238994 => 238995)


--- trunk/Source/WebCore/Sources.txt	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/Sources.txt	2018-12-08 00:26:34 UTC (rev 238995)
@@ -1264,7 +1264,7 @@
 layout/FormattingContextGeometry.cpp
 layout/FormattingContextQuirks.cpp
 layout/FormattingState.cpp
-layout/LayoutFormattingState.cpp
+layout/LayoutState.cpp
 layout/Verification.cpp
 layout/blockformatting/BlockFormattingContext.cpp
 layout/blockformatting/BlockFormattingContextGeometry.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238994 => 238995)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-12-08 00:26:34 UTC (rev 238995)
@@ -2028,7 +2028,7 @@
 		6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */; };
 		6F3E1F622136142000A65A08 /* FloatBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F3E1F612136141700A65A08 /* FloatBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F5217C72177F5A7006583BB /* InlineRunProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F5217C42177F5A6006583BB /* InlineRunProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		6F7CA3C6208C2957002F29AB /* LayoutFormattingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C4208C2956002F29AB /* LayoutFormattingState.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, ); }; };
 		6F995A151A70756200A735F4 /* WebGLSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A131A70756200A735F4 /* WebGLSync.cpp */; };
 		6F995A161A70756200A735F4 /* WebGLSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A141A70756200A735F4 /* WebGLSync.h */; };
@@ -9108,8 +9108,8 @@
 		6F5217C42177F5A6006583BB /* InlineRunProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineRunProvider.h; sourceTree = "<group>"; };
 		6F5217C62177F5A6006583BB /* InlineRunProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineRunProvider.cpp; sourceTree = "<group>"; };
 		6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; };
-		6F7CA3C4208C2956002F29AB /* LayoutFormattingState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutFormattingState.h; sourceTree = "<group>"; };
-		6F7CA3C5208C2956002F29AB /* LayoutFormattingState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutFormattingState.cpp; sourceTree = "<group>"; };
+		6F7CA3C4208C2956002F29AB /* LayoutState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; };
+		6F7CA3C5208C2956002F29AB /* LayoutState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; };
 		6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; };
 		6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContext.cpp; sourceTree = "<group>"; };
 		6F8F460121B03BB40041AC3A /* FormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextQuirks.cpp; sourceTree = "<group>"; };
@@ -16102,8 +16102,8 @@
 				115CFA75208AFE30001E6991 /* FormattingState.cpp */,
 				115CFA74208AFE30001E6991 /* FormattingState.h */,
 				115F7805209CBCBD00739C13 /* Invalidation.h */,
-				6F7CA3C5208C2956002F29AB /* LayoutFormattingState.cpp */,
-				6F7CA3C4208C2956002F29AB /* LayoutFormattingState.h */,
+				6F7CA3C5208C2956002F29AB /* LayoutState.cpp */,
+				6F7CA3C4208C2956002F29AB /* LayoutState.h */,
 				6F73918C2106CEDD006AF262 /* LayoutUnits.h */,
 				11FF02D520BA3C810083F25B /* Verification.cpp */,
 			);
@@ -29989,7 +29989,7 @@
 				11310CF620BA4A560065A8D0 /* LayoutChildIterator.h in Headers */,
 				1199FA46208E35A3002358CC /* LayoutContainer.h in Headers */,
 				11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */,
-				6F7CA3C6208C2957002F29AB /* LayoutFormattingState.h in Headers */,
+				6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */,
 				1199FA53208E38D3002358CC /* LayoutInlineBox.h in Headers */,
 				1199FA4F208E3899002358CC /* LayoutInlineContainer.h in Headers */,
 				11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */,

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -33,7 +33,7 @@
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
 #include "LayoutDescendantIterator.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include "Logging.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/text/TextStream.h>

Modified: trunk/Source/WebCore/layout/FormattingContextQuirks.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/FormattingContextQuirks.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/FormattingContextQuirks.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -30,7 +30,7 @@
 
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 
 namespace WebCore {
 namespace Layout {

Modified: trunk/Source/WebCore/layout/FormattingState.h (238994 => 238995)


--- trunk/Source/WebCore/layout/FormattingState.h	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/FormattingState.h	2018-12-08 00:26:34 UTC (rev 238995)
@@ -30,7 +30,7 @@
 #include "FloatingState.h"
 #include "FormattingContext.h"
 #include "LayoutBox.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include "LayoutUnit.h"
 #include <wtf/IsoMalloc.h>
 

Deleted: trunk/Source/WebCore/layout/LayoutFormattingState.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/LayoutFormattingState.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/LayoutFormattingState.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -1,158 +0,0 @@
-/*
- * 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 "LayoutFormattingState.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 <wtf/IsoMallocInlines.h>
-
-namespace WebCore {
-namespace Layout {
-
-WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
-
-LayoutState::LayoutState(const Container& initialContainingBlock, const LayoutSize& containerSize)
-    : m_initialContainingBlock(makeWeakPtr(initialContainingBlock))
-{
-    // LayoutState is always initiated with the ICB.
-    ASSERT(!initialContainingBlock.parent());
-    ASSERT(initialContainingBlock.establishesBlockFormattingContext());
-
-    auto& displayBox = displayBoxForLayoutBox(initialContainingBlock);
-    displayBox.setHorizontalMargin({ });
-    displayBox.setHorizontalNonComputedMargin({ });
-    displayBox.setVerticalMargin({ });
-    displayBox.setVerticalNonCollapsedMargin({ });
-    displayBox.setBorder({ });
-    displayBox.setPadding({ });
-    displayBox.setTopLeft({ });
-    displayBox.setContentBoxHeight(containerSize.height());
-    displayBox.setContentBoxWidth(containerSize.width());
-
-    m_formattingContextRootListForLayout.add(&initialContainingBlock);
-}
-
-void LayoutState::updateLayout()
-{
-    ASSERT(!m_formattingContextRootListForLayout.isEmpty());
-    for (auto* layoutRoot : m_formattingContextRootListForLayout)
-        layoutFormattingContextSubtree(*layoutRoot);
-    m_formattingContextRootListForLayout.clear();
-}
-
-void LayoutState::layoutFormattingContextSubtree(const Box& layoutRoot)
-{
-    RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
-    auto& formattingState = createFormattingStateForFormattingRootIfNeeded(layoutRoot);
-    auto formattingContext = formattingState.createFormattingContext(layoutRoot);
-    formattingContext->layout();
-    formattingContext->layoutOutOfFlowDescendants(layoutRoot);
-}
-
-Display::Box& LayoutState::displayBoxForLayoutBox(const Box& layoutBox) const
-{
-    return *m_layoutToDisplayBox.ensure(&layoutBox, [&layoutBox] {
-        return std::make_unique<Display::Box>(layoutBox.style());
-    }).iterator->value;
-}
-
-void LayoutState::styleChanged(const Box& layoutBox, StyleDiff styleDiff)
-{
-    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&, OptionSet<UpdateType>)
-{
-}
-
-FormattingState& LayoutState::formattingStateForBox(const Box& layoutBox) const
-{
-    auto& root = layoutBox.formattingContextRoot();
-    RELEASE_ASSERT(m_formattingStates.contains(&root));
-    return *m_formattingStates.get(&root);
-}
-
-FormattingState& LayoutState::establishedFormattingState(const Box& formattingRoot) const
-{
-    ASSERT(formattingRoot.establishesFormattingContext());
-    RELEASE_ASSERT(m_formattingStates.contains(&formattingRoot));
-    return *m_formattingStates.get(&formattingRoot);
-}
-
-FormattingState& LayoutState::createFormattingStateForFormattingRootIfNeeded(const Box& formattingRoot)
-{
-    ASSERT(formattingRoot.establishesFormattingContext());
-
-    if (formattingRoot.establishesInlineFormattingContext()) {
-        return *m_formattingStates.ensure(&formattingRoot, [&] {
-
-            // 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 std::make_unique<InlineFormattingState>(FloatingState::create(*this, formattingRoot), *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.
-            return std::make_unique<InlineFormattingState>(formattingStateForBox(formattingRoot).floatingState(), *this);
-        }).iterator->value;
-    }
-
-    if (formattingRoot.establishesBlockFormattingContext()) {
-        return *m_formattingStates.ensure(&formattingRoot, [&] {
-
-            // Block formatting context always establishes a new floating state.
-            return std::make_unique<BlockFormattingState>(FloatingState::create(*this, formattingRoot), *this);
-        }).iterator->value;
-    }
-
-    CRASH();
-}
-
-}
-}
-
-#endif

Deleted: trunk/Source/WebCore/layout/LayoutFormattingState.h (238994 => 238995)


--- trunk/Source/WebCore/layout/LayoutFormattingState.h	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/LayoutFormattingState.h	2018-12-08 00:26:34 UTC (rev 238995)
@@ -1,100 +0,0 @@
-/*
- * 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 <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/IsoMalloc.h>
-#include <wtf/OptionSet.h>
-
-namespace WebCore {
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-class RenderView;
-#endif
-
-namespace Display {
-class Box;
-}
-
-namespace Layout {
-
-enum class StyleDiff;
-class Box;
-class Container;
-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:
-    LayoutState(const Container& initialContainingBlock, const LayoutSize&);
-
-    void updateLayout();
-    void styleChanged(const Box&, StyleDiff);
-    void setInQuirksMode(bool inQuirksMode) { m_inQuirksMode = inQuirksMode; }
-
-    enum class UpdateType {
-        Overflow = 1 << 0,
-        Position = 1 << 1,
-        Size     = 1 << 2,
-        All      = Overflow | Position | Size
-    };
-    void markNeedsUpdate(const Box&, OptionSet<UpdateType>);
-    bool needsUpdate(const Box&) const;
-
-    FormattingState& formattingStateForBox(const Box&) const;
-    FormattingState& establishedFormattingState(const Box& formattingRoot) const;
-    FormattingState& createFormattingStateForFormattingRootIfNeeded(const Box& formattingRoot);
-
-    Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const;
-    bool hasDisplayBox(const Box& layoutBox) const { return m_layoutToDisplayBox.contains(&layoutBox); }
-
-    bool inQuirksMode() const { return m_inQuirksMode; }
-    // For testing purposes only
-    void verifyAndOutputMismatchingLayoutTree(const RenderView&) const;
-
-private:
-    const Container& initialContainingBlock() const { return *m_initialContainingBlock; }
-    void layoutFormattingContextSubtree(const Box&);
-
-    WeakPtr<const Container> m_initialContainingBlock;
-    HashSet<const Container*> m_formattingContextRootListForLayout;
-    HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
-    mutable HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;
-    bool m_inQuirksMode { false };
-};
-
-}
-}
-#endif

Copied: trunk/Source/WebCore/layout/LayoutState.cpp (from rev 238972, trunk/Source/WebCore/layout/LayoutFormattingState.cpp) (0 => 238995)


--- trunk/Source/WebCore/layout/LayoutState.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/LayoutState.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -0,0 +1,158 @@
+/*
+ * 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 "LayoutState.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 <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutState);
+
+LayoutState::LayoutState(const Container& initialContainingBlock, const LayoutSize& containerSize)
+    : m_initialContainingBlock(makeWeakPtr(initialContainingBlock))
+{
+    // LayoutState is always initiated with the ICB.
+    ASSERT(!initialContainingBlock.parent());
+    ASSERT(initialContainingBlock.establishesBlockFormattingContext());
+
+    auto& displayBox = displayBoxForLayoutBox(initialContainingBlock);
+    displayBox.setHorizontalMargin({ });
+    displayBox.setHorizontalNonComputedMargin({ });
+    displayBox.setVerticalMargin({ });
+    displayBox.setVerticalNonCollapsedMargin({ });
+    displayBox.setBorder({ });
+    displayBox.setPadding({ });
+    displayBox.setTopLeft({ });
+    displayBox.setContentBoxHeight(containerSize.height());
+    displayBox.setContentBoxWidth(containerSize.width());
+
+    m_formattingContextRootListForLayout.add(&initialContainingBlock);
+}
+
+void LayoutState::updateLayout()
+{
+    ASSERT(!m_formattingContextRootListForLayout.isEmpty());
+    for (auto* layoutRoot : m_formattingContextRootListForLayout)
+        layoutFormattingContextSubtree(*layoutRoot);
+    m_formattingContextRootListForLayout.clear();
+}
+
+void LayoutState::layoutFormattingContextSubtree(const Box& layoutRoot)
+{
+    RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
+    auto& formattingState = createFormattingStateForFormattingRootIfNeeded(layoutRoot);
+    auto formattingContext = formattingState.createFormattingContext(layoutRoot);
+    formattingContext->layout();
+    formattingContext->layoutOutOfFlowDescendants(layoutRoot);
+}
+
+Display::Box& LayoutState::displayBoxForLayoutBox(const Box& layoutBox) const
+{
+    return *m_layoutToDisplayBox.ensure(&layoutBox, [&layoutBox] {
+        return std::make_unique<Display::Box>(layoutBox.style());
+    }).iterator->value;
+}
+
+void LayoutState::styleChanged(const Box& layoutBox, StyleDiff styleDiff)
+{
+    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&, OptionSet<UpdateType>)
+{
+}
+
+FormattingState& LayoutState::formattingStateForBox(const Box& layoutBox) const
+{
+    auto& root = layoutBox.formattingContextRoot();
+    RELEASE_ASSERT(m_formattingStates.contains(&root));
+    return *m_formattingStates.get(&root);
+}
+
+FormattingState& LayoutState::establishedFormattingState(const Box& formattingRoot) const
+{
+    ASSERT(formattingRoot.establishesFormattingContext());
+    RELEASE_ASSERT(m_formattingStates.contains(&formattingRoot));
+    return *m_formattingStates.get(&formattingRoot);
+}
+
+FormattingState& LayoutState::createFormattingStateForFormattingRootIfNeeded(const Box& formattingRoot)
+{
+    ASSERT(formattingRoot.establishesFormattingContext());
+
+    if (formattingRoot.establishesInlineFormattingContext()) {
+        return *m_formattingStates.ensure(&formattingRoot, [&] {
+
+            // 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 std::make_unique<InlineFormattingState>(FloatingState::create(*this, formattingRoot), *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.
+            return std::make_unique<InlineFormattingState>(formattingStateForBox(formattingRoot).floatingState(), *this);
+        }).iterator->value;
+    }
+
+    if (formattingRoot.establishesBlockFormattingContext()) {
+        return *m_formattingStates.ensure(&formattingRoot, [&] {
+
+            // Block formatting context always establishes a new floating state.
+            return std::make_unique<BlockFormattingState>(FloatingState::create(*this, formattingRoot), *this);
+        }).iterator->value;
+    }
+
+    CRASH();
+}
+
+}
+}
+
+#endif

Copied: trunk/Source/WebCore/layout/LayoutState.h (from rev 238972, trunk/Source/WebCore/layout/LayoutFormattingState.h) (0 => 238995)


--- trunk/Source/WebCore/layout/LayoutState.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/LayoutState.h	2018-12-08 00:26:34 UTC (rev 238995)
@@ -0,0 +1,100 @@
+/*
+ * 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 <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/IsoMalloc.h>
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+class RenderView;
+#endif
+
+namespace Display {
+class Box;
+}
+
+namespace Layout {
+
+enum class StyleDiff;
+class Box;
+class Container;
+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:
+    LayoutState(const Container& initialContainingBlock, const LayoutSize&);
+
+    void updateLayout();
+    void styleChanged(const Box&, StyleDiff);
+    void setInQuirksMode(bool inQuirksMode) { m_inQuirksMode = inQuirksMode; }
+
+    enum class UpdateType {
+        Overflow = 1 << 0,
+        Position = 1 << 1,
+        Size     = 1 << 2,
+        All      = Overflow | Position | Size
+    };
+    void markNeedsUpdate(const Box&, OptionSet<UpdateType>);
+    bool needsUpdate(const Box&) const;
+
+    FormattingState& formattingStateForBox(const Box&) const;
+    FormattingState& establishedFormattingState(const Box& formattingRoot) const;
+    FormattingState& createFormattingStateForFormattingRootIfNeeded(const Box& formattingRoot);
+
+    Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const;
+    bool hasDisplayBox(const Box& layoutBox) const { return m_layoutToDisplayBox.contains(&layoutBox); }
+
+    bool inQuirksMode() const { return m_inQuirksMode; }
+    // For testing purposes only
+    void verifyAndOutputMismatchingLayoutTree(const RenderView&) const;
+
+private:
+    const Container& initialContainingBlock() const { return *m_initialContainingBlock; }
+    void layoutFormattingContextSubtree(const Box&);
+
+    WeakPtr<const Container> m_initialContainingBlock;
+    HashSet<const Container*> m_formattingContextRootListForLayout;
+    HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
+    mutable HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;
+    bool m_inQuirksMode { false };
+};
+
+}
+}
+#endif

Modified: trunk/Source/WebCore/layout/Verification.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/Verification.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/Verification.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -24,7 +24,7 @@
  */
 
 #include "config.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -34,7 +34,7 @@
 #include "FloatingState.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include "Logging.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/text/TextStream.h>

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -30,7 +30,7 @@
 
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 
 namespace WebCore {
 namespace Layout {

Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -32,7 +32,7 @@
 #include "Invalidation.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/floats/FloatAvoider.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/floats/FloatAvoider.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/floats/FloatAvoider.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -30,7 +30,7 @@
 
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -33,7 +33,7 @@
 #include "FloatBox.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/floats/FloatingState.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -31,7 +31,7 @@
 #include "FormattingContext.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -35,9 +35,9 @@
 #include "InlineRunProvider.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
 #include "LayoutInlineBox.h"
 #include "LayoutInlineContainer.h"
+#include "LayoutState.h"
 #include "Logging.h"
 #include "Textutil.h"
 #include <wtf/IsoMallocInlines.h>

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -32,7 +32,7 @@
 #include "InlineFormattingState.h"
 #include "LayoutBox.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include "TextUtil.h"
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -31,7 +31,7 @@
 #include "InlineFormattingState.h"
 #include "Invalidation.h"
 #include "LayoutBox.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (238994 => 238995)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -34,9 +34,9 @@
 #include "LayoutBox.h"
 #include "LayoutChildIterator.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
 #include "LayoutInlineBox.h"
 #include "LayoutInlineContainer.h"
+#include "LayoutState.h"
 #include "RenderBlock.h"
 #include "RenderChildIterator.h"
 #include "RenderElement.h"

Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (238994 => 238995)


--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2018-12-08 00:26:01 UTC (rev 238994)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2018-12-08 00:26:34 UTC (rev 238995)
@@ -43,7 +43,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 #include "FormattingState.h"
 #include "LayoutContainer.h"
-#include "LayoutFormattingState.h"
+#include "LayoutState.h"
 #include "LayoutTreeBuilder.h"
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to