[LFC][BFC] Do not ignore next sibling box while laying out BFC.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Jan 2019 14:55:16 +0000 (14:55 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Jan 2019 14:55:16 +0000 (14:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193954

Reviewed by Antti Koivisto.

Source/WebCore:

When a block box has no child (<img style="display: block">), we should not ignore the next sibling (move the container check to the function to keep layout logic simple)
Also inFlowNonReplacedWidthAndMargin() is called through inFlowReplacedWidthAndMargin() to compute margins.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren const):
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240654 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index f61060d..e6b3538 100644 (file)
@@ -1,5 +1,22 @@
 2019-01-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][BFC] Do not ignore next sibling box while laying out BFC.
+        https://bugs.webkit.org/show_bug.cgi?id=193954
+
+        Reviewed by Antti Koivisto.
+
+        When a block box has no child (<img style="display: block">), we should not ignore the next sibling (move the container check to the function to keep layout logic simple)
+        Also inFlowNonReplacedWidthAndMargin() is called through inFlowReplacedWidthAndMargin() to compute margins.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        (WebCore::Layout::BlockFormattingContext::placeInFlowPositionedChildren const):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+
+2019-01-29  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][BFC][MarginCollapsing] Remove quirk from MarginCollapse::marginsCollapseThrough
         https://bugs.webkit.org/show_bug.cgi?id=193948
 
index b1a9685..958ed35 100644 (file)
@@ -105,12 +105,9 @@ void BlockFormattingContext::layout() const
             // Formatting root boxes are special-cased and they don't come here.
             ASSERT(!layoutBox.establishesFormattingContext());
             computeHeightAndMargin(layoutBox);
-            if (!is<Container>(layoutBox))
-                continue;
-            auto& container = downcast<Container>(layoutBox);
             // Move in-flow positioned children to their final position.
-            placeInFlowPositionedChildren(container);
-            if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) {
+            placeInFlowPositionedChildren(layoutBox);
+            if (auto* nextSibling = layoutBox.nextInFlowOrFloatingSibling()) {
                 layoutQueue.append(nextSibling);
                 break;
             }
@@ -147,18 +144,22 @@ void BlockFormattingContext::layoutFormattingContextRoot(FloatingContext& floati
     formattingContext->layoutOutOfFlowDescendants(layoutBox);
 }
 
-void BlockFormattingContext::placeInFlowPositionedChildren(const Container& container) const
+void BlockFormattingContext::placeInFlowPositionedChildren(const Box& layoutBox) const
 {
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &container);
-    for (auto& layoutBox : childrenOfType<Box>(container)) {
-        if (!layoutBox.isInFlowPositioned())
+    if (!is<Container>(layoutBox))
+        return;
+
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &layoutBox);
+    auto& container = downcast<Container>(layoutBox);
+    for (auto& childBox : childrenOfType<Box>(container)) {
+        if (!childBox.isInFlowPositioned())
             continue;
 
-        auto computeInFlowPositionedPosition = [&](auto& layoutBox) {
+        auto computeInFlowPositionedPosition = [&]() {
             auto& layoutState = this->layoutState();
-            auto positionOffset = Geometry::inFlowPositionedPositionOffset(layoutState, layoutBox);
+            auto positionOffset = Geometry::inFlowPositionedPositionOffset(layoutState, childBox);
 
-            auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
+            auto& displayBox = layoutState.displayBoxForLayoutBox(childBox);
             auto topLeft = displayBox.topLeft();
 
             topLeft.move(positionOffset);
@@ -166,9 +167,9 @@ void BlockFormattingContext::placeInFlowPositionedChildren(const Container& cont
             displayBox.setTopLeft(topLeft);
         };
 
-        computeInFlowPositionedPosition(layoutBox);
+        computeInFlowPositionedPosition();
     }
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &container);
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &layoutBox);
 }
 
 void BlockFormattingContext::computeStaticPosition(const FloatingContext& floatingContext, const Box& layoutBox) const
index 3e99c42..f4cc701 100644 (file)
@@ -53,7 +53,7 @@ public:
 
 private:
     void layoutFormattingContextRoot(FloatingContext&, const Box&) const;
-    void placeInFlowPositionedChildren(const Container&) const;
+    void placeInFlowPositionedChildren(const Box&) const;
 
     void computeWidthAndMargin(const Box&) const;
     void computeHeightAndMargin(const Box&) const;
index 6484ded..05f07a6 100644 (file)
@@ -109,7 +109,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
 
 WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)
 {
-    ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
+    ASSERT(layoutBox.isInFlow());
 
     auto compute = [&]() {
 
index d86f39a..0d0461d 100644 (file)
@@ -1,3 +1,12 @@
+2019-01-29  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BFC] Do not ignore next sibling box while laying out BFC.
+        https://bugs.webkit.org/show_bug.cgi?id=193954
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2019-01-29  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         WebDriver: add support for running subtests
index 135934e..af555da 100644 (file)
@@ -148,6 +148,7 @@ fast/block/margin-collapse/040.html
 fast/block/margin-collapse/043.html
 fast/block/margin-collapse/044.html
 fast/block/margin-collapse/063.html
+fast/block/margin-collapse/100.html
 fast/block/margin-collapse/collapsed-through-child-simple.html
 fast/block/positioning/003.html
 fast/block/positioning/004.html