зеркало из https://github.com/mozilla/gecko-dev.git
Bug 841983: Require whitespace around 'not', 'and', and 'or' keywords in @supports rules. r=heycam
Matches spec change in https://dvcs.w3.org/hg/csswg/rev/34b185ae3bac .
This commit is contained in:
Родитель
4b987799be
Коммит
9f0532a6a2
|
@ -119,6 +119,7 @@ PEBadDirValue=Expected 'ltr' or 'rtl' in direction selector but found '%1$S'.
|
|||
PESupportsConditionStartEOF2='not', '(', or function
|
||||
PESupportsConditionInParensEOF=')'
|
||||
PESupportsConditionNotEOF='not'
|
||||
PESupportsWhitespaceRequired=Expected whitespace after 'not', 'and', or 'or'.
|
||||
PESupportsConditionExpectedOpenParenOrFunction=Expected '(' or function while parsing supports condition but found '%1$S'.
|
||||
PESupportsConditionExpectedCloseParen=Expected ')' while parsing supports condition but found '%1$S'.
|
||||
PESupportsConditionExpectedStart2=Expected 'not', '(', or function while parsing supports condition but found '%1$S'.
|
||||
|
|
|
@ -2537,7 +2537,7 @@ CSSParserImpl::ParseSupportsCondition(bool& aConditionMet)
|
|||
}
|
||||
|
||||
// supports_condition_negation
|
||||
// : 'not' S* supports_condition_in_parens
|
||||
// : 'not' S+ supports_condition_in_parens
|
||||
// ;
|
||||
bool
|
||||
CSSParserImpl::ParseSupportsConditionNegation(bool& aConditionMet)
|
||||
|
@ -2553,6 +2553,11 @@ CSSParserImpl::ParseSupportsConditionNegation(bool& aConditionMet)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!RequireWhitespace()) {
|
||||
REPORT_UNEXPECTED(PESupportsWhitespaceRequired);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ParseSupportsConditionInParens(aConditionMet)) {
|
||||
aConditionMet = !aConditionMet;
|
||||
return true;
|
||||
|
@ -2665,14 +2670,14 @@ CSSParserImpl::ParseSupportsConditionInParensInsideParens(bool& aConditionMet)
|
|||
}
|
||||
|
||||
// supports_condition_terms
|
||||
// : 'and' S* supports_condition_terms_after_operator('and')
|
||||
// | 'or' S* supports_condition_terms_after_operator('or')
|
||||
// : S+ 'and' supports_condition_terms_after_operator('and')
|
||||
// | S+ 'or' supports_condition_terms_after_operator('or')
|
||||
// |
|
||||
// ;
|
||||
bool
|
||||
CSSParserImpl::ParseSupportsConditionTerms(bool& aConditionMet)
|
||||
{
|
||||
if (!GetToken(true)) {
|
||||
if (!RequireWhitespace() || !GetToken(false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2694,13 +2699,18 @@ CSSParserImpl::ParseSupportsConditionTerms(bool& aConditionMet)
|
|||
}
|
||||
|
||||
// supports_condition_terms_after_operator(operator)
|
||||
// : supports_condition_in_parens ( <operator> supports_condition_in_parens )*
|
||||
// : S+ supports_condition_in_parens ( <operator> supports_condition_in_parens )*
|
||||
// ;
|
||||
bool
|
||||
CSSParserImpl::ParseSupportsConditionTermsAfterOperator(
|
||||
bool& aConditionMet,
|
||||
CSSParserImpl::SupportsConditionTermOperator aOperator)
|
||||
{
|
||||
if (!RequireWhitespace()) {
|
||||
REPORT_UNEXPECTED(PESupportsWhitespaceRequired);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* token = aOperator == eAnd ? "and" : "or";
|
||||
for (;;) {
|
||||
bool termConditionMet = false;
|
||||
|
|
|
@ -12,10 +12,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=649740
|
|||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=649740">Mozilla Bug 649740</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<p id="display1"></p>
|
||||
<p id="display2"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
|
@ -44,6 +42,41 @@ function runTest() {
|
|||
is(condition(sheet.cssRules[3].cssText), "(color: green) and (color: blue)");
|
||||
is(condition(sheet.cssRules[4].cssText), "( Font: 20px serif ! Important)");
|
||||
|
||||
var cs1 = getComputedStyle(document.getElementById("display1"), "");
|
||||
var cs2 = getComputedStyle(document.getElementById("display2"), "");
|
||||
function check_balanced_condition(condition, expected_match) {
|
||||
style.textContent = "#display1, #display2 { text-decoration: overline }\n" +
|
||||
"@supports " + condition + "{\n" +
|
||||
" #display1 { text-decoration: line-through }\n" +
|
||||
"}\n" +
|
||||
"#display2 { text-decoration: underline }\n";
|
||||
is(cs1.textDecoration,
|
||||
expected_match ? "line-through" : "overline",
|
||||
"@supports condition \"" + condition + "\" should " +
|
||||
(expected_match ? "" : "NOT ") + "match");
|
||||
is(cs2.textDecoration, "underline",
|
||||
"@supports condition \"" + condition + "\" should be balanced");
|
||||
}
|
||||
|
||||
check_balanced_condition("not (color: green)", false);
|
||||
check_balanced_condition("not (colour: green)", true);
|
||||
check_balanced_condition("not(color: green)", false);
|
||||
check_balanced_condition("not(colour: green)", false);
|
||||
check_balanced_condition("not/* */(color: green)", false);
|
||||
check_balanced_condition("not/* */(colour: green)", false);
|
||||
check_balanced_condition("not /* */ (color: green)", false);
|
||||
check_balanced_condition("not /* */ (colour: green)", true);
|
||||
check_balanced_condition("(color: green) and (color: blue)", true);
|
||||
check_balanced_condition("(color: green) /* */ /* */ and /* */ /* */ (color: blue)", true);
|
||||
check_balanced_condition("(color: green) and(color: blue)", false);
|
||||
check_balanced_condition("(color: green) and/* */(color: blue)", false);
|
||||
check_balanced_condition("(color: green)and (color: blue)", false);
|
||||
check_balanced_condition("(color: green) or (color: blue)", true);
|
||||
check_balanced_condition("(color: green) /* */ /* */ or /* */ /* */ (color: blue)", true);
|
||||
check_balanced_condition("(color: green) or(color: blue)", false);
|
||||
check_balanced_condition("(color: green) or/* */(color: blue)", false);
|
||||
check_balanced_condition("(color: green)or (color: blue)", false);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче