Title: [254266] trunk/Source/WebCore
Revision
254266
Author
za...@apple.com
Date
2020-01-09 09:59:33 -0800 (Thu, 09 Jan 2020)

Log Message

[LFC] computeHeightAndMargin/placeInFlowPositionedChildren should take UsedHorizontalValues::Constraints
https://bugs.webkit.org/show_bug.cgi?id=205904
<rdar://problem/58398413>

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
(WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren):
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::move):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254265 => 254266)


--- trunk/Source/WebCore/ChangeLog	2020-01-09 17:54:07 UTC (rev 254265)
+++ trunk/Source/WebCore/ChangeLog	2020-01-09 17:59:33 UTC (rev 254266)
@@ -1,5 +1,22 @@
 2020-01-09  Zalan Bujtas  <za...@apple.com>
 
+        [LFC] computeHeightAndMargin/placeInFlowPositionedChildren should take UsedHorizontalValues::Constraints
+        https://bugs.webkit.org/show_bug.cgi?id=205904
+        <rdar://problem/58398413>
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
+        (WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren):
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::move):
+
+2020-01-09  Zalan Bujtas  <za...@apple.com>
+
         [LFC][BFC] BlockFormattingContext::layoutFormattingContextRoot should take the horizontal constraints
         https://bugs.webkit.org/show_bug.cgi?id=205894
         <rdar://problem/58391798>

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (254265 => 254266)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-01-09 17:54:07 UTC (rev 254265)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-01-09 17:59:33 UTC (rev 254266)
@@ -128,9 +128,10 @@
         while (!layoutQueue.isEmpty()) {
             // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
             auto& layoutBox = *layoutQueue.takeLast();
+            auto horizontalConstraints = horizontalConstraintsForLayoutBox(layoutBox);
             // Formatting root boxes are special-cased and they don't come here.
             ASSERT(!layoutBox.establishesFormattingContext());
-            computeHeightAndMargin(layoutBox);
+            computeHeightAndMargin(layoutBox, horizontalConstraints);
             // Move in-flow positioned children to their final position.
             placeInFlowPositionedChildren(layoutBox);
             if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
@@ -138,7 +139,7 @@
         }
     }
     // Place the inflow positioned children.
-    placeInFlowPositionedChildren(formattingRoot);
+    placeInFlowPositionedChildren(formattingRoot, rootHorizontalConstraints);
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")");
 }
 
@@ -198,13 +199,13 @@
         auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState());
         formattingContext->layoutInFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(rootContainerDisplayBox));
         // Come back and finalize the root's geometry.
-        computeHeightAndMargin(rootContainer);
+        computeHeightAndMargin(rootContainer, adjustedHorizontalConstraints);
         // Now that we computed the root's height, we can go back and layout the out-of-flow content.
         auto horizontalConstraintsForOutOfFlow =  Geometry::horizontalConstraintsForOutOfFlow(rootContainerDisplayBox);
         auto verticalConstraintsForOutOfFlow = Geometry::verticalConstraintsForOutOfFlow(rootContainerDisplayBox);
         formattingContext->layoutOutOfFlowContent(invalidationState, horizontalConstraintsForOutOfFlow, verticalConstraintsForOutOfFlow);
     } else
-        computeHeightAndMargin(layoutBox);
+        computeHeightAndMargin(layoutBox, adjustedHorizontalConstraints);
     // Float related final positioning.
     if (layoutBox.isFloatingPositioned()) {
         computeFloatingPosition(floatingContext, layoutBox);
@@ -213,30 +214,19 @@
         computePositionToAvoidFloats(floatingContext, layoutBox);
 }
 
