From f51451f8053d1e9c54738574b903537a170b9627 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 27 Oct 2008 10:55:51 -0700 Subject: [PATCH] Add nsCSSProps::PropHasFlags to address bzbarsky's review comments. (Bug 461731) r+sr=bzbarsky --- layout/style/nsCSSDeclaration.cpp | 6 +++--- layout/style/nsCSSProps.h | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/layout/style/nsCSSDeclaration.cpp b/layout/style/nsCSSDeclaration.cpp index df5cd3b9a60..1fa34fbb42c 100644 --- a/layout/style/nsCSSDeclaration.cpp +++ b/layout/style/nsCSSDeclaration.cpp @@ -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; } diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index d5b456ae23c..2b25f559d7b 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -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_)