Commit dae5c876 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1699220 - Add support for the revert-layer keyword. r=boris

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
parent 74d515b9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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],
+2 −0
Original line number Diff line number Diff line
@@ -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],
@@ -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],
];
+1 −1
Original line number Diff line number Diff line
@@ -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"]],
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ window.onload = function() {
      "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.");
+527 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading