[LFC][IFC] Add support for out-of-flow positioned boxes
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 14:51:36 +0000 (14:51 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 14:51:36 +0000 (14:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191726

Reviewed by Antti Koivisto.

Source/WebCore:

While laying out formatting context roots (inline-block, floats) in an inline formatting context, we need to make sure
that their out-of-flow descendants get laid out as well.

Test: fast/inline/simple-inline-with-out-of-flow-descendant.html

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const):
* layout/layouttree/LayoutTreeBuilder.cpp: This was returning the wrong context root when the container was also a context root.
(WebCore::Layout::TreeBuilder::createSubTree):

Tools:

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

LayoutTests:

* fast/inline/simple-inline-with-out-of-flow-descendant-expected.txt: Added.
* fast/inline/simple-inline-with-out-of-flow-descendant.html: Added.
* platform/ios/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant-expected.txt [new file with mode: 0644]
LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index 6f4c193..adb8814 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-16  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Add support for out-of-flow positioned boxes
+        https://bugs.webkit.org/show_bug.cgi?id=191726
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/simple-inline-with-out-of-flow-descendant-expected.txt: Added.
+        * fast/inline/simple-inline-with-out-of-flow-descendant.html: Added.
+        * platform/ios/TestExpectations:
+
 2018-11-16  Thibault Saunier  <tsaunier@igalia.com>
 
         [GStreamer][MediaStream] Handle track addition and removal
diff --git a/LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant-expected.txt b/LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant-expected.txt
new file mode 100644 (file)
index 0000000..f41a0e0
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 202x202 clip at (9,9) size 200x200
+  RenderBlock {DIV} at (0,0) size 202x202 [border: (1px solid #008000)]
+    RenderText {#text} at (1,1) size 37x18
+      text run at (1,1) width 37: "inline"
+    RenderText {#text} at (37,1) size 48x18
+      text run at (37,1) width 48: "content"
+layer at (95,73) size 69x56
+  RenderBlock (positioned) {SPAN} at (50,50) size 69x56 [border: (1px solid #0000FF)]
+    RenderText {#text} at (1,1) size 67x54
+      text run at (1,1) width 54: "absolute"
+      text run at (1,19) width 67: "positioned"
+      text run at (1,37) width 48: "content"
diff --git a/LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant.html b/LayoutTests/fast/inline/simple-inline-with-out-of-flow-descendant.html
new file mode 100644 (file)
index 0000000..a22b920
--- /dev/null
@@ -0,0 +1,22 @@
+<style>
+.inlineContextRoot {
+       border: 1px solid green;
+       width: 200px;
+       height: 200px;
+       overflow: hidden;
+}
+
+.blockContextRoot {
+       position: absolute;
+       left: 50px;
+       top: 50px;
+       border: 1px solid blue;
+}
+
+.inlineBlock {
+       display: inline-block;
+       position: relative;
+}
+</style>
+
+<div class=inlineContextRoot>inline<span class=inlineBlock><span class=blockContextRoot>absolute positioned content</span></span>content</div>
index 09e8cda..b482009 100644 (file)
@@ -3109,6 +3109,7 @@ fast/inline/simple-intruding-floats3.html [ Failure ]
 fast/inline/simple-inline-block.html [ Failure ]
 fast/inline/simple-shrink-to-fit-inline-block.html [ Failure ]
 fast/inline/simple-inline-inflow-positioned.html [ Failure ]
+fast/inline/simple-inline-with-out-of-flow-descendant.html [ Failure ]
 fast/block/basic/height-percentage-simple.html [ Failure ]
 fast/block/basic/child-block-level-box-with-height-percent.html [ Failure ]
 fast/block/basic/quirk-mode-percent-height.html [ Failure ]
index 59e20a5..576c6e0 100644 (file)
@@ -1,3 +1,20 @@
+2018-11-16  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Add support for out-of-flow positioned boxes
+        https://bugs.webkit.org/show_bug.cgi?id=191726
+
+        Reviewed by Antti Koivisto.
+
+        While laying out formatting context roots (inline-block, floats) in an inline formatting context, we need to make sure
+        that their out-of-flow descendants get laid out as well.
+
+        Test: fast/inline/simple-inline-with-out-of-flow-descendant.html
+
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const):
+        * layout/layouttree/LayoutTreeBuilder.cpp: This was returning the wrong context root when the container was also a context root.
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
 2018-11-16  Thibault Saunier  <tsaunier@igalia.com>
 
         [GStreamer][WebRTC] Add API to enable/disable device mocks
index 3ad1572..8811fa2 100644 (file)
@@ -383,18 +383,19 @@ void InlineFormattingContext::computeHeightAndMargin(const Box& layoutBox) const
     displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
 }
 
-void InlineFormattingContext::layoutFormattingContextRoot(const Box& layoutBox) const
+void InlineFormattingContext::layoutFormattingContextRoot(const Box& root) const
 {
-    ASSERT(layoutBox.isFloatingPositioned() || layoutBox.isInlineBlockBox());
+    ASSERT(root.isFloatingPositioned() || root.isInlineBlockBox());
 
-    auto& layoutState = this->layoutState();
-    auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox);
-    computeBorderAndPadding(layoutBox);
-    computeWidthAndMargin(layoutBox);
+    computeBorderAndPadding(root);
+    computeWidthAndMargin(root);
     // Swich over to the new formatting context (the one that the root creates).
-    formattingState.formattingContext(layoutBox)->layout();
+    auto formattingContext = layoutState().createFormattingStateForFormattingRootIfNeeded(root).formattingContext(root);
+    formattingContext->layout();
     // Come back and finalize the root's height and margin.
-    computeHeightAndMargin(layoutBox);
+    computeHeightAndMargin(root);
+    // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any).
+    formattingContext->layoutOutOfFlowDescendants(root);
 }
 
 void InlineFormattingContext::computeWidthAndHeightForReplacedInlineBox(const Box& layoutBox) const
index 3e5e0e8..f6f58cb 100644 (file)
@@ -125,9 +125,8 @@ void TreeBuilder::createSubTree(const RenderElement& rootRenderer, Container& ro
 
         if (box->isOutOfFlowPositioned()) {
             // Not efficient, but this is temporary anyway.
-            // Collect the out-of-flow descendants at the formatting root lever (as opposed to at the containing block level, though they might be the same).
-            auto& containingBlockFormattingContextRoot = box->containingBlock()->formattingContextRoot();
-            const_cast<Container&>(containingBlockFormattingContextRoot).addOutOfFlowDescendant(*box);
+            // Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).
+            const_cast<Container&>(box->formattingContextRoot()).addOutOfFlowDescendant(*box);
         }
         if (is<Container>(*box))
             createSubTree(downcast<RenderElement>(child), downcast<Container>(*box));
index 0a74029..b6925b8 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-16  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Add support for out-of-flow positioned boxes
+        https://bugs.webkit.org/show_bug.cgi?id=191726
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-11-15  Myles C. Maxfield  <mmaxfield@apple.com>
 
         WKPreferencesSetFontSmoothingLevel doesn't actually do anything
index de2f274..c1ca488 100644 (file)
@@ -70,6 +70,7 @@ fast/inline/simple-intruding-floats3.html
 fast/inline/simple-inline-block.html
 fast/inline/simple-shrink-to-fit-inline-block.html
 fast/inline/simple-inline-inflow-positioned.html
+fast/inline/simple-inline-with-out-of-flow-descendant.html
 fast/block/basic/height-percentage-simple.html
 fast/block/basic/child-block-level-box-with-height-percent.html
 fast/block/basic/quirk-mode-percent-height.html