зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1338486: Support implied parentheses in CSS.supports; r=xidorn
MozReview-Commit-ID: CUo371Hvj4T --HG-- extra : rebase_source : ee80540522e959bdf6d7ec5bd5a45081dbd9a384
This commit is contained in:
Родитель
b152f9ab2e
Коммит
7d791c9ebe
|
@ -93,7 +93,8 @@ CSS::Supports(const GlobalObject& aGlobal,
|
|||
|
||||
nsCSSParser parser;
|
||||
return parser.EvaluateSupportsCondition(aCondition, info.mDocURI,
|
||||
info.mBaseURI, info.mPrincipal);
|
||||
info.mBaseURI, info.mPrincipal,
|
||||
css::SupportsParsingSettings::ImpliedParentheses);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
|
|
|
@ -263,7 +263,9 @@ public:
|
|||
bool EvaluateSupportsCondition(const nsAString& aCondition,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsIPrincipal* aDocPrincipal);
|
||||
nsIPrincipal* aDocPrincipal,
|
||||
SupportsParsingSettings aSettings
|
||||
= SupportsParsingSettings::Normal);
|
||||
|
||||
already_AddRefed<nsIAtom> ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL);
|
||||
|
@ -2414,7 +2416,8 @@ bool
|
|||
CSSParserImpl::EvaluateSupportsCondition(const nsAString& aDeclaration,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsIPrincipal* aDocPrincipal)
|
||||
nsIPrincipal* aDocPrincipal,
|
||||
SupportsParsingSettings aSettings)
|
||||
{
|
||||
nsCSSScanner scanner(aDeclaration, 0);
|
||||
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aDocURL);
|
||||
|
@ -2422,7 +2425,13 @@ CSSParserImpl::EvaluateSupportsCondition(const nsAString& aDeclaration,
|
|||
nsAutoSuppressErrors suppressErrors(this);
|
||||
|
||||
bool conditionMet;
|
||||
bool parsedOK = ParseSupportsCondition(conditionMet) && !GetToken(true);
|
||||
bool parsedOK;
|
||||
|
||||
if (aSettings == SupportsParsingSettings::ImpliedParentheses) {
|
||||
parsedOK = ParseSupportsConditionInParensInsideParens(conditionMet) && !GetToken(true);
|
||||
} else {
|
||||
parsedOK = ParseSupportsCondition(conditionMet) && !GetToken(true);
|
||||
}
|
||||
|
||||
CLEAR_ERROR();
|
||||
ReleaseScanner();
|
||||
|
@ -18155,10 +18164,12 @@ bool
|
|||
nsCSSParser::EvaluateSupportsCondition(const nsAString& aCondition,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsIPrincipal* aDocPrincipal)
|
||||
nsIPrincipal* aDocPrincipal,
|
||||
SupportsParsingSettings aSettings)
|
||||
{
|
||||
return static_cast<CSSParserImpl*>(mImpl)->
|
||||
EvaluateSupportsCondition(aCondition, aDocURL, aBaseURL, aDocPrincipal);
|
||||
EvaluateSupportsCondition(aCondition, aDocURL, aBaseURL,
|
||||
aDocPrincipal, aSettings);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -34,6 +34,12 @@ namespace css {
|
|||
class Rule;
|
||||
class Declaration;
|
||||
class StyleRule;
|
||||
|
||||
enum class SupportsParsingSettings {
|
||||
Normal,
|
||||
ImpliedParentheses
|
||||
};
|
||||
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -252,11 +258,17 @@ public:
|
|||
/**
|
||||
* Parse an @supports condition and returns the result of evaluating the
|
||||
* condition.
|
||||
*
|
||||
* The one-argument CSS.supports() allows for providing a parentheses-less
|
||||
* @supports condition, i.e. the parentheses are "implied". In such a case,
|
||||
* aSettings can be set to ImpliedParentheses.
|
||||
*/
|
||||
bool EvaluateSupportsCondition(const nsAString& aCondition,
|
||||
nsIURI* aDocURL,
|
||||
nsIURI* aBaseURL,
|
||||
nsIPrincipal* aDocPrincipal);
|
||||
nsIPrincipal* aDocPrincipal,
|
||||
mozilla::css::SupportsParsingSettings aSettings
|
||||
= mozilla::css::SupportsParsingSettings::Normal);
|
||||
|
||||
typedef void (*VariableEnumFunc)(const nsAString&, void*);
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ to mochitest command.
|
|||
* getComputedStyle style doesn't contain custom properties bug 1336891
|
||||
* test_variable_serialization_computed.html [35]
|
||||
* test_variables.html `custom property name` [2]
|
||||
* test_css_supports.html: issues around @supports syntax servo/servo#15482 [8]
|
||||
* test_css_supports.html: issues around @supports syntax servo/servo#15482 [7]
|
||||
* test_author_specified_style.html: support serializing color as author specified bug 1348165 [27]
|
||||
* browser_newtab_share_rule_processors.js: agent style sheet sharing [1]
|
||||
* :visited support (bug 1328509)
|
||||
|
|
|
@ -22,6 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=779917
|
|||
function runTest()
|
||||
{
|
||||
var passingConditions = [
|
||||
"color: green",
|
||||
"(color: green)",
|
||||
"((color: green))",
|
||||
"(color: green !important)",
|
||||
|
@ -69,7 +70,6 @@ function runTest()
|
|||
"(color: green) or an-extension(that is [unbalanced)",
|
||||
"not(unknown: unknown)",
|
||||
"(color: green) or(color: blue)",
|
||||
"color: green",
|
||||
"(color: green;)",
|
||||
"(font-family: 'Helvetica\n",
|
||||
"(font-family: 'Helvetica\n')",
|
||||
|
|
Загрузка…
Ссылка в новой задаче