Title: [261974] trunk
Revision
261974
Author
obru...@igalia.com
Date
2020-05-20 17:12:45 -0700 (Wed, 20 May 2020)

Log Message

Computed min-width/height for auto depends on box
https://bugs.webkit.org/show_bug.cgi?id=209651

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

Update test expectations.

* web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001-expected.txt:

Source/WebCore:

Resolved value of min-width and min-height for auto min sizing of flex
and grid items may be 'auto'. We based this on the computed style of the
shadow including parent. Instead we should rely on whether the element
will actually be a rendered flex/grid item.

The difference matters e.g. when the parent has 'display: contents' and
thus is not a flex nor grid container, but the element can still be a
flex or grid item, depending on the grand-parent.

This patch is based on https://crrev.com/540901 from Chromium.

Tests: imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html
       imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::isFlexOrGridItem):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (261973 => 261974)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-21 00:02:31 UTC (rev 261973)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-21 00:12:45 UTC (rev 261974)
@@ -1,5 +1,17 @@
 2020-05-20  Oriol Brufau  <obru...@igalia.com>
 
+        Computed min-width/height for auto depends on box
+        https://bugs.webkit.org/show_bug.cgi?id=209651
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Update test expectations.
+
+        * web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size-expected.txt:
+        * web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001-expected.txt:
+
+2020-05-20  Oriol Brufau  <obru...@igalia.com>
+
         [css-grid] Fix auto repeat with multiple tracks and gutters
         https://bugs.webkit.org/show_bug.cgi?id=182922
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size-expected.txt (261973 => 261974)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size-expected.txt	2020-05-21 00:02:31 UTC (rev 261973)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size-expected.txt	2020-05-21 00:12:45 UTC (rev 261974)
@@ -1,6 +1,6 @@
 
 PASS Computed min-width/min-height of specified auto for flex item. 
-FAIL Computed min-width/min-height of specified auto inside display:none which would otherwise have been a flex item. assert_equals: expected "0px" but got "auto"
-FAIL Computed min-width/min-height of specified auto for flex item inside display:contents. assert_equals: expected "auto" but got "0px"
-FAIL Computed min-width/min-height of specified auto with display:none which would otherwise have been a flex item. assert_equals: expected "0px" but got "auto"
+PASS Computed min-width/min-height of specified auto inside display:none which would otherwise have been a flex item. 
+PASS Computed min-width/min-height of specified auto for flex item inside display:contents. 
+PASS Computed min-width/min-height of specified auto with display:none which would otherwise have been a flex item. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001-expected.txt (261973 => 261974)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001-expected.txt	2020-05-21 00:02:31 UTC (rev 261973)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001-expected.txt	2020-05-21 00:12:45 UTC (rev 261974)
@@ -1,6 +1,6 @@
 
 PASS Computed min-width/min-height of specified auto for grid item. 
-FAIL Computed min-width/min-height of specified auto inside display:none which would otherwise have been a grid item. assert_equals: expected "0px" but got "auto"
-FAIL Computed min-width/min-height of specified auto for grid item inside display:contents. assert_equals: expected "auto" but got "0px"
-FAIL Computed min-width/min-height of specified auto with display:none which would otherwise have been a grid item. assert_equals: expected "0px" but got "auto"
+PASS Computed min-width/min-height of specified auto inside display:none which would otherwise have been a grid item. 
+PASS Computed min-width/min-height of specified auto for grid item inside display:contents. 
+PASS Computed min-width/min-height of specified auto with display:none which would otherwise have been a grid item. 
 

Modified: trunk/Source/WebCore/ChangeLog (261973 => 261974)


--- trunk/Source/WebCore/ChangeLog	2020-05-21 00:02:31 UTC (rev 261973)
+++ trunk/Source/WebCore/ChangeLog	2020-05-21 00:12:45 UTC (rev 261974)
@@ -1,3 +1,28 @@
+2020-05-20  Oriol Brufau  <obru...@igalia.com>
+
+        Computed min-width/height for auto depends on box
+        https://bugs.webkit.org/show_bug.cgi?id=209651
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Resolved value of min-width and min-height for auto min sizing of flex
+        and grid items may be 'auto'. We based this on the computed style of the
+        shadow including parent. Instead we should rely on whether the element
+        will actually be a rendered flex/grid item.
+
+        The difference matters e.g. when the parent has 'display: contents' and
+        thus is not a flex nor grid container, but the element can still be a
+        flex or grid item, depending on the grand-parent.
+
+        This patch is based on https://crrev.com/540901 from Chromium.
+
+        Tests: imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html
+               imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::isFlexOrGridItem):
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+
 2020-05-20  Alex Christensen  <achristen...@webkit.org>
 
         Remove implicit URL->String conversion operators

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (261973 => 261974)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-05-21 00:02:31 UTC (rev 261973)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-05-21 00:12:45 UTC (rev 261974)
@@ -2350,9 +2350,12 @@
     return paintOrderList;
 }
 
-inline static bool isFlexOrGrid(ContainerNode* element)
+inline static bool isFlexOrGridItem(RenderObject* renderer)
 {
-    return element && element->computedStyle() && element->computedStyle()->isDisplayFlexibleOrGridBox();
+    if (!renderer || !renderer->isBox())
+        return false;
+    auto& box = downcast<RenderBox>(*renderer);
+    return box.isFlexItem() || box.isGridItem();
 }
 
 RefPtr<CSSValue> ComputedStyleExtractor::customPropertyValue(const String& propertyName)
@@ -2990,8 +2993,7 @@
         }
         case CSSPropertyMinHeight:
             if (style.minHeight().isAuto()) {
-                auto* styledElement = this->styledElement();
-                if (styledElement && isFlexOrGrid(styledElement->parentNode()))
+                if (isFlexOrGridItem(renderer))
                     return cssValuePool.createIdentifierValue(CSSValueAuto);
                 return zoomAdjustedPixelValue(0, style);
             }
@@ -2998,8 +3000,7 @@
             return zoomAdjustedPixelValueForLength(style.minHeight(), style);
         case CSSPropertyMinWidth:
             if (style.minWidth().isAuto()) {
-                auto* styledElement = this->styledElement();
-                if (styledElement && isFlexOrGrid(styledElement->parentNode()))
+                if (isFlexOrGridItem(renderer))
                     return cssValuePool.createIdentifierValue(CSSValueAuto);
                 return zoomAdjustedPixelValue(0, style);
             }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to