Bug 1448757 part 1 - Add more filters for InspectorUtils.getCSSPropertyNames. r=heycam
authorXidorn Quan <me@upsuper.org>
Fri, 20 Apr 2018 13:42:14 +1000
changeset 468191 e7cdcd1099382abb0d3557e23ee2738758ca2125
parent 468190 af9e7a50afc5f06982c6e6f1bda0147884b4e56c
child 468192 616bbf7a88158aa859ec2b6de12aebd1b090eaf1
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1448757
milestone61.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 1448757 part 1 - Add more filters for InspectorUtils.getCSSPropertyNames. r=heycam MozReview-Commit-ID: 4io5CRLE7op
dom/chrome-webidl/InspectorUtils.webidl
layout/inspector/InspectorUtils.cpp
--- a/dom/chrome-webidl/InspectorUtils.webidl
+++ b/dom/chrome-webidl/InspectorUtils.webidl
@@ -83,16 +83,18 @@ namespace InspectorUtils {
   boolean hasPseudoClassLock(Element element, DOMString pseudoClass);
   void clearPseudoClassLocks(Element element);
   [Throws] void parseStyleSheet(CSSStyleSheet sheet, DOMString input);
   void scrollElementIntoView(Element element);
 };
 
 dictionary PropertyNamesOptions {
   boolean includeAliases = false;
+  boolean includeShorthands = true;
+  boolean includeExperimentals = false;
 };
 
 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.
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -364,44 +364,47 @@ InspectorUtils::IsInheritedProperty(Glob
   return Servo_Property_IsInherited(&propName);
 }
 
 /* static */ void
 InspectorUtils::GetCSSPropertyNames(GlobalObject& aGlobalObject,
                                     const PropertyNamesOptions& aOptions,
                                     nsTArray<nsString>& aResult)
 {
-#define DO_PROP(_prop)                                                      \
-  PR_BEGIN_MACRO                                                            \
-    nsCSSPropertyID cssProp = nsCSSPropertyID(_prop);                       \
-    if (nsCSSProps::IsEnabled(cssProp, CSSEnabledState::eForAllContent)) {  \
-      nsDependentCString name(kCSSRawProperties[_prop]);                    \
-      aResult.AppendElement(NS_ConvertASCIItoUTF16(name));                  \
-    }                                                                       \
-  PR_END_MACRO
+  CSSEnabledState enabledState = aOptions.mIncludeExperimentals
+    ? CSSEnabledState::eIgnoreEnabledState
+    : CSSEnabledState::eForAllContent;
+
+  auto appendProperty = [enabledState, &aResult](uint32_t prop) {
+    nsCSSPropertyID cssProp = nsCSSPropertyID(prop);
+    if (nsCSSProps::IsEnabled(cssProp, enabledState)) {
+      nsDependentCString name(kCSSRawProperties[prop]);
+      aResult.AppendElement(NS_ConvertASCIItoUTF16(name));
+    }
+  };
 
   uint32_t prop = 0;
   for ( ; prop < eCSSProperty_COUNT_no_shorthands; ++prop) {
     if (nsCSSProps::PropertyParseType(nsCSSPropertyID(prop)) !=
         CSS_PROPERTY_PARSE_INACCESSIBLE) {
-      DO_PROP(prop);
+      appendProperty(prop);
     }
   }
 
-  for ( ; prop < eCSSProperty_COUNT; ++prop) {
-    DO_PROP(prop);
+  if (aOptions.mIncludeShorthands) {
+    for ( ; prop < eCSSProperty_COUNT; ++prop) {
+      appendProperty(prop);
+    }
   }
 
   if (aOptions.mIncludeAliases) {
     for (prop = eCSSProperty_COUNT; prop < eCSSProperty_COUNT_with_aliases; ++prop) {
-      DO_PROP(prop);
+      appendProperty(prop);
     }
   }
-
-#undef DO_PROP
 }
 
 static void InsertNoDuplicates(nsTArray<nsString>& aArray,
                                const nsAString& aString)
 {
   size_t i = aArray.IndexOfFirstElementGt(aString);
   if (i > 0 && aArray[i-1].Equals(aString)) {
     return;