Bug 1121768 - Part 2: Give CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES an nsCSSProps::EnabledState argument. r=dbaron

This commit is contained in:
Cameron McCormack 2015-01-17 15:55:07 +11:00
parent 7da6d1231d
commit 80f6b98f27
6 changed files with 39 additions and 15 deletions

View File

@ -748,7 +748,8 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
GetOtherValuesForProperty(propertyParserVariant, array);
} else {
// Property is shorthand.
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID,
nsCSSProps::eEnabledForAllContent) {
// Get colors (once) first.
uint32_t propertyParserVariant = nsCSSProps::ParserVariant(*subproperty);
if (propertyParserVariant & VARIANT_COLOR) {
@ -756,7 +757,8 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
break;
}
}
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subproperty, propertyID,
nsCSSProps::eEnabledForAllContent) {
uint32_t propertyParserVariant = nsCSSProps::ParserVariant(*subproperty);
if (propertyParserVariant & VARIANT_KEYWORD) {
GetKeywordsForProperty(*subproperty, array);

View File

@ -69,7 +69,8 @@ Declaration::RemoveProperty(nsCSSProperty aProperty)
NS_ABORT_IF_FALSE(!mData && !mImportantData, "Expand didn't null things out");
if (nsCSSProps::IsShorthand(aProperty)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty,
nsCSSProps::eEnabledForAllContent) {
data.ClearLonghandProperty(*p);
mOrder.RemoveElement(static_cast<uint32_t>(*p));
}
@ -168,7 +169,8 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
uint32_t totalCount = 0, importantCount = 0,
initialCount = 0, inheritCount = 0, unsetCount = 0,
matchingTokenStreamCount = 0, nonMatchingTokenStreamCount = 0;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty,
nsCSSProps::eEnabledForAllContent) {
if (*p == eCSSProperty__x_system_font) {
// The system-font subproperty doesn't count.
continue;
@ -1122,7 +1124,8 @@ Declaration::GetValueIsImportant(nsCSSProperty aProperty) const
return mImportantData->ValueFor(aProperty) != nullptr;
}
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty,
nsCSSProps::eEnabledForAllContent) {
if (*p == eCSSProperty__x_system_font) {
// The system_font subproperty doesn't count.
continue;

View File

@ -587,7 +587,8 @@ void
nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID)
{
if (nsCSSProps::IsShorthand(aPropID)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID,
nsCSSProps::eEnabledForAllContent) {
ClearLonghandProperty(*p);
}
} else {
@ -619,8 +620,14 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
aMustCallValueAppended, aDeclaration);
}
// 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.
bool changed = false;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID,
nsCSSProps::eEnabledForAllContent) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration);

View File

@ -9644,7 +9644,8 @@ CSSParserImpl::ParseProperty(nsCSSProperty aPropID)
if (nsCSSProps::IsShorthand(aPropID)) {
// If this is a shorthand property, we store the token stream on each
// of its corresponding longhand properties.
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID,
nsCSSProps::eEnabledForAllContent) {
nsCSSValueTokenStream* tokenStream = new nsCSSValueTokenStream;
tokenStream->mPropertyID = *p;
tokenStream->mShorthandPropertyID = aPropID;
@ -14743,7 +14744,11 @@ CSSParserImpl::ParseAll()
return false;
}
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, eCSSProperty_all) {
// It's unlikely we'll want to use 'all' from within a UA style sheet, so
// 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) {
AppendValue(*p, value);
}
return true;

View File

@ -540,10 +540,15 @@ public:
public:
#define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(iter_, prop_) \
for (const nsCSSProperty* iter_ = nsCSSProps::SubpropertyEntryFor(prop_); \
*iter_ != eCSSProperty_UNKNOWN; ++iter_) \
if (nsCSSProps::IsEnabled(*iter_))
// 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
// 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_))
// Keyword/Enum value tables
static const KTableValue kAnimationDirectionKTable[];

View File

@ -229,7 +229,8 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
&startedAny, &whichStarted);
}
} else if (nsCSSProps::IsShorthand(property)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
subprop, property, nsCSSProps::eEnabledForAllContent) {
ConsiderStartingTransition(*subprop, t, aElement, collection,
aOldStyleContext, aNewStyleContext,
&startedAny, &whichStarted);
@ -268,7 +269,8 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
allTransitionProperties.AddProperty(p);
}
} else if (nsCSSProps::IsShorthand(property)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
subprop, property, nsCSSProps::eEnabledForAllContent) {
allTransitionProperties.AddProperty(*subprop);
}
} else {