Title: [235773] trunk
Revision
235773
Author
[email protected]
Date
2018-09-06 19:27:37 -0700 (Thu, 06 Sep 2018)

Log Message

[LFC] Add support for min/max-height percentage values.
https://bugs.webkit.org/show_bug.cgi?id=189391

Reviewed by Antti Koivisto.

Source/WebCore:

The percentage is calculated with respect to the height of the generated box's containing block.
If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element
is not absolutely positioned, the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').

Test: fast/block/block-only/min-max-height-percentage.html

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::computedValueIfNotAuto):
(WebCore::Layout::FormattingContext::Geometry::computedMaxHeight):
(WebCore::Layout::FormattingContext::Geometry::computedMinHeight):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):

Tools:

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

LayoutTests:

* fast/block/block-only/min-max-height-percentage-expected.txt: Added.
* fast/block/block-only/min-max-height-percentage.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (235772 => 235773)


--- trunk/LayoutTests/ChangeLog	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/LayoutTests/ChangeLog	2018-09-07 02:27:37 UTC (rev 235773)
@@ -1,3 +1,13 @@
+2018-09-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] Add support for min/max-height percentage values.
+        https://bugs.webkit.org/show_bug.cgi?id=189391
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/min-max-height-percentage-expected.txt: Added.
+        * fast/block/block-only/min-max-height-percentage.html: Added.
+
 2018-09-06  Megan Gardner  <[email protected]>
 
         Add Support for Conic Gradients

Added: trunk/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt (0 => 235773)


--- trunk/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt	2018-09-07 02:27:37 UTC (rev 235773)
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x586
+  RenderBlock {HTML} at (0,0) size 800x586
+    RenderBody {BODY} at (8,8) size 784x570
+      RenderBlock {DIV} at (0,0) size 200x100
+        RenderBlock {DIV} at (0,0) size 100x50
+          RenderBlock {DIV} at (0,0) size 20x80
+      RenderBlock {DIV} at (0,100) size 200x100
+        RenderBlock {DIV} at (0,0) size 100x50
+          RenderBlock {DIV} at (0,0) size 20x10
+      RenderBlock {DIV} at (0,200) size 200x10
+        RenderBlock {DIV} at (0,0) size 100x10
+          RenderBlock {DIV} at (0,0) size 20x10
+layer at (8,318) size 200x80
+  RenderBlock (relative positioned) {DIV} at (0,310) size 200x80
+    RenderBlock {DIV} at (0,0) size 20x80
+layer at (8,318) size 100x40
+  RenderBlock (positioned) {DIV} at (0,0) size 100x40
+    RenderBlock {DIV} at (0,0) size 20x80
+layer at (8,498) size 200x80
+  RenderBlock (relative positioned) {DIV} at (0,490) size 200x80
+    RenderBlock {DIV} at (0,0) size 20x80
+layer at (8,498) size 100x40
+  RenderBlock (positioned) {DIV} at (0,0) size 100x40

Added: trunk/LayoutTests/fast/block/block-only/min-max-height-percentage.html (0 => 235773)


--- trunk/LayoutTests/fast/block/block-only/min-max-height-percentage.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/min-max-height-percentage.html	2018-09-07 02:27:37 UTC (rev 235773)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="width: 200px; height: 100px;">
+    <div style="width: 100px; max-height: 50%;">
+	    <div style="width: 20px; height: 80px;"></div>
+    </div>
+</div>
+
+<div style="width: 200px; height: 100px;">
+    <div style="width: 100px; min-height: 50%;">
+	    <div style="width: 20px; height: 10px;"></div>
+    </div>
+</div>
+
+<div style="width: 200px; margin-bottom: 100px;">
+    <div style="width: 100px; min-height: 50%;">
+	    <div style="width: 20px; height: 10px;"></div>
+    </div>
+</div>
+
+<div style="position: relative; width: 200px; margin-bottom: 100px;">
+    <div style="position: absolute; width: 100px; max-height: 50%;">
+		<div style="width: 20px; height: 80px;"></div>
+    </div>
+	<div style="width: 20px; height: 80px;"></div>
+</div>
+
+<div style="position: relative; width: 200px;">
+    <div style="position: absolute; width: 100px; min-height: 50%;"></div>
+	<div style="width: 20px; height: 80px;"></div>
+</div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (235772 => 235773)


--- trunk/Source/WebCore/ChangeLog	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Source/WebCore/ChangeLog	2018-09-07 02:27:37 UTC (rev 235773)
@@ -1,3 +1,26 @@
+2018-09-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] Add support for min/max-height percentage values.
+        https://bugs.webkit.org/show_bug.cgi?id=189391
+
+        Reviewed by Antti Koivisto.
+
+        The percentage is calculated with respect to the height of the generated box's containing block.
+        If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element
+        is not absolutely positioned, the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
+
+        Test: fast/block/block-only/min-max-height-percentage.html
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
+        * layout/FormattingContext.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::computedValueIfNotAuto):
+        (WebCore::Layout::FormattingContext::Geometry::computedMaxHeight):
+        (WebCore::Layout::FormattingContext::Geometry::computedMinHeight):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+
 2018-09-06  Megan Gardner  <[email protected]>
 
         Add Support for Conic Gradients

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (235772 => 235773)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-07 02:27:37 UTC (rev 235773)
@@ -86,14 +86,13 @@
     };
 
     auto verticalGeometry = compute({ });
