Title: [288113] trunk
Revision
288113
Author
[email protected]
Date
2022-01-18 03:02:49 -0800 (Tue, 18 Jan 2022)

Log Message

[css-flexbox] Add support for intrinsic sizes in flex-basis
https://bugs.webkit.org/show_bug.cgi?id=235291

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-flexbox/flex-basis-intrinsics-001-expected.txt: Replaced FAIL by PASS expectations.
* web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt: Ditto.
* web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt: Ditto.

Source/WebCore:

The flex-basis property should allow the same values as <'width'>. However we were only allowing 'auto', 'content'
and any Length. That did not include intrinsic sizes like 'min-content', 'fit-content' etc. Added the proper parsing
machinery in order to fix that.

Apart from that, a change in the flexbox code was needed. In particular the code was incorrectly assuming that a
flex-basis with intrinsic size in a column flexbox was always an indefinite size. That's true as long as the flexbox
has an horizontal writing mode (in that case the main axis would be the block axis). However that's totally wrong for
a flexbox with vertical writing mode (as in that case the main axis would be the inline axis).

The flexbox fix + the parsing additions allow us to pass 12 more WPT subtests.

* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFlexBasis): Additionally check for any validWidthOrHeightKeyword().
(WebCore::CSSPropertyParser::parseSingleValue): Pass the context instead of the mode.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::childMainSizeIsDefinite): Replaced isColumnFlow() by !mainAxisIsChildInlineAxis().

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288112 => 288113)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-18 11:02:49 UTC (rev 288113)
@@ -1,3 +1,14 @@
+2022-01-17  Sergio Villar Senin  <[email protected]>
+
+        [css-flexbox] Add support for intrinsic sizes in flex-basis
+        https://bugs.webkit.org/show_bug.cgi?id=235291
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/css/css-flexbox/flex-basis-intrinsics-001-expected.txt: Replaced FAIL by PASS expectations.
+        * web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt: Ditto.
+        * web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt: Ditto.
+
 2022-01-17  Antti Koivisto  <[email protected]>
 
         [:has() pseudo-class] Disallow nested :has()

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-basis-intrinsics-001-expected.txt (288112 => 288113)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-basis-intrinsics-001-expected.txt	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-basis-intrinsics-001-expected.txt	2022-01-18 11:02:49 UTC (rev 288113)
@@ -1,38 +1,14 @@
 
-FAIL .flex-item 1 assert_equals:
-<div class="flex-item" style="flex-basis: min-content;" data-expected-width="50">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-width expected 50 but got 100
-FAIL .flex-item 2 assert_equals:
-<div class="flex-item" style="flex-basis: max-content; width: 300px;" data-expected-width="100">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-width expected 100 but got 300
-FAIL .flex-item 3 assert_equals:
-<div class="flex-item" style="flex-basis: fit-content;" data-expected-width="75">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-width expected 75 but got 100
+PASS .flex-item 1
+PASS .flex-item 2
+PASS .flex-item 3
 PASS .flex-item 4
 PASS .flex-item 5
 PASS .flex-item 6
 PASS .flex-item 7
-FAIL .flex-item 8 assert_equals:
-<div class="flex-item ortho-item" style="flex-basis: max-content; width: 300px;" data-expected-width="100">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-width expected 100 but got 300
+PASS .flex-item 8
 PASS .flex-item 9
-FAIL .flex-item 10 assert_equals:
-<div class="flex-item ortho-item" style="flex-basis: min-content;" data-expected-height="50">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-height expected 50 but got 100
+PASS .flex-item 10
 PASS .flex-item 11
-FAIL .flex-item 12 assert_equals:
-<div class="flex-item ortho-item" style="flex-basis: fit-content;" data-expected-height="75">
-    <div class="inline-block"></div><div class="inline-block"></div>
-  </div>
-height expected 75 but got 100
+PASS .flex-item 12
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt (288112 => 288113)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt	2022-01-18 11:02:49 UTC (rev 288113)
@@ -3,9 +3,9 @@
 PASS Property flex-basis value '400%'
 PASS Property flex-basis value 'auto'
 PASS Property flex-basis value 'content'
