Bug 1465628 part 2 - Add InspectorUtils API for getting property preferences. r=emilio
☠☠ backed out by a9e6e98ff2c2 ☠ ☠
authorXidorn Quan <me@upsuper.org>
Thu, 31 May 2018 14:11:01 +1000
changeset 804128 6832baa28e3fa16dc59480f9f475a85e6aca65c3
parent 804127 e5ac0c7a9fb49d3d011095283014bae7324361d0
child 804129 e9cdff1227930054a35a2af291a3f945b99f5e08
push id112312
push userbmo:standard8@mozilla.com
push dateTue, 05 Jun 2018 16:07:56 +0000
reviewersemilio
bugs1465628
milestone62.0a1
Bug 1465628 part 2 - Add InspectorUtils API for getting property preferences. r=emilio MozReview-Commit-ID: G3ZjnC4cTKD
dom/chrome-webidl/InspectorUtils.webidl
layout/inspector/InspectorUtils.cpp
layout/inspector/InspectorUtils.h
--- a/dom/chrome-webidl/InspectorUtils.webidl
+++ b/dom/chrome-webidl/InspectorUtils.webidl
@@ -28,16 +28,17 @@ namespace InspectorUtils {
                                              unsigned long selectorIndex);
   [Throws] boolean selectorMatchesElement(
       Element element,
       CSSStyleRule rule,
       unsigned long selectorIndex,
       [TreatNullAs=EmptyString] optional DOMString pseudo = "");
   boolean isInheritedProperty(DOMString property);
   sequence<DOMString> getCSSPropertyNames(optional PropertyNamesOptions options);
+  sequence<PropertyPref> getCSSPropertyPrefs();
   [Throws] sequence<DOMString> getCSSValuesForProperty(DOMString property);
   [Throws] DOMString rgbToColorName(octet r, octet g, octet b);
   InspectorRGBATuple? colorToRGBA(DOMString colorString);
   boolean isValidCSSColor(DOMString colorString);
   [Throws] sequence<DOMString> getSubpropertiesForCSSProperty(DOMString property);
   [Throws] boolean cssPropertyIsShorthand(DOMString property);
 
   // TODO: Change this to use an enum.
@@ -80,16 +81,21 @@ namespace InspectorUtils {
 };
 
 dictionary PropertyNamesOptions {
   boolean includeAliases = false;
   boolean includeShorthands = true;
   boolean includeExperimentals = false;
 };
 
+dictionary PropertyPref {
+  required DOMString name;
+  required DOMString pref;
+};
+
 dictionary InspectorRGBATuple {
   /*
    * NOTE: This tuple is in the normal 0-255-sized RGB space but can be
    * fractional and may extend outside the 0-255 range.
    *
    * a is in the range 0 - 1.
    */
   double r = 0;
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -394,16 +394,29 @@ InspectorUtils::GetCSSPropertyNames(Glob
   if (aOptions.mIncludeAliases) {
     for (prop = eCSSProperty_COUNT; prop < eCSSProperty_COUNT_with_aliases; ++prop) {
       appendProperty(prop);
     }
   }
 }
 
 /* static */ void
+InspectorUtils::GetCSSPropertyPrefs(GlobalObject& aGlobalObject,
+                                    nsTArray<PropertyPref>& aResult)
+{
+  for (const auto* src = nsCSSProps::kPropertyPrefTable;
+       src->mPropID != eCSSProperty_UNKNOWN; src++) {
+    PropertyPref& dest = *aResult.AppendElement();
+    const nsCString& name = nsCSSProps::GetStringValue(src->mPropID);
+    dest.mName.Assign(NS_ConvertASCIItoUTF16(name));
+    dest.mPref.AssignASCII(src->mPref);
+  }
+}
+
+/* static */ void
 InspectorUtils::GetSubpropertiesForCSSProperty(GlobalObject& aGlobal,
                                                const nsAString& aProperty,
                                                nsTArray<nsString>& aResult,
                                                ErrorResult& aRv)
 {
   nsCSSPropertyID propertyID =
     nsCSSProps::LookupProperty(aProperty, CSSEnabledState::eForAllContent);
 
--- a/layout/inspector/InspectorUtils.h
+++ b/layout/inspector/InspectorUtils.h
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 #ifndef mozilla_dom_InspectorUtils_h
 #define mozilla_dom_InspectorUtils_h
 
-#include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/dom/InspectorUtilsBinding.h"
 
 class nsAtom;
 class nsIDocument;
 class ComputedStyle;
 
 namespace mozilla {
 class StyleSheet;
 namespace css {
@@ -109,16 +109,21 @@ public:
                                   const nsAString& aPropertyName);
 
   // Get a list of all our supported property names.  Optionally
   // property aliases included.
   static void GetCSSPropertyNames(GlobalObject& aGlobal,
                                   const PropertyNamesOptions& aOptions,
                                   nsTArray<nsString>& aResult);
 
+  // Get a list of all properties controlled by preference, as well as
+  // their corresponding preference names.
+  static void GetCSSPropertyPrefs(GlobalObject& aGlobal,
+                                  nsTArray<PropertyPref>& aResult);
+
   // Get a list of all valid keywords and colors for aProperty.
   static void GetCSSValuesForProperty(GlobalObject& aGlobal,
                                       const nsAString& aPropertyName,
                                       nsTArray<nsString>& aResult,
                                       ErrorResult& aRv);
 
   // Utilities for working with CSS colors
   static void RgbToColorName(GlobalObject& aGlobal,