Title: [279070] trunk
Revision
279070
Author
[email protected]
Date
2021-06-21 11:18:55 -0700 (Mon, 21 Jun 2021)

Log Message

CSSOM test for serializing font-variant fails
https://bugs.webkit.org/show_bug.cgi?id=226770

Patch by Rob Buis <[email protected]> on 2021-06-21
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update improved test result.

* web-platform-tests/css/css-fonts/parsing/font-variant-east-asian-invalid-expected.txt:
* web-platform-tests/css/css-fonts/parsing/font-variant-valid-expected.txt:
* web-platform-tests/css/cssom/serialize-values-expected.txt:

Source/WebCore:

Implement font-variant serializing according to:
https://drafts.csswg.org/cssom/#serializing-css-values

* css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const):
(WebCore::StyleProperties::appendFontLonghandValueIfExplicit const):
(WebCore::StyleProperties::fontVariantValue const):
* css/StyleProperties.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontVariantEastAsian):
(WebCore::CSSPropertyParser::consumeFontVariantShorthand):

LayoutTests:

* css3/font-variant-parsing-expected.txt:
* css3/font-variant-parsing.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279069 => 279070)


--- trunk/LayoutTests/ChangeLog	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/ChangeLog	2021-06-21 18:18:55 UTC (rev 279070)
@@ -1,3 +1,13 @@
+2021-06-21  Rob Buis  <[email protected]>
+
+        CSSOM test for serializing font-variant fails
+        https://bugs.webkit.org/show_bug.cgi?id=226770
+
+        Reviewed by Darin Adler.
+
+        * css3/font-variant-parsing-expected.txt:
+        * css3/font-variant-parsing.html:
+
 2021-06-20  Darin Adler  <[email protected]>
 
         CSS counter style improvements for Armenian, Tamil, and some CJK styles

Modified: trunk/LayoutTests/css3/font-variant-parsing-expected.txt (279069 => 279070)


--- trunk/LayoutTests/css3/font-variant-parsing-expected.txt	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/css3/font-variant-parsing-expected.txt	2021-06-21 18:18:55 UTC (rev 279070)
@@ -74,13 +74,13 @@
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "full-width"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "proportional-width"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "ruby"
-PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "jis83"
-PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "traditional"
+PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "normal"
+PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "normal"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "traditional full-width"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "jis04 proportional-width"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "jis04 proportional-width ruby"
 PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "jis83 ruby"
-PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "proportional-width"
+PASS window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('font-variant-east-asian').cssText is "normal"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/css3/font-variant-parsing.html (279069 => 279070)


--- trunk/LayoutTests/css3/font-variant-parsing.html	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/css3/font-variant-parsing.html	2021-06-21 18:18:55 UTC (rev 279070)
@@ -96,13 +96,13 @@
 runTest("font-variant-east-asian", "full-width", "full-width");
 runTest("font-variant-east-asian", "proportional-width", "proportional-width");
 runTest("font-variant-east-asian", "ruby", "ruby");
-runTest("font-variant-east-asian", "jis78 jis83", "jis83");
-runTest("font-variant-east-asian", "jis90 traditional", "traditional");
+runTest("font-variant-east-asian", "jis78 jis83", "normal");
+runTest("font-variant-east-asian", "jis90 traditional", "normal");
 runTest("font-variant-east-asian", "full-width traditional", "traditional full-width");
 runTest("font-variant-east-asian", "jis04 proportional-width", "jis04 proportional-width");
 runTest("font-variant-east-asian", "jis04 proportional-width ruby", "jis04 proportional-width ruby");
 runTest("font-variant-east-asian", "jis83 ruby", "jis83 ruby");
-runTest("font-variant-east-asian", "full-width proportional-width", "proportional-width");
+runTest("font-variant-east-asian", "full-width proportional-width", "normal");
 </script>
 <script src=""
 </body>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279069 => 279070)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-21 18:18:55 UTC (rev 279070)
