Title: [276293] trunk
Revision
276293
Author
[email protected]
Date
2021-04-20 02:14:49 -0700 (Tue, 20 Apr 2021)

Log Message

Implement CSS display property 2-value syntax
https://bugs.webkit.org/show_bug.cgi?id=224574

Patch by Tim Nguyen <[email protected]> on 2021-04-20
Reviewed by Darin Adler.

Except for list-item which doesn't have layout support for different variants.
Also fix a WPT to expect the most backwards-compatible form for `display: flow` computed value.

Test: web-platform-tests/css/css-display/parsing/display-valid.html

LayoutTests/imported/w3c:

* web-platform-tests/css/css-display/parsing/display-valid-expected.txt:
* web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt:
* web-platform-tests/html/rendering/widgets/button-layout/computed-style.html:
* web-platform-tests/html/rendering/widgets/button-layout/display-other-expected.txt:

Source/WebCore:

* css/CSSValueKeywords.in:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::CSSParserFastPaths::isKeywordPropertyID):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeDisplay):
(WebCore::CSSPropertyParser::parseSingleValue):

LayoutTests:

* platform/mac-wk1/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276292 => 276293)


--- trunk/LayoutTests/ChangeLog	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/ChangeLog	2021-04-20 09:14:49 UTC (rev 276293)
@@ -1,3 +1,17 @@
+2021-04-20  Tim Nguyen  <[email protected]>
+
+        Implement CSS display property 2-value syntax
+        https://bugs.webkit.org/show_bug.cgi?id=224574
+
+        Reviewed by Darin Adler.
+
+        Except for list-item which doesn't have layout support for different variants.
+        Also fix a WPT to expect the most backwards-compatible form for `display: flow` computed value.
+
+        Test: web-platform-tests/css/css-display/parsing/display-valid.html
+
+        * platform/mac-wk1/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt:
+
 2021-04-20  Diego Pino Garcia  <[email protected]>
 
         [WPE] Unreviewed test gardening. Update baselines and test expectations of recent failures.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276292 => 276293)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-20 09:14:49 UTC (rev 276293)
@@ -1,3 +1,20 @@
+2021-04-20  Tim Nguyen  <[email protected]>
+
+        Implement CSS display property 2-value syntax
+        https://bugs.webkit.org/show_bug.cgi?id=224574
+
+        Reviewed by Darin Adler.
+
+        Except for list-item which doesn't have layout support for different variants.
+        Also fix a WPT to expect the most backwards-compatible form for `display: flow` computed value.
+
+        Test: web-platform-tests/css/css-display/parsing/display-valid.html
+
+        * web-platform-tests/css/css-display/parsing/display-valid-expected.txt:
+        * web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt:
+        * web-platform-tests/html/rendering/widgets/button-layout/computed-style.html:
+        * web-platform-tests/html/rendering/widgets/button-layout/display-other-expected.txt:
+
 2021-04-19  Manuel Rego Casasnovas  <[email protected]>
 
         [selectors] Script focus and :focus-visible

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-display/parsing/display-valid-expected.txt (276292 => 276293)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-display/parsing/display-valid-expected.txt	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-display/parsing/display-valid-expected.txt	2021-04-20 09:14:49 UTC (rev 276293)
@@ -17,7 +17,7 @@
 PASS e.style['display'] = "table-caption" should set the property value
 PASS e.style['display'] = "none" should set the property value
 FAIL e.style['display'] = "run-in" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flow" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['display'] = "flow" should set the property value
 PASS e.style['display'] = "flow-root" should set the property value
 FAIL e.style['display'] = "ruby" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "flow list-item" should set the property value assert_not_equals: property should be set got disallowed value ""
@@ -24,16 +24,16 @@
 FAIL e.style['display'] = "list-item flow" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "flow-root list-item" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "list-item flow-root" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "block flow" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flow block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flow-root block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "block flow-root" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flex block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "block flex" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "grid block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "block grid" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "table block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "block table" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['display'] = "block flow" should set the property value
+PASS e.style['display'] = "flow block" should set the property value
+PASS e.style['display'] = "flow-root block" should set the property value
+PASS e.style['display'] = "block flow-root" should set the property value
+PASS e.style['display'] = "flex block" should set the property value
+PASS e.style['display'] = "block flex" should set the property value
+PASS e.style['display'] = "grid block" should set the property value
+PASS e.style['display'] = "block grid" should set the property value
+PASS e.style['display'] = "table block" should set the property value
+PASS e.style['display'] = "block table" should set the property value
 FAIL e.style['display'] = "block ruby" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "ruby block" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "block list-item" should set the property value assert_not_equals: property should be set got disallowed value ""
@@ -50,16 +50,16 @@
 FAIL e.style['display'] = "block list-item flow-root" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "list-item block flow-root" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "list-item flow-root block" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "inline flow" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flow inline" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flow-root inline" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "inline flow-root" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "flex inline" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "inline flex" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "grid inline" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "inline grid" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "table inline" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['display'] = "inline table" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['display'] = "inline flow" should set the property value
