Title: [233272] trunk/Source/WebCore
Revision
233272
Author
[email protected]
Date
2018-06-27 12:23:13 -0700 (Wed, 27 Jun 2018)

Log Message

[LFC] Out-of-flow positioned element's height depends on its containing block's height.
https://bugs.webkit.org/show_bug.cgi?id=187082

Reviewed by Antti Koivisto.

We can't really compute the final height of an out-of-flow element until after its containing block's height is computed.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
* layout/FormattingContext.h:
* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::updateLayout):
(WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
* layout/LayoutContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
* layout/layouttree/LayoutContainer.h:
(WebCore::Layout::Container::outOfFlowDescendants const):
(WebCore::Layout::Container::outOfFlowDescendants): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233271 => 233272)


--- trunk/Source/WebCore/ChangeLog	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/ChangeLog	2018-06-27 19:23:13 UTC (rev 233272)
@@ -1,3 +1,25 @@
+2018-06-27  Zalan Bujtas  <[email protected]>
+
+        [LFC] Out-of-flow positioned element's height depends on its containing block's height.
+        https://bugs.webkit.org/show_bug.cgi?id=187082
+
+        Reviewed by Antti Koivisto.
+
+        We can't really compute the final height of an out-of-flow element until after its containing block's height is computed.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
+        * layout/FormattingContext.h:
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::updateLayout):
+        (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
+        * layout/LayoutContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        * layout/layouttree/LayoutContainer.h:
+        (WebCore::Layout::Container::outOfFlowDescendants const):
+        (WebCore::Layout::Container::outOfFlowDescendants): Deleted.
+
 2018-06-27  Youenn Fablet  <[email protected]>
 
         Disable content blockers in NetworkLoadChecker except for ping loads

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (233271 => 233272)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-06-27 19:23:13 UTC (rev 233272)
@@ -105,14 +105,22 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> context: " << &layoutContext << " parent: " << &container);
 }
 
-void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext) const
+void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext, const Box& layoutBox) const
 {
-    if (!is<Container>(m_root.get()))
+    // Initial containing block by definition is a containing block.
+    if (!layoutBox.isPositioned() && !layoutBox.isInitialContainingBlock())
         return;
 
+    if (!is<Container>(layoutBox))
+        return;
+
+    auto& container = downcast<Container>(layoutBox);
+    if (!container.hasChild())
+        return;
+
     LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: layout out-of-flow descendants -> context: " << &layoutContext << " root: " << &root());
 
-    for (auto& outOfFlowBox : downcast<Container>(*m_root).outOfFlowDescendants()) {
+    for (auto& outOfFlowBox : container.outOfFlowDescendants()) {
         auto& layoutBox = *outOfFlowBox;
         auto& displayBox = layoutContext.createDisplayBox(layoutBox);
 
@@ -120,7 +128,6 @@
         // More precisely, the static position for 'top' is the distance from the top edge of the containing block to the top margin edge
         // of a hypothetical box that would have been the first box of the element if its specified 'position' value had been 'static' and
         // its specified 'float' had been 'none' and its specified 'clear' had been 'none'.
-        computeStaticPosition(layoutContext, layoutBox, displayBox);
         computeBorderAndPadding(layoutContext, layoutBox, displayBox);
         computeOutOfFlowHorizontalGeometry(layoutContext, layoutBox, displayBox);
 
@@ -129,6 +136,7 @@
         formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext));
 
         computeOutOfFlowVerticalGeometry(layoutContext, layoutBox, displayBox);
+        layoutOutOfFlowDescendants(layoutContext, layoutBox);
     }
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutContext << " root: " << &root());
 }

Modified: trunk/Source/WebCore/layout/FormattingContext.h (233271 => 233272)


--- trunk/Source/WebCore/layout/FormattingContext.h	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2018-06-27 19:23:13 UTC (rev 233272)
@@ -51,6 +51,7 @@
     virtual ~FormattingContext();
 
     virtual void layout(LayoutContext&, FormattingState&) const = 0;
