Bug 914432 - Add support for multiple prefs to enable/disable values in the same property keyword table. r=dbaron

This commit is contained in:
Mats Palmgren 2013-10-27 20:56:32 +00:00
parent 82d5d0bafd
commit 1a8127e873

View File

@ -960,9 +960,7 @@ int32_t nsCSSProps::kDisplayKTable[] = {
eCSSKeyword__moz_popup, NS_STYLE_DISPLAY_POPUP,
eCSSKeyword__moz_groupbox, NS_STYLE_DISPLAY_GROUPBOX,
#endif
// XXXdholbert NOTE: These currently need to be the last entries in the
// table, because the "is flexbox enabled" pref that disables these will
// disable all the entries after them, too.
// The next two entries are controlled by the layout.css.flexbox.enabled pref.
eCSSKeyword_flex, NS_STYLE_DISPLAY_FLEX,
eCSSKeyword_inline_flex, NS_STYLE_DISPLAY_INLINE_FLEX,
eCSSKeyword_UNKNOWN,-1
@ -1380,9 +1378,7 @@ int32_t nsCSSProps::kPositionKTable[] = {
eCSSKeyword_relative, NS_STYLE_POSITION_RELATIVE,
eCSSKeyword_absolute, NS_STYLE_POSITION_ABSOLUTE,
eCSSKeyword_fixed, NS_STYLE_POSITION_FIXED,
// NOTE: This currently needs to be the last entry in the table,
// because the "layout.css.sticky.enabled" pref that disables
// this will disable all the entries after it, too.
// The next entry is controlled by the layout.css.sticky.enabled pref.
eCSSKeyword_sticky, NS_STYLE_POSITION_STICKY,
eCSSKeyword_UNKNOWN,-1
};
@ -1788,15 +1784,33 @@ const int32_t nsCSSProps::kColumnFillKTable[] = {
eCSSKeyword_UNKNOWN, -1
};
static bool IsKeyValSentinel(nsCSSKeyword aKey, int32_t aValue)
{
return aKey == eCSSKeyword_UNKNOWN && aValue == -1;
}
int32_t
nsCSSProps::FindIndexOfKeyword(nsCSSKeyword aKeyword, const int32_t aTable[])
{
int32_t index = 0;
while (eCSSKeyword_UNKNOWN != nsCSSKeyword(aTable[index])) {
if (aKeyword == nsCSSKeyword(aTable[index])) {
return index;
if (eCSSKeyword_UNKNOWN == aKeyword) {
// NOTE: we can have keyword tables where eCSSKeyword_UNKNOWN is used
// not only for the sentinel, but also in the middle of the table to
// knock out values that have been disabled by prefs, e.g. kDisplayKTable.
// So we deal with eCSSKeyword_UNKNOWN up front to avoid returning a valid
// index in the loop below.
return -1;
}
int32_t i = 0;
for (;;) {
nsCSSKeyword key = nsCSSKeyword(aTable[i]);
int32_t val = aTable[i + 1];
if (::IsKeyValSentinel(key, val)) {
break;
}
index += 2;
if (aKeyword == key) {
return i;
}
i += 2;
}
return -1;
}
@ -1818,11 +1832,13 @@ nsCSSProps::ValueToKeywordEnum(int32_t aValue, const int32_t aTable[])
{
int32_t i = 1;
for (;;) {
if (aTable[i] == -1 && aTable[i-1] == eCSSKeyword_UNKNOWN) {
int32_t val = aTable[i];
nsCSSKeyword key = nsCSSKeyword(aTable[i - 1]);
if (::IsKeyValSentinel(key, val)) {
break;
}
if (aValue == aTable[i]) {
return nsCSSKeyword(aTable[i-1]);
if (aValue == val) {
return key;
}
i += 2;
}