зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1259889 Part 1 - Add @supports -moz-bool-pref for internal-only style sheets. r=heycam
This is a internal-only syntax for guarding rules from a boolean preference. Nothing causes @supports rules to be re-evaluated except html.css registered in Part 2. This is needed for rendering the disclosure triangle of the summary element by using "display: list-item". Usage example: @supports -moz-bool-pref("dom.details_element.enabled") { /* css rules */ } MozReview-Commit-ID: HDCa8zHxYTA --HG-- extra : rebase_source : b7a72a48166edf1d486014ff37363ed8be9127d9
This commit is contained in:
Родитель
7a0b88f906
Коммит
219e330768
|
@ -6,3 +6,4 @@
|
|||
== at-rule-error-handling-media-1.html at-rule-error-handling-ref.html
|
||||
== invalid-font-face-descriptor-1.html invalid-font-face-descriptor-1-ref.html
|
||||
== two-dash-identifiers.html two-dash-identifiers-ref.html
|
||||
== supports-moz-bool-pref.html supports-moz-bool-pref-ref.html
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<p>This text should not have background color.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<html>
|
||||
<style>
|
||||
/* This is not a user agent style sheet, so the style will be ignored.
|
||||
"testing.supports.moz-bool-pref" is set to true in
|
||||
layout/tools/reftest/reftest-preferences.js. */
|
||||
@supports -moz-bool-pref("testing.supports.moz-bool-pref") {
|
||||
p {
|
||||
background-color: red;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<p>This text should not have background color.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -694,6 +694,7 @@ protected:
|
|||
bool ParseSupportsCondition(bool& aConditionMet);
|
||||
bool ParseSupportsConditionNegation(bool& aConditionMet);
|
||||
bool ParseSupportsConditionInParens(bool& aConditionMet);
|
||||
bool ParseSupportsMozBoolPrefName(bool& aConditionMet);
|
||||
bool ParseSupportsConditionInParensInsideParens(bool& aConditionMet);
|
||||
bool ParseSupportsConditionTerms(bool& aConditionMet);
|
||||
enum SupportsConditionTermOperator { eAnd, eOr };
|
||||
|
@ -4526,6 +4527,7 @@ CSSParserImpl::ParseSupportsConditionNegation(bool& aConditionMet)
|
|||
|
||||
// supports_condition_in_parens
|
||||
// : '(' S* supports_condition_in_parens_inside_parens ')' S*
|
||||
// | supports_condition_pref
|
||||
// | general_enclosed
|
||||
// ;
|
||||
bool
|
||||
|
@ -4541,6 +4543,12 @@ CSSParserImpl::ParseSupportsConditionInParens(bool& aConditionMet)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (AgentRulesEnabled() &&
|
||||
mToken.mType == eCSSToken_Function &&
|
||||
mToken.mIdent.LowerCaseEqualsLiteral("-moz-bool-pref")) {
|
||||
return ParseSupportsMozBoolPrefName(aConditionMet);
|
||||
}
|
||||
|
||||
if (mToken.mType == eCSSToken_Function ||
|
||||
mToken.mType == eCSSToken_Bad_URL) {
|
||||
if (!SkipUntil(')')) {
|
||||
|
@ -4575,6 +4583,32 @@ CSSParserImpl::ParseSupportsConditionInParens(bool& aConditionMet)
|
|||
return true;
|
||||
}
|
||||
|
||||
// supports_condition_pref
|
||||
// : '-moz-bool-pref(' bool_pref_name ')'
|
||||
// ;
|
||||
bool
|
||||
CSSParserImpl::ParseSupportsMozBoolPrefName(bool& aConditionMet)
|
||||
{
|
||||
if (!GetToken(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mToken.mType != eCSSToken_String) {
|
||||
SkipUntil(')');
|
||||
return false;
|
||||
}
|
||||
|
||||
aConditionMet = Preferences::GetBool(
|
||||
NS_ConvertUTF16toUTF8(mToken.mIdent).get());
|
||||
|
||||
if (!ExpectSymbol(')', true)) {
|
||||
SkipUntil(')');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// supports_condition_in_parens_inside_parens
|
||||
// : core_declaration
|
||||
// | supports_condition_negation
|
||||
|
|
|
@ -114,3 +114,6 @@ user_pref("startup.homepage_override_url", "");
|
|||
user_pref("browser.usedOnWindows10.introURL", "");
|
||||
|
||||
user_pref("media.gmp-manager.url.override", "http://localhost/dummy-gmp-manager.xml");
|
||||
|
||||
// A fake bool pref for "@supports -moz-bool-pref" sanify test.
|
||||
user_pref("testing.supports.moz-bool-pref", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче