-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing color scheme does not update gradients with system colors or light-dark()
#25394
Conversation
EWS run on previous version of this PR (hash d0cd549)
|
EWS run on previous version of this PR (hash 8568573) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we convert the test to a WPT one ?
@@ -132,6 +132,17 @@ bool StyleColor::containsCurrentColor(const CSSPrimitiveValue& value) | |||
return false; | |||
} | |||
|
|||
bool StyleColor::containsColorSchemeDependentColor(const CSSPrimitiveValue& value) | |||
{ | |||
if (StyleColor::isSystemColorKeyword(value.valueID())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does all system colors depend on color scheme ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all of them do, and even the ones that do can be platform-specific. On Cocoa platforms, the majority of them are color-scheme dependent.
However, I think that using an allowlist or denylist for that set of system colors would be complicated to maintain, for limited benefit. Both an allowlist and denylist would have the problem of knowing the keep the list up-to-date, as new colors are added, or colors change their dependency on color-scheme.
Let me know if you feel strongly about a more specific list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, having a platform specific list would require some more code (stuff in /platform
..etc..) I will follow your judgment for the cost-benefit ratio
I agree with Matthieu, would be nice to create WPTs |
EWS run on current version of this PR (hash bbaae52) |
Rewrote the test as a WPT. |
… `light-dark()` https://bugs.webkit.org/show_bug.cgi?id=267790 rdar://121285450 Reviewed by Matthieu Dubet. `CSSGradientValue`s cache their generated `StyleImage` when possible. Currently, caching is disallowed when the gradient contains one of the following color keywords as a color stop: "-internal-document-text", "-webkit-link", "-webkit-active-link", and "currentcolor". However, that denylist is not comprehensive with respect to dynamic colors. Notably, it excludes almost all system color keywords, and `light-dark()`. Consequently, the same cached `StyleImage` is used even when the used color scheme of an element changes. Fix by updating `BuilderState::isColorFromPrimitiveValueDerivedFromElement` to account for other scenarios where colors change dynamically. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops.html: Added. * Source/WebCore/css/StyleColor.cpp: (WebCore::StyleColor::colorFromKeyword): Drive-by style fix. (WebCore::StyleColor::containsColorSchemeDependentColor): System colors, `light-dark()`, and any other unresolved colors containing either of those, are color-scheme dependent colors. * Source/WebCore/css/StyleColor.h: * Source/WebCore/css/color/CSSUnresolvedColor.cpp: (WebCore::CSSUnresolvedColor::containsColorSchemeDependentColor const): * Source/WebCore/css/color/CSSUnresolvedColor.h: * Source/WebCore/style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::isColorFromPrimitiveValueDerivedFromElement): Update to cover colors that are color-scheme dependent. Canonical link: https://commits.webkit.org/275645@main
bbaae52
to
5596316
Compare
Committed 275645@main (5596316): https://commits.webkit.org/275645@main Reviewed commits have been landed. Closing PR #25394 and removing active labels. |
5596316
bbaae52