Title: [289876] trunk
Revision
289876
Author
[email protected]
Date
2022-02-15 21:27:04 -0800 (Tue, 15 Feb 2022)

Log Message

Implement parsing and animation support for offset shorthand
https://bugs.webkit.org/show_bug.cgi?id=233109

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

* web-platform-tests/css/motion/animation/offset-interpolation-expected.txt:
* web-platform-tests/css/motion/parsing/offset-parsing-valid-expected.txt:
* web-platform-tests/css/motion/parsing/offset-parsing-valid.html:
* web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt:

Source/WebCore:

This patch implements support for the offset shorthand for css motion path. This involves
adding the offset property to CSSProperties.json, the introduction of consumeOffset() to
parse the set offset, and serialization of the offset values.

* animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::CSSPropertyIDToIDLAttributeName):
(WebCore::IDLAttributeNameToAnimationPropertyName):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForOffsetShorthand):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSOffsetRotateValue.cpp:
(WebCore::CSSOffsetRotateValue::initialValue):
(WebCore::CSSOffsetRotateValue::isInitialValue const):
* css/CSSOffsetRotateValue.h:
* css/CSSProperties.json:
* css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const):
(WebCore::StyleProperties::offsetValue const):
* css/StyleProperties.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeBasicShapeOrBox):
(WebCore::CSSPropertyParser::consumeOffset):
(WebCore::CSSPropertyParser::parseShorthand):
* css/parser/CSSPropertyParser.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (289875 => 289876)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-16 05:27:04 UTC (rev 289876)
@@ -1,5 +1,17 @@
 2022-02-15  Nikolaos Mouchtaris  <[email protected]>
 
+        Implement parsing and animation support for offset shorthand
+        https://bugs.webkit.org/show_bug.cgi?id=233109
+
+        Reviewed by Dean Jackson.
+
+        * web-platform-tests/css/motion/animation/offset-interpolation-expected.txt:
+        * web-platform-tests/css/motion/parsing/offset-parsing-valid-expected.txt:
+        * web-platform-tests/css/motion/parsing/offset-parsing-valid.html:
+        * web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt:
+
+2022-02-15  Nikolaos Mouchtaris  <[email protected]>
+
         [css-transforms] properly handle interpolation of non-invertible matrices
         https://bugs.webkit.org/show_bug.cgi?id=236480
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/animation/offset-interpolation-expected.txt (289875 => 289876)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/animation/offset-interpolation-expected.txt	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/animation/offset-interpolation-expected.txt	2022-02-16 05:27:04 UTC (rev 289876)
@@ -1,38 +1,38 @@
 
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 300H 700 Z") 470px 770deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 300H 700 Z") 500px 800deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 300H 700 Z") 530px 830deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0H 170") 470px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0H 200") 500px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0H 230") 530px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 260") 560px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 350") 650px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 200H 700") 470px 770deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 200H 700") 500px 800deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 200H 700") 530px 830deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0H 170") 470px] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0H 200") 500px] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0H 230") 530px] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 260") 560px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 350") 650px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 200H 700") 470px 770deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 200H 700") 500px 800deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 200H 700") 530px 830deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0V 200") 470px] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0V 200") 500px] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0V 200") 530px] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 300") 560px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 300") 650px 0deg] assert_true: 'from' value should be supported expected true got false
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 300H 700 Z") 470px 770deg]
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 300H 700 Z") 500px 800deg]
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 300H 700 Z") 530px 830deg]
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg]
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg]
+PASS CSS Transitions: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0H 170") 470px 0deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0H 200") 500px 0deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0H 230") 530px 0deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 260") 560px 0deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg]
+PASS CSS Transitions: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 350") 650px 0deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 200H 700") 470px 770deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 200H 700") 500px 800deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 200H 700") 530px 830deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg]
+PASS CSS Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0H 170") 470px]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0H 200") 500px]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0H 230") 530px]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 260") 560px 0deg]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg]
+PASS CSS Animations: property <offset> from [path("M0 0H 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 350") 650px 0deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (-0.3) should be [path("M0 200H 700") 470px 770deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0) should be [path("M0 200H 700") 500px 800deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.3) should be [path("M0 200H 700") 530px 830deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (0.6) should be [path("M0 300H 700 Z") 560px 860deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1) should be [path("M0 300H 700 Z") 600px 900deg]
+PASS Web Animations: property <offset> from [path("M0 200H 700") 500px 800deg] to [path("M0 300H 700 Z") 600px 900deg] at (1.5) should be [path("M0 300H 700 Z") 650px 950deg]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (-0.3) should be [path("M0 0V 200") 470px]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0) should be [path("M0 0V 200") 500px]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.3) should be [path("M0 0V 200") 530px]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (0.6) should be [path("M0 0H 300") 560px 0deg]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1) should be [path("M0 0H 300") 600px 0deg]
+PASS Web Animations: property <offset> from [path("M0 0V 200") 500px auto] to [path("M0 0H 300") 600px 0deg] at (1.5) should be [path("M0 0H 300") 650px 0deg]
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid-expected.txt (289875 => 289876)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid-expected.txt	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid-expected.txt	2022-02-16 05:27:04 UTC (rev 289876)
@@ -1,31 +1,31 @@
 
