Add nsCSSProps::PropHasFlags to address bzbarsky's review comments. (Bug 461731) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-10-27 10:55:51 -07:00
parent 869bc0c707
commit f2ee7b15f0
2 changed files with 9 additions and 4 deletions

View File

@ -237,8 +237,8 @@ PRBool nsCSSDeclaration::AppendValueToString(nsCSSProperty aProperty, nsAString&
AppendCSSValueToString(aProperty, val->mValue, aResult);
val = val->mNext;
if (val) {
if (nsCSSProps::kFlagsTable[aProperty] &
CSS_PROPERTY_VALUE_LIST_USES_COMMAS)
if (nsCSSProps::PropHasFlags(aProperty,
CSS_PROPERTY_VALUE_LIST_USES_COMMAS))
aResult.Append(PRUnichar(','));
aResult.Append(PRUnichar(' '));
}
@ -547,7 +547,7 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
initialCount = 0, inheritCount = 0;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
if (*p == eCSSProperty__x_system_font ||
nsCSSProps::kFlagsTable[*p] & CSS_PROPERTY_DIRECTIONAL_SOURCE) {
nsCSSProps::PropHasFlags(*p, CSS_PROPERTY_DIRECTIONAL_SOURCE)) {
// The system-font subproperty and the *-source properties don't count.
continue;
}

View File

@ -101,11 +101,11 @@ public:
static const nsCSSType kTypeTable[eCSSProperty_COUNT_no_shorthands];
static const nsStyleStructID kSIDTable[eCSSProperty_COUNT_no_shorthands];
static const PRInt32* const kKeywordTableTable[eCSSProperty_COUNT_no_shorthands];
private:
static const PRUint32 kFlagsTable[eCSSProperty_COUNT];
// A table for shorthand properties. The appropriate index is the
// property ID minus eCSSProperty_COUNT_no_shorthands.
private:
static const nsCSSProperty *const
kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands];
@ -119,6 +119,11 @@ public:
eCSSProperty_COUNT_no_shorthands];
}
static inline PRBool PropHasFlags(nsCSSProperty aProperty, PRUint32 aFlags)
{
return (nsCSSProps::kFlagsTable[aProperty] & aFlags) == aFlags;
}
#define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(iter_, prop_) \
for (const nsCSSProperty* iter_ = nsCSSProps::SubpropertyEntryFor(prop_); \
*iter_ != eCSSProperty_UNKNOWN; ++iter_)