@@ -1,3 +1,16 @@
+2021-06-21  Rob Buis  <[email protected]>
+
+        CSSOM test for serializing font-variant fails
+        https://bugs.webkit.org/show_bug.cgi?id=226770
+
+        Reviewed by Darin Adler.
+
+        Update improved test result.
+
+        * web-platform-tests/css/css-fonts/parsing/font-variant-east-asian-invalid-expected.txt:
+        * web-platform-tests/css/css-fonts/parsing/font-variant-valid-expected.txt:
+        * web-platform-tests/css/cssom/serialize-values-expected.txt:
+
 2021-06-19  Darin Adler  <[email protected]>
 
         Fix CSS serialization issues affecting css-counter-styles tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-east-asian-invalid-expected.txt (279069 => 279070)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-east-asian-invalid-expected.txt	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-east-asian-invalid-expected.txt	2021-06-21 18:18:55 UTC (rev 279070)
@@ -1,5 +1,5 @@
 
 PASS e.style['font-variant-east-asian'] = "normal ruby" should not set the property value
-FAIL e.style['font-variant-east-asian'] = "jis78 jis83" should not set the property value assert_equals: expected "" but got "jis83"
-FAIL e.style['font-variant-east-asian'] = "full-width proportional-width" should not set the property value assert_equals: expected "" but got "proportional-width"
+PASS e.style['font-variant-east-asian'] = "jis78 jis83" should not set the property value
+PASS e.style['font-variant-east-asian'] = "full-width proportional-width" should not set the property value
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-valid-expected.txt (279069 => 279070)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-valid-expected.txt	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-valid-expected.txt	2021-06-21 18:18:55 UTC (rev 279070)
@@ -1,22 +1,22 @@
 
