зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1269975 part 1 - Move nsCSSProps::EnabledState to a top level enum class mozilla::CSSEnabledState. r=heycam
MozReview-Commit-ID: 3KH5cqDFzUI --HG-- extra : rebase_source : 3c8355f7807982152a16a913b31cbcdd6ef78030 extra : source : 73e89d25a34ca5587f306b848b0b801342f9432f
This commit is contained in:
Родитель
a0d82b351a
Коммит
fa7ba2cb82
|
@ -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<Keyframe>& aKeyframes,
|
|||
continue;
|
||||
}
|
||||
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
|
||||
prop, pair.mProperty, nsCSSProps::eEnabledForAllContent) {
|
||||
prop, pair.mProperty, CSSEnabledState::eForAllContent) {
|
||||
addToPropertySets(*prop, offsetToUse);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -686,7 +686,7 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation(
|
|||
} else {
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName),
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
CSSEnabledState::eForAllContent);
|
||||
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<char16_t**>(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;
|
||||
|
|
|
@ -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
|
|
@ -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<uint32_t>(*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;
|
||||
|
|
|
@ -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<PropertyStyleAnimationValuePair,1> values;
|
||||
bool ok = ComputeValuesFromStyleRule(aProperty,
|
||||
nsCSSProps::eIgnoreEnabledState,
|
||||
CSSEnabledState::eIgnoreEnabledState,
|
||||
aTargetElement, aStyleContext, styleRule,
|
||||
values, aIsContextSensitive);
|
||||
if (!ok) {
|
||||
|
@ -2960,7 +2960,7 @@ template <class T>
|
|||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -81,6 +81,7 @@ EXPORTS += [
|
|||
|
||||
EXPORTS.mozilla += [
|
||||
'AnimationCollection.h',
|
||||
'CSSEnabledState.h',
|
||||
'CSSStyleSheet.h',
|
||||
'CSSVariableDeclarations.h',
|
||||
'CSSVariableResolver.h',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -264,7 +264,7 @@ public:
|
|||
*/
|
||||
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
|
||||
nsCSSProperty aPropID,
|
||||
nsCSSProps::EnabledState aEnabledState,
|
||||
mozilla::CSSEnabledState aEnabledState,
|
||||
bool aIsImportant,
|
||||
bool aOverrideImportant,
|
||||
bool aMustCallValueAppended,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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___ */
|
||||
|
|
|
@ -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<CSSValue>
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче