Skip to content

Commit

Permalink
Bug 1320607 - [devtools] Remove the generated CSS Properties database…
Browse files Browse the repository at this point in the history
…. r=devtools-reviewers,nchevobbe

This wasn't really used anymore.
We are fetching the database from the server runtime in order to support
remote debugging correctly, where frontend CSS may be different from debuggee CSS.

Differential Revision: https://phabricator.services.mozilla.com/D187492
  • Loading branch information
ochameau committed Sep 7, 2023
1 parent 4d87f3f commit 2e2e9b1
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 12,859 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ devtools/client/debugger/webpack.config.js
devtools/client/preferences/

# Ignore devtools generated code
devtools/shared/css/generated/properties-db.js
devtools/client/webconsole/test/node/fixtures/stubs/*.js
!devtools/client/webconsole/test/node/fixtures/stubs/index.js
devtools/client/shared/components/test/node/stubs/reps/*.js
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@ devtools/client/debugger/webpack.config.js
devtools/client/preferences/

# Ignore devtools generated code
devtools/shared/css/generated/properties-db.js
devtools/client/webconsole/test/node/fixtures/stubs/*.js
!devtools/client/webconsole/test/node/fixtures/stubs/index.js
devtools/client/shared/components/test/node/stubs/reps/*.js
Expand Down
63 changes: 4 additions & 59 deletions devtools/client/fronts/css-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ loader.lazyRequireGetter(
"resource://devtools/shared/css/color-db.js",
true
);
loader.lazyRequireGetter(
this,
"CSS_PROPERTIES_DB",
"resource://devtools/shared/css/properties-db.js",
true
);
loader.lazyRequireGetter(
this,
"CSS_TYPES",
Expand Down Expand Up @@ -181,16 +175,6 @@ function isCssVariable(input) {
return !!input.match(IS_VARIABLE_TOKEN);
}

/**
* Get a client-side CssProperties. This is useful for dependencies in tests, or parts
* of the codebase that don't particularly need to match every known CSS property on
* the target.
* @return {CssProperties}
*/
function getClientCssProperties() {
return new CssProperties(normalizeCssData(CSS_PROPERTIES_DB));
}