-FAIL e.style['offset'] = "100px none auto 90deg" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "100px" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "auto none reverse" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "center bottom path(\"M 1 2 V 3 Z\")" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "center center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "left top" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "none 30deg reverse" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "none 50px reverse 30deg" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "none calc(10px + 20%) auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "none reverse" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") -200% auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") -200%" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path('M 0 0 H 1') 50px" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") auto 0deg" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") auto 0rad" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\") auto 0.5turn" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path('M 0 0 H 1') reverse 30deg 50px" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 1\")" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path('m 20 0 h 100') -7rad 8px / auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path('m 0 30 v 100') -7rad 8px / left top" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path('m 0 0 h 100') -7rad 8px" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 100\") 100px 0deg" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "path(  'm 1 2   v 3.00 z')" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "ray(farthest-corner 90deg) 1%" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "ray(sides 0deg) 50% 90deg auto" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['offset'] = "right bottom / left top" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['offset'] = "100px none auto 90deg" should set the property value
+PASS e.style['offset'] = "100px" should set the property value
+PASS e.style['offset'] = "auto none reverse" should set the property value
+PASS e.style['offset'] = "auto" should set the property value
+PASS e.style['offset'] = "center bottom path(\"M 1 2 V 3 Z\")" should set the property value
+PASS e.style['offset'] = "center center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom" should set the property value
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set the property value
+PASS e.style['offset'] = "left top" should set the property value
+PASS e.style['offset'] = "none 30deg reverse" should set the property value
+PASS e.style['offset'] = "none 50px reverse 30deg" should set the property value
+PASS e.style['offset'] = "none calc(10px + 20%) auto" should set the property value
+PASS e.style['offset'] = "none reverse" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") -200% auto" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") -200%" should set the property value
+PASS e.style['offset'] = "path('M 0 0 H 1') 50px" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") auto" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") auto 0deg" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") auto 0rad" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\") auto 0.5turn" should set the property value
+PASS e.style['offset'] = "path('M 0 0 H 1') reverse 30deg 50px" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 1\")" should set the property value
+PASS e.style['offset'] = "path('m 20 0 h 100') -7rad 8px / auto" should set the property value
+PASS e.style['offset'] = "path('m 0 30 v 100') -7rad 8px / left top" should set the property value
+PASS e.style['offset'] = "path('m 0 0 h 100') -7rad 8px" should set the property value
+PASS e.style['offset'] = "path(\"M 0 0 H 100\") 100px 0deg" should set the property value
+PASS e.style['offset'] = "path(  'm 1 2   v 3.00 z')" should set the property value
+PASS e.style['offset'] = "ray(farthest-corner 90deg) 1%" should set the property value
+PASS e.style['offset'] = "ray(sides 0deg) 50% 90deg auto" should set the property value
+PASS e.style['offset'] = "right bottom / left top" should set the property value
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid.html (289875 => 289876)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid.html	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-parsing-valid.html	2022-02-16 05:27:04 UTC (rev 289876)
@@ -17,7 +17,7 @@
 test_valid_value("offset", "auto none reverse");
 test_valid_value("offset", "auto");
 test_valid_value("offset", "center bottom path(\"M 1 2 V 3 Z\")");
