mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 15:18:06 +00:00
LibWeb/CSS: Correct behavior of revert
inside a @layer
`revert` is supposed to revert to the previous cascade origin, but we previously had it reverting to the previous layer. To support both, track them separately during the cascade. As part of this, we make `set_property_expanding_shorthands()` fall back to `initial` if it can't find a previous value to revert to. Previously we would just shrug and do nothing if that happened, which only works if the value you want to revert to is whatever is currently in `style`. That's no longer the case, because `revert` should skip over any layer styles that have been applied since the previous origin.
This commit is contained in:
parent
a7a24fed68
commit
bea47a2554
Notes:
github-actions[bot]
2024-09-26 06:09:32 +00:00
Author: https://github.com/AtkinsSJ
Commit: bea47a2554
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1524
4 changed files with 88 additions and 30 deletions
35
Tests/LibWeb/Text/input/css/revert-ignores-layers.html
Normal file
35
Tests/LibWeb/Text/input/css/revert-ignores-layers.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
@layer A, B, C;
|
||||
@layer A {
|
||||
#target {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
@layer B {
|
||||
#target {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
@layer C {
|
||||
#target {
|
||||
color: revert;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<div id="target"></div>
|
||||
<div id="initial"></div>
|
||||
<script>
|
||||
test(() => {
|
||||
const target = document.getElementById("target");
|
||||
const initial = document.getElementById("target");
|
||||
const expected = getComputedStyle(initial).color;
|
||||
const actual = getComputedStyle(target).color;
|
||||
if (expected === actual) {
|
||||
println('PASS, revert skipped the layers');
|
||||
} else {
|
||||
println(`FAIL: got ${actual}, expected ${expected}`);
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue