Bug 1465628 part 3 - Generate preference list from inspector utils. r=tromey
authorXidorn Quan <me@upsuper.org>
Thu, 31 May 2018 15:36:33 +1000
changeset 421243 2ce03f7e1d5b01788d612f8b7a5b625f93fbe167
parent 421242 017d65a99eabff0bc9b86a38cbcfe375d4686c9b
child 421244 425391ffe743954234da00734d1f86e784c730e5
push id64841
push userxquan@mozilla.com
push dateTue, 05 Jun 2018 04:35:02 +0000
treeherderautoland@425391ffe743 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1465628
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1465628 part 3 - Generate preference list from inspector utils. r=tromey MozReview-Commit-ID: 5EK7Vhn0rrG
devtools/shared/css/generated/generate-properties-db.js
devtools/shared/css/generated/mach_commands.py
--- 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')