Skip to content

Commit

Permalink
Bug 1699220 - Add support for the revert-layer keyword. r=boris
Browse files Browse the repository at this point in the history
This patch looks bigger than it is, but it's mostly because
of plumbing.

To implement revert-layer we need not only the cascade origin of the
declaration, but the whole cascade level, plus also the layer order.

In order to do this, encapsulate these two things inside a 32-bit
`CascadePriority` struct and plumb it through the rule tree and so on.
This allows us to remove the packing and unpacking of CascadeLevel,
though I kept the ShadowCascadeOrder limit for now in case we need to
reintroduce it.

Fix `!important` behavior of layers while at it (implementing it in
`CascadeLevel::cmp`, spec quote included since it was tricky to find)
since some revert-layer tests were depending on it.

The style attribute test is failing now, but follow-up commit fixes
it, see spec issue.

In terms of the actual keyword implementation, it's sort of
straight-forward: We implement revert and revert-layer in a shared
way, by storing the cascade priority that reverted it.

Differential Revision: https://phabricator.services.mozilla.com/D133372
  • Loading branch information
emilio committed Dec 14, 2021
1 parent 74d515b commit dae5c87
Show file tree
Hide file tree
Showing 35 changed files with 912 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const testData = [
["r", {}, "rebeccapurple", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "red", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "revert", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "revert-layer", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "rgb", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "rgba", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "rosybrown", OPEN, SELECTED, CHANGE],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const newAreaTestData = [
["VK_BACK_SPACE", {}, "c", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "", OPEN, !SELECTED, CHANGE],
["r", {}, "revert", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "revert-layer", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "row1-start", OPEN, SELECTED, CHANGE],
["r", {}, "rr", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "r", !OPEN, !SELECTED, CHANGE],
Expand All @@ -60,6 +61,7 @@ const newRowTestData = [
["c", {}, "c", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "", OPEN, !SELECTED, CHANGE],
["r", {}, "revert", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "revert-layer", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "row1-start", OPEN, SELECTED, CHANGE],
["VK_TAB", {}, "", !OPEN, !SELECTED, CHANGE],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"background-clip", "background-color", "background-image",
"background-origin", "background-position", "background-position-x",
"background-position-y", "background-repeat", "background-size"]],
[[21, 9], ["auto", "inherit", "initial", "revert", "unset" ]],
[[21, 9], ["auto", "inherit", "initial", "revert", "revert-layer", "unset" ]],
[[25, 26], [".devtools-toolbarbutton > tab",
".devtools-toolbarbutton > hbox",
".devtools-toolbarbutton > .toolbarbutton-menubutton-button"]],
Expand Down
2 changes: 1 addition & 1 deletion devtools/server/tests/chrome/test_css-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"A CSS variable with spaces fails");

is(toSortedString(cssProperties.getValues("margin")),
toSortedString(["auto", "inherit", "initial", "unset", "revert"]),
toSortedString(["auto", "inherit", "initial", "unset", "revert", "revert-layer"]),
"Can get values for the CSS margin.");
is(cssProperties.getValues("foobar").length, 0,
"Unknown values return an empty array.");
Expand Down
Loading

0 comments on commit dae5c87

Please sign in to comment.