-FAIL Property flex-basis value 'fit-content' assert_true: 'fit-content' is a supported value for flex-basis. expected true got false
-FAIL Property flex-basis value 'min-content' assert_true: 'min-content' is a supported value for flex-basis. expected true got false
-FAIL Property flex-basis value 'max-content' assert_true: 'max-content' is a supported value for flex-basis. expected true got false
+PASS Property flex-basis value 'fit-content'
+PASS Property flex-basis value 'min-content'
+PASS Property flex-basis value 'max-content'
 PASS Property flex-basis value 'calc(10px + 0.5em)'
 PASS Property flex-basis value 'calc(10px - 0.5em)'
 PASS Property flex-basis value 'calc(10%)'

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt (288112 => 288113)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt	2022-01-18 11:02:49 UTC (rev 288113)
@@ -3,8 +3,8 @@
 PASS e.style['flex-basis'] = "calc(2em + 3ex)" should set the property value
 PASS e.style['flex-basis'] = "400%" should set the property value
 PASS e.style['flex-basis'] = "auto" should set the property value
-FAIL e.style['flex-basis'] = "fit-content" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['flex-basis'] = "min-content" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['flex-basis'] = "max-content" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['flex-basis'] = "fit-content" should set the property value
+PASS e.style['flex-basis'] = "min-content" should set the property value
+PASS e.style['flex-basis'] = "max-content" should set the property value
 PASS e.style['flex-basis'] = "content" should set the property value
 

Modified: trunk/Source/WebCore/ChangeLog (288112 => 288113)


--- trunk/Source/WebCore/ChangeLog	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/Source/WebCore/ChangeLog	2022-01-18 11:02:49 UTC (rev 288113)
@@ -1,3 +1,27 @@
+2022-01-17  Sergio Villar Senin  <[email protected]>
+
+        [css-flexbox] Add support for intrinsic sizes in flex-basis
+        https://bugs.webkit.org/show_bug.cgi?id=235291
+
+        Reviewed by Darin Adler.
+
+        The flex-basis property should allow the same values as <'width'>. However we were only allowing 'auto', 'content'
+        and any Length. That did not include intrinsic sizes like 'min-content', 'fit-content' etc. Added the proper parsing
+        machinery in order to fix that.
+
+        Apart from that, a change in the flexbox code was needed. In particular the code was incorrectly assuming that a
+        flex-basis with intrinsic size in a column flexbox was always an indefinite size. That's true as long as the flexbox
+        has an horizontal writing mode (in that case the main axis would be the block axis). However that's totally wrong for
+        a flexbox with vertical writing mode (as in that case the main axis would be the inline axis).
+
+        The flexbox fix + the parsing additions allow us to pass 12 more WPT subtests.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeFlexBasis): Additionally check for any validWidthOrHeightKeyword().
+        (WebCore::CSSPropertyParser::parseSingleValue): Pass the context instead of the mode.
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::childMainSizeIsDefinite): Replaced isColumnFlow() by !mainAxisIsChildInlineAxis().
+
 2022-01-17  Antti Koivisto  <[email protected]>
 
         [:has() pseudo-class] Disallow nested :has()

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (288112 => 288113)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2022-01-18 11:02:49 UTC (rev 288113)
@@ -2284,12 +2284,11 @@
     return consumeUrl(range);
 }
 
-static RefPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode)
+static RefPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, const CSSParserContext& context)
 {
-    // FIXME: Support intrinsic dimensions too.
-    if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueContent)
+    if (identMatches<CSSValueAuto, CSSValueContent>(range.peek().id()) || validWidthOrHeightKeyword(range.peek().id(), context))
         return consumeIdent(range);
-    return consumeLengthOrPercent(range, cssParserMode, ValueRange::NonNegative);
+    return consumeLengthOrPercent(range, context.mode, ValueRange::NonNegative);
 }
 
 static RefPtr<CSSValue> consumeKerning(CSSParserTokenRange& range, CSSParserMode mode)
@@ -4458,7 +4457,7 @@
     case CSSPropertyMarkerEnd:
         return consumeNoneOrURI(m_range);
     case CSSPropertyFlexBasis:
-        return consumeFlexBasis(m_range, m_context.mode);
+        return consumeFlexBasis(m_range, m_context);
     case CSSPropertyFlexGrow:
     case CSSPropertyFlexShrink:
         return consumeNumber(m_range, ValueRange::NonNegative);

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (288112 => 288113)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2022-01-18 08:30:06 UTC (rev 288112)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2022-01-18 11:02:49 UTC (rev 288113)
@@ -968,7 +968,7 @@
 {
     if (flexBasis.isAuto() || flexBasis.isContent())
         return false;
-    if (isColumnFlow() && (flexBasis.isIntrinsic() || flexBasis.type() == LengthType::Intrinsic))
+    if (!mainAxisIsChildInlineAxis(child) && (flexBasis.isIntrinsic() || flexBasis.type() == LengthType::Intrinsic))
         return false;
     if (flexBasis.isPercentOrCalculated())
         return canComputePercentageFlexBasis(child, flexBasis, UpdatePercentageHeightDescendants::No);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to