WebKit Bugzilla
Attachment 339797 Details for
Bug 185377
: [LFC] Add FormattingContext::layoutOutOfFlowDescendants implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185377-20180507213732.patch (text/plain), 14.92 KB, created by
zalan
on 2018-05-07 21:37:33 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-07 21:37:33 PDT
Size:
14.92 KB
patch
obsolete
>Subversion Revision: 231403 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b20d52b4d02a2bbc126d85eb4cb6b53df23a60f0..f0c0caff8fe213feedf7dfd1a5ea8aa3efad69db 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-05-07 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Add FormattingContext::layoutOutOfFlowDescendants implementation >+ https://bugs.webkit.org/show_bug.cgi?id=185377 >+ >+ Reviewed by Antti Koivisto. >+ >+ Also, remove FormattingContext's m_layoutContext member and pass it in to ::layout() instead. >+ In theory LayoutContext is needed only during ::layout() call. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): >+ * layout/FormattingContext.h: >+ (WebCore::Layout::FormattingContext::layoutContext const): >+ * layout/LayoutContext.cpp: >+ (WebCore::Layout::LayoutContext::updateLayout): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::layout const): >+ * layout/blockformatting/BlockFormattingContext.h: >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::InlineFormattingContext::layout const): >+ * layout/inlineformatting/InlineFormattingContext.h: >+ > 2018-05-06 Zalan Bujtas <zalan@apple.com> > > [LFC] Add assertions for stale Display::Box geometry >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 63f1b500b3521cb23c7abcfc9ff65f0882c116d6..79f61ee95b7076d4c0e9c7ab49e2ac62fb217bc3 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -29,6 +29,8 @@ > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > > #include "LayoutBox.h" >+#include "LayoutContainer.h" >+#include "LayoutContext.h" > #include <wtf/IsoMallocInlines.h> > > namespace WebCore { >@@ -36,9 +38,8 @@ namespace Layout { > > WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext); > >-FormattingContext::FormattingContext(const Box& formattingContextRoot, LayoutContext& layoutContext) >+FormattingContext::FormattingContext(const Box& formattingContextRoot) > : m_root(makeWeakPtr(const_cast<Box&>(formattingContextRoot))) >- , m_layoutContext(layoutContext) > { > } > >@@ -46,7 +47,7 @@ FormattingContext::~FormattingContext() > { > } > >-void FormattingContext::computeStaticPosition(const Box&, Display::Box&) const >+void FormattingContext::computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const > { > } > >@@ -116,8 +117,23 @@ void FormattingContext::placeInFlowPositionedChildren(const Container&) const > { > } > >-void FormattingContext::layoutOutOfFlowDescendants() const >+void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext) const > { >+ if (!is<Container>(m_root.get())) >+ return; >+ for (auto& outOfFlowBox : downcast<Container>(*m_root).outOfFlowDescendants()) { >+ auto& layoutBox = *outOfFlowBox; >+ auto& displayBox = layoutContext.createDisplayBox(layoutBox); >+ >+ computeOutOfFlowPosition(layoutBox, displayBox); >+ computeOutOfFlowWidth(layoutBox, displayBox); >+ >+ ASSERT(layoutBox.establishesFormattingContext()); >+ auto formattingContext = layoutContext.formattingContext(layoutBox); >+ formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext)); >+ >+ computeOutOfFlowHeight(layoutBox, displayBox); >+ } > } > > } >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 5379ebdb3baddf805b6f3ac221b71c5afa6850e3..6f4dfe56f340f5dda1edf38e205645e4355ce7e8 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -48,12 +48,12 @@ class LayoutContext; > class FormattingContext { > WTF_MAKE_ISO_ALLOCATED(FormattingContext); > public: >- FormattingContext(const Box& formattingContextRoot, LayoutContext&); >+ FormattingContext(const Box& formattingContextRoot); > virtual ~FormattingContext(); > > virtual void layout(LayoutContext&, FormattingState&) const = 0; > virtual std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const = 0; >- virtual Ref<FloatingState> createOrFindFloatingState() const = 0; >+ virtual Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const = 0; > > protected: > struct LayoutPair { >@@ -63,9 +63,8 @@ protected: > using LayoutQueue = Vector<std::unique_ptr<LayoutPair>>; > > const Box& root() const { return *m_root; } >- const LayoutContext& layoutContext() const { return m_layoutContext; } > >- virtual void computeStaticPosition(const Box&, Display::Box&) const; >+ virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeInFlowPositionedPosition(const Box&, Display::Box&) const; > virtual void computeOutOfFlowPosition(const Box&, Display::Box&) const; > >@@ -86,11 +85,10 @@ protected: > virtual LayoutUnit marginRight(const Box&) const; > > void placeInFlowPositionedChildren(const Container&) const; >- void layoutOutOfFlowDescendants() const; >+ void layoutOutOfFlowDescendants(LayoutContext&s) const; > > private: > WeakPtr<Box> m_root; >- LayoutContext& m_layoutContext; > }; > > } >diff --git a/Source/WebCore/layout/LayoutContext.cpp b/Source/WebCore/layout/LayoutContext.cpp >index 608949447952caf5095199e927ff9acca9ec470e..658f8cbc56e4b8a446285709f41794952f2b3d29 100644 >--- a/Source/WebCore/layout/LayoutContext.cpp >+++ b/Source/WebCore/layout/LayoutContext.cpp >@@ -98,17 +98,17 @@ FormattingState& LayoutContext::formattingStateForBox(const Box& layoutBox) cons > FormattingState& LayoutContext::establishedFormattingState(const Box& formattingContextRoot, const FormattingContext& context) > { > return *m_formattingStates.ensure(&formattingContextRoot, [this, &context] { >- return context.createFormattingState(context.createOrFindFloatingState()); >+ return context.createFormattingState(context.createOrFindFloatingState(*this)); > }).iterator->value; > } > > std::unique_ptr<FormattingContext> LayoutContext::formattingContext(const Box& formattingContextRoot) > { > if (formattingContextRoot.establishesBlockFormattingContext()) >- return std::make_unique<BlockFormattingContext>(formattingContextRoot, *this); >+ return std::make_unique<BlockFormattingContext>(formattingContextRoot); > > if (formattingContextRoot.establishesInlineFormattingContext()) >- return std::make_unique<InlineFormattingContext>(formattingContextRoot, *this); >+ return std::make_unique<InlineFormattingContext>(formattingContextRoot); > > ASSERT_NOT_REACHED(); > return nullptr; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 464c0b0e05b9aaa740a16cac215491ab0cf67d27..d93360d180c4ceb1914bfbd9da9ebb6827a85414 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -42,8 +42,8 @@ namespace Layout { > > WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext); > >-BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot, LayoutContext& layoutContext) >- : FormattingContext(formattingContextRoot, layoutContext) >+BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot) >+ : FormattingContext(formattingContextRoot) > { > } > >@@ -74,7 +74,7 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat > auto& displayBox = layoutPair.displayBox; > > computeWidth(layoutBox, displayBox); >- computeStaticPosition(layoutBox, layoutPair.displayBox); >+ computeStaticPosition(layoutContext, layoutBox, layoutPair.displayBox); > if (layoutBox.establishesFormattingContext()) { > auto formattingContext = layoutContext.formattingContext(layoutBox); > formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext)); >@@ -110,7 +110,7 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat > // Place the inflow positioned children. > placeInFlowPositionedChildren(formattingRoot); > // And take care of out-of-flow boxes as the final step. >- layoutOutOfFlowDescendants(); >+ layoutOutOfFlowDescendants(layoutContext); > } > > std::unique_ptr<FormattingState> BlockFormattingContext::createFormattingState(Ref<FloatingState>&& floatingState) const >@@ -118,25 +118,25 @@ std::unique_ptr<FormattingState> BlockFormattingContext::createFormattingState(R > return std::make_unique<BlockFormattingState>(WTFMove(floatingState)); > } > >-Ref<FloatingState> BlockFormattingContext::createOrFindFloatingState() const >+Ref<FloatingState> BlockFormattingContext::createOrFindFloatingState(LayoutContext&) const > { > // Block formatting context always establishes a new floating state. > return FloatingState::create(); > } > >-void BlockFormattingContext::computeStaticPosition(const Box& layoutBox, Display::Box& displayBox) const >+void BlockFormattingContext::computeStaticPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > // https://www.w3.org/TR/CSS22/visuren.html#block-formatting > // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block. > // The vertical distance between two sibling boxes is determined by the 'margin' properties. > // Vertical margins between adjacent block-level boxes in a block formatting context collapse. > // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). >- auto containingBlockContentBox = layoutContext().displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBox(); >+ auto containingBlockContentBox = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBox(); > // Start from the top of the container's content box. > auto top = containingBlockContentBox.y(); > auto left = containingBlockContentBox.x(); > if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) >- top = layoutContext().displayBoxForLayoutBox(*previousInFlowSibling)->bottom() + marginBottom(*previousInFlowSibling); >+ top = layoutContext.displayBoxForLayoutBox(*previousInFlowSibling)->bottom() + marginBottom(*previousInFlowSibling); > LayoutPoint topLeft = { top, left }; > topLeft.moveBy({ marginLeft(layoutBox), marginTop(layoutBox) }); > displayBox.setTopLeft(topLeft); >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index 03cff356364e3da1203a4f0895c4a4c5a0a3cbc4..691c4693afba9555b6e664383a14c45cf79adf79 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -43,14 +43,14 @@ class Box; > class BlockFormattingContext : public FormattingContext { > WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext); > public: >- BlockFormattingContext(const Box& formattingContextRoot, LayoutContext&); >+ BlockFormattingContext(const Box& formattingContextRoot); > > void layout(LayoutContext&, FormattingState&) const override; > std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const override; >- Ref<FloatingState> createOrFindFloatingState() const override; >+ Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override; > > protected: >- void computeStaticPosition(const Box&, Display::Box&) const override; >+ void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override; > void computeInFlowWidth(const Box&, Display::Box&) const override; > void computeInFlowHeight(const Box&, Display::Box&) const override; > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index f934f68ab536702f01be9681de75bc0e0d559faa..49c73e81f4c03cffa8ea17b390f342c53a78b8d9 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -39,8 +39,8 @@ namespace Layout { > > WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext); > >-InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot, LayoutContext& layoutContext) >- : FormattingContext(formattingContextRoot, layoutContext) >+InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot) >+ : FormattingContext(formattingContextRoot) > { > } > >@@ -53,7 +53,7 @@ std::unique_ptr<FormattingState> InlineFormattingContext::createFormattingState( > return std::make_unique<InlineFormattingState>(WTFMove(floatingState)); > } > >-Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState() const >+Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState(LayoutContext& layoutContext) const > { > // 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. >@@ -62,7 +62,7 @@ Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState() const > return FloatingState::create(); > // 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 (this) and use its floating state. >- auto& formattingState = layoutContext().formattingStateForBox(root()); >+ auto& formattingState = layoutContext.formattingStateForBox(root()); > return formattingState.floatingState(); > } > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index 9760b8d05501b1cd21ad3d5e43d3fe204ef470ce..3b1f25836027d1557714d21b369631372f559f3f 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -41,11 +41,11 @@ class InlineFormattingState; > class InlineFormattingContext : public FormattingContext { > WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext); > public: >- InlineFormattingContext(const Box& formattingContextRoot, LayoutContext&); >+ InlineFormattingContext(const Box& formattingContextRoot); > > void layout(LayoutContext&, FormattingState&) const override; > std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const override; >- Ref<FloatingState> createOrFindFloatingState() const override; >+ Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override; > > private: > void computeInFlowWidth(const Box&, Display::Box&) const override;
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 185377
:
339718
| 339797