-void BlockFormattingContext::placeInFlowPositionedChildren(const Box& layoutBox)
+void BlockFormattingContext::placeInFlowPositionedChildren(const Box& layoutBox, Optional<UsedHorizontalValues::Constraints> horizontalConstraints)
 {
     if (!is<Container>(layoutBox))
         return;
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &layoutBox);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &layoutBox);
+    auto usedHorizontalValues = UsedHorizontalValues { horizontalConstraints ? *horizontalConstraints : Geometry::horizontalConstraintsForInFlow(geometryForBox(layoutBox)) };
     auto& container = downcast<Container>(layoutBox);
     for (auto& childBox : childrenOfType<Box>(container)) {
         if (!childBox.isInFlowPositioned())
             continue;
-
-        auto computeInFlowPositionedPosition = [&] {
-            auto usedHorizontalValues = UsedHorizontalValues { Geometry::horizontalConstraintsForInFlow(geometryForBox(*childBox.containingBlock())) };
-            auto positionOffset = geometry().inFlowPositionedPositionOffset(childBox, usedHorizontalValues);
-
-            auto& displayBox = formattingState().displayBox(childBox);
-            auto topLeft = displayBox.topLeft();
-
-            topLeft.move(positionOffset);
-
-            displayBox.setTopLeft(topLeft);
-        };
-
-        computeInFlowPositionedPosition();
+        auto positionOffset = geometry().inFlowPositionedPositionOffset(childBox, usedHorizontalValues);
+        formattingState().displayBox(childBox).move(positionOffset);
     }
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &layoutBox);
 }
@@ -414,10 +404,9 @@
     displayBox.setHorizontalComputedMargin(contentWidthAndMargin.computedMargin);
 }
 
-void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox)
+void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox, const UsedHorizontalValues::Constraints& horizontalConstraints)
 {
-    auto& containingBlockGeometry = geometryForBox(*layoutBox.containingBlock());
-    auto usedHorizontalValues = UsedHorizontalValues { Geometry::horizontalConstraintsForInFlow(containingBlockGeometry) };
+    auto usedHorizontalValues = UsedHorizontalValues { horizontalConstraints };
     auto compute = [&](auto usedVerticalValues) -> ContentHeightAndMargin {
         if (layoutBox.isInFlow())
             return geometry().inFlowHeightAndMargin(layoutBox, usedHorizontalValues, usedVerticalValues);
@@ -429,7 +418,7 @@
         return { };
     };
 
-    auto verticalConstraints = UsedVerticalValues::Constraints { containingBlockGeometry.contentBoxTop() };
+    auto verticalConstraints = UsedVerticalValues::Constraints { geometryForBox(*layoutBox.containingBlock()).contentBoxTop() };
     auto contentHeightAndMargin = compute(UsedVerticalValues { verticalConstraints });
     if (auto maxHeight = geometry().computedMaxHeight(layoutBox)) {
         if (contentHeightAndMargin.contentHeight > *maxHeight) {

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (254265 => 254266)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2020-01-09 17:54:07 UTC (rev 254265)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2020-01-09 17:59:33 UTC (rev 254266)
@@ -52,10 +52,10 @@
 
 private:
     void layoutFormattingContextRoot(const Box&, FloatingContext&, InvalidationState&, const UsedHorizontalValues::Constraints&);
-    void placeInFlowPositionedChildren(const Box&);
+    void placeInFlowPositionedChildren(const Box&, Optional<UsedHorizontalValues::Constraints> = WTF::nullopt);
 
     void computeWidthAndMargin(const Box&, const UsedHorizontalValues::Constraints&);
-    void computeHeightAndMargin(const Box&);
+    void computeHeightAndMargin(const Box&, const UsedHorizontalValues::Constraints&);
 
     void computeStaticHorizontalPosition(const Box&, const UsedHorizontalValues::Constraints&);
     void computeStaticVerticalPosition(const FloatingContext&, const Box&);

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (254265 => 254266)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2020-01-09 17:54:07 UTC (rev 254265)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2020-01-09 17:59:33 UTC (rev 254266)
@@ -121,6 +121,7 @@
     void setLeft(LayoutUnit);
     void moveHorizontally(LayoutUnit offset) { m_topLeft.move(offset, 0_lu); }
     void moveVertically(LayoutUnit offset) { m_topLeft.move(0_lu, offset); }
+    void move(const LayoutSize& size) { m_topLeft.move(size); }
     void moveBy(LayoutPoint offset) { m_topLeft.moveBy(offset); }
 
     void setContentBoxHeight(LayoutUnit);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to