+PASS e.style['display'] = "flow inline" should set the property value
+PASS e.style['display'] = "flow-root inline" should set the property value
+PASS e.style['display'] = "inline flow-root" should set the property value
+PASS e.style['display'] = "flex inline" should set the property value
+PASS e.style['display'] = "inline flex" should set the property value
+PASS e.style['display'] = "grid inline" should set the property value
+PASS e.style['display'] = "inline grid" should set the property value
+PASS e.style['display'] = "table inline" should set the property value
+PASS e.style['display'] = "inline table" should set the property value
 FAIL e.style['display'] = "inline ruby" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "ruby inline" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['display'] = "inline list-item" should set the property value assert_not_equals: property should be set got disallowed value ""

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt (276292 => 276293)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt	2021-04-20 09:14:49 UTC (rev 276293)
@@ -80,11 +80,11 @@
 PASS computed display of <input type=submit> with display: contents
 PASS computed display of <input type=color> with display: contents
 PASS computed display of <button type=submit> with display: contents
-FAIL computed display of <input type=reset> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=button> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=submit> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=color> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <button type=submit> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
+PASS computed display of <input type=reset> with display: flow
+PASS computed display of <input type=button> with display: flow
+PASS computed display of <input type=submit> with display: flow
+PASS computed display of <input type=color> with display: flow
+PASS computed display of <button type=submit> with display: flow
 PASS computed display of <input type=reset> with display: flow-root
 PASS computed display of <input type=button> with display: flow-root
 PASS computed display of <input type=submit> with display: flow-root

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style.html (276292 => 276293)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style.html	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style.html	2021-04-20 09:14:49 UTC (rev 276293)
@@ -24,6 +24,11 @@
       if (el instanceof HTMLInputElement && val === 'contents') {
         expectedVal = 'none'; // https://drafts.csswg.org/css-display/#unbox-html
       }
+      if (val == 'flow') {
+        // Use the more backwards-compatible form, `block` is better than `flow`
+        // https://drafts.csswg.org/cssom/#serializing-css-values
+        expectedVal = 'block';
+      }
       assert_equals(getComputedStyle(el).display, expectedVal);
     }, `computed display of ${tag} with display: ${val}`);
   });

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/display-other-expected.txt (276292 => 276293)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/display-other-expected.txt	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/display-other-expected.txt	2021-04-20 09:14:49 UTC (rev 276293)
@@ -2,7 +2,7 @@
 
 FAIL display: block assert_equals: buttonTop expected 0 but got 2
 FAIL display: run-in assert_true: display: run-in is not supported expected true got false
-FAIL display: flow assert_true: display: flow is not supported expected true got false
+PASS display: flow
 PASS display: flow-root
 PASS display: table
 PASS display: list-item

Modified: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt (276292 => 276293)


--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/rendering/widgets/button-layout/computed-style-expected.txt	2021-04-20 09:14:49 UTC (rev 276293)
@@ -80,11 +80,11 @@
 PASS computed display of <input type=submit> with display: contents
 PASS computed display of <input type=text> with display: contents
 PASS computed display of <button type=submit> with display: contents
-FAIL computed display of <input type=reset> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=button> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=submit> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <input type=text> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
-FAIL computed display of <button type=submit> with display: flow assert_not_equals: display: flow is not supported got disallowed value ""
+PASS computed display of <input type=reset> with display: flow
+PASS computed display of <input type=button> with display: flow
+PASS computed display of <input type=submit> with display: flow
+PASS computed display of <input type=text> with display: flow
+PASS computed display of <button type=submit> with display: flow
 PASS computed display of <input type=reset> with display: flow-root
 PASS computed display of <input type=button> with display: flow-root
 PASS computed display of <input type=submit> with display: flow-root

Modified: trunk/Source/WebCore/ChangeLog (276292 => 276293)


--- trunk/Source/WebCore/ChangeLog	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/Source/WebCore/ChangeLog	2021-04-20 09:14:49 UTC (rev 276293)
@@ -1,3 +1,23 @@
+2021-04-20  Tim Nguyen  <[email protected]>
+
+        Implement CSS display property 2-value syntax
+        https://bugs.webkit.org/show_bug.cgi?id=224574
+
+        Reviewed by Darin Adler.
+
+        Except for list-item which doesn't have layout support for different variants.
+        Also fix a WPT to expect the most backwards-compatible form for `display: flow` computed value.
+
+        Test: web-platform-tests/css/css-display/parsing/display-valid.html
+
+        * css/CSSValueKeywords.in:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+        (WebCore::CSSParserFastPaths::isKeywordPropertyID):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeDisplay):
+        (WebCore::CSSPropertyParser::parseSingleValue):
+
 2021-04-19  Antti Koivisto  <[email protected]>
 
         Render tree updates for Text node content mutations should happen during rendering update

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (276292 => 276293)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2021-04-20 09:14:49 UTC (rev 276293)
@@ -473,6 +473,7 @@
 grid
 inline-grid
 flow-root
+flow
 //none
 //
 // CSS_PROP_CURSOR:

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (276292 => 276293)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2021-04-20 09:14:49 UTC (rev 276293)
@@ -631,13 +631,6 @@
         return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueOptimizeQuality;
     case CSSPropertyDirection: // ltr | rtl
         return valueID == CSSValueLtr || valueID == CSSValueRtl;