-test_valid_value("offset", "center center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom");
+test_valid_value("offset", "center center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom", "center path(\"M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z\") 100% 90deg / left bottom");
 test_valid_value("offset", "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom");
 test_valid_value("offset", "left top");
 test_valid_value("offset", "none 30deg reverse", "none reverse 30deg");

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt (289875 => 289876)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt	2022-02-16 05:27:04 UTC (rev 289876)
@@ -1,20 +1,20 @@
 
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-anchor assert_equals: offset-anchor should be canonical expected "right bottom" but got ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-distance assert_equals: offset-distance should be canonical expected "10px" but got ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-path assert_equals: offset-path should be canonical expected "ray(0rad closest-side)" but got ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-position assert_equals: offset-position should be canonical expected "left bottom" but got ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-rotate assert_equals: offset-rotate should be canonical expected "auto 30deg" but got ""
-FAIL e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should not set unrelated longhands assert_true: expected true got false
-FAIL e.style['offset'] = "top right / top left" should set offset-anchor assert_equals: offset-anchor should be canonical expected "left top" but got ""
-FAIL e.style['offset'] = "top right / top left" should set offset-distance assert_equals: offset-distance should be canonical expected "0px" but got ""
-FAIL e.style['offset'] = "top right / top left" should set offset-path assert_equals: offset-path should be canonical expected "none" but got ""
-FAIL e.style['offset'] = "top right / top left" should set offset-position assert_equals: offset-position should be canonical expected "right top" but got ""
-FAIL e.style['offset'] = "top right / top left" should set offset-rotate assert_equals: offset-rotate should be canonical expected "auto" but got ""
-FAIL e.style['offset'] = "top right / top left" should not set unrelated longhands assert_true: expected true got false
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-anchor assert_equals: offset-anchor should be canonical expected "auto" but got ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-distance assert_equals: offset-distance should be canonical expected "50%" but got ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-path assert_equals: offset-path should be canonical expected "path(\"M 0 0 H 2\")" but got ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-position assert_equals: offset-position should be canonical expected "auto" but got ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-rotate assert_equals: offset-rotate should be canonical expected "reverse" but got ""
-FAIL e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should not set unrelated longhands assert_true: expected true got false
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-anchor
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-distance
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-path
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-position
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should set offset-rotate
+PASS e.style['offset'] = "left bottom ray(0rad closest-side) 10px auto 30deg / right bottom" should not set unrelated longhands
+PASS e.style['offset'] = "top right / top left" should set offset-anchor
+PASS e.style['offset'] = "top right / top left" should set offset-distance
+PASS e.style['offset'] = "top right / top left" should set offset-path
+PASS e.style['offset'] = "top right / top left" should set offset-position
+PASS e.style['offset'] = "top right / top left" should set offset-rotate
+PASS e.style['offset'] = "top right / top left" should not set unrelated longhands
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-anchor
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-distance
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-path
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-position
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should set offset-rotate
+PASS e.style['offset'] = "path(\"M 0 0 H 2\") reverse 50%" should not set unrelated longhands
 

Modified: trunk/Source/WebCore/ChangeLog (289875 => 289876)


