Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[web-animations] support custom properties in @Keyframes rules
https://bugs.webkit.org/show_bug.cgi?id=241843 Reviewed by Antti Koivisto. We start work towards broad support of custom properties in animations by adding support for custom properties in @Keyframes rules. The first thing required is to allow KeyframeList and KeyframeValue to track custom properties on top of common properties (CSSPropertyID). To that end, we add HashSet<AtomString> members to both those classes and ensure KeyframeList::insert() adds any new custom property found on the inserted KeyframeValue to the KeyframeList. Dedicated methods, such as KeyframeValue::addCustomProperty() allow setting what custom properties are found on the KeyframeValue. Then, we need to detect that we have custom properties set in @Keyframes rules. We update Style::Resolver::styleForKeyframe() to determine whether a property in a keyframe is a CSSCustomPropertyValue, and if it is, we get its name and use KeyframeValue::addCustomProperty() to add it to the keyframe. Finally, we must actually blend custom properties. Since custom properties are only animated discretely, the logic here is simple and we add a new CSSPropertyAnimation::blendCustomProperty() method which simply gets the custom property from either the from or to style depending on what side of the 0.5 boundary we are. We call this new method from KeyframeEffect::setAnimatedPropertiesInStyle() where we must now not only iterate through common properties (CSSPropertyID) but also custom properties. We now wrap much of that function's logic into a lambda which takes in an std::variant<CSSPropertyID, AtomString> type with some simple checks to deal with either type in the lambda body. * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-inner-at-rules-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-longhand-animation-type-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-animation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/font-size-animation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-revert-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-animation-from-to-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-animation-over-transition-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-animation-to-only-expected.txt: * Source/WebCore/animation/CSSPropertyAnimation.cpp: (WebCore::CSSPropertyAnimation::blendProperties): (WebCore::CSSPropertyAnimation::blendCustomProperty): * Source/WebCore/animation/CSSPropertyAnimation.h: * Source/WebCore/animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): * Source/WebCore/rendering/style/KeyframeList.cpp: (WebCore::KeyframeList::insert): (WebCore::KeyframeList::copyKeyframes): (WebCore::KeyframeList::containsAnimatableProperty const): Any and all custom properties is considered animatable. * Source/WebCore/rendering/style/KeyframeList.h: (WebCore::KeyframeValue::addCustomProperty): (WebCore::KeyframeValue::containsCustomProperty const): (WebCore::KeyframeValue::customProperties const): (WebCore::KeyframeList::addCustomProperty): (WebCore::KeyframeList::containsCustomProperty const): (WebCore::KeyframeList::customProperties const): * Source/WebCore/style/StyleResolver.cpp: (WebCore::Style::Resolver::styleForKeyframe): Canonical link: https://commits.webkit.org/251733@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
14 changed files
with
96 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,5 +1,5 @@ | ||
|
||
FAIL Reference variable is applied assert_equals: expected "PASS" but got "FAIL" | ||
PASS Reference variable is applied | ||
PASS container-name is not animatable | ||
PASS container-type is not animatable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,3 +1,3 @@ | ||
|
||
FAIL Animating font-size handled identically for standard and custom properties assert_equals: expected "0px" but got "250px" | ||
FAIL Animating font-size handled identically for standard and custom properties assert_equals: expected "400px" but got "250px" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,6 +1,6 @@ | ||
|
||
PASS Inherited registered custom property can be reverted | ||
PASS Non-inherited registered custom property can be reverted | ||
FAIL Non-inherited registered custom property can be reverted in animation assert_equals: expected "50px" but got "0px" | ||
FAIL Inherited registered custom property can be reverted in animation assert_equals: expected "50px" but got "0px" | ||
FAIL Non-inherited registered custom property can be reverted in animation assert_equals: expected "50px" but got "100px" | ||
FAIL Inherited registered custom property can be reverted in animation assert_equals: expected "50px" but got "100px" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,7 +1,7 @@ | ||
This text should animate from blue to green over a period of 1 second. | ||
|
||
FAIL Verify CSS variable value before animation assert_equals: --value is blue before animation runs expected "blue" but got "red" | ||
PASS Verify CSS variable value before animation | ||
FAIL Verify substituted color value before animation assert_equals: color is blue before animation runs expected "rgb(0, 0, 255)" but got "rgb(255, 0, 0)" | ||
FAIL Verify CSS variable value after animation assert_equals: --value is green after animation runs expected "green" but got "red" | ||
PASS Verify CSS variable value after animation | ||
FAIL Verify substituted color value after animation assert_equals: color is green after animation runs expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,7 +1,7 @@ | ||
This text should animate from blue to green over a period of 1 second. The transition is not visible because the animation overrides it. | ||
|
||
FAIL Verify CSS variable value before animation assert_equals: --value is blue before animation runs expected "blue" but got "red" | ||
PASS Verify CSS variable value before animation | ||
FAIL Verify substituted color value before animation assert_equals: color is blue before animation runs expected "rgb(0, 0, 255)" but got "rgb(255, 0, 0)" | ||
FAIL Verify CSS variable value after animation assert_equals: --value is green after animation runs expected "green" but got "black" | ||
PASS Verify CSS variable value after animation | ||
FAIL Verify substituted color value after animation assert_equals: color is green after animation runs expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,5 +1,5 @@ | ||
This text should animate from blue to green over a period of 1 second. | ||
|
||
PASS Verify CSS variable value before animation | ||
FAIL Verify CSS variable value after animation assert_equals: --value is green after animation runs expected "green" but got "blue" | ||
PASS Verify CSS variable value after animation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters