[LFC][Floating] Now that the document renderer belongs to "complicated cases", adjust...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 15:38:10 +0000 (15:38 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 15:38:10 +0000 (15:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188306

Reviewed by Antti Koivisto.

Source/WebCore:

And add passing cases for floats.

* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::initialContainingBlock):
(WebCore::Layout::isStretchedToInitialContainingBlock):
(WebCore::Layout::stretchHeightToInitialContainingBlock):
(WebCore::Layout::stretchWidthToInitialContainingBlock):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
(WebCore::Layout::isStretchedToViewport): Deleted.

Tools:

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

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

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

index 11ff0f5..4e4c656 100644 (file)
@@ -1,5 +1,24 @@
 2018-08-03  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][Floating] Now that the document renderer belongs to "complicated cases", adjust viewport stretching.
+        https://bugs.webkit.org/show_bug.cgi?id=188306
+
+        Reviewed by Antti Koivisto.
+
+        And add passing cases for floats.
+
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::initialContainingBlock):
+        (WebCore::Layout::isStretchedToInitialContainingBlock):
+        (WebCore::Layout::stretchHeightToInitialContainingBlock):
+        (WebCore::Layout::stretchWidthToInitialContainingBlock):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+        (WebCore::Layout::isStretchedToViewport): Deleted.
+
+2018-08-03  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Do not check margin box while validating geometry.
         https://bugs.webkit.org/show_bug.cgi?id=188297
 
index a6d7f09..6dffc0b 100644 (file)
 namespace WebCore {
 namespace Layout {
 
-static bool isStretchedToViewport(const LayoutContext& layoutContext, const Box& layoutBox)
+static const Container& initialContainingBlock(const Box& layoutBox)
+{
+    auto* containingBlock = layoutBox.containingBlock();
+    while (containingBlock->containingBlock())
+        containingBlock = containingBlock->containingBlock();
+    return *containingBlock;
+}
+
+static bool isStretchedToInitialContainingBlock(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow());
     // In quirks mode, body and html stretch to the viewport.
@@ -49,12 +57,24 @@ static bool isStretchedToViewport(const LayoutContext& layoutContext, const Box&
     return layoutBox.style().logicalHeight().isAuto();
 }
 
-static const Container& initialContainingBlock(const Box& layoutBox)
+static HeightAndMargin stretchHeightToInitialContainingBlock(HeightAndMargin heightAndMargin, LayoutUnit initialContainingBlockHeight)
 {
-    auto* containingBlock = layoutBox.containingBlock();
-    while (containingBlock->containingBlock())
-        containingBlock = containingBlock->containingBlock();
-    return *containingBlock;
+    auto verticalMargins = heightAndMargin.margin.top + heightAndMargin.margin.bottom;
+    // Stretch but never overstretch with the margins.
+    if (heightAndMargin.height + verticalMargins < initialContainingBlockHeight)
+        heightAndMargin.height = initialContainingBlockHeight - verticalMargins;
+
+    return heightAndMargin;
+}
+
+static WidthAndMargin stretchWidthToInitialContainingBlock(WidthAndMargin widthAndMargin, LayoutUnit initialContainingBlockWidth)
+{
+    auto horizontalMargins = widthAndMargin.margin.left + widthAndMargin.margin.right;
+    // Stretch but never overstretch with the margins.
+    if (widthAndMargin.width + horizontalMargins < initialContainingBlockWidth)
+        widthAndMargin.width = initialContainingBlockWidth - horizontalMargins;
+
+    return widthAndMargin;
 }
 
 HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -129,17 +149,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
 
     auto heightAndMargin = compute();
 
-    if (!isStretchedToViewport(layoutContext, layoutBox)) {
-        LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
-        return heightAndMargin;
-    }
-
-    auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBoxHeight();
-    // Stretch but never overstretch with the margins.
-    if (heightAndMargin.height + heightAndMargin.margin.top + heightAndMargin.margin.bottom < initialContainingBlockHeight)
-        heightAndMargin.height = initialContainingBlockHeight - heightAndMargin.margin.top - heightAndMargin.margin.bottom;
-
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
     return heightAndMargin;
 }
 
@@ -230,16 +240,13 @@ WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin
     };
 
     auto widthAndMargin = compute();
-    if (!isStretchedToViewport(layoutContext, layoutBox)) {
+    if (!isStretchedToInitialContainingBlock(layoutContext, layoutBox)) {
         LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")");
         return widthAndMargin;
     }
 
     auto initialContainingBlockWidth = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBoxWidth();
-    auto horizontalMargins = widthAndMargin.margin.left + widthAndMargin.margin.right;
-    // Stretch but never overstretch with the margins.
-    if (widthAndMargin.width + horizontalMargins < initialContainingBlockWidth)
-        widthAndMargin.width = initialContainingBlockWidth - horizontalMargins;
+    widthAndMargin = stretchWidthToInitialContainingBlock(widthAndMargin, initialContainingBlockWidth);
 
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> streched to viewport-> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")");
     return widthAndMargin;
@@ -370,13 +377,24 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutCo
     if (layoutBox.replaced())
         return FormattingContext::Geometry::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 
+    HeightAndMargin heightAndMargin;
     // TODO: Figure out the case for the document element. Let's just complicated-case it for now.
     if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox())
-        return inFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
+        heightAndMargin = inFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
+    else {
+        // 10.6.6 Complicated cases
+        // Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport).
+        heightAndMargin = FormattingContext::Geometry::complicatedCases(layoutContext, layoutBox);
+    }
+
+    if (!isStretchedToInitialContainingBlock(layoutContext, layoutBox))
+        return heightAndMargin;
+
+    auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBoxHeight();
+    heightAndMargin = stretchHeightToInitialContainingBlock(heightAndMargin, initialContainingBlockHeight);
 
-    // 10.6.6 Complicated cases
-    // Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport).
-    return FormattingContext::Geometry::complicatedCases(layoutContext, layoutBox);
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
+    return heightAndMargin;
 }
 
 WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
index 63bc8a7..24723e8 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-03  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][Floating] Now that the document renderer belongs to "complicated cases", adjust viewport stretching.
+        https://bugs.webkit.org/show_bug.cgi?id=188306
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-08-03  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [WPE] Use the new key mapper API from WPEBackend
index fc58a33..72d352a 100644 (file)
@@ -33,4 +33,16 @@ fast/block/block-only/relative-siblings.html
 fast/block/block-only/relative-simple.html
 fast/block/block-only/absolute-position-when-containing-block-is-not-in-the-formatting-context2.html
 fast/block/block-only/margin-collapse-with-block-formatting-context.html
-fast/block/block-only/margin-collapse-with-block-formatting-context2.html
\ No newline at end of file
+fast/block/block-only/margin-collapse-with-block-formatting-context2.html
+fast/block/block-only/float-left-when-container-has-padding-margin.html
+fast/block/block-only/floating-box-left-and-right-multiple-with-top-offset.html
+fast/block/block-only/floating-box-left-and-right-multiple.html
+fast/block/block-only/floating-box-right-simple.html
+fast/block/block-only/floating-box-with-new-formatting-context.html
+fast/block/block-only/floating-box-with-relative-positioned-sibling.html
+fast/block/block-only/floating-left-right-simple.html
+fast/block/block-only/floating-left-right-with-all-margins.html
+fast/block/block-only/floating-lefts-and-rights-simple.html
+fast/block/block-only/floating-multiple-lefts-in-body.html
+fast/block/block-only/floating-multiple-lefts-multiple-lines.html
+fast/block/block-only/floating-multiple-lefts.html