--- trunk/Source/WebCore/ChangeLog	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/ChangeLog	2022-02-16 05:27:04 UTC (rev 289876)
@@ -1,3 +1,37 @@
+2022-02-15  Nikolaos Mouchtaris  <[email protected]>
+
+        Implement parsing and animation support for offset shorthand
+        https://bugs.webkit.org/show_bug.cgi?id=233109
+
+        Reviewed by Dean Jackson.
+
+        This patch implements support for the offset shorthand for css motion path. This involves
+        adding the offset property to CSSProperties.json, the introduction of consumeOffset() to
+        parse the set offset, and serialization of the offset values.
+
+        * animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::CSSPropertyIDToIDLAttributeName):
+        (WebCore::IDLAttributeNameToAnimationPropertyName):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForOffsetShorthand):
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * css/CSSOffsetRotateValue.cpp:
+        (WebCore::CSSOffsetRotateValue::initialValue):
+        (WebCore::CSSOffsetRotateValue::isInitialValue const):
+        * css/CSSOffsetRotateValue.h:
+        * css/CSSProperties.json:
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::getPropertyValue const):
+        (WebCore::StyleProperties::offsetValue const):
+        * css/StyleProperties.h:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeBasicShapeOrBox):
+        (WebCore::CSSPropertyParser::consumeOffset):
+        (WebCore::CSSPropertyParser::parseShorthand):
+        * css/parser/CSSPropertyParser.h:
+
 2022-02-15  Chris Dumez  <[email protected]>
 
         Do preliminary work to pass domain names to CoreLocation

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (289875 => 289876)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -2820,7 +2820,8 @@
         CSSPropertyColumnRule,
         CSSPropertyWebkitBorderRadius,
         CSSPropertyTransformOrigin,
-        CSSPropertyPerspectiveOrigin
+        CSSPropertyPerspectiveOrigin,
+        CSSPropertyOffset
     };
     const unsigned animatableShorthandPropertiesCount = WTF_ARRAY_LENGTH(animatableShorthandProperties);
 

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (289875 => 289876)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -85,7 +85,8 @@
         return "cssFloat";
 
     // 3. If property refers to the CSS offset property, return the string "cssOffset".
-    // FIXME: we don't support the CSS "offset" property
+    if (cssPropertyId == CSSPropertyOffset)
+        return "cssOffset";
 
     // 4. Otherwise, return the result of applying the CSS property to IDL attribute algorithm [CSSOM] to property.
     return getJSPropertyName(cssPropertyId);
@@ -102,7 +103,8 @@
         return CSSPropertyFloat;
 
     // 3. If attribute is the string "cssOffset", then return an animation property representing the CSS offset property.
-    // FIXME: We don't support the CSS "offset" property.
+    if (idlAttributeName == "cssOffset")
+        return CSSPropertyOffset;
 
     // 4. Otherwise, return the result of applying the IDL attribute to CSS property algorithm [CSSOM] to attribute.
     auto cssPropertyId = CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(idlAttributeName);

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (289875 => 289876)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -2663,6 +2663,24 @@
     return result;
 }
 
