From 2fe625751b6a35a935fcd546ba993bab9c159ff7 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 20 Apr 2018 13:42:14 +1000 Subject: [PATCH] Bug 1448757 part 1 - Add more filters for InspectorUtils.getCSSPropertyNames. r=heycam MozReview-Commit-ID: 4io5CRLE7op --HG-- extra : rebase_source : bcb3fe53647ee3c0526decff7ad30ac7da0b11d6 --- dom/chrome-webidl/InspectorUtils.webidl | 2 ++ layout/inspector/InspectorUtils.cpp | 31 ++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dom/chrome-webidl/InspectorUtils.webidl b/dom/chrome-webidl/InspectorUtils.webidl index c1a96f6a9ff0..07292e4ec781 100644 --- a/dom/chrome-webidl/InspectorUtils.webidl +++ b/dom/chrome-webidl/InspectorUtils.webidl @@ -88,6 +88,8 @@ namespace InspectorUtils { dictionary PropertyNamesOptions { boolean includeAliases = false; + boolean includeShorthands = true; + boolean includeExperimentals = false; }; dictionary InspectorRGBATuple { diff --git a/layout/inspector/InspectorUtils.cpp b/layout/inspector/InspectorUtils.cpp index 3c23e19ca369..418bbcba2a73 100644 --- a/layout/inspector/InspectorUtils.cpp +++ b/layout/inspector/InspectorUtils.cpp @@ -369,34 +369,37 @@ InspectorUtils::GetCSSPropertyNames(GlobalObject& aGlobalObject, const PropertyNamesOptions& aOptions, nsTArray& 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& aArray,