Skip to content

Commit

Permalink
Fix a crash in CSS Custom Property application
Browse files Browse the repository at this point in the history
The root highlight pseudo styles do not get recalculated when
a CSS custom property is registered, causing crashes when that
property is used in the pseudo class. Fix it by checking for a
change in InitialData in Element::CalculateHighlightRecalc.

Add a test for this case.

Bug: 381362600
Change-Id: Iabeaf88bedecfb0ee039b2e98151750844c7ab7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6077895
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Stephen Chenney <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1394243}
  • Loading branch information
schenney-chromium authored and chromium-wpt-export-bot committed Dec 10, 2024
1 parent 6d70cd3 commit c9a08c2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions css/css-pseudo/highlight-cascade/highlight-cascade-010.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: highlight styling: late property registration updates highlights</title>
<link rel="author" title="Stephen Chenney" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-cascade">
<meta name="assert" value="This test verifies that custom property values when defined on a highlight pseudo update when the property registration happens after first style recalc.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#originating::spelling-error {
color: white;
--x: initial;
background-color: var(--x, red);
}
</style>
<div id="originating">Text wth a spelling error</div>
<script>
promise_test(async () => {
await new Promise(requestAnimationFrame);
CSS.registerProperty({
name: '--x',
inherits: true,
initialValue: "green"
});
await new Promise(requestAnimationFrame);
const originating_spelling = getComputedStyle(document.querySelector("div"), "::spelling-error");
assert_equals(originating_spelling.getPropertyValue("--x"), "green");
}, "the custom property receives its initial value from a deferred registration");
</script>

0 comments on commit c9a08c2

Please sign in to comment.