+static Ref<CSSValue> valueForOffsetShorthand(const RenderStyle& style)
+{
+    // offset is serialized as follow:
+    // [offset-position] [offset-path] [offset-distance] [offset-rotate] / [offset-anchor]
+    // The first four elements are serialized in a space separated CSSValueList.
+    // This is then combined with offset-anchor in a slash separated CSSValueList.
+
+    auto outerList = CSSValueList::createSlashSeparated();
+    auto innerList = CSSValueList::createSpaceSeparated();
+    innerList->append(valueForPositionOrAuto(style, style.offsetPosition()));
+    innerList->append(valueForPathOperation(style, style.offsetPath(), SVGPathConversion::ForceAbsolute));
+    innerList->append(CSSValuePool::singleton().createValue(style.offsetDistance(), style));
+    innerList->append(valueForOffsetRotate(style.offsetRotate()));
+    outerList->append(WTFMove(innerList));
+    outerList->append(valueForPositionOrAuto(style, style.offsetAnchor()));
+    return outerList;
+}
+
 static Ref<CSSValue> paintOrder(PaintOrder paintOrder)
 {
     if (paintOrder == PaintOrder::Normal)
@@ -3367,6 +3385,8 @@
             return valueForPositionOrAuto(style, style.offsetAnchor());
         case CSSPropertyOffsetRotate:
             return valueForOffsetRotate(style.offsetRotate());
+        case CSSPropertyOffset:
+            return valueForOffsetShorthand(style);
         case CSSPropertyOpacity:
             return cssValuePool.createValue(style.opacity(), CSSUnitType::CSS_NUMBER);
         case CSSPropertyOrphans:

Modified: trunk/Source/WebCore/css/CSSOffsetRotateValue.cpp (289875 => 289876)


--- trunk/Source/WebCore/css/CSSOffsetRotateValue.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/CSSOffsetRotateValue.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "CSSOffsetRotateValue.h"
 
+#include "CSSValuePool.h"
+
 namespace WebCore {
 
 String CSSOffsetRotateValue::customCSSText() const
@@ -45,6 +47,17 @@
     return builder.toString();
 }
 
+Ref<CSSOffsetRotateValue> CSSOffsetRotateValue::initialValue()
+{
+    return CSSOffsetRotateValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueAuto), nullptr);
+}
+
+bool CSSOffsetRotateValue::isInitialValue() const
+{
+    return m_modifier && m_modifier->valueID() == CSSValueAuto
+        && (!m_angle || m_angle->computeDegrees() == 0.0);
+}
+
 bool CSSOffsetRotateValue::equals(const CSSOffsetRotateValue& o) const
 {
     return compareCSSValuePtr(m_modifier, o.m_modifier)

Modified: trunk/Source/WebCore/css/CSSOffsetRotateValue.h (289875 => 289876)


--- trunk/Source/WebCore/css/CSSOffsetRotateValue.h	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/CSSOffsetRotateValue.h	2022-02-16 05:27:04 UTC (rev 289876)
@@ -42,6 +42,9 @@
     CSSPrimitiveValue* modifier() const { return m_modifier.get(); }
     CSSPrimitiveValue* angle() const { return m_angle.get(); }
 
+    static Ref<CSSOffsetRotateValue> initialValue();
+    bool isInitialValue() const;
+
     bool equals(const CSSOffsetRotateValue&) const;
 
 private:

Modified: trunk/Source/WebCore/css/CSSProperties.json (289875 => 289876)


--- trunk/Source/WebCore/css/CSSProperties.json	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/CSSProperties.json	2022-02-16 05:27:04 UTC (rev 289876)
@@ -3735,6 +3735,21 @@
                 "url": "https://drafts.fxtf.org/motion-1/#offset-anchor-property"
             }
         },
