WebKit Bugzilla
Attachment 356845 Details for
Bug 192520
: [LFC] Rename LayoutFormattingState files to LayoutState
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
layoutstate-rename.patch (text/plain), 37.10 KB, created by
Antti Koivisto
on 2018-12-07 15:41:28 PST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2018-12-07 15:41:28 PST
Size:
37.10 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 238970) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,32 @@ >+2018-12-07 Antti Koivisto <antti@apple.com> >+ >+ [LFC] Rename LayoutFormattingState files to LayoutState >+ https://bugs.webkit.org/show_bug.cgi?id=192520 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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_michaud@apple.com> > > CSS Painting API code cleanup >Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 238968) >+++ Source/WebCore/Sources.txt (working copy) >@@ -1264,7 +1264,7 @@ layout/FormattingContext.cpp > 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 >Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 238968) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -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 */, >Index: Source/WebCore/layout/FormattingContext.cpp >=================================================================== >--- Source/WebCore/layout/FormattingContext.cpp (revision 238968) >+++ Source/WebCore/layout/FormattingContext.cpp (working copy) >@@ -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> >Index: Source/WebCore/layout/FormattingContextQuirks.cpp >=================================================================== >--- Source/WebCore/layout/FormattingContextQuirks.cpp (revision 238968) >+++ Source/WebCore/layout/FormattingContextQuirks.cpp (working copy) >@@ -30,7 +30,7 @@ > > #include "LayoutBox.h" > #include "LayoutContainer.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > > namespace WebCore { > namespace Layout { >Index: Source/WebCore/layout/FormattingState.h >=================================================================== >--- Source/WebCore/layout/FormattingState.h (revision 238968) >+++ Source/WebCore/layout/FormattingState.h (working copy) >@@ -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> > >Index: Source/WebCore/layout/LayoutFormattingState.cpp >=================================================================== >--- Source/WebCore/layout/LayoutFormattingState.cpp (revision 238968) >+++ Source/WebCore/layout/LayoutFormattingState.cpp (nonexistent) >@@ -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 >Index: Source/WebCore/layout/LayoutFormattingState.h >=================================================================== >--- Source/WebCore/layout/LayoutFormattingState.h (revision 238968) >+++ Source/WebCore/layout/LayoutFormattingState.h (nonexistent) >@@ -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 >Index: Source/WebCore/layout/LayoutState.cpp >=================================================================== >--- Source/WebCore/layout/LayoutState.cpp (revision 238968) (from Source/WebCore/layout/LayoutFormattingState.cpp:238968) >+++ Source/WebCore/layout/LayoutState.cpp (working copy) >@@ -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 "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 >Index: Source/WebCore/layout/LayoutState.cpp >=================================================================== >--- Source/WebCore/layout/LayoutState.cpp (revision 238968) >+++ Source/WebCore/layout/LayoutState.cpp (working copy) >@@ -24,7 +24,7 @@ > */ > > #include "config.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > >Index: Source/WebCore/layout/LayoutState.h >=================================================================== >--- Source/WebCore/layout/LayoutState.h (revision 238968) (from Source/WebCore/layout/LayoutFormattingState.h:238968) >+++ Source/WebCore/layout/LayoutState.h (working copy) >@@ -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 >Index: Source/WebCore/layout/Verification.cpp >=================================================================== >--- Source/WebCore/layout/Verification.cpp (revision 238968) >+++ Source/WebCore/layout/Verification.cpp (working copy) >@@ -24,7 +24,7 @@ > */ > > #include "config.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > >Index: Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >=================================================================== >--- Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (revision 238968) >+++ Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (working copy) >@@ -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> >Index: Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp >=================================================================== >--- Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (revision 238968) >+++ Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (working copy) >@@ -30,7 +30,7 @@ > > #include "LayoutBox.h" > #include "LayoutContainer.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > > namespace WebCore { > namespace Layout { >Index: Source/WebCore/layout/blockformatting/BlockInvalidation.cpp >=================================================================== >--- Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (revision 238968) >+++ Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (working copy) >@@ -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 { >Index: Source/WebCore/layout/floats/FloatAvoider.cpp >=================================================================== >--- Source/WebCore/layout/floats/FloatAvoider.cpp (revision 238968) >+++ Source/WebCore/layout/floats/FloatAvoider.cpp (working copy) >@@ -30,7 +30,7 @@ > > #include "LayoutBox.h" > #include "LayoutContainer.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > #include <wtf/IsoMallocInlines.h> > > namespace WebCore { >Index: Source/WebCore/layout/floats/FloatingContext.cpp >=================================================================== >--- Source/WebCore/layout/floats/FloatingContext.cpp (revision 238968) >+++ Source/WebCore/layout/floats/FloatingContext.cpp (working copy) >@@ -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 { >Index: Source/WebCore/layout/floats/FloatingState.cpp >=================================================================== >--- Source/WebCore/layout/floats/FloatingState.cpp (revision 238968) >+++ Source/WebCore/layout/floats/FloatingState.cpp (working copy) >@@ -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 { >Index: Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >=================================================================== >--- Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (revision 238968) >+++ Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (working copy) >@@ -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> >Index: Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp >=================================================================== >--- Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (revision 238968) >+++ Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (working copy) >@@ -32,7 +32,7 @@ > #include "InlineFormattingState.h" > #include "LayoutBox.h" > #include "LayoutContainer.h" >-#include "LayoutFormattingState.h" >+#include "LayoutState.h" > #include "TextUtil.h" > > namespace WebCore { >Index: Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp >=================================================================== >--- Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (revision 238968) >+++ Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (working copy) >@@ -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 { >Index: Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp >=================================================================== >--- Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (revision 238968) >+++ Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (working copy) >@@ -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" >Index: Source/WebCore/page/FrameViewLayoutContext.cpp >=================================================================== >--- Source/WebCore/page/FrameViewLayoutContext.cpp (revision 238968) >+++ Source/WebCore/page/FrameViewLayoutContext.cpp (working copy) >@@ -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 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192520
: 356845