mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 977757 - 1/3 - make nsCSSProps::EnabledState a bitfield - r=dbaron,bz
This commit is contained in:
parent
2e28589dc1
commit
52d36cb055
@ -1205,7 +1205,7 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
|
||||
// Get the nsCSSProperty ID for our mapped attribute.
|
||||
nsCSSProperty propertyID =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName),
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propertyID != eCSSProperty_UNKNOWN) {
|
||||
bool changed; // outparam for ParseProperty. (ignored)
|
||||
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
|
||||
@ -2539,7 +2539,7 @@ nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName)
|
||||
if (IsAttributeMapped(aName)) {
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(aName),
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
// Check IsPropertyAnimatable to avoid attributes that...
|
||||
// - map to explicitly unanimatable properties (e.g. 'direction')
|
||||
// - map to unsupported attributes (e.g. 'glyph-orientation-horizontal')
|
||||
|
@ -2617,8 +2617,8 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
|
||||
|
||||
// Convert direction-dependent properties as appropriate, e.g.,
|
||||
// border-left to border-left-value.
|
||||
nsCSSProperty property = nsCSSProps::LookupProperty(aProperty,
|
||||
nsCSSProps::eAny);
|
||||
nsCSSProperty property =
|
||||
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
|
||||
if (property != eCSSProperty_UNKNOWN && nsCSSProps::IsShorthand(property)) {
|
||||
nsCSSProperty subprop0 = *nsCSSProps::SubpropertyEntryFor(property);
|
||||
if (nsCSSProps::PropHasFlags(subprop0, CSS_PROPERTY_REPORT_OTHER_NAME) &&
|
||||
|
@ -794,7 +794,7 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation(
|
||||
} else {
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName),
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ nsSMILCompositor::CreateSMILAttr()
|
||||
if (mKey.mIsCSS) {
|
||||
nsCSSProperty propId =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName),
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (nsSMILCSSProperty::IsPropertyAnimatable(propId)) {
|
||||
return new nsSMILCSSProperty(propId, mKey.mElement.get());
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
|
||||
}
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(aProperty),
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
MOZ_ASSERT(prop != eCSSProperty_UNKNOWN);
|
||||
rule->GetDeclaration()->GetValue(prop, aValue);
|
||||
|
||||
|
@ -227,7 +227,7 @@ inCSSValueSearch::AddPropertyCriteria(const char16_t *aPropName)
|
||||
{
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentString(aPropName),
|
||||
nsCSSProps::eAny);
|
||||
nsCSSProps::eIgnoreEnabledState);
|
||||
mProperties[mPropertyCount] = prop;
|
||||
mPropertyCount++;
|
||||
return NS_OK;
|
||||
|
@ -383,8 +383,8 @@ inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement,
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::IsInheritedProperty(const nsAString &aPropertyName, bool *_retval)
|
||||
{
|
||||
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eAny);
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(aPropertyName, nsCSSProps::eIgnoreEnabledState);
|
||||
if (prop == eCSSProperty_UNKNOWN) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
@ -565,7 +565,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
|
||||
char16_t*** aValues)
|
||||
{
|
||||
nsCSSProperty propertyID = nsCSSProps::LookupProperty(aProperty,
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propertyID == eCSSProperty_UNKNOWN) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -959,7 +959,8 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
|
||||
bool
|
||||
Declaration::GetValueIsImportant(const nsAString& aProperty) const
|
||||
{
|
||||
nsCSSProperty propID = nsCSSProps::LookupProperty(aProperty, nsCSSProps::eAny);
|
||||
nsCSSProperty propID =
|
||||
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
|
||||
if (propID == eCSSProperty_UNKNOWN) {
|
||||
return false;
|
||||
}
|
||||
|
@ -248,9 +248,14 @@ public:
|
||||
uint32_t aLineOffset);
|
||||
|
||||
nsCSSProperty LookupEnabledProperty(const nsAString& aProperty) {
|
||||
return nsCSSProps::LookupProperty(aProperty, mUnsafeRulesEnabled ?
|
||||
nsCSSProps::eEnabledInUASheets :
|
||||
nsCSSProps::eEnabled);
|
||||
static_assert(nsCSSProps::eEnabledForAllContent == 0,
|
||||
"nsCSSProps::eEnabledForAllContent should be zero for "
|
||||
"this bitfield to work");
|
||||
nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent;
|
||||
if (mUnsafeRulesEnabled) {
|
||||
enabledState |= nsCSSProps::eEnabledInUASheets;
|
||||
}
|
||||
return nsCSSProps::LookupProperty(aProperty, enabledState);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -395,13 +395,13 @@ 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 for aliases yet
|
||||
// because it's unlikely there will be a need for it.
|
||||
if (IsEnabled(res) || aEnabled == eAny) {
|
||||
// We intentionally don't support eEnabledInUASheets
|
||||
// for aliases yet because it's unlikely there will be a need for it.
|
||||
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
|
||||
res = gAliases[res - eCSSProperty_COUNT];
|
||||
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
|
||||
"aliases must not point to other aliases");
|
||||
if (IsEnabled(res) || aEnabled == eAny) {
|
||||
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -431,11 +431,11 @@ nsCSSProps::LookupProperty(const nsAString& aProperty, EnabledState aEnabled)
|
||||
"'res' must be an alias at this point so we better have some!");
|
||||
// We intentionally don't support eEnabledInUASheets for aliases yet
|
||||
// because it's unlikely there will be a need for it.
|
||||
if (IsEnabled(res) || aEnabled == eAny) {
|
||||
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
|
||||
res = gAliases[res - eCSSProperty_COUNT];
|
||||
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
|
||||
"aliases must not point to other aliases");
|
||||
if (IsEnabled(res) || aEnabled == eAny) {
|
||||
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -258,12 +258,19 @@ public:
|
||||
static void AddRefTable(void);
|
||||
static void ReleaseTable(void);
|
||||
|
||||
// Given a property string, return the enum value
|
||||
enum EnabledState {
|
||||
eEnabled,
|
||||
eEnabledInUASheets,
|
||||
eAny
|
||||
// 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,
|
||||
// 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.
|
||||
@ -447,11 +454,20 @@ public:
|
||||
return gPropertyEnabled[aProperty];
|
||||
}
|
||||
|
||||
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled) {
|
||||
return IsEnabled(aProperty) ||
|
||||
(aEnabled == eEnabledInUASheets &&
|
||||
PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS)) ||
|
||||
aEnabled == eAny;
|
||||
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled)
|
||||
{
|
||||
if (IsEnabled(aProperty)) {
|
||||
return true;
|
||||
}
|
||||
if (aEnabled == eIgnoreEnabledState) {
|
||||
return true;
|
||||
}
|
||||
if ((aEnabled & eEnabledInUASheets) &&
|
||||
PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
@ -607,4 +623,28 @@ public:
|
||||
static const KTableValue kHyphensKTable[];
|
||||
};
|
||||
|
||||
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___ */
|
||||
|
@ -718,7 +718,7 @@ already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorResult& aRv)
|
||||
{
|
||||
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
|
||||
bool needsLayoutFlush;
|
||||
nsComputedStyleMap::Entry::ComputeMethod getter;
|
||||
|
@ -169,8 +169,9 @@ NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabled);
|
||||
const nsCSSProperty propID =
|
||||
nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propID == eCSSProperty_UNKNOWN) {
|
||||
aReturn.Truncate();
|
||||
return NS_OK;
|
||||
@ -188,8 +189,9 @@ NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabled);
|
||||
const nsCSSProperty propID =
|
||||
nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propID == eCSSProperty_UNKNOWN) {
|
||||
aReturn.Truncate();
|
||||
return NS_OK;
|
||||
@ -229,8 +231,9 @@ nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
|
||||
const nsAString& aPriority)
|
||||
{
|
||||
// In the common (and fast) cases we can use the property id
|
||||
nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProperty propID =
|
||||
nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propID == eCSSProperty_UNKNOWN) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -265,8 +268,9 @@ NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabled);
|
||||
const nsCSSProperty propID =
|
||||
nsCSSProps::LookupProperty(aPropertyName,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (propID == eCSSProperty_UNKNOWN) {
|
||||
aReturn.Truncate();
|
||||
return NS_OK;
|
||||
|
@ -4858,8 +4858,9 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
|
||||
if (val.GetUnit() == eCSSUnit_Ident) {
|
||||
nsDependentString
|
||||
propertyStr(property.list->mValue.GetStringBufferValue());
|
||||
nsCSSProperty prop = nsCSSProps::LookupProperty(propertyStr,
|
||||
nsCSSProps::eEnabled);
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(propertyStr,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (prop == eCSSProperty_UNKNOWN) {
|
||||
transition->SetUnknownProperty(propertyStr);
|
||||
} else {
|
||||
@ -5502,7 +5503,8 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
|
||||
}
|
||||
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(buffer, nsCSSProps::eEnabled);
|
||||
nsCSSProps::LookupProperty(buffer,
|
||||
nsCSSProps::eEnabledForAllContent);
|
||||
if (prop != eCSSProperty_UNKNOWN &&
|
||||
nsCSSProps::PropHasFlags(prop,
|
||||
CSS_PROPERTY_CREATES_STACKING_CONTEXT))
|
||||
|
@ -2230,7 +2230,7 @@ void nsTransition::SetInitialValues()
|
||||
void nsTransition::SetUnknownProperty(const nsAString& aUnknownProperty)
|
||||
{
|
||||
NS_ASSERTION(nsCSSProps::LookupProperty(aUnknownProperty,
|
||||
nsCSSProps::eEnabled) ==
|
||||
nsCSSProps::eEnabledForAllContent) ==
|
||||
eCSSProperty_UNKNOWN,
|
||||
"should be unknown property");
|
||||
mProperty = eCSSProperty_UNKNOWN;
|
||||
|
@ -40,7 +40,8 @@ TestProps()
|
||||
PL_strcpy(tagName, *et);
|
||||
index = nsCSSProperty(int32_t(index) + 1);
|
||||
|
||||
id = nsCSSProps::LookupProperty(nsCString(tagName), nsCSSProps::eAny);
|
||||
id = nsCSSProps::LookupProperty(nsCString(tagName),
|
||||
nsCSSProps::eIgnoreEnabledState);
|
||||
if (id == eCSSProperty_UNKNOWN) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
success = false;
|
||||
@ -55,7 +56,7 @@ TestProps()
|
||||
tagName[0] = tagName[0] - 32;
|
||||
}
|
||||
id = nsCSSProps::LookupProperty(NS_ConvertASCIItoUTF16(tagName),
|
||||
nsCSSProps::eAny);
|
||||
nsCSSProps::eIgnoreEnabledState);
|
||||
if (id < 0) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
success = false;
|
||||
@ -70,7 +71,8 @@ TestProps()
|
||||
// Now make sure we don't find some garbage
|
||||
for (int i = 0; i < (int) (sizeof(kJunkNames) / sizeof(const char*)); i++) {
|
||||
const char* const tag = kJunkNames[i];
|
||||
id = nsCSSProps::LookupProperty(nsAutoCString(tag), nsCSSProps::eAny);
|
||||
id = nsCSSProps::LookupProperty(nsAutoCString(tag),
|
||||
nsCSSProps::eIgnoreEnabledState);
|
||||
if (id >= 0) {
|
||||
printf("bug: found '%s'\n", tag ? tag : "(null)");
|
||||
success = false;
|
||||
|
Loading…
Reference in New Issue
Block a user