Skip to content

Commit

Permalink
Bug 1215878 - Implement CSS revert keyword. r=heycam,birtles
Browse files Browse the repository at this point in the history
The only fishy bit is the animation stuff. In particular, there are two places
where we just mint the revert behavior:

 * When serializing web-animations keyframes (the custom properties stuff in
   declaration_block.rs). That codepath is already not sound and I wanted to
   get rid of it in bug 1501530, but what do I know.

 * When getting an animation value from a property declaration. At that point
   we no longer have the CSS rules that apply to the element to compute the
   right revert value handy. It'd also use the wrong style anyway, I think,
   given the way StyleBuilder::for_animation works.

   We _could_ probably get them out of somewhere, but it seems like a whole lot
   of code reinventing the wheel which is probably not useful, and that Blink
   and WebKit just cannot implement either since they don't have a rule tree,
   so it just doesn't seem worth the churn.

The custom properties code looks a bit different in order to minimize hash
lookups in the common case. FWIW, `revert` for custom properties doesn't seem
very useful either, but oh well.

Differential Revision: https://phabricator.services.mozilla.com/D21877

--HG--
extra : moz-landing-system : lando
  • Loading branch information
emilio committed Mar 7, 2019
1 parent 82f098d commit 0b5807b
Show file tree
Hide file tree
Showing 21 changed files with 820 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const testData = [
["VK_TAB", {}, "none", !OPEN, !SELECTED, CHANGE],
["r", {}, "rebeccapurple", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "red", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "revert", 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 @@ -37,7 +37,8 @@ const newAreaTestData = [
["c", {}, "col1-start", OPEN, SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "c", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "", !OPEN, !SELECTED, CHANGE],
["r", {}, "row1-start", OPEN, SELECTED, CHANGE],
["r", {}, "revert", OPEN, SELECTED, CHANGE],
["VK_DOWN", {}, "row1-start", OPEN, SELECTED, CHANGE],
["r", {}, "rr", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "r", !OPEN, !SELECTED, CHANGE],
["o", {}, "row1-start", OPEN, SELECTED, CHANGE],
Expand All @@ -57,7 +58,8 @@ const newRowTestData = [
"grid-line-names-updated",
["c", {}, "c", !OPEN, !SELECTED, CHANGE],
["VK_BACK_SPACE", {}, "", !OPEN, !SELECTED, CHANGE],
["r", {}, "row1-start", OPEN, SELECTED, CHANGE],
["r", {}, "revert", 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
@@ -1,11 +1,11 @@
{
"description": [
"Test states to be tested for css state machine in css-autocompelter.js file.",
"Test states to be tested for css state machine in css-autocompleter.js file.",
"Test cases are of the following format:",
"[",
" [",
" line, # The line location of the cursor",
" ch # The column locaiton of the cursor",
" ch # The column location of the cursor",
" ],",
" suggestions # Array of expected results",
"]"
Expand All @@ -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","unset"]],
[[21, 9], ["auto", "inherit", "initial", "revert", "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/mochitest/test_css-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"A CSS variable with spaces fails");

is(toSortedString(cssProperties.getValues("margin")),
toSortedString(["auto", "inherit", "initial", "unset"]),
toSortedString(["auto", "inherit", "initial", "unset", "revert"]),
"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 0b5807b

Please sign in to comment.