-    case CSSPropertyDisplay:
-        // inline | block | list-item | inline-block | table |
-        // inline-table | table-row-group | table-header-group | table-footer-group | table-row |
-        // table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none
-        // flex | inline-flex | -webkit-flex | -webkit-inline-flex | grid | inline-grid
-        return (valueID >= CSSValueInline && valueID <= CSSValueContents) || valueID == CSSValueNone
-            || valueID == CSSValueGrid || valueID == CSSValueInlineGrid || valueID == CSSValueFlowRoot;
     case CSSPropertyDominantBaseline:
         // auto | use-script | no-change | reset-size | ideographic |
         // alphabetic | hanging | mathematical | central | middle |
@@ -929,7 +922,6 @@
     case CSSPropertyWebkitColumnProgression:
     case CSSPropertyColumnRuleStyle:
     case CSSPropertyDirection:
-    case CSSPropertyDisplay:
     case CSSPropertyEmptyCells:
     case CSSPropertyFlexDirection:
     case CSSPropertyFlexWrap:

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (276292 => 276293)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-04-20 08:46:50 UTC (rev 276292)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-04-20 09:14:49 UTC (rev 276293)
@@ -380,6 +380,103 @@
 }
 
 // Methods for consuming non-shorthand properties starts here.
+static RefPtr<CSSValue> consumeDisplay(CSSParserTokenRange& range)
+{
+    // Parse single keyword values
+    auto singleKeyword = consumeIdent<
+        // <display-box>
+        CSSValueContents,
+        CSSValueNone,
+        // <display-internal>
+        CSSValueTableCaption,
+        CSSValueTableCell,
+        CSSValueTableColumnGroup,
+        CSSValueTableColumn,
+        CSSValueTableHeaderGroup,
+        CSSValueTableFooterGroup,
+        CSSValueTableRow,
+        CSSValueTableRowGroup,
+        // <display-legacy>
+        CSSValueInlineBlock,
+        CSSValueInlineFlex,
+        CSSValueInlineGrid,
+        CSSValueInlineTable,
+        // Prefixed values
+        CSSValueWebkitInlineBox,
+        CSSValueWebkitBox,
+        CSSValueWebkitInlineFlex,
+        CSSValueWebkitFlex,
+        // No layout support for the full <display-listitem> syntax, so treat it as <display-legacy>
+        CSSValueListItem
+    >(range);
+
+    if (singleKeyword)
+        return singleKeyword;
+
+    // Empty value, stop parsing
+    if (range.atEnd())
+        return nullptr;
+
+    // Parse [ <display-outside> || <display-inside> ]
+    Optional<CSSValueID> parsedDisplayOutside;
+    Optional<CSSValueID> parsedDisplayInside;
+    while (!range.atEnd()) {
+        auto nextValueID = range.peek().id();
+        switch (nextValueID) {
+        // <display-outside>
+        case CSSValueBlock:
+        case CSSValueInline:
+            if (parsedDisplayOutside)
+                return nullptr;
+            parsedDisplayOutside = nextValueID;
+            break;
+        // <display-inside>
+        case CSSValueFlex:
+        case CSSValueFlow:
+        case CSSValueFlowRoot:
+        case CSSValueGrid:
+        case CSSValueTable:
+            if (parsedDisplayInside)
+                return nullptr;
+            parsedDisplayInside = nextValueID;
+            break;
+        default:
+            return nullptr;
+        }
+        consumeIdent(range);
+    }
+
+    // Set defaults when one of the two values are unspecified
+    CSSValueID displayOutside = parsedDisplayOutside.valueOr(CSSValueBlock);
+    CSSValueID displayInside = parsedDisplayInside.valueOr(CSSValueFlow);
+
+    auto selectShortValue = [&]() -> CSSValueID {
+        if (displayOutside == CSSValueBlock) {
+            // Alias display: flow to display: block
+            return displayInside == CSSValueFlow ? CSSValueBlock : displayInside;
+        }
+
+        // Convert `display: inline <display-inside>` to the equivalent short value
+        switch (displayInside) {
+        case CSSValueFlex:
+            return CSSValueInlineFlex;
+        case CSSValueFlow:
+            return CSSValueInline;
+        case CSSValueFlowRoot:
+            return CSSValueInlineBlock;
+        case CSSValueGrid:
+            return CSSValueInlineGrid;
+        case CSSValueTable:
+            return CSSValueInlineTable;
+        default:
+            ASSERT_NOT_REACHED();
+            return CSSValueInline;
+        }
+    };
+
+    return CSSValuePool::singleton().createValue(selectShortValue());
+}
+
 static RefPtr<CSSValue> consumeWillChange(CSSParserTokenRange& range)
 {
     if (range.peek().id() == CSSValueAuto)
@@ -3884,6 +3981,8 @@
             return nullptr;
     }
     switch (property) {
+    case CSSPropertyDisplay:
+        return consumeDisplay(m_range);
     case CSSPropertyWillChange:
         return consumeWillChange(m_range);
     case CSSPropertyPage:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to