+        "offset": {
+            "codegen-properties": {
+                "longhands": [
+                    "offset-path",
+                    "offset-distance",
+                    "offset-position",
+                    "offset-anchor",
+                    "offset-rotate"
+                ]
+            },
+            "specification": {
+                "category": "css-motion-path",
+                "url": "https://drafts.fxtf.org/motion-1/#offset-shorthand"
+            }
+        },
         "opacity": {
             "codegen-properties": {
                 "converter": "Opacity",

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (289875 => 289876)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -26,6 +26,7 @@
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSCustomPropertyValue.h"
 #include "CSSDeferredParser.h"
+#include "CSSOffsetRotateValue.h"
 #include "CSSParser.h"
 #include "CSSPendingSubstitutionValue.h"
 #include "CSSPropertyParser.h"
@@ -228,6 +229,8 @@
         return getShorthandValue(borderInlineStartShorthand());
     case CSSPropertyBorderInlineEnd:
         return getShorthandValue(borderInlineEndShorthand());
+    case CSSPropertyOffset:
+        return offsetValue();
     case CSSPropertyOutline:
         return getShorthandValue(outlineShorthand());
     case CSSPropertyBorderColor:
@@ -453,6 +456,93 @@
     return result.toString();
 }
 
+String StyleProperties::offsetValue() const
+{
+    StringBuilder result;
+
+    auto offsetPositionIndex = findPropertyIndex(CSSPropertyOffsetPosition);
+    auto offsetPathIndex = findPropertyIndex(CSSPropertyOffsetPath);
+
+    // Either offset-position and offset-path must be specified.
+    if (offsetPositionIndex == -1 && offsetPathIndex == -1)
+        return String();
+
+    if (offsetPositionIndex != -1) {
+        auto offsetPosition = propertyAt(offsetPositionIndex);
+        if (!offsetPosition.isImplicit()) {
+            if (!offsetPosition.value())
+                return String();
+
+            result.append(offsetPosition.value()->cssText());
+        }
+    }
+
+    if (offsetPathIndex != -1) {
+        auto offsetPath = propertyAt(offsetPathIndex);
+        if (!offsetPath.isImplicit()) {
+            if (!offsetPath.value())
+                return String();
+
+            if (!result.isEmpty())
+                result.append(' ');
+            result.append(offsetPath.value()->cssText());
+        }
+    }
+
+    // At this point, result is not empty because either offset-position or offset-path
+    // must be present.
+
+    auto offsetDistanceIndex = findPropertyIndex(CSSPropertyOffsetDistance);
+    if (offsetDistanceIndex != -1) {
+        auto offsetDistance = propertyAt(offsetDistanceIndex);
+        if (!offsetDistance.isImplicit()) {
+            auto offsetDistanceValue = offsetDistance.value();
+            if (!offsetDistanceValue || !is<CSSPrimitiveValue>(offsetDistanceValue))
+                return String();
+            // Only include offset-distance if the distance is non-zero.
+            // isZero() returns std::nullopt if offsetDistanceValue is a calculated value, in which case
+            // we use value_or() to override to false.
+            if (!(downcast<CSSPrimitiveValue>(offsetDistanceValue)->isZero().value_or(false))) {
+                result.append(' ');
+                result.append(downcast<CSSPrimitiveValue>(offsetDistanceValue)->cssText());
+            }
+        }
+    }
+
+    auto offsetRotateIndex = findPropertyIndex(CSSPropertyOffsetRotate);
+    if (offsetRotateIndex != -1) {
+        auto offsetRotate = propertyAt(offsetRotateIndex);
+        if (!offsetRotate.isImplicit()) {
+            auto offsetRotateValue = offsetRotate.value();
+            if (!offsetRotateValue || !is<CSSOffsetRotateValue>(offsetRotateValue))
+                return String();
+
+            if (!(downcast<CSSOffsetRotateValue>(offsetRotateValue)->isInitialValue())) {
+                result.append(' ');
+                result.append(downcast<CSSOffsetRotateValue>(offsetRotateValue)->cssText());
+            }
+        }
+    }
+
+    auto offsetAnchorIndex = findPropertyIndex(CSSPropertyOffsetAnchor);
+    if (offsetAnchorIndex != -1) {
+        auto offsetAnchor = propertyAt(offsetAnchorIndex);
+        if (!offsetAnchor.isImplicit()) {
+            auto offsetAnchorValue = offsetAnchor.value();
+            if (!offsetAnchorValue)
+                return String();
+
+            if (!is<CSSPrimitiveValue>(offsetAnchorValue) || !downcast<CSSPrimitiveValue>(offsetAnchorValue)->isValueID()
+                || downcast<CSSPrimitiveValue>(offsetAnchorValue)->valueID() != CSSValueAuto) {
+                result.append(" / ");
+                result.append(offsetAnchorValue->cssText());
+            }
+        }
+    }
+
+    return result.toString();
+}
+
 String StyleProperties::textDecorationSkipValue() const
 {
     int textDecorationSkipInkPropertyIndex = findPropertyIndex(CSSPropertyTextDecorationSkipInk);

Modified: trunk/Source/WebCore/css/StyleProperties.h (289875 => 289876)


--- trunk/Source/WebCore/css/StyleProperties.h	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/StyleProperties.h	2022-02-16 05:27:04 UTC (rev 289876)
@@ -174,6 +174,7 @@
     String fontValue() const;
     String fontVariantValue() const;
     String textDecorationSkipValue() const;
+    String offsetValue() const;
     void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
     bool shorthandHasVariableReference(CSSPropertyID, String&) const;
 

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (289875 => 289876)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2022-02-16 05:27:04 UTC (rev 289876)
@@ -2781,11 +2781,11 @@
             boxFound = true;
         }
         if (!componentValue)
-            return nullptr;
+            break;
         list->append(componentValue.releaseNonNull());
     }
     
-    if (!range.atEnd() || !list->length())
+    if (!list->length())
         return nullptr;
     
     return list;
@@ -6207,6 +6207,59 @@
     return true;
 }
 