-    // FIXME: Add support for percentage values where the containing block's height is explicitly specified.
-    if (auto maxHeight = Geometry::fixedValue(layoutBox.style().logicalMaxHeight())) {
+    if (auto maxHeight = Geometry::computedMaxHeight(layoutContext, layoutBox)) {
         auto maxVerticalGeometry = compute(maxHeight);
         if (verticalGeometry.heightAndMargin.height > maxVerticalGeometry.heightAndMargin.height)
             verticalGeometry = maxVerticalGeometry;
     }
 
-    if (auto minHeight = Geometry::fixedValue(layoutBox.style().logicalMinHeight())) {
+    if (auto minHeight = Geometry::computedMinHeight(layoutContext, layoutBox)) {
         auto minVerticalGeometry = compute(minHeight);
         if (verticalGeometry.heightAndMargin.height < minVerticalGeometry.heightAndMargin.height)
             verticalGeometry = minVerticalGeometry;

Modified: trunk/Source/WebCore/layout/FormattingContext.h (235772 => 235773)


--- trunk/Source/WebCore/layout/FormattingContext.h	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2018-09-07 02:27:37 UTC (rev 235773)
@@ -103,6 +103,9 @@
         static std::optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth);
         static std::optional<LayoutUnit> fixedValue(const Length& geometryProperty);
 
+        static std::optional<LayoutUnit> computedMinHeight(const LayoutContext&, const Box&);
+        static std::optional<LayoutUnit> computedMaxHeight(const LayoutContext&, const Box&);
+
     private:
         static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedHeight = { });
         static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = { });

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (235772 => 235773)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-09-07 02:27:37 UTC (rev 235773)
@@ -82,6 +82,7 @@
 
     if (geometryProperty.isAuto())
         return std::nullopt;
+
     return valueForLength(geometryProperty, containingBlockWidth);
 }
 
@@ -92,6 +93,58 @@
     return { geometryProperty.value() };
 }
 
+// https://www.w3.org/TR/CSS22/visudet.html#min-max-heights
+// Specifies a percentage for determining the used value. The percentage is calculated with respect to the height of the generated box's containing block.
+// If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned,
+// the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
+std::optional<LayoutUnit> FormattingContext::Geometry::computedMaxHeight(const LayoutContext& layoutContext, const Box& layoutBox)
+{
+    auto maxHeight = layoutBox.style().logicalMaxHeight();
+    if (maxHeight.isUndefined() || maxHeight.isAuto())
+        return { };
+
+    if (maxHeight.isFixed())
+        return { maxHeight.value() };
+
+    std::optional<LayoutUnit> containingBlockHeightValue;
+    auto height = layoutBox.containingBlock()->style().logicalHeight();
+    if (height.isFixed())
+        containingBlockHeightValue = { height.value() };
+    else if (layoutBox.isOutOfFlowPositioned()) {
+        // Containing block's height is already computed.
+        containingBlockHeightValue = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()).height();
+    }
+
+    if (containingBlockHeightValue)
+        return valueForLength(maxHeight, *containingBlockHeightValue);
+
+    return { };
+}
+
+std::optional<LayoutUnit> FormattingContext::Geometry::computedMinHeight(const LayoutContext& layoutContext, const Box& layoutBox)
+{
+    auto minHeight = layoutBox.style().logicalMinHeight();
+    if (minHeight.isUndefined() || minHeight.isAuto())
+        return { };
+
+    if (minHeight.isFixed())
+        return { minHeight.value() };
+
+    std::optional<LayoutUnit> containingBlockHeightValue;
+    auto height = layoutBox.containingBlock()->style().logicalHeight();
+    if (height.isFixed())
+        containingBlockHeightValue = { height.value() };
+    else if (layoutBox.isOutOfFlowPositioned()) {
+        // Containing block's height is already computed.
+        containingBlockHeightValue = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()).height();
+    }
+
+    if (containingBlockHeightValue)
+        return valueForLength(minHeight, *containingBlockHeightValue);
+
+    return { 0 };
+}
+
 static LayoutUnit staticVerticalPositionForOutOfFlowPositioned(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (235772 => 235773)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-07 02:27:37 UTC (rev 235773)
@@ -291,14 +291,13 @@
     };
 
     auto heightAndMargin = compute({ });
-    // FIXME: Add support for percentage values where the containing block's height is explicitly specified.
-    if (auto maxHeight = Geometry::fixedValue(layoutBox.style().logicalMaxHeight())) {
+    if (auto maxHeight = Geometry::computedMaxHeight(layoutContext, layoutBox)) {
         auto maxHeightAndMargin = compute(maxHeight);
         if (heightAndMargin.height > maxHeightAndMargin.height)
             heightAndMargin = maxHeightAndMargin;
     }
 
-    if (auto minHeight = Geometry::fixedValue(layoutBox.style().logicalMinHeight())) {
+    if (auto minHeight = Geometry::computedMinHeight(layoutContext, layoutBox)) {
         auto minHeightAndMargin = compute(minHeight);
         if (heightAndMargin.height < minHeightAndMargin.height)
             heightAndMargin = minHeightAndMargin;

Modified: trunk/Tools/ChangeLog (235772 => 235773)


--- trunk/Tools/ChangeLog	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Tools/ChangeLog	2018-09-07 02:27:37 UTC (rev 235773)
@@ -1,3 +1,12 @@
+2018-09-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] Add support for min/max-height percentage values.
+        https://bugs.webkit.org/show_bug.cgi?id=189391
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-09-06  Simon Fraser  <[email protected]>
 
         Log when leak detection changes the test result

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


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-09-07 01:36:36 UTC (rev 235772)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-09-07 02:27:37 UTC (rev 235773)
@@ -61,3 +61,4 @@
 fast/block/block-only/inflow-min-max-height.html
 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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to