Title: [275281] trunk
Revision
275281
Author
[email protected]
Date
2021-03-31 08:40:46 -0700 (Wed, 31 Mar 2021)

Log Message

font-stretch should support 0% and disallow animating to a value below 0%
https://bugs.webkit.org/show_bug.cgi?id=223994

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Mark 23 tests as PASS results.

* web-platform-tests/css/css-fonts/animations/font-stretch-interpolation-expected.txt:
* web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt:
* web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt:
* web-platform-tests/css/css-fonts/variations/font-stretch-expected.txt:

Source/WebCore:

Trying to fix css/css-fonts/animations/font-stretch-interpolation.html showed two issues:

1. we disallowed 0% as a valid value when parsing font-stretch,
2. we allowed negative values when blending.

This patch addresses both.

* animation/CSSPropertyAnimation.cpp:
(WebCore::blendFunc):
* css/parser/CSSPropertyParser.cpp:
(WebCore::fontStretchIsWithinRange):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (275280 => 275281)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-03-31 15:40:46 UTC (rev 275281)
@@ -1,3 +1,17 @@
+2021-03-31  Antoine Quint  <[email protected]>
+
+        font-stretch should support 0% and disallow animating to a value below 0%
+        https://bugs.webkit.org/show_bug.cgi?id=223994
+
+        Reviewed by Antti Koivisto.
+
+        Mark 23 tests as PASS results.
+
+        * web-platform-tests/css/css-fonts/animations/font-stretch-interpolation-expected.txt:
+        * web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt:
+        * web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt:
+        * web-platform-tests/css/css-fonts/variations/font-stretch-expected.txt:
+
 2021-03-30  Antoine Quint  <[email protected]>
 
         Computed style for a border-radius corner should never be 0px when the provided width isn't 0px

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-stretch-interpolation-expected.txt (275280 => 275281)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-stretch-interpolation-expected.txt	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-stretch-interpolation-expected.txt	2021-03-31 15:40:46 UTC (rev 275281)
@@ -1,6 +1,6 @@
 TT
 
-FAIL CSS Transitions: property <font-stretch> from [100%] to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (-2) should be [0%]
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (-0.25) should be [75%]
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (0) should be [100%]
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (0.3) should be [130%]
@@ -7,7 +7,7 @@
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (0.6) should be [160%]
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (1) should be [200%]
 PASS CSS Transitions: property <font-stretch> from [100%] to [200%] at (1.5) should be [250%]
