Title: [238701] trunk
Revision
238701
Author
[email protected]
Date
2018-11-29 15:23:47 -0800 (Thu, 29 Nov 2018)

Log Message

[LFC][BFC][Quirk] Body and html height stretching.
https://bugs.webkit.org/show_bug.cgi?id=192154

Reviewed by Antti Koivisto.

Source/WebCore:

This patch takes the document box's margin/border/padding into account when stretching html/body to the height of the initial containing block.

Tests: fast/block/block-only/body-height-with-auto-html-height-quirk.html
       fast/block/block-only/body-height-with-auto-html-height-quirk2.html
       fast/block/block-only/body-height-with-non-auto-html-height-quirk.html
       fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html

* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::estimatedMarginBottom):
* layout/blockformatting/BlockFormattingContextQuirks.cpp:
(WebCore::Layout::BlockFormattingContext::Quirks::stretchedHeight):

Tools:

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

LayoutTests:

* fast/block/block-only/body-height-with-auto-html-height-quirk-expected.txt: Added.
* fast/block/block-only/body-height-with-auto-html-height-quirk.html: Added.
* fast/block/block-only/body-height-with-auto-html-height-quirk2-expected.txt: Added.
* fast/block/block-only/body-height-with-auto-html-height-quirk2.html: Added.
* fast/block/block-only/body-height-with-non-auto-html-height-quirk-expected.txt: Added.
* fast/block/block-only/body-height-with-non-auto-html-height-quirk.html: Added.
* fast/block/block-only/body-height-with-non-auto-html-height-quirk2-expected.txt: Added.
* fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238700 => 238701)


