forked from mirrors/gecko-dev
Bug 1898502 - [devtools] Turn output-parser.js lookup Arrays into Sets. r=devtools-reviewers,bomsy.
Depends on D211330 Differential Revision: https://phabricator.services.mozilla.com/D211371
This commit is contained in:
parent
e5dd4777c7
commit
2ea7429590
1 changed files with 16 additions and 11 deletions
|
|
@ -21,7 +21,7 @@ const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
|
||||||
const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES);
|
const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES);
|
||||||
|
|
||||||
// Functions that accept an angle argument.
|
// Functions that accept an angle argument.
|
||||||
const ANGLE_TAKING_FUNCTIONS = [
|
const ANGLE_TAKING_FUNCTIONS = new Set([
|
||||||
"linear-gradient",
|
"linear-gradient",
|
||||||
"-moz-linear-gradient",
|
"-moz-linear-gradient",
|
||||||
"repeating-linear-gradient",
|
"repeating-linear-gradient",
|
||||||
|
|
@ -37,17 +37,17 @@ const ANGLE_TAKING_FUNCTIONS = [
|
||||||
"skewX",
|
"skewX",
|
||||||
"skewY",
|
"skewY",
|
||||||
"hue-rotate",
|
"hue-rotate",
|
||||||
];
|
]);
|
||||||
// All cubic-bezier CSS timing-function names.
|
// All cubic-bezier CSS timing-function names.
|
||||||
const BEZIER_KEYWORDS = [
|
const BEZIER_KEYWORDS = new Set([
|
||||||
"linear",
|
"linear",
|
||||||
"ease-in-out",
|
"ease-in-out",
|
||||||
"ease-in",
|
"ease-in",
|
||||||
"ease-out",
|
"ease-out",
|
||||||
"ease",
|
"ease",
|
||||||
];
|
]);
|
||||||
// Functions that accept a color argument.
|
// Functions that accept a color argument.
|
||||||
const COLOR_TAKING_FUNCTIONS = [
|
const COLOR_TAKING_FUNCTIONS = new Set([
|
||||||
"linear-gradient",
|
"linear-gradient",
|
||||||
"-moz-linear-gradient",
|
"-moz-linear-gradient",
|
||||||
"repeating-linear-gradient",
|
"repeating-linear-gradient",
|
||||||
|
|
@ -60,9 +60,14 @@ const COLOR_TAKING_FUNCTIONS = [
|
||||||
"repeating-conic-gradient",
|
"repeating-conic-gradient",
|
||||||
"drop-shadow",
|
"drop-shadow",
|
||||||
"color-mix",
|
"color-mix",
|
||||||
];
|
]);
|
||||||
// Functions that accept a shape argument.
|
// Functions that accept a shape argument.
|
||||||
const BASIC_SHAPE_FUNCTIONS = ["polygon", "circle", "ellipse", "inset"];
|
const BASIC_SHAPE_FUNCTIONS = new Set([
|
||||||
|
"polygon",
|
||||||
|
"circle",
|
||||||
|
"ellipse",
|
||||||
|
"inset",
|
||||||
|
]);
|
||||||
|
|
||||||
const BACKDROP_FILTER_ENABLED = Services.prefs.getBoolPref(
|
const BACKDROP_FILTER_ENABLED = Services.prefs.getBoolPref(
|
||||||
"layout.css.backdrop-filter.enabled"
|
"layout.css.backdrop-filter.enabled"
|
||||||
|
|
@ -408,12 +413,12 @@ class OutputParser {
|
||||||
const functionName = token.value;
|
const functionName = token.value;
|
||||||
const lowerCaseFunctionName = functionName.toLowerCase();
|
const lowerCaseFunctionName = functionName.toLowerCase();
|
||||||
|
|
||||||
const isColorTakingFunction = COLOR_TAKING_FUNCTIONS.includes(
|
const isColorTakingFunction = COLOR_TAKING_FUNCTIONS.has(
|
||||||
lowerCaseFunctionName
|
lowerCaseFunctionName
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
isColorTakingFunction ||
|
isColorTakingFunction ||
|
||||||
ANGLE_TAKING_FUNCTIONS.includes(lowerCaseFunctionName)
|
ANGLE_TAKING_FUNCTIONS.has(lowerCaseFunctionName)
|
||||||
) {
|
) {
|
||||||
// The function can accept a color or an angle argument, and we know
|
// The function can accept a color or an angle argument, and we know
|
||||||
// it isn't special in some other way. So, we let it
|
// it isn't special in some other way. So, we let it
|
||||||
|
|
@ -545,7 +550,7 @@ class OutputParser {
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (
|
||||||
options.expectShape &&
|
options.expectShape &&
|
||||||
BASIC_SHAPE_FUNCTIONS.includes(lowerCaseFunctionName)
|
BASIC_SHAPE_FUNCTIONS.has(lowerCaseFunctionName)
|
||||||
) {
|
) {
|
||||||
this.#appendShape(functionText, options);
|
this.#appendShape(functionText, options);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -559,7 +564,7 @@ class OutputParser {
|
||||||
case "Ident":
|
case "Ident":
|
||||||
if (
|
if (
|
||||||
options.expectCubicBezier &&
|
options.expectCubicBezier &&
|
||||||
BEZIER_KEYWORDS.includes(lowerCaseTokenText)
|
BEZIER_KEYWORDS.has(lowerCaseTokenText)
|
||||||
) {
|
) {
|
||||||
this.#appendCubicBezier(token.text, options);
|
this.#appendCubicBezier(token.text, options);
|
||||||
} else if (
|
} else if (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue