diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp index bb35dd461519..d0b3d72776b3 100644 --- a/dom/animation/KeyframeUtils.cpp +++ b/dom/animation/KeyframeUtils.cpp @@ -101,7 +101,7 @@ public: if (mSubpropertyCount[aProperty] == 0) { uint32_t count = 0; CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES( - p, aProperty, nsCSSProps::eEnabledForAllContent) { + p, aProperty, CSSEnabledState::eForAllContent) { ++count; } mSubpropertyCount[aProperty] = count; @@ -492,13 +492,13 @@ KeyframeUtils::GetAnimationPropertiesFromKeyframes( if (nsCSSProps::IsShorthand(pair.mProperty)) { nsCSSValueTokenStream* tokenStream = pair.mValue.GetTokenStreamValue(); if (!StyleAnimationValue::ComputeValues(pair.mProperty, - nsCSSProps::eEnabledForAllContent, aElement, aStyleContext, + CSSEnabledState::eForAllContent, aElement, aStyleContext, tokenStream->mTokenStream, /* aUseSVGMode */ false, values)) { continue; } } else { if (!StyleAnimationValue::ComputeValues(pair.mProperty, - nsCSSProps::eEnabledForAllContent, aElement, aStyleContext, + CSSEnabledState::eForAllContent, aElement, aStyleContext, pair.mValue, /* aUseSVGMode */ false, values)) { continue; } @@ -695,7 +695,7 @@ GetPropertyValuesPairs(JSContext* aCx, } nsCSSProperty property = nsCSSProps::LookupPropertyByIDLName(propName, - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); if (property != eCSSProperty_UNKNOWN && (nsCSSProps::IsShorthand(property) || nsCSSProps::kAnimTypeTable[property] != eStyleAnimType_None)) { @@ -1110,7 +1110,7 @@ RequiresAdditiveAnimation(const nsTArray& aKeyframes, continue; } CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES( - prop, pair.mProperty, nsCSSProps::eEnabledForAllContent) { + prop, pair.mProperty, CSSEnabledState::eForAllContent) { addToPropertySets(*prop, offsetToUse); } } else { diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 69493051d60c..46119cae3b79 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2503,7 +2503,7 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement, NS_ENSURE_SUCCESS(rv, rv); nsCSSProperty property = - nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState); + nsCSSProps::LookupProperty(aProperty, CSSEnabledState::eIgnoreEnabledState); if (property != eCSSProperty_UNKNOWN && nsCSSProps::IsShorthand(property)) { property = eCSSProperty_UNKNOWN; } diff --git a/dom/smil/nsSMILAnimationController.cpp b/dom/smil/nsSMILAnimationController.cpp index a3b51170bc93..eb19386806ab 100644 --- a/dom/smil/nsSMILAnimationController.cpp +++ b/dom/smil/nsSMILAnimationController.cpp @@ -686,7 +686,7 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation( } else { nsCSSProperty prop = nsCSSProps::LookupProperty(nsDependentAtomString(attributeName), - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop); } } diff --git a/dom/smil/nsSMILCompositor.cpp b/dom/smil/nsSMILCompositor.cpp index 34ac388ad609..f64a2efbf379 100644 --- a/dom/smil/nsSMILCompositor.cpp +++ b/dom/smil/nsSMILCompositor.cpp @@ -126,7 +126,7 @@ nsSMILCompositor::CreateSMILAttr() if (mKey.mIsCSS) { nsCSSProperty propId = nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName), - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); if (nsSMILCSSProperty::IsPropertyAnimatable(propId)) { return new nsSMILCSSProperty(propId, mKey.mElement.get()); } diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp index 1605719f75a6..e068c58fb8d9 100644 --- a/dom/svg/nsSVGElement.cpp +++ b/dom/svg/nsSVGElement.cpp @@ -1186,7 +1186,7 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName, // Get the nsCSSProperty ID for our mapped attribute. nsCSSProperty propertyID = nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName), - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); if (propertyID != eCSSProperty_UNKNOWN) { bool changed = false; // outparam for ParseProperty. mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI, @@ -1196,7 +1196,7 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName, // since it doesn't have a sheet. if (nsCSSProps::IsShorthand(propertyID)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, propertyID, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { UseCounter useCounter = nsCSSProps::UseCounterFor(*subprop); if (useCounter != eUseCounter_UNKNOWN) { mElement->OwnerDoc()->SetDocumentAndPageUseCounter(useCounter); @@ -2544,7 +2544,7 @@ nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName) if (IsAttributeMapped(aName)) { nsCSSProperty prop = nsCSSProps::LookupProperty(nsDependentAtomString(aName), - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); // Check IsPropertyAnimatable to avoid attributes that... // - map to explicitly unanimatable properties (e.g. 'direction') // - map to unsupported attributes (e.g. 'glyph-orientation-horizontal') diff --git a/editor/libeditor/nsHTMLCSSUtils.cpp b/editor/libeditor/nsHTMLCSSUtils.cpp index d86bbc740dbc..bee4dceaba08 100644 --- a/editor/libeditor/nsHTMLCSSUtils.cpp +++ b/editor/libeditor/nsHTMLCSSUtils.cpp @@ -522,7 +522,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty, } nsCSSProperty prop = nsCSSProps::LookupProperty(nsDependentAtomString(aProperty), - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); MOZ_ASSERT(prop != eCSSProperty_UNKNOWN); decl->GetValue(prop, aValue); diff --git a/layout/inspector/inCSSValueSearch.cpp b/layout/inspector/inCSSValueSearch.cpp index d8a770519b05..3beb3789a595 100644 --- a/layout/inspector/inCSSValueSearch.cpp +++ b/layout/inspector/inCSSValueSearch.cpp @@ -224,7 +224,7 @@ inCSSValueSearch::AddPropertyCriteria(const char16_t *aPropName) { nsCSSProperty prop = nsCSSProps::LookupProperty(nsDependentString(aPropName), - nsCSSProps::eIgnoreEnabledState); + CSSEnabledState::eIgnoreEnabledState); mProperties[mPropertyCount] = prop; mPropertyCount++; return NS_OK; diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index 0641e6d1aac1..be614156ff49 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -485,8 +485,8 @@ inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement, NS_IMETHODIMP inDOMUtils::IsInheritedProperty(const nsAString &aPropertyName, bool *_retval) { - nsCSSProperty prop = - nsCSSProps::LookupProperty(aPropertyName, nsCSSProps::eIgnoreEnabledState); + nsCSSProperty prop = nsCSSProps:: + LookupProperty(aPropertyName, CSSEnabledState::eIgnoreEnabledState); if (prop == eCSSProperty_UNKNOWN) { *_retval = false; return NS_OK; @@ -528,14 +528,14 @@ inDOMUtils::GetCSSPropertyNames(uint32_t aFlags, uint32_t* aCount, char16_t** props = static_cast(moz_xmalloc(maxCount * sizeof(char16_t*))); -#define DO_PROP(_prop) \ - PR_BEGIN_MACRO \ - nsCSSProperty cssProp = nsCSSProperty(_prop); \ - if (nsCSSProps::IsEnabled(cssProp, nsCSSProps::eEnabledForAllContent)) { \ - props[propCount] = \ - ToNewUnicode(nsDependentCString(kCSSRawProperties[_prop])); \ - ++propCount; \ - } \ +#define DO_PROP(_prop) \ + PR_BEGIN_MACRO \ + nsCSSProperty cssProp = nsCSSProperty(_prop); \ + if (nsCSSProps::IsEnabled(cssProp, CSSEnabledState::eForAllContent)) { \ + props[propCount] = \ + ToNewUnicode(nsDependentCString(kCSSRawProperties[_prop])); \ + ++propCount; \ + } \ PR_END_MACRO // prop is the property id we're considering; propCount is how many properties @@ -674,7 +674,7 @@ inDOMUtils::GetSubpropertiesForCSSProperty(const nsAString& aProperty, char16_t*** aValues) { nsCSSProperty propertyID = - nsCSSProps::LookupProperty(aProperty, nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aProperty, CSSEnabledState::eForAllContent); if (propertyID == eCSSProperty_UNKNOWN) { return NS_ERROR_FAILURE; @@ -716,7 +716,7 @@ NS_IMETHODIMP inDOMUtils::CssPropertyIsShorthand(const nsAString& aProperty, bool *_retval) { nsCSSProperty propertyID = - nsCSSProps::LookupProperty(aProperty, nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aProperty, CSSEnabledState::eForAllContent); if (propertyID == eCSSProperty_UNKNOWN) { return NS_ERROR_FAILURE; } @@ -861,7 +861,7 @@ inDOMUtils::CssPropertySupportsType(const nsAString& aProperty, uint32_t aType, bool *_retval) { nsCSSProperty propertyID = - nsCSSProps::LookupProperty(aProperty, nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aProperty, CSSEnabledState::eForAllContent); if (propertyID == eCSSProperty_UNKNOWN) { return NS_ERROR_FAILURE; } @@ -921,8 +921,8 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty, uint32_t* aLength, char16_t*** aValues) { - nsCSSProperty propertyID = nsCSSProps::LookupProperty(aProperty, - nsCSSProps::eEnabledForAllContent); + nsCSSProperty propertyID = nsCSSProps:: + LookupProperty(aProperty, CSSEnabledState::eForAllContent); if (propertyID == eCSSProperty_UNKNOWN) { return NS_ERROR_FAILURE; } @@ -944,7 +944,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty, } else { // Property is shorthand. CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { // Get colors (once) first. uint32_t propertyParserVariant = nsCSSProps::ParserVariant(*subproperty); if (propertyParserVariant & VARIANT_COLOR) { @@ -953,7 +953,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty, } } CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { uint32_t propertyParserVariant = nsCSSProps::ParserVariant(*subproperty); if (propertyParserVariant & VARIANT_KEYWORD) { GetKeywordsForProperty(*subproperty, array); @@ -1056,8 +1056,8 @@ inDOMUtils::CssPropertyIsValid(const nsAString& aPropertyName, const nsAString& aPropertyValue, bool *_retval) { - nsCSSProperty propertyID = - nsCSSProps::LookupProperty(aPropertyName, nsCSSProps::eIgnoreEnabledState); + nsCSSProperty propertyID = nsCSSProps:: + LookupProperty(aPropertyName, CSSEnabledState::eIgnoreEnabledState); if (propertyID == eCSSProperty_UNKNOWN) { *_retval = false; diff --git a/layout/style/CSSEnabledState.h b/layout/style/CSSEnabledState.h new file mode 100644 index 000000000000..650397072ad8 --- /dev/null +++ b/layout/style/CSSEnabledState.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +/* + * enum for whether a CSS feature (property, pseudo-class, etc.) is + * enabled in a specific context + */ + +#ifndef mozilla_CSSEnabledState_h +#define mozilla_CSSEnabledState_h + +#include "mozilla/TypedEnumBits.h" + +namespace mozilla { + +enum class CSSEnabledState +{ + // The default CSSEnabledState: only enable what's enabled for all + // content, given the current values of preferences. + eForAllContent = 0, + // Enable features available in UA sheets. + eInUASheets = 0x01, + // Enable features available in chrome code. + eInChrome = 0x02, + // Special value to unconditionally enable everything. This implies + // all the bits above, but is strictly more than just their OR-ed + // union. This just skips any test so a feature will be enabled even + // if it would have been disabled with all the bits above set. + eIgnoreEnabledState = 0xff +}; + +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CSSEnabledState) + +} // namespace mozilla + +#endif // mozilla_CSSEnabledState_h diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index 30358221a371..12f02252d256 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -146,7 +146,7 @@ Declaration::RemoveProperty(nsCSSProperty aProperty) if (nsCSSProps::IsShorthand(aProperty)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { data.ClearLonghandProperty(*p); mOrder.RemoveElement(static_cast(*p)); } @@ -512,7 +512,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue, initialCount = 0, inheritCount = 0, unsetCount = 0, matchingTokenStreamCount = 0, nonMatchingTokenStreamCount = 0; CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { if (*p == eCSSProperty__x_system_font) { // The system-font subproperty doesn't count. continue; @@ -1432,8 +1432,8 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue, bool Declaration::GetValueIsImportant(const nsAString& aProperty) const { - nsCSSProperty propID = - nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState); + nsCSSProperty propID = nsCSSProps:: + LookupProperty(aProperty, CSSEnabledState::eIgnoreEnabledState); if (propID == eCSSProperty_UNKNOWN) { return false; } @@ -1458,7 +1458,7 @@ Declaration::GetValueIsImportant(nsCSSProperty aProperty) const } CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { if (*p == eCSSProperty__x_system_font) { // The system_font subproperty doesn't count. continue; @@ -1572,7 +1572,7 @@ Declaration::ToString(nsAString& aString) const continue; } - if (!nsCSSProps::IsEnabled(property, nsCSSProps::eEnabledForAllContent)) { + if (!nsCSSProps::IsEnabled(property, CSSEnabledState::eForAllContent)) { continue; } bool doneProperty = false; diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 0792b66fabb3..63324facf1fb 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -2821,7 +2821,7 @@ BuildStyleRule(nsCSSProperty aProperty, static bool ComputeValuesFromStyleRule(nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + CSSEnabledState aEnabledState, dom::Element* aTargetElement, nsStyleContext* aStyleContext, css::StyleRule* aStyleRule, @@ -2942,7 +2942,7 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty, AutoTArray values; bool ok = ComputeValuesFromStyleRule(aProperty, - nsCSSProps::eIgnoreEnabledState, + CSSEnabledState::eIgnoreEnabledState, aTargetElement, aStyleContext, styleRule, values, aIsContextSensitive); if (!ok) { @@ -2960,7 +2960,7 @@ template bool ComputeValuesFromSpecifiedValue( nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + CSSEnabledState aEnabledState, dom::Element* aTargetElement, nsStyleContext* aStyleContext, T& aSpecifiedValue, @@ -2988,7 +2988,7 @@ ComputeValuesFromSpecifiedValue( /* static */ bool StyleAnimationValue::ComputeValues( nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + CSSEnabledState aEnabledState, dom::Element* aTargetElement, nsStyleContext* aStyleContext, const nsAString& aSpecifiedValue, @@ -3004,7 +3004,7 @@ StyleAnimationValue::ComputeValues( /* static */ bool StyleAnimationValue::ComputeValues( nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + CSSEnabledState aEnabledState, dom::Element* aTargetElement, nsStyleContext* aStyleContext, const nsCSSValue& aSpecifiedValue, diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h index 960328b49383..7e26a395b70b 100644 --- a/layout/style/StyleAnimationValue.h +++ b/layout/style/StyleAnimationValue.h @@ -176,7 +176,7 @@ public: * in it. */ static bool ComputeValues(nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + mozilla::CSSEnabledState aEnabledState, mozilla::dom::Element* aTargetElement, nsStyleContext* aStyleContext, const nsAString& aSpecifiedValue, @@ -188,7 +188,7 @@ public: * value. Only longhand properties are supported. */ static bool ComputeValues(nsCSSProperty aProperty, - nsCSSProps::EnabledState aEnabledState, + mozilla::CSSEnabledState aEnabledState, mozilla::dom::Element* aTargetElement, nsStyleContext* aStyleContext, const nsCSSValue& aSpecifiedValue, diff --git a/layout/style/moz.build b/layout/style/moz.build index ba5a97b16e13..3387cab89ade 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -81,6 +81,7 @@ EXPORTS += [ EXPORTS.mozilla += [ 'AnimationCollection.h', + 'CSSEnabledState.h', 'CSSStyleSheet.h', 'CSSVariableDeclarations.h', 'CSSVariableResolver.h', diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp index 2bdbb189571e..ac88d95aaf2d 100644 --- a/layout/style/nsCSSDataBlock.cpp +++ b/layout/style/nsCSSDataBlock.cpp @@ -623,8 +623,8 @@ void nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID) { if (nsCSSProps::IsShorthand(aPropID)) { - CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, - nsCSSProps::eIgnoreEnabledState) { + CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES( + p, aPropID, CSSEnabledState::eIgnoreEnabledState) { ClearLonghandProperty(*p); } } else { @@ -645,7 +645,7 @@ nsCSSExpandedDataBlock::ClearLonghandProperty(nsCSSProperty aPropID) bool nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock, nsCSSProperty aPropID, - nsCSSProps::EnabledState aEnabledState, + CSSEnabledState aEnabledState, bool aIsImportant, bool aOverrideImportant, bool aMustCallValueAppended, @@ -659,11 +659,11 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock, aSheetDocument); } - // We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather - // than a value corresponding to whether we're parsing a UA style sheet or - // certified app because we assert in nsCSSProps::AddRefTable that shorthand - // properties available in these contexts also have all of their - // subproperties available in these contexts. + // We can pass CSSEnabledState::eIgnore (here, and in ClearProperty + // above) rather than a value corresponding to whether we're parsing + // a UA style sheet or certified app because we assert in nsCSSProps:: + // AddRefTable that shorthand properties available in these contexts + // also have all of their subproperties available in these contexts. bool changed = false; CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) { changed |= DoTransferFromBlock(aFromBlock, *p, diff --git a/layout/style/nsCSSDataBlock.h b/layout/style/nsCSSDataBlock.h index 67b53eddbc47..33f30230f0d1 100644 --- a/layout/style/nsCSSDataBlock.h +++ b/layout/style/nsCSSDataBlock.h @@ -264,7 +264,7 @@ public: */ bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock, nsCSSProperty aPropID, - nsCSSProps::EnabledState aEnabledState, + mozilla::CSSEnabledState aEnabledState, bool aIsImportant, bool aOverrideImportant, bool aMustCallValueAppended, diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index b89ee0e3ed3b..a0d833211349 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -356,16 +356,16 @@ public: mParsingMode == css::eUserSheetFeatures; } - nsCSSProps::EnabledState PropertyEnabledState() const { - static_assert(nsCSSProps::eEnabledForAllContent == 0, - "nsCSSProps::eEnabledForAllContent should be zero for " + CSSEnabledState PropertyEnabledState() const { + static_assert(int(CSSEnabledState::eForAllContent) == 0, + "CSSEnabledState::eForAllContent should be zero for " "this bitfield to work"); - nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent; + CSSEnabledState enabledState = CSSEnabledState::eForAllContent; if (AgentRulesEnabled()) { - enabledState |= nsCSSProps::eEnabledInUASheets; + enabledState |= CSSEnabledState::eInUASheets; } if (mIsChrome) { - enabledState |= nsCSSProps::eEnabledInChrome; + enabledState |= CSSEnabledState::eInChrome; } return enabledState; } @@ -17017,7 +17017,7 @@ CSSParserImpl::ParseAll() // instead of computing the correct EnabledState value we just expand out // to all content-visible properties. CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, eCSSProperty_all, - nsCSSProps::eEnabledForAllContent) { + CSSEnabledState::eForAllContent) { AppendValue(*p, value); } return true; diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index bab465782b84..d231c7a83996 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -538,13 +538,14 @@ nsCSSProps::LookupProperty(const nsACString& aProperty, } MOZ_ASSERT(eCSSAliasCount != 0, "'res' must be an alias at this point so we better have some!"); - // We intentionally don't support eEnabledInUASheets or eEnabledInChrome - // for aliases yet because it's unlikely there will be a need for it. - if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) { + // We intentionally don't support CSSEnabledState::eInUASheets or + // CSSEnabledState::eInChrome for aliases yet because it's unlikely + // there will be a need for it. + if (IsEnabled(res) || aEnabled == CSSEnabledState::eIgnoreEnabledState) { res = gAliases[res - eCSSProperty_COUNT]; MOZ_ASSERT(0 <= res && res < eCSSProperty_COUNT, "aliases must not point to other aliases"); - if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) { + if (IsEnabled(res) || aEnabled == CSSEnabledState::eIgnoreEnabledState) { return res; } } @@ -572,13 +573,14 @@ nsCSSProps::LookupProperty(const nsAString& aProperty, EnabledState aEnabled) } MOZ_ASSERT(eCSSAliasCount != 0, "'res' must be an alias at this point so we better have some!"); - // We intentionally don't support eEnabledInUASheets or eEnabledInChrome - // for aliases yet because it's unlikely there will be a need for it. - if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) { + // We intentionally don't support CSSEnabledState::eInUASheets or + // CSSEnabledState::eInChrome for aliases yet because it's unlikely + // there will be a need for it. + if (IsEnabled(res) || aEnabled == CSSEnabledState::eIgnoreEnabledState) { res = gAliases[res - eCSSProperty_COUNT]; MOZ_ASSERT(0 <= res && res < eCSSProperty_COUNT, "aliases must not point to other aliases"); - if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) { + if (IsEnabled(res) || aEnabled == CSSEnabledState::eIgnoreEnabledState) { return res; } } diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 9c8a68bb010f..6cd374a93a08 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -15,6 +15,7 @@ #include "nsCSSProperty.h" #include "nsStyleStructFwd.h" #include "nsCSSKeywords.h" +#include "mozilla/CSSEnabledState.h" #include "mozilla/UseCounter.h" // Length of the "--" prefix on custom names (such as custom property names, @@ -330,6 +331,8 @@ enum nsStyleAnimType { class nsCSSProps { public: + typedef mozilla::CSSEnabledState EnabledState; + struct KTableEntry { nsCSSKeyword mKeyword; int16_t mValue; @@ -338,21 +341,6 @@ public: static void AddRefTable(void); static void ReleaseTable(void); - enum EnabledState { - // The default EnabledState: only enable what's enabled for all content, - // given the current values of preferences. - eEnabledForAllContent = 0, - // Enable a property in UA sheets. - eEnabledInUASheets = 0x01, - // Enable a property in chrome code. - eEnabledInChrome = 0x02, - // Special value to unconditionally enable a property. This implies all the - // bits above, but is strictly more than just their OR-ed union. - // This just skips any test so a property will be enabled even if it would - // have been disabled with all the bits above set. - eIgnoreEnabledState = 0xff - }; - // Looks up the property with name aProperty and returns its corresponding // nsCSSProperty value. If aProperty is the name of a custom property, // then eCSSPropertyExtra_variable will be returned. @@ -624,15 +612,15 @@ public: if (IsEnabled(aProperty)) { return true; } - if (aEnabled == eIgnoreEnabledState) { + if (aEnabled == EnabledState::eIgnoreEnabledState) { return true; } - if ((aEnabled & eEnabledInUASheets) && + if ((aEnabled & EnabledState::eInUASheets) && PropHasFlags(aProperty, CSS_PROPERTY_ENABLED_IN_UA_SHEETS)) { return true; } - if ((aEnabled & eEnabledInChrome) && + if ((aEnabled & EnabledState::eInChrome) && PropHasFlags(aProperty, CSS_PROPERTY_ENABLED_IN_CHROME)) { return true; @@ -644,13 +632,13 @@ public: // Storing the enabledstate_ value in an nsCSSProperty variable is a small hack // to avoid needing a separate variable declaration for its real type -// (nsCSSProps::EnabledState), which would then require using a block and +// (CSSEnabledState), which would then require using a block and // therefore a pair of macros by consumers for the start and end of the loop. #define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(it_, prop_, enabledstate_) \ for (const nsCSSProperty *it_ = nsCSSProps::SubpropertyEntryFor(prop_), \ es_ = (nsCSSProperty) (enabledstate_); \ *it_ != eCSSProperty_UNKNOWN; ++it_) \ - if (nsCSSProps::IsEnabled(*it_, (nsCSSProps::EnabledState) es_)) + if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState) es_)) // Keyword/Enum value tables static const KTableEntry kAnimationDirectionKTable[]; @@ -840,28 +828,4 @@ public: static const KTableEntry kWritingModeKTable[]; }; -inline nsCSSProps::EnabledState operator|(nsCSSProps::EnabledState a, - nsCSSProps::EnabledState b) -{ - return nsCSSProps::EnabledState(int(a) | int(b)); -} - -inline nsCSSProps::EnabledState operator&(nsCSSProps::EnabledState a, - nsCSSProps::EnabledState b) -{ - return nsCSSProps::EnabledState(int(a) & int(b)); -} - -inline nsCSSProps::EnabledState& operator|=(nsCSSProps::EnabledState& a, - nsCSSProps::EnabledState b) -{ - return a = a | b; -} - -inline nsCSSProps::EnabledState& operator&=(nsCSSProps::EnabledState& a, - nsCSSProps::EnabledState b) -{ - return a = a & b; -} - #endif /* nsCSSProps_h___ */ diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index d5c8364e73c4..fab63d4c4a9f 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -98,8 +98,7 @@ struct nsComputedStyleMap bool IsEnabled() const { - return nsCSSProps::IsEnabled(mProperty, - nsCSSProps::eEnabledForAllContent); + return nsCSSProps::IsEnabled(mProperty, CSSEnabledState::eForAllContent); } }; @@ -765,8 +764,8 @@ nsComputedDOMStyle::ClearCurrentStyleSources() already_AddRefed nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorResult& aRv) { - nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName, - nsCSSProps::eEnabledForAllContent); + nsCSSProperty prop = + nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent); bool needsLayoutFlush; nsComputedStyleMap::Entry::ComputeMethod getter; diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index b5c36e1d5e58..5d1ae9df75eb 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -196,8 +196,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName, nsAString& aReturn) { const nsCSSProperty propID = - nsCSSProps::LookupProperty(aPropertyName, - nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent); if (propID == eCSSProperty_UNKNOWN) { aReturn.Truncate(); return NS_OK; @@ -216,8 +215,7 @@ nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName, nsAString& aReturn) { const nsCSSProperty propID = - nsCSSProps::LookupProperty(aPropertyName, - nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent); if (propID == eCSSProperty_UNKNOWN) { aReturn.Truncate(); return NS_OK; @@ -258,8 +256,7 @@ nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName, { // In the common (and fast) cases we can use the property id nsCSSProperty propID = - nsCSSProps::LookupProperty(aPropertyName, - nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent); if (propID == eCSSProperty_UNKNOWN) { return NS_OK; } @@ -295,8 +292,7 @@ nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName, nsAString& aReturn) { const nsCSSProperty propID = - nsCSSProps::LookupProperty(aPropertyName, - nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent); if (propID == eCSSProperty_UNKNOWN) { aReturn.Truncate(); return NS_OK; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 44f71e01d231..17d930f62c14 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -5393,7 +5393,7 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct, propertyStr(property.list->mValue.GetStringBufferValue()); nsCSSProperty prop = nsCSSProps::LookupProperty(propertyStr, - nsCSSProps::eEnabledForAllContent); + CSSEnabledState::eForAllContent); if (prop == eCSSProperty_UNKNOWN || prop == eCSSPropertyExtra_variable) { transition->SetUnknownProperty(prop, propertyStr); @@ -6197,8 +6197,7 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct, } nsCSSProperty prop = - nsCSSProps::LookupProperty(buffer, - nsCSSProps::eEnabledForAllContent); + nsCSSProps::LookupProperty(buffer, CSSEnabledState::eForAllContent); if (prop != eCSSProperty_UNKNOWN && prop != eCSSPropertyExtra_variable) { // If the property given is a shorthand, it indicates the expectation diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 0def395962bd..eb5df0ed02e6 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2740,7 +2740,7 @@ mozilla::StyleTransition::SetUnknownProperty(nsCSSProperty aProperty, const nsAString& aPropertyString) { MOZ_ASSERT(nsCSSProps::LookupProperty(aPropertyString, - nsCSSProps::eEnabledForAllContent) == + CSSEnabledState::eForAllContent) == aProperty, "property and property string should match"); MOZ_ASSERT(aProperty == eCSSProperty_UNKNOWN || diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index 29d4109ed98c..defa1dae365a 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -414,7 +414,7 @@ nsTransitionManager::UpdateTransitions( } } else if (nsCSSProps::IsShorthand(property)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property, - nsCSSProps::eEnabledForAllContent) + CSSEnabledState::eForAllContent) { ConsiderStartingTransition(*subprop, t, aElement, aElementTransitions, aOldStyleContext, aNewStyleContext, @@ -459,7 +459,7 @@ nsTransitionManager::UpdateTransitions( } } else if (nsCSSProps::IsShorthand(property)) { CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES( - subprop, property, nsCSSProps::eEnabledForAllContent) { + subprop, property, CSSEnabledState::eForAllContent) { allTransitionProperties.AddProperty(*subprop); } } else { @@ -530,7 +530,7 @@ nsTransitionManager::ConsiderStartingTransition( // Ignore disabled properties. We can arrive here if the transition-property // is 'all' and the disabled property has a default value which derives value // from another property, e.g. color. - if (!nsCSSProps::IsEnabled(aProperty, nsCSSProps::eEnabledForAllContent)) { + if (!nsCSSProps::IsEnabled(aProperty, CSSEnabledState::eForAllContent)) { return; } diff --git a/layout/style/test/TestCSSPropertyLookup.cpp b/layout/style/test/TestCSSPropertyLookup.cpp index 30e265888831..fc751d4fbc01 100644 --- a/layout/style/test/TestCSSPropertyLookup.cpp +++ b/layout/style/test/TestCSSPropertyLookup.cpp @@ -9,6 +9,8 @@ #include "nsString.h" #include "nsXPCOM.h" +using namespace mozilla; + static const char* const kJunkNames[] = { nullptr, "", @@ -41,7 +43,7 @@ TestProps() index = nsCSSProperty(int32_t(index) + 1); id = nsCSSProps::LookupProperty(nsCString(tagName), - nsCSSProps::eIgnoreEnabledState); + CSSEnabledState::eIgnoreEnabledState); if (id == eCSSProperty_UNKNOWN) { printf("bug: can't find '%s'\n", tagName); success = false; @@ -56,7 +58,7 @@ TestProps() tagName[0] = tagName[0] - 32; } id = nsCSSProps::LookupProperty(NS_ConvertASCIItoUTF16(tagName), - nsCSSProps::eIgnoreEnabledState); + CSSEnabledState::eIgnoreEnabledState); if (id < 0) { printf("bug: can't find '%s'\n", tagName); success = false; @@ -72,7 +74,7 @@ TestProps() for (int i = 0; i < (int) (sizeof(kJunkNames) / sizeof(const char*)); i++) { const char* const tag = kJunkNames[i]; id = nsCSSProps::LookupProperty(nsAutoCString(tag), - nsCSSProps::eIgnoreEnabledState); + CSSEnabledState::eIgnoreEnabledState); if (id >= 0) { printf("bug: found '%s'\n", tag ? tag : "(null)"); success = false;