-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing color scheme does not update gradients with system colors or…
… `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
- Loading branch information
Showing
8 changed files
with
183 additions
and
10 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...b-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops-expected.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme-prop"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#light-dark"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#color-mix"> | ||
<title>Reference: Test changing used color-scheme updates gradient with color-scheme dependent color stops.</title> | ||
<style> | ||
|
||
.box { | ||
color-scheme: dark; | ||
|
||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
#system-color { | ||
background-image: linear-gradient(CanvasText, CanvasText); | ||
} | ||
|
||
#system-color-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, Canvas, pink), color-mix(in lch, Canvas, pink)); | ||
} | ||
|
||
#light-dark { | ||
background-image: linear-gradient(light-dark(red, green), light-dark(red, green)); | ||
} | ||
|
||
#light-dark-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, light-dark(red, green), pink), color-mix(in lch, light-dark(red, green), pink)); | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<p>Test system color</p> | ||
<div id="system-color" class="box"></div> | ||
<p>Test system color in color-mix()</p> | ||
<div id="system-color-in-color-mix" class="box"></div> | ||
<p>Test light-dark()</p> | ||
<div id="light-dark" class="box"></div> | ||
<p>Test light-dark() in color-mix()</p> | ||
<div id="light-dark-in-color-mix" class="box"></div> | ||
</body> | ||
</html> |
47 changes: 47 additions & 0 deletions
47
...3c/web-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops-ref.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme-prop"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#light-dark"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#color-mix"> | ||
<title>Reference: Test changing used color-scheme updates gradient with color-scheme dependent color stops.</title> | ||
<style> | ||
|
||
.box { | ||
color-scheme: dark; | ||
|
||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
#system-color { | ||
background-image: linear-gradient(CanvasText, CanvasText); | ||
} | ||
|
||
#system-color-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, Canvas, pink), color-mix(in lch, Canvas, pink)); | ||
} | ||
|
||
#light-dark { | ||
background-image: linear-gradient(light-dark(red, green), light-dark(red, green)); | ||
} | ||
|
||
#light-dark-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, light-dark(red, green), pink), color-mix(in lch, light-dark(red, green), pink)); | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<p>Test system color</p> | ||
<div id="system-color" class="box"></div> | ||
<p>Test system color in color-mix()</p> | ||
<div id="system-color-in-color-mix" class="box"></div> | ||
<p>Test light-dark()</p> | ||
<div id="light-dark" class="box"></div> | ||
<p>Test light-dark() in color-mix()</p> | ||
<div id="light-dark-in-color-mix" class="box"></div> | ||
</body> | ||
</html> |
61 changes: 61 additions & 0 deletions
61
...ed/w3c/web-platform-tests/css/css-images/gradient/color-scheme-dependent-color-stops.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html class="reftest-wait"> | ||
<head> | ||
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme-prop"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#light-dark"> | ||
<link rel="help" href="https://www.w3.org/TR/css-color-5/#color-mix"> | ||
<title>Test changing used color-scheme updates gradient with color-scheme dependent color stops.</title> | ||
<link rel="match" href="color-scheme-dependent-color-stops-ref.html"> | ||
<style> | ||
|
||
.dark { | ||
color-scheme: dark; | ||
} | ||
|
||
.box { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
#system-color { | ||
background-image: linear-gradient(CanvasText, CanvasText); | ||
} | ||
|
||
#system-color-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, Canvas, pink), color-mix(in lch, Canvas, pink)); | ||
} | ||
|
||
#light-dark { | ||
background-image: linear-gradient(light-dark(red, green), light-dark(red, green)); | ||
} | ||
|
||
#light-dark-in-color-mix { | ||
background-image: linear-gradient(color-mix(in lch, light-dark(red, green), pink), color-mix(in lch, light-dark(red, green), pink)); | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<p>Test system color</p> | ||
<div id="system-color" class="box"></div> | ||
<p>Test system color in color-mix()</p> | ||
<div id="system-color-in-color-mix" class="box"></div> | ||
<p>Test light-dark()</p> | ||
<div id="light-dark" class="box"></div> | ||
<p>Test light-dark() in color-mix()</p> | ||
<div id="light-dark-in-color-mix" class="box"></div> | ||
<script> | ||
|
||
setTimeout(() => { | ||
document.querySelectorAll(".box").forEach((box) => { | ||
box.classList.add("dark"); | ||
}); | ||
|
||
document.documentElement.className = ''; | ||
}, 0); | ||
|
||
</script> | ||
</body> | ||
</html> |
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