--- trunk/LayoutTests/ChangeLog	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/LayoutTests/ChangeLog	2018-11-29 23:23:47 UTC (rev 238701)
@@ -1,3 +1,19 @@
+2018-11-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC][Quirk] Body and html height stretching.
+        https://bugs.webkit.org/show_bug.cgi?id=192154
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/body-height-with-auto-html-height-quirk-expected.txt: Added.
+        * fast/block/block-only/body-height-with-auto-html-height-quirk.html: Added.
+        * fast/block/block-only/body-height-with-auto-html-height-quirk2-expected.txt: Added.
+        * fast/block/block-only/body-height-with-auto-html-height-quirk2.html: Added.
+        * fast/block/block-only/body-height-with-non-auto-html-height-quirk-expected.txt: Added.
+        * fast/block/block-only/body-height-with-non-auto-html-height-quirk.html: Added.
+        * fast/block/block-only/body-height-with-non-auto-html-height-quirk2-expected.txt: Added.
+        * fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html: Added.
+
 2018-11-29  Youenn Fablet  <[email protected]>
 
         CSS subresource loads should not be observable from resource timing if the stylesheet is opaque

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk-expected.txt (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk-expected.txt	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,5 @@
+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

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk.html (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk.html	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,4 @@
+<html>
+<body style="outline: 1px solid green">
+</body>
+</html>

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2-expected.txt (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2-expected.txt	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (10,10) size 780x580
+  RenderBlock {HTML} at (10,10) size 780x580 [border: (20px solid #FF0000)]
+    RenderBody {BODY} at (58,58) size 664x464

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2.html (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-auto-html-height-quirk2.html	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,4 @@
+<html style="margin: 10px; border: 20px solid red; padding: 30px;">
+<body style="outline: 1px solid green">
+</body>
+</html>

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk-expected.txt (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk-expected.txt	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x100
+  RenderBlock {HTML} at (0,0) size 800x100
+    RenderBody {BODY} at (8,8) size 784x584

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk.html (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk.html	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,4 @@
+<html style="height: 100px">
+<body style="outline: 1px solid green">
+</body>
+</html>

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2-expected.txt (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2-expected.txt	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (10,10) size 780x200
+  RenderBlock {HTML} at (10,10) size 780x200 [border: (20px solid #FF0000)]
+    RenderBody {BODY} at (58,58) size 664x464

Added: trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html (0 => 238701)


--- trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html	2018-11-29 23:23:47 UTC (rev 238701)
@@ -0,0 +1,4 @@
+<html style="margin: 10px; border: 20px solid red; padding: 30px; height: 100px">
+<body style="outline: 1px solid green">
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (238700 => 238701)


--- trunk/Source/WebCore/ChangeLog	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Source/WebCore/ChangeLog	2018-11-29 23:23:47 UTC (rev 238701)
@@ -1,3 +1,23 @@
+2018-11-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC][Quirk] Body and html height stretching.
+        https://bugs.webkit.org/show_bug.cgi?id=192154
+
+        Reviewed by Antti Koivisto.
+
+        This patch takes the document box's margin/border/padding into account when stretching html/body to the height of the initial containing block.
+
+        Tests: fast/block/block-only/body-height-with-auto-html-height-quirk.html
+               fast/block/block-only/body-height-with-auto-html-height-quirk2.html
+               fast/block/block-only/body-height-with-non-auto-html-height-quirk.html
+               fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html
+
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::estimatedMarginBottom):
+        * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+        (WebCore::Layout::BlockFormattingContext::Quirks::stretchedHeight):
+
 2018-11-29  Justin Fan  <[email protected]>
 
         [WebGPU] Replace forward declare of WebGPUCommandBuffer with include

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (238700 => 238701)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-11-29 23:23:47 UTC (rev 238701)
@@ -80,6 +80,7 @@
         static InstrinsicWidthConstraints instrinsicWidthConstraints(const LayoutState&, const Box&);
 
         static LayoutUnit estimatedMarginTop(const LayoutState&, const Box&);
+        static LayoutUnit estimatedMarginBottom(const LayoutState&, const Box&);
 
     private:
         // This class implements margin collapsing for block formatting context.

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (238700 => 238701)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-11-29 23:23:47 UTC (rev 238701)
@@ -333,8 +333,19 @@
     return MarginCollapse::marginTop(layoutState, layoutBox);
 }
 
+LayoutUnit BlockFormattingContext::Geometry::estimatedMarginBottom(const LayoutState& layoutState, const Box& layoutBox)
+{
+    ASSERT(layoutBox.isBlockLevelBox());
+    // Can't estimate vertical margins for out of flow boxes (and we shouldn't need to do it for float boxes).
+    ASSERT(layoutBox.isInFlow());
+    // Can't cross block formatting context boundary.
+    ASSERT(!layoutBox.establishesBlockFormattingContext());
 
+    // Let's just use the normal path for now.
+    return MarginCollapse::marginBottom(layoutState, layoutBox);
 }
+
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (238700 => 238701)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-11-29 23:23:47 UTC (rev 238701)
@@ -68,15 +68,35 @@
 
 HeightAndMargin BlockFormattingContext::Quirks::stretchedHeight(const LayoutState& layoutState, const Box& layoutBox, HeightAndMargin heightAndMargin)
 {
-    auto initialContainingBlockHeight = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox)).contentBoxHeight();
-    // This quirk happens when the body height is 0 which means its vertical margins collapse through (top and bottom margins are adjoining).
-    // However now that we stretch the body they don't collapse through anymore, so we need to use the non-collapsed values instead.
-    ASSERT(initialContainingBlockHeight);
-    auto verticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.margin;
-    auto totalVerticalMargins = verticalMargins.top + verticalMargins.bottom;
+    ASSERT(layoutBox.isDocumentBox() || layoutBox.isBodyBox());
+
+    auto& documentBox = layoutBox.isDocumentBox() ? layoutBox : *layoutBox.parent();
+    auto& documentBoxDisplayBox = layoutState.displayBoxForLayoutBox(documentBox);
+    auto documentBoxVerticalBorders = documentBoxDisplayBox.borderTop() + documentBoxDisplayBox.borderBottom();
+    auto documentBoxVerticalPaddings = documentBoxDisplayBox.paddingTop().value_or(0) + documentBoxDisplayBox.paddingBottom().value_or(0);
+
+    auto strechedHeight = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox)).contentBoxHeight();
+    strechedHeight -= documentBoxVerticalBorders + documentBoxVerticalPaddings;
+
+    LayoutUnit totalVerticalMargins;
+    if (layoutBox.isDocumentBox())
+        totalVerticalMargins = heightAndMargin.margin.top + heightAndMargin.margin.bottom;
+    else if (layoutBox.isBodyBox()) {
+        // Here is the quirky part for body box:
+        // Stretch the body using the initial containing block's height and shrink it with document box's margin/border/padding.
+        // This looks extremely odd when html has non-auto height.
+        auto verticalMargins = Geometry::estimatedMarginTop(layoutState, documentBox) + Geometry::estimatedMarginBottom(layoutState, documentBox);
+        strechedHeight -= verticalMargins;
+
+        // This quirk happens when the body height is 0 which means its vertical margins collapse through (top and bottom margins are adjoining).
+        // However now that we stretch the body they don't collapse through anymore, so we need to use the non-collapsed values instead.
+        auto bodyBoxVerticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.margin;
+        totalVerticalMargins = bodyBoxVerticalMargins.top + bodyBoxVerticalMargins.bottom;
+    }
+
     // Stretch but never overstretch with the margins.
-    if (heightAndMargin.height + totalVerticalMargins < initialContainingBlockHeight)
-        heightAndMargin.height = initialContainingBlockHeight - totalVerticalMargins;
+    if (heightAndMargin.height + totalVerticalMargins < strechedHeight)
+        heightAndMargin.height = strechedHeight - totalVerticalMargins;
 
     return heightAndMargin;
 }

Modified: trunk/Tools/ChangeLog (238700 => 238701)


--- trunk/Tools/ChangeLog	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Tools/ChangeLog	2018-11-29 23:23:47 UTC (rev 238701)
@@ -1,3 +1,12 @@
+2018-11-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC][Quirk] Body and html height stretching.
+        https://bugs.webkit.org/show_bug.cgi?id=192154
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-11-29  Jonathan Bedard  <[email protected]>
 
         webkitpy: Unify device creation

Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (238700 => 238701)


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-11-29 23:18:38 UTC (rev 238700)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-11-29 23:23:47 UTC (rev 238701)
@@ -62,6 +62,10 @@
 fast/block/block-only/absolute-position-min-max-height.html
 fast/block/block-only/float-min-max-height.html
 fast/block/block-only/min-max-height-percentage.html
+fast/block/block-only/body-height-with-non-auto-html-height-quirk.html
+fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html
+fast/block/block-only/body-height-with-auto-html-height-quirk.html
+fast/block/block-only/body-height-with-auto-html-height-quirk2.html
 fast/block/basic/inline-content-with-floating-image.html
 fast/block/basic/inline-content-with-floating-images2.html
 fast/inline/simple-intruding-float1.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to