Bug 1465628 part 3 - Generate preference list from inspector utils. r=tromey
☠☠ backed out by a9e6e98ff2c2 ☠ ☠
authorXidorn Quan <me@upsuper.org>
Thu, 31 May 2018 15:36:33 +1000
changeset 421316 e9cdff1227930054a35a2af291a3f945b99f5e08
parent 421315 6832baa28e3fa16dc59480f9f475a85e6aca65c3
child 421317 04f276eb2f0ea509ded9f185c0f3287ba3b91b87
push id34091
push userbtara@mozilla.com
push dateTue, 05 Jun 2018 13:52:34 +0000
treeherdermozilla-central@752465b44c79 [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();
+  let result = [];
+  for (let {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')