Log Message
"animation" shorthand should list all longhand values when serializing https://bugs.webkit.org/show_bug.cgi?id=234792
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Mark 20 new WPT progressions.
* web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt:
* web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt:
* web-platform-tests/css/css-animations/style-animation-parsing-expected.txt:
Source/WebCore:
Currently we omit any initial value when serializing the "animation" shorthand. However,
the CSS Animations spec says:
Note that order is also important within each animation definition for distinguishing
<keyframes-name> values from other keywords. When parsing, keywords that are valid for
properties other than animation-name whose values were not found earlier in the shorthand
must be accepted for those properties rather than for animation-name. Furthermore, when
serializing, default values of other properties must be output in at least the cases
necessary to distinguish an animation-name that could be a value of another property,
and may be output in additional cases.
Both Firefox and Chrome always include all longhand values when querying the inline style,
such that <div style="animation: none"> yields "0s ease 0s 1 normal none running none" for
element.style.animation. Currently, Safari only outputs "none".
When parsing the "animation" shorthand in consumeAnimationShorthand(), we now fill in initial
values as if they were explicitly set to their initial value, for instance duration is set to
"0s".
To do this, we refactored code in CSSComputedStyleDeclaration.cpp that dealt with the creation
of CSSValue from various values exposed on Animation such that it may be called from within
CSSPropertyParser.cpp.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForAnimationDuration):
(WebCore::ComputedStyleExtractor::valueForAnimationDelay):
(WebCore::ComputedStyleExtractor::valueForAnimationIterationCount):
(WebCore::ComputedStyleExtractor::valueForAnimationDirection):
(WebCore::ComputedStyleExtractor::valueForAnimationFillMode):
(WebCore::ComputedStyleExtractor::valueForAnimationPlayState):
(WebCore::ComputedStyleExtractor::valueForAnimationName):
(WebCore::delayValue):
(WebCore::durationValue):
(WebCore::ComputedStyleExtractor::valueForAnimationTimingFunction):
(WebCore::timingFunctionValue):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
(WebCore::createTimingFunctionValue): Deleted.
* css/CSSComputedStyleDeclaration.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeAnimationShorthand):
LayoutTests:
Add the initial longhand values for some non-WPT tests that expected them to be
absent in the shorthand serialization.
* fast/css/longhand-overrides-shorthand-prefixing.html:
* fast/css/transform-inline-style-remove-expected.txt:
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/fast/css/longhand-overrides-shorthand-prefixing.html
- trunk/LayoutTests/fast/css/transform-inline-style-remove-expected.txt
- trunk/LayoutTests/imported/w3c/ChangeLog
- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt
- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt
- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/style-animation-parsing-expected.txt
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h
- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
Diff
Modified: trunk/LayoutTests/ChangeLog (287533 => 287534)
--- trunk/LayoutTests/ChangeLog 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/ChangeLog 2022-01-03 10:00:53 UTC (rev 287534)
@@ -1,3 +1,16 @@
+2022-01-02 Antoine Quint <[email protected]>
+
+ "animation" shorthand should list all longhand values when serializing
+ https://bugs.webkit.org/show_bug.cgi?id=234792
+
+ Reviewed by Darin Adler.
+
+ Add the initial longhand values for some non-WPT tests that expected them to be
+ absent in the shorthand serialization.
+
+ * fast/css/longhand-overrides-shorthand-prefixing.html:
+ * fast/css/transform-inline-style-remove-expected.txt:
+
2022-01-03 Youenn Fablet <[email protected]>
FetchRequest.clone does not need to be called with the current context
Modified: trunk/LayoutTests/fast/css/longhand-overrides-shorthand-prefixing.html (287533 => 287534)
--- trunk/LayoutTests/fast/css/longhand-overrides-shorthand-prefixing.html 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/fast/css/longhand-overrides-shorthand-prefixing.html 2022-01-03 10:00:53 UTC (rev 287534)
@@ -63,7 +63,7 @@
debug("");
}
-testPropertyVariants("animation", "animation-duration", "2s move", "10s move", "10s");
+testPropertyVariants("animation", "animation-duration", "2s move", "10s ease 0s 1 normal none running move", "10s");
successfullyParsed = true;
Modified: trunk/LayoutTests/fast/css/transform-inline-style-remove-expected.txt (287533 => 287534)
--- trunk/LayoutTests/fast/css/transform-inline-style-remove-expected.txt 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/fast/css/transform-inline-style-remove-expected.txt 2022-01-03 10:00:53 UTC (rev 287534)
@@ -19,7 +19,7 @@
transform origin X (after):
transform origin Y (after):
-animation (before): 5s ease-in-out infinite alternate test
+animation (before): 5s ease-in-out 0s infinite alternate none running test
animation name (before): test
animation duration (before): 5s
animation timing function (before): ease-in-out
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (287533 => 287534)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-03 10:00:53 UTC (rev 287534)
@@ -1,5 +1,18 @@
2022-01-02 Antoine Quint <[email protected]>
+ "animation" shorthand should list all longhand values when serializing
+ https://bugs.webkit.org/show_bug.cgi?id=234792
+
+ Reviewed by Darin Adler.
+
+ Mark 20 new WPT progressions.
+
+ * web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt:
+ * web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt:
+ * web-platform-tests/css/css-animations/style-animation-parsing-expected.txt:
+
+2022-01-02 Antoine Quint <[email protected]>
+
[Web Animations] getKeyframes() should handle multiple 0% and 100% keyframes
https://bugs.webkit.org/show_bug.cgi?id=234799
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt (287533 => 287534)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-shorthand-expected.txt 2022-01-03 10:00:53 UTC (rev 287534)
@@ -9,24 +9,24 @@
FAIL e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline assert_equals: animation-timeline should be canonical expected (string) "auto" but got (undefined) undefined
PASS e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timing-function
PASS e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should not set unrelated longhands
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-delay assert_equals: animation-delay should be canonical expected "0s, -3s" but got "initial, -3s"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-direction assert_equals: animation-direction should be canonical expected "reverse, normal" but got "reverse, initial"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-duration assert_equals: animation-duration should be canonical expected "0s, 1s" but got "initial, 1s"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-fill-mode assert_equals: animation-fill-mode should be canonical expected "both, none" but got "both, initial"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-iteration-count assert_equals: animation-iteration-count should be canonical expected "1, 4" but got "initial, 4"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-name assert_equals: animation-name should be canonical expected "anim, none" but got "anim, initial"
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-play-state assert_equals: animation-play-state should be canonical expected "paused, running" but got "paused, initial"
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-delay
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-direction
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-duration
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-fill-mode
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-iteration-count
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-name
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-play-state
FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline assert_equals: animation-timeline should be canonical expected (string) "auto, auto" but got (undefined) undefined
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timing-function assert_equals: animation-timing-function should be canonical expected "ease, cubic-bezier(0, -2, 1, 3)" but got "initial, cubic-bezier(0, -2, 1, 3)"
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timing-function
PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should not set unrelated longhands
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-delay assert_equals: animation-delay should be canonical expected "-3s, 0s" but got "-3s, initial"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-direction assert_equals: animation-direction should be canonical expected "normal, reverse" but got "initial, reverse"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-duration assert_equals: animation-duration should be canonical expected "1s, 0s" but got "1s, initial"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-fill-mode assert_equals: animation-fill-mode should be canonical expected "none, both" but got "initial, both"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-iteration-count assert_equals: animation-iteration-count should be canonical expected "4, 1" but got "4, initial"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-name assert_equals: animation-name should be canonical expected "none, anim" but got "initial, anim"
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-play-state assert_equals: animation-play-state should be canonical expected "running, paused" but got "initial, paused"
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-delay
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-direction
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-duration
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-fill-mode
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-iteration-count
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-name
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-play-state
FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timeline assert_equals: animation-timeline should be canonical expected (string) "auto, auto" but got (undefined) undefined
-FAIL e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timing-function assert_equals: animation-timing-function should be canonical expected "cubic-bezier(0, -2, 1, 3), ease" but got "cubic-bezier(0, -2, 1, 3), initial"
+PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timing-function
PASS e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should not set unrelated longhands
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt (287533 => 287534)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/animation-valid-expected.txt 2022-01-03 10:00:53 UTC (rev 287534)
@@ -9,5 +9,5 @@
PASS e.style['animation'] = "none" should set the property value
PASS e.style['animation'] = "anim" should set the property value
PASS e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set the property value
-FAIL e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set the property value assert_equals: serialization should be canonical expected "0s ease 0s 1 reverse both paused anim, 1s cubic-bezier(0, -2, 1, 3) -3s 4 normal none running none" but got "reverse both paused anim, 1s cubic-bezier(0, -2, 1, 3) -3s 4"
+PASS e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set the property value
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/style-animation-parsing-expected.txt (287533 => 287534)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/style-animation-parsing-expected.txt 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/style-animation-parsing-expected.txt 2022-01-03 10:00:53 UTC (rev 287534)
@@ -1,7 +1,7 @@
PASS Test animation name being empty.
PASS Test a non-conflicting animation name.
-FAIL Test an animation name that is the same as a possible animation fill-mode. assert_equals: style1.animationName expected "none" but got "initial"
-FAIL Test an animation name that is the same as a possible animation direction. assert_equals: style1.animationName expected "none" but got "initial"
-FAIL Test an animation name that is the same as a possible running state. assert_equals: style1.animationName expected "none" but got "initial"
+PASS Test an animation name that is the same as a possible animation fill-mode.
+PASS Test an animation name that is the same as a possible animation direction.
+PASS Test an animation name that is the same as a possible running state.
Modified: trunk/Source/WebCore/ChangeLog (287533 => 287534)
--- trunk/Source/WebCore/ChangeLog 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/Source/WebCore/ChangeLog 2022-01-03 10:00:53 UTC (rev 287534)
@@ -1,3 +1,51 @@
+2022-01-02 Antoine Quint <[email protected]>
+
+ "animation" shorthand should list all longhand values when serializing
+ https://bugs.webkit.org/show_bug.cgi?id=234792
+
+ Reviewed by Darin Adler.
+
+ Currently we omit any initial value when serializing the "animation" shorthand. However,
+ the CSS Animations spec says:
+
+ Note that order is also important within each animation definition for distinguishing
+ <keyframes-name> values from other keywords. When parsing, keywords that are valid for
+ properties other than animation-name whose values were not found earlier in the shorthand
+ must be accepted for those properties rather than for animation-name. Furthermore, when
+ serializing, default values of other properties must be output in at least the cases
+ necessary to distinguish an animation-name that could be a value of another property,
+ and may be output in additional cases.
+
+ Both Firefox and Chrome always include all longhand values when querying the inline style,
+ such that <div style="animation: none"> yields "0s ease 0s 1 normal none running none" for
+ element.style.animation. Currently, Safari only outputs "none".
+
+ When parsing the "animation" shorthand in consumeAnimationShorthand(), we now fill in initial
+ values as if they were explicitly set to their initial value, for instance duration is set to
+ "0s".
+
+ To do this, we refactored code in CSSComputedStyleDeclaration.cpp that dealt with the creation
+ of CSSValue from various values exposed on Animation such that it may be called from within
+ CSSPropertyParser.cpp.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::valueForAnimationDuration):
+ (WebCore::ComputedStyleExtractor::valueForAnimationDelay):
+ (WebCore::ComputedStyleExtractor::valueForAnimationIterationCount):
+ (WebCore::ComputedStyleExtractor::valueForAnimationDirection):
+ (WebCore::ComputedStyleExtractor::valueForAnimationFillMode):
+ (WebCore::ComputedStyleExtractor::valueForAnimationPlayState):
+ (WebCore::ComputedStyleExtractor::valueForAnimationName):
+ (WebCore::delayValue):
+ (WebCore::durationValue):
+ (WebCore::ComputedStyleExtractor::valueForAnimationTimingFunction):
+ (WebCore::timingFunctionValue):
+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+ (WebCore::createTimingFunctionValue): Deleted.
+ * css/CSSComputedStyleDeclaration.h:
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::CSSPropertyParser::consumeAnimationShorthand):
+
2022-01-03 Carlos Garcia Campos <[email protected]>
AX: web process crash with isolated tree mode enabled
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (287533 => 287534)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2022-01-03 10:00:53 UTC (rev 287534)
@@ -1345,16 +1345,77 @@
return valueList;
}
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationDuration(double duration)
+{
+ return CSSValuePool::singleton().createValue(duration, CSSUnitType::CSS_S);
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationDelay(double delay)
+{
+ return CSSValuePool::singleton().createValue(delay, CSSUnitType::CSS_S);
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationIterationCount(double iterationCount)
+{
+ if (iterationCount == Animation::IterationCountInfinite)
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueInfinite);
+ return CSSValuePool::singleton().createValue(iterationCount, CSSUnitType::CSS_NUMBER);
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationDirection(Animation::AnimationDirection direction)
+{
+ switch (direction) {
+ case Animation::AnimationDirectionNormal:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
+ case Animation::AnimationDirectionAlternate:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueAlternate);
+ case Animation::AnimationDirectionReverse:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueReverse);
+ case Animation::AnimationDirectionAlternateReverse:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueAlternateReverse);
+ }
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationFillMode(AnimationFillMode fillMode)
+{
+ switch (fillMode) {
+ case AnimationFillMode::None:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
+ case AnimationFillMode::Forwards:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueForwards);
+ case AnimationFillMode::Backwards:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueBackwards);
+ case AnimationFillMode::Both:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueBoth);
+ }
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationPlayState(AnimationPlayState playState)
+{
+ switch (playState) {
+ case AnimationPlayState::Playing:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValueRunning);
+ case AnimationPlayState::Paused:
+ return CSSValuePool::singleton().createIdentifierValue(CSSValuePaused);
+ }
+}
+
+Ref<CSSPrimitiveValue> ComputedStyleExtractor::valueForAnimationName(const Animation::Name& name)
+{
+ if (name.isIdentifier)
+ return CSSValuePool::singleton().createCustomIdent(name.string);
+ return CSSValuePool::singleton().createValue(name.string, CSSUnitType::CSS_STRING);
+}
+
static Ref<CSSValueList> delayValue(const AnimationList* animationList)
{
- auto& cssValuePool = CSSValuePool::singleton();
auto list = CSSValueList::createCommaSeparated();
if (animationList) {
for (size_t i = 0; i < animationList->size(); ++i)
- list->append(cssValuePool.createValue(animationList->animation(i).delay(), CSSUnitType::CSS_S));
+ list->append(ComputedStyleExtractor::valueForAnimationDelay(animationList->animation(i).delay()));
} else {
// Note that initialAnimationDelay() is used for both transitions and animations
- list->append(cssValuePool.createValue(Animation::initialDelay(), CSSUnitType::CSS_S));
+ list->append(ComputedStyleExtractor::valueForAnimationDelay(Animation::initialDelay()));
}
return list;
}
@@ -1361,19 +1422,18 @@
static Ref<CSSValueList> durationValue(const AnimationList* animationList)
{
- auto& cssValuePool = CSSValuePool::singleton();
auto list = CSSValueList::createCommaSeparated();
if (animationList) {
for (size_t i = 0; i < animationList->size(); ++i)
- list->append(cssValuePool.createValue(animationList->animation(i).duration(), CSSUnitType::CSS_S));
+ list->append(ComputedStyleExtractor::valueForAnimationDuration(animationList->animation(i).duration()));
} else {
// Note that initialAnimationDuration() is used for both transitions and animations
- list->append(cssValuePool.createValue(Animation::initialDuration(), CSSUnitType::CSS_S));
+ list->append(ComputedStyleExtractor::valueForAnimationDuration(Animation::initialDuration()));
}
return list;
}
-static Ref<CSSValue> createTimingFunctionValue(const TimingFunction& timingFunction)
+Ref<CSSValue> ComputedStyleExtractor::valueForAnimationTimingFunction(const TimingFunction& timingFunction)
{
switch (timingFunction.type()) {
case TimingFunction::CubicBezierFunction: {
@@ -1418,10 +1478,10 @@
auto list = CSSValueList::createCommaSeparated();
if (animationList) {
for (size_t i = 0; i < animationList->size(); ++i)
- list->append(createTimingFunctionValue(*animationList->animation(i).timingFunction()));
+ list->append(ComputedStyleExtractor::valueForAnimationTimingFunction(*animationList->animation(i).timingFunction()));
} else
// Note that initialAnimationTimingFunction() is used for both transitions and animations
- list->append(createTimingFunctionValue(Animation::initialTimingFunction()));
+ list->append(ComputedStyleExtractor::valueForAnimationTimingFunction(Animation::initialTimingFunction()));
return list;
}
@@ -3512,22 +3572,8 @@
auto list = CSSValueList::createCommaSeparated();
const AnimationList* t = style.animations();
if (t) {
- for (size_t i = 0; i < t->size(); ++i) {
- switch (t->animation(i).direction()) {
- case Animation::AnimationDirectionNormal:
- list->append(cssValuePool.createIdentifierValue(CSSValueNormal));
- break;
- case Animation::AnimationDirectionAlternate:
- list->append(cssValuePool.createIdentifierValue(CSSValueAlternate));
- break;
- case Animation::AnimationDirectionReverse:
- list->append(cssValuePool.createIdentifierValue(CSSValueReverse));
- break;
- case Animation::AnimationDirectionAlternateReverse:
- list->append(cssValuePool.createIdentifierValue(CSSValueAlternateReverse));
- break;
- }
- }
+ for (size_t i = 0; i < t->size(); ++i)
+ list->append(valueForAnimationDirection(t->animation(i).direction()));
} else
list->append(cssValuePool.createIdentifierValue(CSSValueNormal));
return list;
@@ -3538,22 +3584,8 @@
auto list = CSSValueList::createCommaSeparated();
const AnimationList* t = style.animations();
if (t) {
- for (size_t i = 0; i < t->size(); ++i) {
- switch (t->animation(i).fillMode()) {
- case AnimationFillMode::None:
- list->append(cssValuePool.createIdentifierValue(CSSValueNone));
- break;
- case AnimationFillMode::Forwards:
- list->append(cssValuePool.createIdentifierValue(CSSValueForwards));
- break;
- case AnimationFillMode::Backwards:
- list->append(cssValuePool.createIdentifierValue(CSSValueBackwards));
- break;
- case AnimationFillMode::Both:
- list->append(cssValuePool.createIdentifierValue(CSSValueBoth));
- break;
- }
- }
+ for (size_t i = 0; i < t->size(); ++i)
+ list->append(valueForAnimationFillMode(t->animation(i).fillMode()));
} else
list->append(cssValuePool.createIdentifierValue(CSSValueNone));
return list;
@@ -3562,13 +3594,8 @@
auto list = CSSValueList::createCommaSeparated();
const AnimationList* t = style.animations();
if (t) {
- for (size_t i = 0; i < t->size(); ++i) {
- double iterationCount = t->animation(i).iterationCount();
- if (iterationCount == Animation::IterationCountInfinite)
- list->append(cssValuePool.createIdentifierValue(CSSValueInfinite));
- else
- list->append(cssValuePool.createValue(iterationCount, CSSUnitType::CSS_NUMBER));
- }
+ for (size_t i = 0; i < t->size(); ++i)
+ list->append(valueForAnimationIterationCount(t->animation(i).iterationCount()));
} else
list->append(cssValuePool.createValue(Animation::initialIterationCount(), CSSUnitType::CSS_NUMBER));
return list;
@@ -3577,13 +3604,8 @@
auto list = CSSValueList::createCommaSeparated();
const AnimationList* t = style.animations();
if (t) {
- for (size_t i = 0; i < t->size(); ++i) {
- auto& name = t->animation(i).name();
- if (name.isIdentifier)
- list->append(cssValuePool.createCustomIdent(name.string));
- else
- list->append(cssValuePool.createValue(name.string, CSSUnitType::CSS_STRING));
- }
+ for (size_t i = 0; i < t->size(); ++i)
+ list->append(valueForAnimationName(t->animation(i).name()));
} else
list->append(cssValuePool.createIdentifierValue(CSSValueNone));
return list;
@@ -3592,16 +3614,8 @@
auto list = CSSValueList::createCommaSeparated();
const AnimationList* t = style.animations();
if (t) {
- for (size_t i = 0; i < t->size(); ++i) {
- switch (t->animation(i).playState()) {
- case AnimationPlayState::Playing:
- list->append(cssValuePool.createIdentifierValue(CSSValueRunning));
- break;
- case AnimationPlayState::Paused:
- list->append(cssValuePool.createIdentifierValue(CSSValuePaused));
- break;
- }
- }
+ for (size_t i = 0; i < t->size(); ++i)
+ list->append(valueForAnimationPlayState(t->animation(i).playState()));
} else
list->append(cssValuePool.createIdentifierValue(CSSValueRunning));
return list;
@@ -3815,7 +3829,7 @@
auto& animation = animationList->animation(i);
list->append(createTransitionPropertyValue(animation));
list->append(cssValuePool.createValue(animation.duration(), CSSUnitType::CSS_S));
- list->append(createTimingFunctionValue(*animation.timingFunction()));
+ list->append(valueForAnimationTimingFunction(*animation.timingFunction()));
list->append(cssValuePool.createValue(animation.delay(), CSSUnitType::CSS_S));
transitionsList->append(WTFMove(list));
}
@@ -3826,7 +3840,7 @@
// transition-property default value.
list->append(cssValuePool.createIdentifierValue(CSSValueAll));
list->append(cssValuePool.createValue(Animation::initialDuration(), CSSUnitType::CSS_S));
- list->append(createTimingFunctionValue(Animation::initialTimingFunction()));
+ list->append(valueForAnimationTimingFunction(Animation::initialTimingFunction()));
list->append(cssValuePool.createValue(Animation::initialDelay(), CSSUnitType::CSS_S));
return list;
}
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h (287533 => 287534)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h 2022-01-03 10:00:53 UTC (rev 287534)
@@ -20,6 +20,7 @@
#pragma once
+#include "Animation.h"
#include "CSSStyleDeclaration.h"
#include "RenderStyleConstants.h"
#include "SVGRenderStyleDefs.h"
@@ -77,6 +78,15 @@
static Ref<CSSFontStyleValue> fontNonKeywordStyleFromStyleValue(FontSelectionValue);
static Ref<CSSFontStyleValue> fontStyleFromStyleValue(std::optional<FontSelectionValue>, FontStyleAxis);
+ static Ref<CSSPrimitiveValue> valueForAnimationDuration(double);
+ static Ref<CSSValue> valueForAnimationTimingFunction(const TimingFunction&);
+ static Ref<CSSPrimitiveValue> valueForAnimationDelay(double);
+ static Ref<CSSPrimitiveValue> valueForAnimationIterationCount(double);
+ static Ref<CSSPrimitiveValue> valueForAnimationDirection(Animation::AnimationDirection);
+ static Ref<CSSPrimitiveValue> valueForAnimationFillMode(AnimationFillMode);
+ static Ref<CSSPrimitiveValue> valueForAnimationPlayState(AnimationPlayState);
+ static Ref<CSSPrimitiveValue> valueForAnimationName(const Animation::Name&);
+
private:
// The styled element is either the element passed into
// computedPropertyValue, or the PseudoElement for :before and :after if
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (287533 => 287534)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2022-01-03 09:21:23 UTC (rev 287533)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2022-01-03 10:00:53 UTC (rev 287534)
@@ -33,6 +33,7 @@
#include "CSSBasicShapes.h"
#include "CSSBorderImage.h"
#include "CSSBorderImageSliceValue.h"
+#include "CSSComputedStyleDeclaration.h"
#include "CSSContentDistributionValue.h"
#include "CSSCursorImageValue.h"
#include "CSSCustomPropertyValue.h"
@@ -80,6 +81,7 @@
#include "StyleBuilderConverter.h"
#include "StylePropertyShorthand.h"
#include "StylePropertyShorthandFunctions.h"
+#include "TimingFunction.h"
#include <bitset>
#include <memory>
#include <wtf/text/StringBuilder.h>
@@ -1655,8 +1657,29 @@
// FIXME: This will make invalid longhands, see crbug.com/386459
for (size_t i = 0; i < longhandCount; ++i) {
- if (!parsedLonghand[i])
- longhands[i]->append(CSSValuePool::singleton().createImplicitInitialValue());
+ if (!parsedLonghand[i]) {
+ auto property = shorthand.properties()[i];
+ if (property == CSSPropertyAnimationDuration)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationDuration(Animation::initialDuration()));
+ else if (property == CSSPropertyAnimationTimingFunction)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationTimingFunction(CubicBezierTimingFunction::defaultTimingFunction()));
+ else if (property == CSSPropertyAnimationDelay)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationDelay(Animation::initialDelay()));
+ else if (property == CSSPropertyAnimationIterationCount)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationIterationCount(Animation::initialIterationCount()));
+ else if (property == CSSPropertyAnimationDirection)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationDirection(Animation::initialDirection()));
+ else if (property == CSSPropertyAnimationFillMode)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationFillMode(Animation::initialFillMode()));
+ else if (property == CSSPropertyAnimationPlayState)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationPlayState(Animation::initialPlayState()));
+ else if (property == CSSPropertyAnimationName)
+ longhands[i]->append(ComputedStyleExtractor::valueForAnimationName(Animation::initialName()));
+ else {
+ ASSERT(shorthand.id() == CSSPropertyTransition);
+ longhands[i]->append(CSSValuePool::singleton().createImplicitInitialValue());
+ }
+ }
parsedLonghand[i] = false;
}
} while (consumeCommaIncludingWhitespace(m_range));
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
