Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 7838708

Browse files
committed
Bug 1642560 [wpt PR 23906] - Set color-scheme-senstive initial color via cascade, a=testonly
Automatic update from web-platform-tests Set color-scheme-senstive initial color via cascade We currently adjust the computed value of 'color' on the document element to simulate 'canvastext' behavior. However, there's an incorrect assumption that it's safe to adjust whenever there are no 'color' declarations in the cascade. During a transition, the base ComputedStyle is the destination style for the transitioning element, and on the final frame of the transition, the StyleEngine simply emits a copy of the base style, without adding any declaration to the cascade. This causes color- transitions on the document element to "snap back" to black (or white, depending on color-scheme) when the transition ends. This CL fixes this by adding an explicit value (CSSInitialColorValue) which represents this behavior to the cascade. The value is added only when computing the base style, which prevents incorrect adjustments on top of the final transition frame. Bug: 1087188 Change-Id: Ie0d95aaab5b93f1749e461fad0baf41a184f7cb6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2224222 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/master@{#774178} -- wpt-commits: c20b45a0352c65db0ef7f141edfd68d01f1516e2 wpt-pr: 23906 Differential Revision: https://phabricator.services.mozilla.com/D78786
1 parent 90c2404 commit 7838708

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<h1 style="color:green">PASS if green</h1>
4+
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html id=html class="reftest-wait">
3+
<title>Verifies that 'color' stays the color it's transitioned to on :root</title>
4+
<link rel="help" href="https://crbug.com/1087188">
5+
<link rel="match" href="root-color-transition-ref.html">
6+
<script src="support/helper.js"></script>
7+
<h1 id=h1>PASS if green</h1>
8+
<style>
9+
html {
10+
color: red;
11+
transition: color 1s linear;
12+
}
13+
html.green {
14+
color: green;
15+
}
16+
</style>
17+
<script>
18+
getComputedStyle(h1).color;
19+
20+
async function run() {
21+
let transitionEnd = new Promise((resolve) => {
22+
html.addEventListener('transitionend', resolve);
23+
});
24+
// Trigger transition:
25+
html.classList.toggle('green');
26+
27+
const transition = html.getAnimations()[0];
28+
await transition.ready;
29+
await waitForFrame();
30+
31+
// Expedite transition, but let it finish naturally.
32+
transition.currentTime = transition.effect.getTiming().duration - 1;
33+
await transitionEnd;
34+
35+
await waitForFrame();
36+
}
37+
38+
run().then(() => html.classList.toggle('reftest-wait'));
39+
</script>
40+
</html>

0 commit comments

Comments
 (0)