mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 07:07:30 +09:00
Issue #2084 - Part 2: Simplify logic in CSSParserImpl::LookupKeywordPrefixAware
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1259348
This commit is contained in:
parent
db3ce13f28
commit
56e636d8ec
1 changed files with 23 additions and 52 deletions
|
|
@ -7112,65 +7112,36 @@ CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
|
||||||
{
|
{
|
||||||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aKeywordStr);
|
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aKeywordStr);
|
||||||
|
|
||||||
|
if (!sWebkitPrefixedAliasesEnabled) {
|
||||||
|
// Not accepting webkit-prefixed keywords -> don't do anything special.
|
||||||
|
return keyword;
|
||||||
|
}
|
||||||
|
|
||||||
if (aKeywordTable == nsCSSProps::kDisplayKTable) {
|
if (aKeywordTable == nsCSSProps::kDisplayKTable) {
|
||||||
// NOTE: This code will be considerably simpler once we can do away with
|
|
||||||
// all Unprefixing Service code, in bug 1259348. But for the time being, we
|
|
||||||
// have to support two different strategies for handling -webkit-box here:
|
|
||||||
// (1) "Native support" (sWebkitPrefixedAliasesEnabled): we assume that
|
|
||||||
// -webkit-box will parse correctly (via an entry in kDisplayKTable),
|
|
||||||
// and we simply make a note that we've parsed it (so that we can we
|
|
||||||
// can give later "-moz-box" styling special handling as noted below).
|
|
||||||
// (2) "Unprefixing Service support" (ShouldUseUnprefixingService): we
|
|
||||||
// convert "-webkit-box" directly to modern "flex" (& do the same for
|
|
||||||
// any later "-moz-box" styling).
|
|
||||||
//
|
|
||||||
// Note that sWebkitPrefixedAliasesEnabled and
|
|
||||||
// ShouldUseUnprefixingService() are mutually exlusive, because the latter
|
|
||||||
// explicitly defers to the former.
|
|
||||||
if ((keyword == eCSSKeyword__webkit_box ||
|
if ((keyword == eCSSKeyword__webkit_box ||
|
||||||
keyword == eCSSKeyword__webkit_inline_box)) {
|
keyword == eCSSKeyword__webkit_inline_box)) {
|
||||||
const bool usingUnprefixingService = false;
|
// Make a note that we're accepting some "-webkit-{inline-}box" styling,
|
||||||
// XXXdholbert This bool^ will be removed & this whole function will be
|
// so we can give special treatment to subsequent "-moz-{inline}-box".
|
||||||
// simplified in the next patch in this series.
|
// (See special treatment below.)
|
||||||
if (sWebkitPrefixedAliasesEnabled || usingUnprefixingService) {
|
if (mWebkitBoxUnprefixState == eHaveNotUnprefixed) {
|
||||||
// Make a note that we're accepting some "-webkit-{inline-}box" styling,
|
mWebkitBoxUnprefixState = eHaveUnprefixed;
|
||||||
// so we can give special treatment to subsequent "-moz-{inline}-box".
|
|
||||||
// (See special treatment below.)
|
|
||||||
if (mWebkitBoxUnprefixState == eHaveNotUnprefixed) {
|
|
||||||
mWebkitBoxUnprefixState = eHaveUnprefixed;
|
|
||||||
}
|
|
||||||
if (usingUnprefixingService) {
|
|
||||||
// When we're using the unprefixing service, we treat
|
|
||||||
// "display:-webkit-box" as if it were "display:flex"
|
|
||||||
// (and "-webkit-inline-box" as "inline-flex").
|
|
||||||
return (keyword == eCSSKeyword__webkit_box) ?
|
|
||||||
eCSSKeyword_flex : eCSSKeyword_inline_flex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else if (mWebkitBoxUnprefixState == eHaveUnprefixed &&
|
||||||
|
(keyword == eCSSKeyword__moz_box ||
|
||||||
// If we've seen "display: -webkit-box" (or "-webkit-inline-box") in an
|
keyword == eCSSKeyword__moz_inline_box)) {
|
||||||
// earlier declaration and we honored it, then we have to watch out for
|
// If we've seen "display: -webkit-box" (or "-webkit-inline-box") in an
|
||||||
// later "display: -moz-box" (and "-moz-inline-box") declarations; they're
|
// earlier declaration and we honored it, then we have to watch out for
|
||||||
// likely just a halfhearted attempt at compatibility, and they actually
|
// later "display: -moz-box" (and "-moz-inline-box") declarations; they're
|
||||||
// end up stomping on our emulation of the earlier -webkit-box
|
// likely just a halfhearted attempt at compatibility, and they actually
|
||||||
// display-value, via the CSS cascade. To prevent this problem, we treat
|
// end up stomping on our emulation of the earlier -webkit-box
|
||||||
// "display: -moz-box" & "-moz-inline-box" as if they were simply a
|
// display-value, via the CSS cascade. To prevent this problem, we treat
|
||||||
// repetition of the webkit equivalent that we already parsed.
|
// "display: -moz-box" & "-moz-inline-box" as if they were simply a
|
||||||
if (mWebkitBoxUnprefixState == eHaveUnprefixed &&
|
// repetition of the webkit equivalent that we already parsed.
|
||||||
(keyword == eCSSKeyword__moz_box ||
|
|
||||||
keyword == eCSSKeyword__moz_inline_box)) {
|
|
||||||
MOZ_ASSERT(sWebkitPrefixedAliasesEnabled,
|
MOZ_ASSERT(sWebkitPrefixedAliasesEnabled,
|
||||||
"The only way mWebkitBoxUnprefixState can be eHaveUnprefixed "
|
"The only way mWebkitBoxUnprefixState can be eHaveUnprefixed "
|
||||||
"is if we're supporting webkit-prefixed aliases");
|
"is if we're supporting webkit-prefixed aliases");
|
||||||
if (sWebkitPrefixedAliasesEnabled) {
|
|
||||||
return (keyword == eCSSKeyword__moz_box) ?
|
|
||||||
eCSSKeyword__webkit_box : eCSSKeyword__webkit_inline_box;
|
|
||||||
}
|
|
||||||
// (If we get here, we're using the Unprefixing Service, which means
|
|
||||||
// we're unprefixing all the way to modern flexbox display values.)
|
|
||||||
return (keyword == eCSSKeyword__moz_box) ?
|
return (keyword == eCSSKeyword__moz_box) ?
|
||||||
eCSSKeyword_flex : eCSSKeyword_inline_flex;
|
eCSSKeyword__webkit_box : eCSSKeyword__webkit_inline_box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue