Bug 1465628 part 3 - Generate preference list from inspector utils. r?tromey
MozReview-Commit-ID: 5EK7Vhn0rrG
--- a/devtools/shared/css/generated/generate-properties-db.js
+++ b/devtools/shared/css/generated/generate-properties-db.js
@@ -15,16 +15,17 @@ const InspectorUtils = require("Inspecto
// xpcshell can output extra information, so place some delimiter text between
// the output of the css properties database.
dump("DEVTOOLS_CSS_DB_DELIMITER");
// Output JSON
dump(JSON.stringify({
cssProperties: cssProperties(),
+ preferences: preferences(),
pseudoElements: pseudoElements()
}));
dump("DEVTOOLS_CSS_DB_DELIMITER");
/*
* A list of CSS Properties and their various characteristics. This is used on the
* client-side when the CssPropertiesActor is not found, or when the client and server
@@ -42,13 +43,25 @@ function cssProperties() {
if (key.includes("-moz-osx-")) {
properties[key] = undefined;
}
}
return properties;
}
/**
+ * A list of preferences of CSS properties.
+ */
+function preferences() {
+ const prefs = InspectorUtils.getCSSPropertyPrefs();
+ const result = [];
+ for (const {name, pref} of prefs) {
+ result.push([name, pref]);
+ }
+ return result;
+}
+
+/**
* The list of all CSS Pseudo Elements.
*/
function pseudoElements() {
return InspectorUtils.getCSSPseudoElementNames();
}
--- a/devtools/shared/css/generated/mach_commands.py
+++ b/devtools/shared/css/generated/mach_commands.py
@@ -36,38 +36,23 @@ def stringify(obj):
class MachCommands(MachCommandBase):
@Command(
'devtools-css-db', category='post-build',
description='Rebuild the devtool\'s static css properties database.')
def generate_css_db(self):
"""Generate the static css properties database for devtools and write it to file."""
print("Re-generating the css properties database...")
- preferences = self.get_preferences()
db = self.get_properties_db_from_xpcshell()
self.output_template({
- 'preferences': stringify(preferences),
+ 'preferences': stringify(db['preferences']),
'cssProperties': stringify(db['cssProperties']),
'pseudoElements': stringify(db['pseudoElements'])})
- def get_preferences(self):
- """Get all of the preferences associated with enabling and disabling a property."""
- # The data takes the following form:
- # [ (name, prop, id, flags, pref, proptype), ... ]
- dataPath = resolve_path(self.topobjdir, 'layout/style/ServoCSSPropList.py')
- data = runpy.run_path(dataPath)['data']
-
- # Map this list
- preferences = [
- (p.name, p.pref) for p in data
- if 'CSSPropFlags::Internal' not in p.flags and p.pref]
-
- return preferences
-
def get_properties_db_from_xpcshell(self):
"""Generate the static css properties db for devtools from an xpcshell script."""
build = MozbuildObject.from_environment()
# Get the paths
script_path = resolve_path(self.topsrcdir,
'devtools/shared/css/generated/generate-properties-db.js')
gre_path = resolve_path(self.topobjdir, 'dist/bin')