+bool CSSPropertyParser::consumeOffset(bool important)
+{
+    auto& valuePool = CSSValuePool::singleton();
+
+    // The offset shorthand is defined as:
+    // [ <'offset-position'>?
+    //   [ <'offset-path'>
+    //     [ <'offset-distance'> || <'offset-rotate'> ]?
+    //   ]?
+    // ]!
+    // [ / <'offset-anchor'> ]?
+
+    // Parse out offset-position.
+    auto offsetPosition = parseSingleValue(CSSPropertyOffsetPosition, CSSPropertyOffset);
+
+    // Parse out offset-path.
+    auto offsetPath = parseSingleValue(CSSPropertyOffsetPath, CSSPropertyOffset);
+
+    // Either one of offset-position and offset-path must be present.
+    if (!offsetPosition && !offsetPath)
+        return false;
+
+    // Only parse offset-distance and offset-rotate if offset-path is specified.
+    RefPtr<CSSValue> offsetDistance;
+    RefPtr<CSSValue> offsetRotate;
+    if (offsetPath) {
+        // Try to parse offset-distance first. If successful, parse the following offset-rotate.
+        // Otherwise, parse in the reverse order.
+        if ((offsetDistance = parseSingleValue(CSSPropertyOffsetDistance, CSSPropertyOffset)))
+            offsetRotate = parseSingleValue(CSSPropertyOffsetRotate, CSSPropertyOffset);
+        else {
+            offsetRotate = parseSingleValue(CSSPropertyOffsetRotate, CSSPropertyOffset);
+            offsetDistance = parseSingleValue(CSSPropertyOffsetDistance, CSSPropertyOffset);
+        }
+    }
+
+    // Parse out offset-anchor. Only parse if the prefix slash is present.
+    RefPtr<CSSValue> offsetAnchor;
+    if (consumeSlashIncludingWhitespace(m_range)) {
+        // offset-anchor must follow the slash.
+        if (!(offsetAnchor = parseSingleValue(CSSPropertyOffsetAnchor, CSSPropertyOffset)))
+            return false;
+    }
+
+    addPropertyWithImplicitDefault(CSSPropertyOffsetPath, CSSPropertyOffset, WTFMove(offsetPath), valuePool.createIdentifierValue(CSSValueNone), important);
+    addPropertyWithImplicitDefault(CSSPropertyOffsetDistance, CSSPropertyOffset, WTFMove(offsetDistance), valuePool.createValue(0.0, CSSUnitType::CSS_PX), important);
+    addPropertyWithImplicitDefault(CSSPropertyOffsetPosition, CSSPropertyOffset, WTFMove(offsetPosition), valuePool.createIdentifierValue(CSSValueAuto), important);
+    addPropertyWithImplicitDefault(CSSPropertyOffsetAnchor, CSSPropertyOffset, WTFMove(offsetAnchor), valuePool.createIdentifierValue(CSSValueAuto), important);
+    addPropertyWithImplicitDefault(CSSPropertyOffsetRotate, CSSPropertyOffset, WTFMove(offsetRotate), CSSOffsetRotateValue::initialValue(), important);
+
+    return m_range.atEnd();
+}
+
 bool CSSPropertyParser::parseShorthand(CSSPropertyID property, bool important)
 {
     switch (property) {
@@ -6269,6 +6322,8 @@
         return consumeShorthandGreedily(textEmphasisShorthand(), important);
     case CSSPropertyOutline:
         return consumeShorthandGreedily(outlineShorthand(), important);
+    case CSSPropertyOffset:
+        return consumeOffset(important);
     case CSSPropertyBorderInline: {
         RefPtr<CSSValue> width;
         RefPtr<CSSValue> style;

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.h (289875 => 289876)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2022-02-16 05:20:04 UTC (rev 289875)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2022-02-16 05:27:04 UTC (rev 289876)
@@ -120,6 +120,7 @@
 
     bool consumeTransformOrigin(bool important);
     bool consumePerspectiveOrigin(bool important);
+    bool consumeOffset(bool important);
 
     bool consumeOverscrollBehaviorShorthand(bool important);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to