-FAIL CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (-2) should be [0%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (-0.25) should be [75%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (0) should be [100%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (0.3) should be [130%]
@@ -14,7 +14,7 @@
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (0.6) should be [160%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (1) should be [200%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [100%] to [200%] at (1.5) should be [250%]
-FAIL CSS Animations: property <font-stretch> from [100%] to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (-2) should be [0%]
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (-0.25) should be [75%]
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (0) should be [100%]
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (0.3) should be [130%]
@@ -21,7 +21,7 @@
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (0.6) should be [160%]
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (1) should be [200%]
 PASS CSS Animations: property <font-stretch> from [100%] to [200%] at (1.5) should be [250%]
-FAIL Web Animations: property <font-stretch> from [100%] to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS Web Animations: property <font-stretch> from [100%] to [200%] at (-2) should be [0%]
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (-0.25) should be [75%]
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (0) should be [100%]
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (0.3) should be [130%]
@@ -28,7 +28,7 @@
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (0.6) should be [160%]
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (1) should be [200%]
 PASS Web Animations: property <font-stretch> from [100%] to [200%] at (1.5) should be [250%]
-FAIL CSS Transitions: property <font-stretch> from neutral to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (-2) should be [0%]
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (-0.25) should be [75%]
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (0) should be [100%]
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (0.3) should be [130%]
@@ -35,7 +35,7 @@
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (0.6) should be [160%]
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (1) should be [200%]
 PASS CSS Transitions: property <font-stretch> from neutral to [200%] at (1.5) should be [250%]
-FAIL CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (-2) should be [0%]
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (-0.25) should be [75%]
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (0) should be [100%]
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (0.3) should be [130%]
@@ -42,7 +42,7 @@
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (0.6) should be [160%]
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (1) should be [200%]
 PASS CSS Transitions with transition: all: property <font-stretch> from neutral to [200%] at (1.5) should be [250%]
-FAIL CSS Animations: property <font-stretch> from neutral to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Animations: property <font-stretch> from neutral to [200%] at (-2) should be [0%]
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (-0.25) should be [75%]
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (0) should be [100%]
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (0.3) should be [130%]
@@ -49,7 +49,7 @@
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (0.6) should be [160%]
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (1) should be [200%]
 PASS CSS Animations: property <font-stretch> from neutral to [200%] at (1.5) should be [250%]
-FAIL Web Animations: property <font-stretch> from neutral to [200%] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS Web Animations: property <font-stretch> from neutral to [200%] at (-2) should be [0%]
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (-0.25) should be [75%]
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (0) should be [100%]
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (0.3) should be [130%]
@@ -56,7 +56,7 @@
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (0.6) should be [160%]
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (1) should be [200%]
 PASS Web Animations: property <font-stretch> from neutral to [200%] at (1.5) should be [250%]
-FAIL CSS Transitions: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%]
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (-0.25) should be [75%]
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (0) should be [100%]
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (0.3) should be [130%]
@@ -63,7 +63,7 @@
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (0.6) should be [160%]
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (1) should be [200%]
 PASS CSS Transitions: property <font-stretch> from [initial] to [inherit] at (1.5) should be [250%]
-FAIL CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (-0.25) should be [75%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (0) should be [100%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (0.3) should be [130%]
@@ -70,7 +70,7 @@
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (0.6) should be [160%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (1) should be [200%]
 PASS CSS Transitions with transition: all: property <font-stretch> from [initial] to [inherit] at (1.5) should be [250%]
-FAIL CSS Animations: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%]
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (-0.25) should be [75%]
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (0) should be [100%]
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (0.3) should be [130%]
@@ -77,7 +77,7 @@
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (0.6) should be [160%]
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (1) should be [200%]
 PASS CSS Animations: property <font-stretch> from [initial] to [inherit] at (1.5) should be [250%]
-FAIL Web Animations: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%] assert_equals: expected "normal " but got "- 100 % "
+PASS Web Animations: property <font-stretch> from [initial] to [inherit] at (-2) should be [0%]
 PASS Web Animations: property <font-stretch> from [initial] to [inherit] at (-0.25) should be [75%]
 PASS Web Animations: property <font-stretch> from [initial] to [inherit] at (0) should be [100%]
 PASS Web Animations: property <font-stretch> from [initial] to [inherit] at (0.3) should be [130%]

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt (275280 => 275281)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/at-font-face-descriptors-expected.txt	2021-03-31 15:40:46 UTC (rev 275281)
@@ -43,12 +43,12 @@
 PASS font-stretch(valid): Legal percentage: 1000%
 PASS font-stretch(invalid): Only percentages, not numbers allowed: 100
 PASS font-stretch(invalid): Negative values are illegal: -1%
-FAIL font-stretch(valid): Zero is legal: 0% assert_not_equals: Valid value should be accepted. got disallowed value ""
+PASS font-stretch(valid): Zero is legal: 0%
 PASS font-stretch(invalid): Extra content after value: 100% a
 FAIL font-stretch(valid): Simple calc value: calc(200.5%) assert_equals: Unexpected resulting value. expected "200.5%" but got "calc(200.5%)"
 FAIL font-stretch(valid): Valid calc _expression_: calc(50%*2 - 20%) assert_equals: Unexpected resulting value. expected "80%" but got "calc(80%)"
-FAIL font-stretch(valid): Negative calc value (to be clamped): calc(-100%) assert_not_equals: Valid value should be accepted. got disallowed value ""
-FAIL font-stretch(valid): Negative calc _expression_ (to be clamped): calc(50% - 50%*2) assert_not_equals: Valid value should be accepted. got disallowed value ""
+PASS font-stretch(valid): Negative calc value (to be clamped): calc(-100%)
+PASS font-stretch(valid): Negative calc _expression_ (to be clamped): calc(50% - 50%*2)
 PASS font-stretch(invalid): Unit-less calc value: calc(100)
 PASS font-stretch(invalid): Calc value with units: calc(100px)
 PASS font-stretch(valid): Simple range: 100% 200%

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt (275280 => 275281)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-parse-numeric-stretch-style-weight-expected.txt	2021-03-31 15:40:46 UTC (rev 275281)
@@ -11,7 +11,7 @@
 PASS Valid value 51% for font property stretch used for styling.
 PASS Valid value 199% for font property stretch used for styling.
 PASS Valid value calc(10% + 20%) for font property stretch used for styling.
-FAIL Valid value 0% for font property stretch used for styling. assert_true: expected true got false
+PASS Valid value 0% for font property stretch used for styling.
 PASS Valid value normal for font property style used for styling.
 PASS Valid value italic for font property style used for styling.
 PASS Valid value oblique for font property style used for styling.
@@ -37,8 +37,8 @@
 PASS Valid value 100 101.5 matches 100 101.5 for weight in @font-face.
 FAIL Valid value 999.8 999.9 matches 999.8 999.9 for weight in @font-face. assert_equals: expected "999.8 999.9" but got "999.75"
 FAIL Valid value 500 400 matches 500 400 for weight in @font-face. The string did not match the expected pattern.
-FAIL Valid value 0% matches 0% for stretch in @font-face. The string did not match the expected pattern.
-FAIL Valid value calc(0% - 10%) matches calc(-10%) for stretch in @font-face. The string did not match the expected pattern.
+PASS Valid value 0% matches 0% for stretch in @font-face.
+FAIL Valid value calc(0% - 10%) matches calc(-10%) for stretch in @font-face. assert_equals: expected "calc(-10%)" but got "0%"
 FAIL Valid value 100% matches 100% for stretch in @font-face. assert_equals: expected "100%" but got "normal"
 PASS Valid value 110% matches 110% for stretch in @font-face.
 PASS Valid value 111.5% matches 111.5% for stretch in @font-face.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-stretch-expected.txt (275280 => 275281)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-stretch-expected.txt	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/variations/font-stretch-expected.txt	2021-03-31 15:40:46 UTC (rev 275281)
@@ -3,8 +3,8 @@
 
 PASS @supports: 100 - only percentages, not numbers allowed
 PASS @supports: -1% - negative values are illegal
-FAIL @supports: 0% - zero is legal assert_equals: zero is legal expected true but got false
-FAIL @getComputedStyle: 0% - zero is legal assert_equals: zero is legal expected "0%" but got "normal"
+PASS @supports: 0% - zero is legal
+PASS @getComputedStyle: 0% - zero is legal
 PASS @supports: 1% - legal percentage
 PASS @getComputedStyle: 1% - legal percentage
 PASS @supports: 10% - legal percentage
@@ -39,10 +39,10 @@
 PASS @getComputedStyle: calc(200.5%) - Simple calc value
 PASS @supports: calc(50%*2 - 20%) - Valid calc _expression_
 PASS @getComputedStyle: calc(50%*2 - 20%) - Valid calc _expression_
-FAIL @supports: calc(-100%) - Negative calc value (to be clamped) assert_equals: Negative calc value (to be clamped) expected true but got false
-FAIL @getComputedStyle: calc(-100%) - Negative calc value (to be clamped) assert_equals: Negative calc value (to be clamped) expected "0%" but got "80%"
-FAIL @supports: calc(50% - 50%*2) - Negative calc _expression_ (to be clamped) assert_equals: Negative calc _expression_ (to be clamped) expected true but got false
-FAIL @getComputedStyle: calc(50% - 50%*2) - Negative calc _expression_ (to be clamped) assert_equals: Negative calc _expression_ (to be clamped) expected "0%" but got "80%"
+PASS @supports: calc(-100%) - Negative calc value (to be clamped)
+PASS @getComputedStyle: calc(-100%) - Negative calc value (to be clamped)
+PASS @supports: calc(50% - 50%*2) - Negative calc _expression_ (to be clamped)
+PASS @getComputedStyle: calc(50% - 50%*2) - Negative calc _expression_ (to be clamped)
 PASS @supports: calc(100) - Unit-less calc value
 PASS @supports: calc(100px) - Calc value with units
 PASS @supports: 100% 700% - Extra percentage after numeric value

Modified: trunk/Source/WebCore/ChangeLog (275280 => 275281)


--- trunk/Source/WebCore/ChangeLog	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/Source/WebCore/ChangeLog	2021-03-31 15:40:46 UTC (rev 275281)
@@ -1,5 +1,24 @@
 2021-03-31  Antoine Quint  <[email protected]>
 
+        font-stretch should support 0% and disallow animating to a value below 0%
+        https://bugs.webkit.org/show_bug.cgi?id=223994
+
+        Reviewed by Antti Koivisto.
+
+        Trying to fix css/css-fonts/animations/font-stretch-interpolation.html showed two issues:
+        
+        1. we disallowed 0% as a valid value when parsing font-stretch,
+        2. we allowed negative values when blending.
+
+        This patch addresses both.
+
+        * animation/CSSPropertyAnimation.cpp:
+        (WebCore::blendFunc):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::fontStretchIsWithinRange):
+
+2021-03-31  Antoine Quint  <[email protected]>
+
         Remove the Silently argument to WebAnimation::cancel()
         https://bugs.webkit.org/show_bug.cgi?id=223992
 

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (275280 => 275281)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-03-31 15:40:46 UTC (rev 275281)
@@ -559,12 +559,12 @@
 
 static inline FontSelectionValue blendFunc(const CSSPropertyBlendingClient* client, FontSelectionValue from, FontSelectionValue to, double progress)
 {
-    return FontSelectionValue(blendFunc(client, static_cast<float>(from), static_cast<float>(to), progress));
+    return FontSelectionValue(std::max(0.0f, blendFunc(client, static_cast<float>(from), static_cast<float>(to), progress)));
 }
 
 static inline Optional<FontSelectionValue> blendFunc(const CSSPropertyBlendingClient* client, Optional<FontSelectionValue> from, Optional<FontSelectionValue> to, double progress)
 {
-    return FontSelectionValue(blendFunc(client, static_cast<float>(from.value()), static_cast<float>(to.value()), progress));
+    return blendFunc(client, *from, *to, progress);
 }
 
 class AnimationPropertyWrapperBase {

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (275280 => 275281)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-03-31 15:38:00 UTC (rev 275280)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-03-31 15:40:46 UTC (rev 275281)
@@ -892,7 +892,7 @@
 #if ENABLE(VARIATION_FONTS)
 static bool fontStretchIsWithinRange(float stretch)
 {
-    return stretch > 0;
+    return stretch >= 0;
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to