mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +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:
committed by
Andreas Kling
parent
a7a24fed68
commit
bea47a2554
1
Tests/LibWeb/Text/expected/css/revert-ignores-layers.txt
Normal file
1
Tests/LibWeb/Text/expected/css/revert-ignores-layers.txt
Normal file
@@ -0,0 +1 @@
|
||||
PASS, revert skipped the layers
|
||||
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>
|
||||
Reference in New Issue
Block a user