/**
* Even if the target has the cssProperties actor, the returned data may not be in the
* same shape or have all of the data we need. This normalizes the data and fills in
Expand All @@ -200,49 +184,9 @@ function getClientCssProperties() {
*/
function normalizeCssData(db) {
// If there is a `from` attributes, it means that it comes from RDP
// and it is not the client CSS_PROPERTIES_DB object.
// (prevent comparing to CSS_PROPERTIES_DB to avoid loading client database)
// and it is not the client `generateCssProperties()` object passed by tests.
if (typeof db.from == "string") {
const missingSupports = !db.properties.color.supports;
const missingValues = !db.properties.color.values;
const missingSubproperties = !db.properties.background.subproperties;
const missingIsInherited = !db.properties.font.isInherited;

const missingSomething =
missingSupports ||
missingValues ||
missingSubproperties ||
missingIsInherited;

if (missingSomething) {
for (const name in db.properties) {
// Skip the current property if we can't find it in CSS_PROPERTIES_DB.
if (typeof CSS_PROPERTIES_DB.properties[name] !== "object") {
continue;
}

// Add "supports" information to the css properties if it's missing.
if (missingSupports) {
db.properties[name].supports =
CSS_PROPERTIES_DB.properties[name].supports;
}
// Add "values" information to the css properties if it's missing.
if (missingValues) {
db.properties[name].values =
CSS_PROPERTIES_DB.properties[name].values;
}
// Add "subproperties" information to the css properties if it's missing.
if (missingSubproperties) {
db.properties[name].subproperties =
CSS_PROPERTIES_DB.properties[name].subproperties;
}
// Add "isInherited" information to the css properties if it's missing.
if (missingIsInherited) {
db.properties[name].isInherited =
CSS_PROPERTIES_DB.properties[name].isInherited;
}
}
}
// This is where to put backward compat tweaks here to support old runtimes.
}

reattachCssColorValues(db);
Expand Down Expand Up @@ -271,7 +215,8 @@ function reattachCssColorValues(db) {

module.exports = {
CssPropertiesFront,
getClientCssProperties,
isCssVariable,
CssProperties,
normalizeCssData,
};
registerFront(CssPropertiesFront);
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
// tested with an xpcshell test as the output-parser requires the DOM to work.

const OutputParser = require("resource://devtools/client/shared/output-parser.js");
const {
getClientCssProperties,
} = require("resource://devtools/client/fronts/css-properties.js");

const COLOR_CLASS = "color-class";
const URL_CLASS = "url-class";
Expand Down
6 changes: 1 addition & 5 deletions devtools/client/shared/sourceeditor/css-autocompleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const {
cssTokenizer,
cssTokenizerWithLineColumn,
} = require("resource://devtools/shared/css/parsing-utils.js");
const {
getClientCssProperties,
} = require("resource://devtools/client/fronts/css-properties.js");

/**
* Here is what this file (+ css-parsing-utils.js) do.
Expand Down Expand Up @@ -89,8 +86,7 @@ const SELECTOR_STATES = {
function CSSCompleter(options = {}) {
this.walker = options.walker;
this.maxEntries = options.maxEntries || 15;
// If no css properties database is passed in, default to the client list.
this.cssProperties = options.cssProperties || getClientCssProperties();
this.cssProperties = options.cssProperties;

this.propertyNames = this.cssProperties.getNames().sort();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ async function runTests() {
const target = await createAndAttachTargetForTab(gBrowser.selectedTab);
inspector = await target.getFront("inspector");
const walker = inspector.walker;
const cssPropertiesFront = await target.getFront("cssProperties");
completer = new CSSCompleter({
walker,
cssProperties: getClientCssProperties(),
cssProperties: cssPropertiesFront.cssProperties,
});
await checkStateAndMoveOn();
await completer.walker.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ async function runTests() {
const target = await createAndAttachTargetForTab(gBrowser.selectedTab);
const inspector = await target.getFront("inspector");
const walker = inspector.walker;
const cssPropertiesFront = await target.getFront("cssProperties");
const { ed, win, edWin } = await setup({
autocomplete: true,
mode: Editor.modes.css,
autocompleteOpts: {
walker,
cssProperties: getClientCssProperties(),
cssProperties: cssPropertiesFront.cssProperties,
},
});
await testMouse(ed, edWin);
Expand Down
3 changes: 0 additions & 3 deletions devtools/client/shared/sourceeditor/test/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ Services.scriptloader.loadSubScript(
);

const Editor = require("resource://devtools/client/shared/sourceeditor/editor.js");
const {
getClientCssProperties,
} = require("resource://devtools/client/fronts/css-properties.js");

function promiseWaitForFocus(el) {
return new Promise(resolve => waitForFocus(resolve, el));
Expand Down
4 changes: 0 additions & 4 deletions devtools/client/shared/test/browser_outputparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

"use strict";

const {
getClientCssProperties,
} = require("resource://devtools/client/fronts/css-properties.js");

add_task(async function () {
await pushPref("layout.css.backdrop-filter.enabled", true);
await pushPref("layout.css.individual-transform.enabled", true);
Expand Down
21 changes: 21 additions & 0 deletions devtools/client/shared/test/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -2207,3 +2207,24 @@ function logCssCompatDataPropertiesWithoutMDNUrl() {
}
walk(cssPropertiesCompatData);
}

/**
* Craft a CssProperties instance without involving RDP for tests
* manually spawning OutputParser, CssCompleter, Editor...
*
* Otherwise this should instead be fetched from CssPropertiesFront.
*
* @return {CssProperties}
*/
function getClientCssProperties() {
const {
generateCssProperties,
} = require("resource://devtools/server/actors/css-properties.js");
const {
CssProperties,
normalizeCssData,
} = require("resource://devtools/client/fronts/css-properties.js");
return new CssProperties(
normalizeCssData({ properties: generateCssProperties() })
);
}
51 changes: 0 additions & 51 deletions devtools/shared/css/generated/generate-properties-db.js

This file was deleted.

119 changes: 0 additions & 119 deletions devtools/shared/css/generated/mach_commands.py

This file was deleted.

9 changes: 0 additions & 9 deletions devtools/shared/css/generated/moz.build

This file was deleted.

Loading

0 comments on commit 2e2e9b1

Please sign in to comment.