Skip to content

Commit

Permalink
[web-animations] color-scheme should support discrete animation
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=241179
rdar://94615599

Reviewed by Tim Nguyen.

The `color-scheme` property should support discrete animation, per
https://drafts.csswg.org/css-color-adjust/#color-scheme-prop.

* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/animation/color-scheme-no-interpolation-expected.txt:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* Source/WebCore/rendering/style/StyleColorScheme.h:
(WebCore::operator<<):

Canonical link: https://commits.webkit.org/267750@main
  • Loading branch information
pxlcoder committed Sep 7, 2023
1 parent 1696f58 commit 8d8787b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ PASS CSS Transitions with transition: all: property <color-scheme> from [initial
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (-0.3) should be [initial]
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (0) should be [initial]
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (0.3) should be [initial]
FAIL CSS Animations: property <color-scheme> from [initial] to [dark] at (0.5) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL CSS Animations: property <color-scheme> from [initial] to [dark] at (0.6) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL CSS Animations: property <color-scheme> from [initial] to [dark] at (1) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL CSS Animations: property <color-scheme> from [initial] to [dark] at (1.5) should be [dark] assert_equals: expected "dark " but got "normal "
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (0.5) should be [dark]
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (0.6) should be [dark]
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (1) should be [dark]
PASS CSS Animations: property <color-scheme> from [initial] to [dark] at (1.5) should be [dark]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (-0.3) should be [initial]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (0) should be [initial]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (0.3) should be [initial]
FAIL Web Animations: property <color-scheme> from [initial] to [dark] at (0.5) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL Web Animations: property <color-scheme> from [initial] to [dark] at (0.6) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL Web Animations: property <color-scheme> from [initial] to [dark] at (1) should be [dark] assert_equals: expected "dark " but got "normal "
FAIL Web Animations: property <color-scheme> from [initial] to [dark] at (1.5) should be [dark] assert_equals: expected "dark " but got "normal "
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (0.5) should be [dark]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (0.6) should be [dark]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (1) should be [dark]
PASS Web Animations: property <color-scheme> from [initial] to [dark] at (1.5) should be [dark]

6 changes: 3 additions & 3 deletions Source/WebCore/animation/CSSPropertyAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,9 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
new DiscretePropertyWrapper<Isolation>(CSSPropertyIsolation, &RenderStyle::isolation, &RenderStyle::setIsolation),
new DiscretePropertyWrapper<BlendMode>(CSSPropertyMixBlendMode, &RenderStyle::blendMode, &RenderStyle::setBlendMode),
new DiscretePropertyWrapper<BlendMode>(CSSPropertyBackgroundBlendMode, &RenderStyle::backgroundBlendMode, &RenderStyle::setBackgroundBlendMode),
#endif
#if ENABLE(DARK_MODE_CSS)
new DiscretePropertyWrapper<StyleColorScheme>(CSSPropertyColorScheme, &RenderStyle::colorScheme, &RenderStyle::setColorScheme),
#endif
new PropertyWrapperAspectRatio,
new DiscretePropertyWrapper<FontPalette>(CSSPropertyFontPalette, &RenderStyle::fontPalette, &RenderStyle::setFontPalette),
Expand Down Expand Up @@ -3977,9 +3980,6 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
// When adding a new property, you should make sure it belongs in this list
// or provide a wrapper for it above. If you are adding to this list but the
// property should be animatable, make sure to file a bug.
#if ENABLE(DARK_MODE_CSS)
case CSSPropertyColorScheme:
#endif
case CSSPropertyDirection:
case CSSPropertyDisplay:
#if ENABLE(VARIATION_FONTS)
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/rendering/style/StyleColorScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "RenderStyleConstants.h"
#include <wtf/OptionSet.h>
#include <wtf/text/TextStream.h>

namespace WebCore {

Expand Down Expand Up @@ -59,6 +60,13 @@ class StyleColorScheme {
bool m_allowsTransformations { true };
};

inline WTF::TextStream& operator<<(WTF::TextStream& ts, const StyleColorScheme& styleColorScheme)
{
ts.dumpProperty("color-scheme", styleColorScheme.colorScheme());
ts.dumpProperty("allows-transformations", styleColorScheme.allowsTransformations());
return ts;
}

} // namespace WebCore

#endif // ENABLE(DARK_MODE_CSS)

0 comments on commit 8d8787b

Please sign in to comment.