Index: Source/core/css/parser/MediaQueryParser.cpp |
diff --git a/Source/core/css/parser/MediaQueryParser.cpp b/Source/core/css/parser/MediaQueryParser.cpp |
index f1a1a2438223bb92fdd8678db216f0cff21c14f5..34f5c9b26ca99b83d421205862f0d9aeaa740486 100644 |
--- a/Source/core/css/parser/MediaQueryParser.cpp |
+++ b/Source/core/css/parser/MediaQueryParser.cpp |
@@ -76,15 +76,30 @@ void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToke |
readFeatureStart(type, token); |
} |
+static bool isRestrictorOrLogicalOperator(const String& tokenValue) |
+{ |
+ // FIXME: it would be more efficient to use lower-case always for tokenValue. |
+ return equalIgnoringCase(tokenValue, "not") |
+ || equalIgnoringCase(tokenValue, "and") |
+ || equalIgnoringCase(tokenValue, "or") |
+ || equalIgnoringCase(tokenValue, "only"); |
+} |
+ |
void MediaQueryParser::readMediaType(CSSParserTokenType type, const CSSParserToken& token) |
{ |
if (type == LeftParenthesisToken) { |
- m_state = ReadFeature; |
+ if (m_mediaQueryData.restrictor() != MediaQuery::None) |
+ m_state = SkipUntilComma; |
+ else |
+ m_state = ReadFeature; |
} else if (type == IdentToken) { |
if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "not")) { |
setStateAndRestrict(ReadMediaType, MediaQuery::Not); |
} else if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "only")) { |
setStateAndRestrict(ReadMediaType, MediaQuery::Only); |
+ } else if (m_mediaQueryData.restrictor() != MediaQuery::None |
+ && isRestrictorOrLogicalOperator(token.value())) { |
+ m_state = SkipUntilComma; |
} else { |
m_mediaQueryData.setMediaType(token.value()); |
m_state = ReadAnd; |