mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Bug 1236400 part 3: If webkit prefix support is enabled, skip CSS Parser code that converts "display: -webkit-box" directly to "display: flex". r=mats
This makes "display: -webkit-box" & "display: -webkit-inline-box" into bona fide "display" values (instead of just aliases), when webkit prefix support is enabled, and allows us to actually exercise the code added in the earlier patches on this bug. (Note that when webkit prefix support is *disabled*, our CSS Unprefixing Service strategy will instead have an opportunity to take effect, for whitelisted sites, and it'll continue to convert "-webkit-box" to "flex".) MozReview-Commit-ID: BV93xs4ddbK
This commit is contained in:
parent
8b9d86b0ef
commit
2b7c7ca3d2
@ -168,9 +168,11 @@ function do_test() {
|
||||
"table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row",
|
||||
"table-column-group", "table-column", "table-cell", "table-caption", "-moz-box", "-moz-inline-box",
|
||||
"-moz-grid", "-moz-inline-grid", "-moz-grid-group", "-moz-grid-line", "-moz-stack", "-moz-inline-stack",
|
||||
"-moz-deck", "-moz-popup", "-moz-groupbox", "flex", "inline-flex", "grid",
|
||||
"inline-grid", "ruby", "ruby-base", "ruby-base-container", "ruby-text",
|
||||
"ruby-text-container", "contents" ];
|
||||
"-moz-deck", "-moz-popup", "-moz-groupbox",
|
||||
"flex", "inline-flex", "-webkit-box", "-webkit-inline-box",
|
||||
"grid", "inline-grid",
|
||||
"ruby", "ruby-base", "ruby-base-container", "ruby-text", "ruby-text-container",
|
||||
"contents" ];
|
||||
ok(testValues(values, expected), "property display's values.");
|
||||
|
||||
// test property
|
||||
|
@ -6923,28 +6923,48 @@ CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
|
||||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aKeywordStr);
|
||||
|
||||
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 ||
|
||||
keyword == eCSSKeyword__webkit_inline_box) &&
|
||||
(sWebkitPrefixedAliasesEnabled || ShouldUseUnprefixingService())) {
|
||||
// Treat "display: -webkit-box" as "display: flex", and
|
||||
// "display: -webkit-inline-box" as "display: inline-flex". In simple
|
||||
// scenarios, they largely behave the same, as long as we alias the
|
||||
// associated properties to modern flexbox equivalents as well.
|
||||
if (mWebkitBoxUnprefixState == eHaveNotUnprefixed) {
|
||||
mWebkitBoxUnprefixState = eHaveUnprefixed;
|
||||
keyword == eCSSKeyword__webkit_inline_box)) {
|
||||
const bool usingUnprefixingService = ShouldUseUnprefixingService();
|
||||
if (sWebkitPrefixedAliasesEnabled || usingUnprefixingService) {
|
||||
// Make a note that we're accepting some "-webkit-{inline-}box" styling,
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
return (keyword == eCSSKeyword__webkit_box) ?
|
||||
eCSSKeyword_flex : eCSSKeyword_inline_flex;
|
||||
}
|
||||
|
||||
// If we've seen "display: -webkit-box" (or "-webkit-inline-box") in an
|
||||
// earlier declaration and we tried to unprefix it to emulate support for
|
||||
// it, then we have to watch out for later "display: -moz-box" (and
|
||||
// "-moz-inline-box") declarations; they're likely just a halfhearted
|
||||
// attempt at compatibility, and they actually end up stomping on our
|
||||
// emulation of the earlier -webkit-box display-value, via the CSS
|
||||
// cascade. To prevent this problem, we also treat "display: -moz-box" as
|
||||
// "display: flex" (but only if we unprefixed an earlier "-webkit-box").
|
||||
// earlier declaration and we honored it, then we have to watch out for
|
||||
// later "display: -moz-box" (and "-moz-inline-box") declarations; they're
|
||||
// likely just a halfhearted attempt at compatibility, and they actually
|
||||
// end up stomping on our emulation of the earlier -webkit-box
|
||||
// display-value, via the CSS cascade. To prevent this problem, we treat
|
||||
// "display: -moz-box" & "-moz-inline-box" as if they were simply a
|
||||
// repetition of the webkit equivalent that we already parsed.
|
||||
if (mWebkitBoxUnprefixState == eHaveUnprefixed &&
|
||||
(keyword == eCSSKeyword__moz_box ||
|
||||
keyword == eCSSKeyword__moz_inline_box)) {
|
||||
@ -6952,6 +6972,12 @@ CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
|
||||
"mDidUnprefixWebkitBoxInEarlierDecl should only be set if "
|
||||
"we're supporting webkit-prefixed aliases, or if we're using "
|
||||
"the css unprefixing service on this site");
|
||||
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) ?
|
||||
eCSSKeyword_flex : eCSSKeyword_inline_flex;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user