Bug 1465628 part 3 - Generate preference list from inspector utils. r?tromey draft
authorXidorn Quan <me@upsuper.org>
Thu, 31 May 2018 15:36:33 +1000
changeset 803957 31c0364198569aa71d19a00fd55fe69ff4814726
parent 803956 8b16a81b7d10dda5c84971bd61ad48d04ad9400c
child 803958 05ad81a29f7f621e4125d5153d6c8e272b710a6e
push id112243
push userxquan@mozilla.com
push dateTue, 05 Jun 2018 04:32:37 +0000
reviewerstromey
bugs1465628
milestone62.0a1
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')