+    void layoutOutOfFlowDescendants(LayoutContext&, const Box&) const;
     virtual std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const = 0;
     virtual Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const = 0;
 
@@ -72,7 +73,6 @@
     void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const;
 
     void placeInFlowPositionedChildren(LayoutContext&, const Container&) const;
-    void layoutOutOfFlowDescendants(LayoutContext&s) const;
 
 #ifndef NDEBUG
     virtual void validateGeometryConstraintsAfterLayout(const LayoutContext&) const;

Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (233271 => 233272)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2018-06-27 19:23:13 UTC (rev 233272)
@@ -71,15 +71,20 @@
 void LayoutContext::updateLayout()
 {
     ASSERT(!m_formattingContextRootListForLayout.isEmpty());
-    for (auto* layoutRoot : m_formattingContextRootListForLayout) {
-        RELEASE_ASSERT(layoutRoot->establishesFormattingContext());
-        auto context = formattingContext(*layoutRoot);
-        auto& state = establishedFormattingState(*layoutRoot, *context);
-        context->layout(*this, state);
-    }
+    for (auto* layoutRoot : m_formattingContextRootListForLayout)
+        layoutFormattingContextSubtree(*layoutRoot);
     m_formattingContextRootListForLayout.clear();
 }
 
+void LayoutContext::layoutFormattingContextSubtree(const Box& layoutRoot)
+{
+    RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
+    auto formattingContext = this->formattingContext(layoutRoot);
+    auto& formattingState = establishedFormattingState(layoutRoot, *formattingContext);
+    formattingContext->layout(*this, formattingState);
+    formattingContext->layoutOutOfFlowDescendants(*this, layoutRoot);
+}
+
 Display::Box& LayoutContext::createDisplayBox(const Box& layoutBox)
 {
     std::unique_ptr<Display::Box> displayBox(new Display::Box(layoutBox.style()));

Modified: trunk/Source/WebCore/layout/LayoutContext.h (233271 => 233272)


--- trunk/Source/WebCore/layout/LayoutContext.h	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/LayoutContext.h	2018-06-27 19:23:13 UTC (rev 233272)
@@ -86,6 +86,8 @@
     void verifyAndOutputMismatchingLayoutTree(const RenderView&) const;
 
 private:
+    void layoutFormattingContextSubtree(const Box&);
+
     WeakPtr<Container> m_root;
     HashSet<const Container*> m_formattingContextRootListForLayout;
     HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (233271 => 233272)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 19:23:13 UTC (rev 233272)
@@ -114,6 +114,7 @@
             auto& container = downcast<Container>(layoutBox);
             // Move in-flow positioned children to their final position.
             placeInFlowPositionedChildren(layoutContext, container);
+            layoutOutOfFlowDescendants(layoutContext, container);
             if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) {
                 layoutQueue.append(std::make_unique<LayoutPair>(LayoutPair {*nextSibling, layoutContext.createDisplayBox(*nextSibling)}));
                 break;
@@ -122,11 +123,6 @@
     }
     // Place the inflow positioned children.
     placeInFlowPositionedChildren(layoutContext, formattingRoot);
-    // And take care of out-of-flow boxes as the final step.
-    layoutOutOfFlowDescendants(layoutContext);
-#ifndef NDEBUG
-    validateGeometryConstraintsAfterLayout(layoutContext);
-#endif
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")");
 }
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainer.h (233271 => 233272)


--- trunk/Source/WebCore/layout/layouttree/LayoutContainer.h	2018-06-27 19:19:16 UTC (rev 233271)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainer.h	2018-06-27 19:23:13 UTC (rev 233272)
@@ -53,7 +53,7 @@
     bool hasInFlowChild() const { return firstInFlowChild(); }
     bool hasInFlowOrFloatingChild() const { return firstInFlowOrFloatingChild(); }
 
-    const Vector<WeakPtr<Box>>& outOfFlowDescendants() { return m_outOfFlowDescendants; }
+    const Vector<WeakPtr<Box>>& outOfFlowDescendants() const { return m_outOfFlowDescendants; }
 
 protected:
     Container(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to