-FAIL e.style['font-variant'] = "normal" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "none" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "common-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "no-common-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "discretionary-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "no-discretionary-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "historical-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "no-historical-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "contextual" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "no-contextual" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "small-caps" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "all-small-caps" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "petite-caps" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "all-petite-caps" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "unicase" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "titling-caps" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['font-variant'] = "normal" should set the property value
+PASS e.style['font-variant'] = "none" should set the property value
+PASS e.style['font-variant'] = "common-ligatures" should set the property value
+PASS e.style['font-variant'] = "no-common-ligatures" should set the property value
+PASS e.style['font-variant'] = "discretionary-ligatures" should set the property value
+PASS e.style['font-variant'] = "no-discretionary-ligatures" should set the property value
+PASS e.style['font-variant'] = "historical-ligatures" should set the property value
+PASS e.style['font-variant'] = "no-historical-ligatures" should set the property value
+PASS e.style['font-variant'] = "contextual" should set the property value
+PASS e.style['font-variant'] = "no-contextual" should set the property value
+PASS e.style['font-variant'] = "small-caps" should set the property value
+PASS e.style['font-variant'] = "all-small-caps" should set the property value
+PASS e.style['font-variant'] = "petite-caps" should set the property value
+PASS e.style['font-variant'] = "all-petite-caps" should set the property value
+PASS e.style['font-variant'] = "unicase" should set the property value
+PASS e.style['font-variant'] = "titling-caps" should set the property value
 FAIL e.style['font-variant'] = "stylistic(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "historical-forms" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['font-variant'] = "historical-forms" should set the property value
 FAIL e.style['font-variant'] = "styleset(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['font-variant'] = "character-variant(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['font-variant'] = "swash(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
@@ -24,25 +24,25 @@
 FAIL e.style['font-variant'] = "annotation(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['font-variant'] = "stylistic(flowing) historical-forms styleset(flowing) character-variant(flowing) swash(flowing) ornaments(flowing) annotation(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['font-variant'] = "annotation(flowing) ornaments(flowing) swash(flowing) character-variant(flowing) styleset(flowing) historical-forms stylistic(flowing)" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "lining-nums" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "oldstyle-nums" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "proportional-nums" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "tabular-nums" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "diagonal-fractions" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "stacked-fractions" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "ordinal" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "slashed-zero" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "jis78" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "jis83" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "jis90" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "jis04" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "simplified" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "traditional" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "full-width" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "proportional-width" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "ruby" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "sub" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['font-variant'] = "super" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['font-variant'] = "lining-nums" should set the property value
+PASS e.style['font-variant'] = "oldstyle-nums" should set the property value
+PASS e.style['font-variant'] = "proportional-nums" should set the property value
+PASS e.style['font-variant'] = "tabular-nums" should set the property value
+PASS e.style['font-variant'] = "diagonal-fractions" should set the property value
+PASS e.style['font-variant'] = "stacked-fractions" should set the property value
+PASS e.style['font-variant'] = "ordinal" should set the property value
+PASS e.style['font-variant'] = "slashed-zero" should set the property value
+PASS e.style['font-variant'] = "jis78" should set the property value
+PASS e.style['font-variant'] = "jis83" should set the property value
+PASS e.style['font-variant'] = "jis90" should set the property value
+PASS e.style['font-variant'] = "jis04" should set the property value
+PASS e.style['font-variant'] = "simplified" should set the property value
+PASS e.style['font-variant'] = "traditional" should set the property value
+PASS e.style['font-variant'] = "full-width" should set the property value
+PASS e.style['font-variant'] = "proportional-width" should set the property value
+PASS e.style['font-variant'] = "ruby" should set the property value
+PASS e.style['font-variant'] = "sub" should set the property value
+PASS e.style['font-variant'] = "super" should set the property value
 FAIL e.style['font-variant'] = "common-ligatures discretionary-ligatures historical-ligatures contextual small-caps stylistic(flowing) lining-nums proportional-nums diagonal-fractions ordinal slashed-zero jis78 full-width ruby sub" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['font-variant'] = "super proportional-width jis83 stacked-fractions tabular-nums oldstyle-nums historical-forms all-small-caps no-contextual no-historical-ligatures no-discretionary-ligatures no-common-ligatures" should set the property value assert_not_equals: property should be set got disallowed value ""
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt (279069 => 279070)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt	2021-06-21 18:18:55 UTC (rev 279070)
@@ -393,9 +393,9 @@
 PASS font-style: italic
 PASS font-style: oblique
 PASS font-style: inherit
-FAIL font-variant: normal assert_equals: font-variant raw inline style declaration expected "normal" but got ""
-FAIL font-variant: small-caps assert_equals: font-variant raw inline style declaration expected "small-caps" but got ""
-FAIL font-variant: inherit assert_equals: font-variant raw inline style declaration expected "inherit" but got ""
+PASS font-variant: normal
+PASS font-variant: small-caps
+PASS font-variant: inherit
 PASS font-weight: normal
 PASS font-weight: bold
 PASS font-weight: bolder

Modified: trunk/Source/WebCore/ChangeLog (279069 => 279070)


--- trunk/Source/WebCore/ChangeLog	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/Source/WebCore/ChangeLog	2021-06-21 18:18:55 UTC (rev 279070)
@@ -1,3 +1,22 @@
+2021-06-21  Rob Buis  <[email protected]>
+
+        CSSOM test for serializing font-variant fails
+        https://bugs.webkit.org/show_bug.cgi?id=226770
+
+        Reviewed by Darin Adler.
+
+        Implement font-variant serializing according to:
+        https://drafts.csswg.org/cssom/#serializing-css-values
+
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::getPropertyValue const):
+        (WebCore::StyleProperties::appendFontLonghandValueIfExplicit const):
+        (WebCore::StyleProperties::fontVariantValue const):
+        * css/StyleProperties.h:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeFontVariantEastAsian):
+        (WebCore::CSSPropertyParser::consumeFontVariantShorthand):
+
 2021-06-21  Alan Bujtas  <[email protected]>
 
         Remove redundant HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (279069 => 279070)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2021-06-21 18:18:55 UTC (rev 279070)
@@ -237,6 +237,8 @@
         return getAlignmentShorthandValue(placeSelfShorthand());
     case CSSPropertyFont:
         return fontValue();
+    case CSSPropertyFontVariant:
+        return fontVariantValue();
     case CSSPropertyInset:
         return get4Values(insetShorthand());
     case CSSPropertyInsetBlock:
@@ -362,7 +364,12 @@
     case CSSPropertyFontStyle:
         break; // No prefix.
     case CSSPropertyFontFamily:
+    case CSSPropertyFontVariantAlternates:
     case CSSPropertyFontVariantCaps:
