Title: [256710] trunk/Source/WebCore
Revision
256710
Author
[email protected]
Date
2020-02-16 07:23:56 -0800 (Sun, 16 Feb 2020)

Log Message

[LFC][BFC] Formatting context roots position their own relative children
https://bugs.webkit.org/show_bug.cgi?id=207822
<rdar://problem/59490353>

Reviewed by Antti Koivisto.

Since FCs are responsible for positioning their relative positioned children, we
don't have to do it as part of the final positioning.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
(WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren):
* layout/blockformatting/BlockFormattingContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (256709 => 256710)


--- trunk/Source/WebCore/ChangeLog	2020-02-16 15:18:57 UTC (rev 256709)
+++ trunk/Source/WebCore/ChangeLog	2020-02-16 15:23:56 UTC (rev 256710)
@@ -1,5 +1,21 @@
 2020-02-16  Zalan Bujtas  <[email protected]>
 
+        [LFC][BFC] Formatting context roots position their own relative children
+        https://bugs.webkit.org/show_bug.cgi?id=207822
+        <rdar://problem/59490353>
+
+        Reviewed by Antti Koivisto.
+
+        Since FCs are responsible for positioning their relative positioned children, we
+        don't have to do it as part of the final positioning.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+        (WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren):
+        * layout/blockformatting/BlockFormattingContext.h:
+
+2020-02-16  Zalan Bujtas  <[email protected]>
+
         [LFC] A box establishing an independent formatting context is not a float avoider
         https://bugs.webkit.org/show_bug.cgi?id=207820
         <rdar://problem/59490056>

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (256709 => 256710)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-02-16 15:18:57 UTC (rev 256709)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-02-16 15:23:56 UTC (rev 256710)
@@ -154,7 +154,8 @@
             // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
             computeHeightAndMargin(layoutBox, horizontalConstraints, verticalConstraints);
 
-            if (layoutBox.establishesFormattingContext()) {
+            auto establishesFormattingContext = layoutBox.establishesFormattingContext(); 
+            if (establishesFormattingContext) {
                 // Now that we computed the root's height, we can layout the out-of-flow descendants.
                 if (is<ContainerBox>(layoutBox) && downcast<ContainerBox>(layoutBox).hasChild()) {
                     auto& containerBox = downcast<ContainerBox>(layoutBox);
@@ -165,7 +166,6 @@
                 }
             }
             // Resolve final positions.
-            placeInFlowPositionedChildren(layoutBox, horizontalConstraints);
             if (layoutBox.isFloatAvoider()) {
                 auto horizontalConstraintsPair = ConstraintsPair<HorizontalConstraints> { rootHorizontalConstraints, horizontalConstraints };
                 auto verticalConstraintsPair = ConstraintsPair<VerticalConstraints> { rootVerticalConstraints, verticalConstraints };
@@ -173,6 +173,8 @@
                 if (layoutBox.isFloatingPositioned())
                     floatingContext.append(layoutBox);
             }
+            if (!establishesFormattingContext && is<ContainerBox>(layoutBox))
+                placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), horizontalConstraints);
 
             if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
                 break;
@@ -221,12 +223,9 @@
     return availableWidth;
 }
 
-void BlockFormattingContext::placeInFlowPositionedChildren(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints)
+void BlockFormattingContext::placeInFlowPositionedChildren(const ContainerBox& containerBox, const HorizontalConstraints& horizontalConstraints)
 {
-    if (!is<ContainerBox>(layoutBox))
-        return;
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &layoutBox);
-    auto& containerBox = downcast<ContainerBox>(layoutBox);
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &containerBox);
     for (auto& childBox : childrenOfType<Box>(containerBox)) {
         if (!childBox.isInFlowPositioned())
             continue;
@@ -233,7 +232,7 @@
         auto positionOffset = geometry().inFlowPositionedPositionOffset(childBox, horizontalConstraints);
         formattingState().displayBox(childBox).move(positionOffset);
     }
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &layoutBox);
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &containerBox);
 }
 
 void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints)

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (256709 => 256710)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2020-02-16 15:18:57 UTC (rev 256709)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2020-02-16 15:23:56 UTC (rev 256710)
@@ -57,7 +57,7 @@
         const T root;
         const T containingBlock;
     };
-    void placeInFlowPositionedChildren(const Box&, const HorizontalConstraints&);
+    void placeInFlowPositionedChildren(const ContainerBox&, const HorizontalConstraints&);
 
     void computeWidthAndMargin(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
     void computeHeightAndMargin(const Box&, const HorizontalConstraints&, const VerticalConstraints&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to