+    case CSSPropertyFontVariantLigatures:
+    case CSSPropertyFontVariantNumeric:
+    case CSSPropertyFontVariantPosition:
+    case CSSPropertyFontVariantEastAsian:
     case CSSPropertyFontWeight:
     case CSSPropertyFontStretch:
         prefix = ' ';
@@ -412,6 +419,21 @@
     return result.toString();
 }
 
+String StyleProperties::fontVariantValue() const
+{
+    String commonValue;
+    StringBuilder result;
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantLigatures, result, commonValue);
+    if (isCSSWideValueKeyword(result.toString()))
+        return result.toString();
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantAlternates, result, commonValue);
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantCaps, result, commonValue);
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantEastAsian, result, commonValue);
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantNumeric, result, commonValue);
+    appendFontLonghandValueIfExplicit(CSSPropertyFontVariantPosition, result, commonValue);
+    return result.toString();
+}
+
 String StyleProperties::get2Values(const StylePropertyShorthand& shorthand) const
 {
     // Assume the properties are in the usual order start, end.

Modified: trunk/Source/WebCore/css/StyleProperties.h (279069 => 279070)


--- trunk/Source/WebCore/css/StyleProperties.h	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/Source/WebCore/css/StyleProperties.h	2021-06-21 18:18:55 UTC (rev 279070)
@@ -172,6 +172,7 @@
     String get4Values(const StylePropertyShorthand&) const;
     String borderSpacingValue(const StylePropertyShorthand&) const;
     String fontValue() const;
+    String fontVariantValue() const;
     void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
 
     friend class PropertySetCSSStyleDeclaration;

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (279069 => 279070)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-06-21 18:15:04 UTC (rev 279069)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-06-21 18:18:55 UTC (rev 279070)
@@ -691,42 +691,60 @@
         return consumeIdent(range);
     
     RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
-    FontVariantEastAsianVariant variant = FontVariantEastAsianVariant::Normal;
-    FontVariantEastAsianWidth width = FontVariantEastAsianWidth::Normal;
-    FontVariantEastAsianRuby ruby = FontVariantEastAsianRuby::Normal;
+    std::optional<FontVariantEastAsianVariant> variant;
+    std::optional<FontVariantEastAsianWidth> width;
+    std::optional<FontVariantEastAsianRuby> ruby;
     
     while (!range.atEnd()) {
         if (range.peek().type() != IdentToken)
             return nullptr;
-        
+
         auto id = range.peek().id();
         
         switch (id) {
         case CSSValueJis78:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Jis78;
             break;
         case CSSValueJis83:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Jis83;
             break;
         case CSSValueJis90:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Jis90;
             break;
         case CSSValueJis04:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Jis04;
             break;
         case CSSValueSimplified:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Simplified;
             break;
         case CSSValueTraditional:
+            if (variant)
+                return nullptr;
             variant = FontVariantEastAsianVariant::Traditional;
             break;
         case CSSValueFullWidth:
+            if (width)
+                return nullptr;
             width = FontVariantEastAsianWidth::Full;
             break;
         case CSSValueProportionalWidth:
+            if (width)
+                return nullptr;
             width = FontVariantEastAsianWidth::Proportional;
             break;
         case CSSValueRuby:
+            if (ruby)
+                return nullptr;
             ruby = FontVariantEastAsianRuby::Yes;
             break;
         default:
@@ -735,8 +753,8 @@
         
         range.consumeIncludingWhitespace();
     }
-        
-    switch (variant) {
+
+    switch (variant.value_or(FontVariantEastAsianVariant::Normal)) {
     case FontVariantEastAsianVariant::Normal:
         break;
     case FontVariantEastAsianVariant::Jis78:
@@ -758,8 +776,8 @@
         values->append(CSSValuePool::singleton().createIdentifierValue(CSSValueTraditional));
         break;
     }
-        
-    switch (width) {
+
+    switch (width.value_or(FontVariantEastAsianWidth::Normal)) {
     case FontVariantEastAsianWidth::Normal:
         break;
     case FontVariantEastAsianWidth::Full:
@@ -770,7 +788,7 @@
         break;
     }
         
-    switch (ruby) {
+    switch (ruby.value_or(FontVariantEastAsianRuby::Normal)) {
     case FontVariantEastAsianRuby::Normal:
         break;
     case FontVariantEastAsianRuby::Yes:
@@ -4933,9 +4951,9 @@
 {
     if (identMatches<CSSValueNormal, CSSValueNone>(m_range.peek().id())) {
         addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, consumeIdent(m_range).releaseNonNull(), important);
-        addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-        addProperty(CSSPropertyFontVariantEastAsian, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-        addProperty(CSSPropertyFontVariantPosition, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
+        addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
+        addProperty(CSSPropertyFontVariantEastAsian, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
+        addProperty(CSSPropertyFontVariantPosition, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
         return m_range.atEnd();
     }
 
@@ -4946,6 +4964,8 @@
     RefPtr<CSSValue> eastAsianValue;
     FontVariantLigaturesParser ligaturesParser;
     FontVariantNumericParser numericParser;
+    bool implicitLigatures = true;
+    bool implicitNumeric = true;
     do {
         if (!capsValue) {
             capsValue = consumeFontVariantCaps(m_range);
@@ -4967,9 +4987,14 @@
 
         FontVariantLigaturesParser::ParseResult ligaturesParseResult = ligaturesParser.consumeLigature(m_range);
         FontVariantNumericParser::ParseResult numericParseResult = numericParser.consumeNumeric(m_range);
-        if (ligaturesParseResult == FontVariantLigaturesParser::ParseResult::ConsumedValue
-            || numericParseResult == FontVariantNumericParser::ParseResult::ConsumedValue)
+        if (ligaturesParseResult == FontVariantLigaturesParser::ParseResult::ConsumedValue) {
+            implicitLigatures = false;
             continue;
+        }
+        if (numericParseResult == FontVariantNumericParser::ParseResult::ConsumedValue) {
+            implicitNumeric = false;
+            continue;
+        }
 
         if (ligaturesParseResult == FontVariantLigaturesParser::ParseResult::DisallowedValue
             || numericParseResult == FontVariantNumericParser::ParseResult::DisallowedValue)
@@ -4978,7 +5003,7 @@
         if (!eastAsianValue) {
             eastAsianValue = consumeFontVariantEastAsian(m_range);
             if (eastAsianValue)
-            continue;
+                continue;
         }
 
         // Saw some value that didn't match anything else.
@@ -4986,15 +5011,19 @@
 
     } while (!m_range.atEnd());
 
-    addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, ligaturesParser.finalizeValue().releaseNonNull(), important);
-    addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, numericParser.finalizeValue().releaseNonNull(), important);
-    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, capsValue ? capsValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-    addProperty(CSSPropertyFontVariantAlternates, CSSPropertyFontVariant, alternatesValue ? alternatesValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-    addProperty(CSSPropertyFontVariantPosition, CSSPropertyFontVariant, positionValue ? positionValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-    
+    addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, ligaturesParser.finalizeValue().releaseNonNull(), important, implicitLigatures);
+    addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, numericParser.finalizeValue().releaseNonNull(), important, implicitNumeric);
+    bool implicitCaps = !capsValue;
+    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, capsValue ? capsValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, implicitCaps);
+    bool implicitAlternates = !alternatesValue;
+    addProperty(CSSPropertyFontVariantAlternates, CSSPropertyFontVariant, alternatesValue ? alternatesValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, implicitAlternates);
+    bool implicitPosition = !positionValue;
+    addProperty(CSSPropertyFontVariantPosition, CSSPropertyFontVariant, positionValue ? positionValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, implicitPosition);
+
+    bool implicitEastAsian = !eastAsianValue;
     if (!eastAsianValue)
         eastAsianValue = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
-    addProperty(CSSPropertyFontVariantEastAsian, CSSPropertyFontVariant, eastAsianValue.releaseNonNull(), important);
+    addProperty(CSSPropertyFontVariantEastAsian, CSSPropertyFontVariant, eastAsianValue.releaseNonNull(), important, implicitEastAsian);
     
     return true;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to