Title: [208847] trunk
Revision
208847
Author
[email protected]
Date
2016-11-17 09:28:52 -0800 (Thu, 17 Nov 2016)

Log Message

[CSS Parser] Add @supports, @keyframe and media query parsing options
https://bugs.webkit.org/show_bug.cgi?id=164821

Reviewed by Sam Weinig and Zalan Bujtas.

Source/WebCore:

* css/CSSKeyframeRule.cpp:
(WebCore::StyleKeyframe::setKeyText):
* css/CSSKeyframeRule.h:
* css/CSSKeyframesRule.cpp:
(WebCore::StyleRuleKeyframes::findKeyframeIndex):
Changed to call into CSSParserImpls implementation. The new parser
is now always used when parsing the key list.

* css/MediaList.cpp:
(WebCore::MediaQuerySet::create):
(WebCore::MediaQuerySet::MediaQuerySet):
(WebCore::MediaQuerySet::set):
(WebCore::MediaQuerySet::add):
(WebCore::MediaQuerySet::remove):
(WebCore::MediaList::setMediaText):
(WebCore::parseMediaDescriptor): Deleted.
(WebCore::MediaQuerySet::internalParse): Deleted.
(WebCore::MediaQuerySet::parse): Deleted.
* css/MediaList.h:
Rewritten to remove fallback descriptor support/parsing, since no other
browser supports it, and this was part of our initial 2005 landing that
nobody else appears to use.  Media queries now call into the new parser always.

* css/MediaQueryExp.cpp:
(WebCore::featureWithValidDensity):
(WebCore::featureWithPositiveNumber):
(WebCore::MediaQueryExpression::MediaQueryExpression):
Make sure to support transform2d, animation and transition.

* css/StyleMedia.cpp:
(WebCore::StyleMedia::matchMedium):
Call the normal create now that fallback descriptor syntax is gone.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseKeyframeRule):
(WebCore::CSSParser::parseSupportsCondition):
(WebCore::CSSParser::parseInlineStyleDeclaration):
(WebCore::CSSParser::parseDeclarationDeprecated):
(WebCore::CSSParser::parseDeclaration):
(WebCore::CSSParser::parseKeyframeKeyList):
(WebCore::CSSParser::parseMediaQuery): Deleted.
(WebCore::CSSParser::parseKeyframeSelector): Deleted.
* css/parser/CSSParser.h:
Patched the old parser to have flags to call into the new parser
for supports conditions and keyframes. Rename the parseDeclaration that
is only used by the old parser to have the word Deprecated in it. Removed
the media query and key list parsing functions, since the new parser
now does it always.

* css/parser/CSSParserIdioms.cpp:
(WebCore::convertToASCIILowercaseInPlace): Deleted.
* css/parser/CSSParserIdioms.h:
* css/parser/CSSParserToken.cpp:
(WebCore::convertToASCIILowercaseInPlace):
(WebCore::CSSParserToken::convertToASCIILowercaseInPlace):
* css/parser/CSSParserToken.h:
(WebCore::CSSParserToken::value):
(WebCore::CSSParserToken::initValueFromStringView):
* css/parser/CSSParserValues.cpp:
(WebCore::CSSParserSelector::parsePseudoElementSelectorFromStringView):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeAttr):
* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumeId):
(WebCore::CSSSelectorParser::consumeClass):
(WebCore::CSSSelectorParser::consumePseudo):
Moving convertToASCIILowercase to be a CSSParserToken member function instead
of operating on StringView. This saves an extra step, since the token itself
already had all the correct members. Note that converting in-place is bad,
and we'll be removing it once the new parser turns on.

* css/parser/MediaQueryParser.cpp:
(WebCore::MediaQueryParser::readMediaType):
(WebCore::MediaQueryParser::readFeature):
(WebCore::MediaQueryParser::readFeatureEnd):
Require the closing ")" on features. Fix the in-place lowercasing to only
be done for features, not for types. This matches the old parser.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createCSSStyleSheet):
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::createSheet):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::initializeStyleSheet):
* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::parseAttribute):
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::parseAttribute):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
* html/parser/HTMLResourcePreloader.cpp:
(WebCore::mediaAttributeMatches):
Patched to call the normal MediaQuerySet::create and not the one that had fallback
descriptor support.

Source/WebKit/mac:

Fix up the create call now that fallback descriptor syntax is gone.

* DOM/DOM.mm:
(-[DOMHTMLLinkElement _mediaQueryMatches]):

LayoutTests:

Delete the fallback descriptor tests, since that feature has been
removed. Update some of the other tests based off some parsing changes
from using the new parser always.

* fast/media/media-descriptor-syntax-01-expected.html: Removed.
* fast/media/media-descriptor-syntax-01.html: Removed.
* fast/media/media-descriptor-syntax-02-expected.html: Removed.
* fast/media/media-descriptor-syntax-02.html: Removed.
* fast/media/media-descriptor-syntax-03-expected.html: Removed.
* fast/media/media-descriptor-syntax-03.html: Removed.
* fast/media/media-descriptor-syntax-04-expected.html: Removed.
* fast/media/media-descriptor-syntax-04.html: Removed.
* fast/media/media-descriptor-syntax-06-expected.html: Removed.
* fast/media/media-descriptor-syntax-06.html: Removed.
* fast/media/media-query-list-02-expected.txt:
* fast/media/media-query-list-03-expected.txt:
* fast/media/media-query-list-04-expected.txt:
* fast/media/media-query-list-05-expected.txt:
* fast/media/media-query-list-06-expected.txt:
* fast/media/mq-pointer-expected.txt:
* fast/media/w3c/test_media_queries-expected.txt:

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208846 => 208847)


--- trunk/LayoutTests/ChangeLog	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/ChangeLog	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,3 +1,32 @@
+2016-11-16  Dave Hyatt  <[email protected]>
+
+        [CSS Parser] Add @supports, @keyframe and media query parsing options
+        https://bugs.webkit.org/show_bug.cgi?id=164821
+
+        Reviewed by Sam Weinig and Zalan Bujtas.
+
+        Delete the fallback descriptor tests, since that feature has been
+        removed. Update some of the other tests based off some parsing changes
+        from using the new parser always.
+
+        * fast/media/media-descriptor-syntax-01-expected.html: Removed.
+        * fast/media/media-descriptor-syntax-01.html: Removed.
+        * fast/media/media-descriptor-syntax-02-expected.html: Removed.
+        * fast/media/media-descriptor-syntax-02.html: Removed.
+        * fast/media/media-descriptor-syntax-03-expected.html: Removed.
+        * fast/media/media-descriptor-syntax-03.html: Removed.
+        * fast/media/media-descriptor-syntax-04-expected.html: Removed.
+        * fast/media/media-descriptor-syntax-04.html: Removed.
+        * fast/media/media-descriptor-syntax-06-expected.html: Removed.
+        * fast/media/media-descriptor-syntax-06.html: Removed.
+        * fast/media/media-query-list-02-expected.txt:
+        * fast/media/media-query-list-03-expected.txt:
+        * fast/media/media-query-list-04-expected.txt:
+        * fast/media/media-query-list-05-expected.txt:
+        * fast/media/media-query-list-06-expected.txt:
+        * fast/media/mq-pointer-expected.txt:
+        * fast/media/w3c/test_media_queries-expected.txt:
+
 2016-11-17  Ryan Haddad  <[email protected]>
 
         Remove pass expectation for custom-elements tests on ios-sim because CEReactions were disabled in r208837.

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-01-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-01-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-01-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-01.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-01.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-01.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,14 +0,0 @@
-<html>
-<head>
-<title>HTML4 media descriptors test: parsing style element media attribute, forward-compatible syntax</title>
-<link rel="help" href="" />
-
-<style type="text/css" media="3d-glasses, screen and resolution > 40dpi, braille">
-p { color: green }
-</style>
-
-</head>
-<body>
-</body>
-<p> This text should be green. </p>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-02-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-02-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-02-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-02.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-02.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-02.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,15 +0,0 @@
-<html>
-<head>
-<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title> 
-<link rel="help" href="" />
-<!-- actual testcase from http://www.hixie.ch/tests/evil/css/import/extra/styleexoticmedia.html -->
-
-<style type="text/css" media="screen;braille">
-p { color: green }
-</style>
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-03-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-03-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-03-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-03.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-03.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-03.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,14 +0,0 @@
-<html>
-<head>
-<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
-<link rel="help" href="" />
-<!-- actual testcase from http://www.hixie.ch/tests/evil/css/import/extra/styleexoticmedia.html -->
-<style type="text/css" media="braille, all with print">
-p { color: green }
-</style>
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-04-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-04-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-04-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-04.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-04.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-04.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,13 +0,0 @@
-<html>
-<head>
-<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
-<link rel="help" href="" />
-<style type="text/css" media=",,,,">
-p { color: green }
-</style>
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-06-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-06-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-06-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/media-descriptor-syntax-06.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/media-descriptor-syntax-06.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/media-descriptor-syntax-06.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,13 +0,0 @@
-<html>
-<head>
-<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
-<link rel="help" href="" />
-<style type="text/css" media="     ">
-p { color: green }
-</style>
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-01-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-01-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-01-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-01.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-01.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-01.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,14 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: syntactically invalid media query inside html element should be treated as html media descriptor. Using style element, media attribute.</title>  
-<link rel="help" href="" />
-
-<style type="text/css" media="all and invalid">
-p { color: green }
-</style>
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-02-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-02-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-02-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-02.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-02.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-02.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,12 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: syntactically invalid media query inside html element should be treated as media descriptor. Using link element, media attribute.</title>
-<link rel="help" href="" />
-
-<link rel="stylesheet" type="text/css" media="all and invalid" href="" />
-
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-05-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-05-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-05-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-invalid-syntax-05.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-invalid-syntax-05.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-invalid-syntax-05.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,17 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: syntactically invalid media query inside css rule should eval to false (,,,,). Using style element, css import rule.</title>
-<link rel="help" href="" />
-<!-- this test shows slight disconnect between css media queries and html4 media descriptors -->
-<style type="text/css" media=",,,,,,">
-p { color: green }
-</styl>
-<style type="text/css">
-@import url(import-p-red.css) all,,,,,,;
-
-</style>
-</head>
-<body>
-<p> This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-except-02-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-except-02-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-except-02-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,6 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-<p>Caught exception: SyntaxError (DOM Exception 12): The string did not match the expected pattern.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-except-02.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-except-02.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-except-02.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,38 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: @media css rule media.mediaText property parsing, media query syntax error should be handled correctly.</title>
-<link rel="help" href="" />
-
-<style type="text/css">
-p#result {color: green}
-
-@media not screen {
-/* query will be modified from _javascript_ */
-/* the manipulation contains syntax error, and should fail */
-p#result {color: red}
-}
-
-@media screen and resolution > 40dpi {
-/* media query with syntax error should fail */
-/* corresponding DOM manipulation will fail */
-p#result {color: red}
-}
-</style>
-<script language="_javascript_">
-function test() {
-    try {
-        // this should throw
-        document.styleSheets[0].cssRules[1].media.mediaText = "screen and resolution > 40dpi";
-    } catch (e) {
-        document.getElementById("result").innerHTML = "This text should be green.";
-        document.getElementById("details").innerHTML = "Caught exception: " + e;
-   }
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<p id="result">Failure: test not run</p>
-<p id="details"></p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-except-03-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-except-03-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-except-03-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,6 +0,0 @@
-<html>
-<body>
-<p style="color: green">Success. This text should be green.</p>
-<p>Caught exception: SyntaxError (DOM Exception 12): The string did not match the expected pattern.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-except-03.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-except-03.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-except-03.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,43 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: @media css rule media.mediaText property parsing, media query syntax error should be handled correctly (,,,,).</title>
-<link rel="help" href="" />
-<link rel="help" href="" />
-<!-- this test shows slight disconnect between css media queries and html4 media descriptors -->
-<style type="text/css">
-p#result {color: green}
-
-@media braille {
-/* query will be modified from _javascript_ */
-/* the manipulation contains syntax error, and should fail */
-p#result {color: red}
-}
-}
-</style>
-<script language="_javascript_">
-function test() {
-    try {
-        // this shouldn't throw
-        document.styleSheets[0].media.mediaText = ",,,,";
-    } catch (e) {
-        document.getElementById("result").innerHTML = "Failure. ,,,, should be valid media descriptor.";
-        document.getElementById("details").innerHTML = "Caught exception: " + e;
-        return;
-    }
-    try {
-        // this should throw
-        document.styleSheets[0].cssRules[1].media.mediaText = ",,,,";
-        document.getElementById("result").innerHTML = "Failure. No exception thrown.";
-    } catch (e) {
-        document.getElementById("result").innerHTML = "Success. This text should be green.";
-        document.getElementById("details").innerHTML = "Caught exception: " + e;
-   }
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<p id="result">Failure: test not run</p>
-<p id="details">aaa</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,5 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green.</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-media-forward-syntax.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-media-forward-syntax.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-media-forward-syntax.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,33 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: stylesheet media.mediaText = parsing, media descriptor fallback in document.StyleSheet.media.mediaText</title>
-<link rel="help" href="" />
-
-<!-- the media property of stylesheet below will be manipulated, and
- manipulation should respect html media descriptor forward-compatible syntax.
- This means the manipulation should succeed. -->
-<style type="text/css">
-
-p#result { color: green;}
-
-@media screen and resolution > 40dpi {
-/* media query with syntax error should fail */
-/* corresponding DOM manipulation to the mediaText of the stylesheet will succeed */
-p#result { color: red;}
-
-}
-</style>
-<script language="_javascript_">
-function test() {
-   // this should not throw, because StyleSheet should respect Media Description forward-compatible syntax
-   document.styleSheets[0].media.mediaText = "screen and resolution > 40dpi";
-   document.getElementById("result").innerHTML = "This text should be green.";
-}
-</script>
-
-
-</head>
-<body _onload_="test()">
-<p id="result">Failure: test not run</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,6 +0,0 @@
-<html>
-<body>
-<p>The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty".</p>
-<p style="color: green">braille, media, screen and (color) and (grid: 0), tty</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-01.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,23 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: stylesheet media.mediaText property inspection.</title>
-<link rel="help" href="" />
-
-<style type="text/css" media="braille, media with error, screen and (color) and (grid:0), tty resolution > 600px">
-#result { color: green }
-</style>
-
-<script language="_javascript_">
-function test() {
-    re = document.getElementById("result");
-    re.innerHTML = "started";
-    re.innerHTML = document.styleSheets[0].media.mediaText;
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<p> The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty". </p>
-<p id="result">Failure: test not run</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,6 +0,0 @@
-<html>
-<body>
-<p>The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty".</p>
-<p style="color: green">braille, media, screen and (color) and (grid: 0), tty</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-02.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,27 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: stylesheet media property enumeration.</title>
-<link rel="help" href="" />
-<link rel="help" href="" />
-
-<style type="text/css" media="braille, media with error, screen and (color) and (grid:0), tty resolution > 600px">
-#result { color: green; }
-</style>
-
-<script language="_javascript_">
-function test() {
-    re = document.getElementById("result");
-    re.innerHTML = "started";
-    re.innerHTML = document.styleSheets[0].media.item(0)
-                    + ", " + document.styleSheets[0].media.item(1)
-                    + ", " + document.styleSheets[0].media.item(2)
-                    + ", " + document.styleSheets[0].media.item(3) ;
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<p> The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty". </p>
-<p id="result">Failure: test not run</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,7 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green and below should read "braille, not screen, screen and (color)".</p>
-<p style="color: green">braille, not screen, screen and (color), not screen</p>
-<p style="color: green">expected to fail (24.07.2005)</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-03.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,35 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: stylesheet media.appendMedium</title>
-<link rel="help" href="" />
-<link rel="help" href="" />
-<style type="text/css" media="braille, not screen">
-p { color: green }
-</style>
-
-<script language="_javascript_">
-function test() {
-    var re = document.getElementById("result");
-    var media = document.styleSheets[0].media;
-    media.appendMedium("screen and (color)");
-    media.appendMedium("not screen");
-    var first = true;
-    for (var i = 0; i < media.length; ++i) {
-        if (!first)  re.innerHTML += ", " + media.item(i);
-        else re.innerHTML = media.item(i);
-        first = false;
-    }
-
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<!-- FIXME: NOTE! This will fail until dynamic setting of media property causes style recalculation.
-          This is not the case currently (24.07.2005)
--->
-<p> This text should be green and below should read "braille, not screen, screen and (color)". </p>
-<p id="result">Failure: test not run</p>
-<p> expected to fail (24.07.2005)</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,7 +0,0 @@
-<html>
-<body>
-<p style="color: green">This text should be green and below should read "media list is empty".</p>
-<p style="color: green">media list is empty</p>
-<p style="color: green">Expected to fail (24.7.2005)</p>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04.html (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04.html	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-js-stylesheet-media-04.html	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,37 +0,0 @@
-<html>
-<head>
-<title>CSS3 media query test: stylesheet media deleteMedium </title>
-<link rel="help" href="" />
-<link rel="help" href="" />
-<style type="text/css" media="braille, not screen">
-p { color: green }
-</style>
-
-<script language="_javascript_">
-function test() {
-    var re = document.getElementById("result");
-    var media = document.styleSheets[0].media;
-    media.appendMedium("screen and (color)");
-    while (media.length) {
-        media.deleteMedium(media.item(0));
-    }
-    re.innerHTML = "media list is empty"
-    var first = true;
-    for (var i = 0; i < media.length; ++i) {
-        if (!first)  re.innerHTML += ", " + media.item(i);
-        else re.innerHTML = media.item(i);
-        first = false;
-    }
-}
-</script>
-
-</head>
-<body _onload_="test()">
-<!-- FIXME: NOTE! This will fail until dynamic setting of media property causes style recalculation.
-          This is not the case currently (24.07.2005)
--->
-<p> This text should be green and below should read "media list is empty".  </p>
-<p id="result">Failure: test not run</p>
-<p> Expected to fail (24.7.2005) </p>
-</body>
-</html>

Modified: trunk/LayoutTests/fast/media/mq-pointer-expected.txt (208846 => 208847)


--- trunk/LayoutTests/fast/media/mq-pointer-expected.txt	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/mq-pointer-expected.txt	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,7 +1,7 @@
 Test the (pointer) and (hover) media features. See Bug 87403 for details.
 
 Query "(pointer)": true
-Query "(Pointer)": true
+Query "(pointer)": true
 Query "(pointer:none)": false
 Query "(pointer:coarse)": false
 Query "(pointer:coARse)": false

Modified: trunk/LayoutTests/fast/media/w3c/test_media_queries-expected.txt (208846 => 208847)


--- trunk/LayoutTests/fast/media/w3c/test_media_queries-expected.txt	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/fast/media/w3c/test_media_queries-expected.txt	2016-11-17 17:28:52 UTC (rev 208847)
@@ -278,13 +278,13 @@
 PASS (resolution: dpi) should not apply 
 PASS (resolution: dpi + 1) should not apply 
 FAIL (min-resolution: dpi - 1 ) should apply assert_true: expected true got false
-PASS not all and (min-resolution: dpi - 1 ) should not apply 
-FAIL not all and (min-resolution: dpi + 1 ) should apply assert_true: expected true got false
+FAIL not all and (min-resolution: dpi - 1 ) should not apply assert_false: expected false got true
+PASS not all and (min-resolution: dpi + 1 ) should apply 
 PASS all and (min-resolution: dpi + 1 ) should not apply 
 FAIL (min-resolution: dpcm (dpi - 1) ) should apply assert_true: expected true got false
 FAIL (max-resolution: dpcm  (dpi + 1) ) should apply assert_true: expected true got false
 PASS (max-resolution: dpcm  (dpi - 1) ) should not apply 
-FAIL not all and (min-resolution: dpcm  (dpi + 1) ) should apply assert_true: expected true got false
+PASS not all and (min-resolution: dpcm  (dpi + 1) ) should apply 
 PASS _expression_ grid should be parseable 
 PASS _expression_ grid: 0 should be parseable 
 PASS _expression_ grid: 1 should be parseable 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/update-the-source-set-expected.txt (208846 => 208847)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/update-the-source-set-expected.txt	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/update-the-source-set-expected.txt	2016-11-17 17:28:52 UTC (rev 208847)
@@ -34,8 +34,8 @@
 PASS <picture><source srcset="data:,b" media=""><img src="" data-expect="data:,b"></picture> 
 PASS <picture><source srcset="data:,b" media="all"><img src="" data-expect="data:,b"></picture> 
 PASS <picture><source srcset="data:,b" media="all and (min-width:0)"><img src="" data-expect="data:,b"></picture> 
-FAIL <picture><source srcset="data:,b" media="all and !"><img src="" data-expect="data:,a"></picture> assert_equals: expected "data:,a" but got "data:,b"
-FAIL <picture><source srcset="data:,b" media="all and (!)"><img src="" data-expect="data:,a"></picture> assert_equals: expected "data:,a" but got "data:,b"
+PASS <picture><source srcset="data:,b" media="all and !"><img src="" data-expect="data:,a"></picture> 
+PASS <picture><source srcset="data:,b" media="all and (!)"><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media="not all"><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media="not all and (min-width:0)"><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media="not all and (max-width:0)"><img src="" data-expect="data:,b"></picture> 
@@ -42,7 +42,7 @@
 PASS <picture><source srcset="data:,b" media="not all and !"><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media="not all and (!)"><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media="all, !"><img src="" data-expect="data:,b"></picture> 
-FAIL <picture><source srcset="data:,b" media=","><img src="" data-expect="data:,a"></picture> assert_equals: expected "data:,a" but got "data:,b"
+PASS <picture><source srcset="data:,b" media=","><img src="" data-expect="data:,a"></picture> 
 PASS <picture><source srcset="data:,b" media=", all"><img src="" data-expect="data:,b"></picture> 
 PASS <picture><source srcset="data:,b" type=""><img src="" data-expect="data:,b"></picture> 
 PASS <picture><source srcset="data:,b" type=" "><img src="" data-expect="data:,b"></picture> 

Modified: trunk/Source/WebCore/ChangeLog (208846 => 208847)


--- trunk/Source/WebCore/ChangeLog	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/ChangeLog	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,3 +1,106 @@
+2016-11-16  Dave Hyatt  <[email protected]>
+
+        [CSS Parser] Add @supports, @keyframe and media query parsing options
+        https://bugs.webkit.org/show_bug.cgi?id=164821
+
+        Reviewed by Sam Weinig and Zalan Bujtas.
+
+        * css/CSSKeyframeRule.cpp:
+        (WebCore::StyleKeyframe::setKeyText):
+        * css/CSSKeyframeRule.h:
+        * css/CSSKeyframesRule.cpp:
+        (WebCore::StyleRuleKeyframes::findKeyframeIndex):
+        Changed to call into CSSParserImpls implementation. The new parser
+        is now always used when parsing the key list.
+
+        * css/MediaList.cpp:
+        (WebCore::MediaQuerySet::create):
+        (WebCore::MediaQuerySet::MediaQuerySet):
+        (WebCore::MediaQuerySet::set):
+        (WebCore::MediaQuerySet::add):
+        (WebCore::MediaQuerySet::remove):
+        (WebCore::MediaList::setMediaText):
+        (WebCore::parseMediaDescriptor): Deleted.
+        (WebCore::MediaQuerySet::internalParse): Deleted.
+        (WebCore::MediaQuerySet::parse): Deleted.
+        * css/MediaList.h:
+        Rewritten to remove fallback descriptor support/parsing, since no other
+        browser supports it, and this was part of our initial 2005 landing that
+        nobody else appears to use.  Media queries now call into the new parser always.
+
+        * css/MediaQueryExp.cpp:
+        (WebCore::featureWithValidDensity):
+        (WebCore::featureWithPositiveNumber):
+        (WebCore::MediaQueryExpression::MediaQueryExpression):
+        Make sure to support transform2d, animation and transition.
+
+        * css/StyleMedia.cpp:
+        (WebCore::StyleMedia::matchMedium):
+        Call the normal create now that fallback descriptor syntax is gone.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseKeyframeRule):
+        (WebCore::CSSParser::parseSupportsCondition):
+        (WebCore::CSSParser::parseInlineStyleDeclaration):
+        (WebCore::CSSParser::parseDeclarationDeprecated):
+        (WebCore::CSSParser::parseDeclaration):
+        (WebCore::CSSParser::parseKeyframeKeyList):
+        (WebCore::CSSParser::parseMediaQuery): Deleted.
+        (WebCore::CSSParser::parseKeyframeSelector): Deleted.
+        * css/parser/CSSParser.h:
+        Patched the old parser to have flags to call into the new parser
+        for supports conditions and keyframes. Rename the parseDeclaration that
+        is only used by the old parser to have the word Deprecated in it. Removed
+        the media query and key list parsing functions, since the new parser
+        now does it always.
+
+        * css/parser/CSSParserIdioms.cpp:
+        (WebCore::convertToASCIILowercaseInPlace): Deleted.
+        * css/parser/CSSParserIdioms.h:
+        * css/parser/CSSParserToken.cpp:
+        (WebCore::convertToASCIILowercaseInPlace):
+        (WebCore::CSSParserToken::convertToASCIILowercaseInPlace):
+        * css/parser/CSSParserToken.h:
+        (WebCore::CSSParserToken::value):
+        (WebCore::CSSParserToken::initValueFromStringView):
+        * css/parser/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::parsePseudoElementSelectorFromStringView):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeAttr):
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::CSSSelectorParser::consumeId):
+        (WebCore::CSSSelectorParser::consumeClass):
+        (WebCore::CSSSelectorParser::consumePseudo):
+        Moving convertToASCIILowercase to be a CSSParserToken member function instead
+        of operating on StringView. This saves an extra step, since the token itself
+        already had all the correct members. Note that converting in-place is bad,
+        and we'll be removing it once the new parser turns on.
+
+        * css/parser/MediaQueryParser.cpp:
+        (WebCore::MediaQueryParser::readMediaType):
+        (WebCore::MediaQueryParser::readFeature):
+        (WebCore::MediaQueryParser::readFeatureEnd):
+        Require the closing ")" on features. Fix the in-place lowercasing to only
+        be done for features, not for types. This matches the old parser.
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createCSSStyleSheet):
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::createSheet):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        (WebCore::HTMLLinkElement::initializeStyleSheet):
+        * html/HTMLSourceElement.cpp:
+        (WebCore::HTMLSourceElement::parseAttribute):
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::parseAttribute):
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
+        * html/parser/HTMLResourcePreloader.cpp:
+        (WebCore::mediaAttributeMatches):
+        Patched to call the normal MediaQuerySet::create and not the one that had fallback
+        descriptor support.
+
 2016-11-17  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, attempt to fix link error after r208841 part2

Modified: trunk/Source/WebCore/css/CSSKeyframeRule.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/CSSKeyframeRule.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -70,6 +70,16 @@
 
     return keyText.toString();
 }
+    
+bool StyleKeyframe::setKeyText(const String& keyText)
+{
+    ASSERT(!keyText.isNull());
+    auto keys = CSSParser::parseKeyframeKeyList(keyText);
+    if (!keys || keys->isEmpty())
+        return false;
+    m_keys = *keys;
+    return true;
+}
 
 String StyleKeyframe::cssText() const
 {

Modified: trunk/Source/WebCore/css/CSSKeyframeRule.h (208846 => 208847)


--- trunk/Source/WebCore/css/CSSKeyframeRule.h	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/CSSKeyframeRule.h	2016-11-17 17:28:52 UTC (rev 208847)
@@ -51,7 +51,7 @@
     ~StyleKeyframe();
 
     String keyText() const;
-    void setKeyText(const String& text) { m_keys = CSSParser::parseKeyframeSelector(text); }
+    bool setKeyText(const String&);
     void setKey(double key)
     {
         ASSERT(m_keys.isEmpty());

Modified: trunk/Source/WebCore/css/CSSKeyframesRule.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/CSSKeyframesRule.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/CSSKeyframesRule.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -74,10 +74,10 @@
 
 size_t StyleRuleKeyframes::findKeyframeIndex(const String& key) const
 {
-    Vector<double>&& keys = CSSParser::parseKeyframeSelector(key);
+    auto keys = CSSParser::parseKeyframeKeyList(key);
 
     for (size_t i = m_keyframes.size(); i--; ) {
-        if (m_keyframes[i]->keys() == keys)
+        if (m_keyframes[i]->keys() == *keys)
             return i;
     }
 

Modified: trunk/Source/WebCore/css/MediaList.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/MediaList.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/MediaList.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -30,6 +30,7 @@
 #include "HTMLParserIdioms.h"
 #include "MediaFeatureNames.h"
 #include "MediaQuery.h"
+#include "MediaQueryParser.h"
 #include "ScriptableDocumentParser.h"
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringBuilder.h>
@@ -64,35 +65,21 @@
  * throw SYNTAX_ERR exception.
  */
     
-MediaQuerySet::MediaQuerySet()
-    : m_fallbackToDescriptor(false)
-    , m_lastLine(0)
+Ref<MediaQuerySet> MediaQuerySet::create(const String& mediaString)
 {
+    if (mediaString.isEmpty())
+        return MediaQuerySet::create();
+    
+    return MediaQueryParser::parseMediaQuerySet(mediaString).releaseNonNull();
 }
 
-MediaQuerySet::MediaQuerySet(const String& mediaString, bool fallbackToDescriptor)
-    : m_fallbackToDescriptor(fallbackToDescriptor)
-    , m_lastLine(0)
+MediaQuerySet::MediaQuerySet()
+    : m_lastLine(0)
 {
-    bool success = parse(mediaString);
-
-    // FIXME: parsing can fail. The problem with failing constructor is that
-    // we would need additional flag saying MediaList is not valid
-    // Parse can fail only when fallbackToDescriptor == false, i.e when HTML4 media descriptor
-    // forward-compatible syntax is not in use.
-    // DOMImplementationCSS seems to mandate that media descriptors are used
-    // for both HTML and SVG, even though svg:style doesn't use media descriptors
-    // Currently the only places where parsing can fail are
-    // creating <svg:style>, creating css media / import rules from js
-
-    // FIXME: This doesn't make much sense.
-    if (!success)
-        parse("invalid");
 }
 
 MediaQuerySet::MediaQuerySet(const MediaQuerySet& o)
     : RefCounted()
-    , m_fallbackToDescriptor(o.m_fallbackToDescriptor)
     , m_lastLine(o.m_lastLine)
     , m_queries(o.m_queries)
 {
@@ -102,85 +89,62 @@
 {
 }
 
-static String parseMediaDescriptor(const String& string)
+bool MediaQuerySet::set(const String& mediaString)
 {
-    // http://www.w3.org/TR/REC-html40/types.html#type-media-descriptors
-    // "Each entry is truncated just before the first character that isn't a
-    // US ASCII letter [a-zA-Z] (ISO 10646 hex 41-5a, 61-7a), digit [0-9] (hex 30-39),
-    // or hyphen (hex 2d)."
-    unsigned length = string.length();
-    unsigned i;
-    for (i = 0; i < length; ++i) {
-        auto character = string[i];
-        if (!(isASCIIAlphanumeric(character) || character == '-'))
-            break;
-    }
-    return string.left(i);
+    auto result = create(mediaString);
+    m_queries.swap(result->m_queries);
+    return true;
 }
 
-Optional<MediaQuery> MediaQuerySet::internalParse(CSSParser& parser, const String& queryString)
+bool MediaQuerySet::add(const String& queryString)
 {
-    if (auto query = parser.parseMediaQuery(queryString))
-        return WTFMove(*query);
-    if (!m_fallbackToDescriptor)
-        return Nullopt;
-    return MediaQuery { MediaQuery::None, parseMediaDescriptor(queryString), Vector<MediaQueryExpression> { } };
+    // To "parse a media query" for a given string means to follow "the parse
+    // a media query list" steps and return "null" if more than one media query
+    // is returned, or else the returned media query.
+    auto result = create(queryString);
+    
+    // Only continue if exactly one media query is found, as described above.
+    if (result->m_queries.size() != 1)
+        return true;
+    
+    // If comparing with any of the media queries in the collection of media
+    // queries returns true terminate these steps.
+    for (size_t i = 0; i < m_queries.size(); ++i) {
+        if (m_queries[i] == result->m_queries[0])
+            return true;
+    }
+    
+    m_queries.append(result->m_queries[0]);
+    return true;
 }
 
-Optional<MediaQuery> MediaQuerySet::internalParse(const String& queryString)
+bool MediaQuerySet::remove(const String& queryStringToRemove)
 {
-    CSSParser parser(HTMLStandardMode);
-    return internalParse(parser, queryString);
-}
-
-bool MediaQuerySet::parse(const String& mediaString)
-{
-    CSSParser parser(HTMLStandardMode);
+    // To "parse a media query" for a given string means to follow "the parse
+    // a media query list" steps and return "null" if more than one media query
+    // is returned, or else the returned media query.
+    auto result = create(queryStringToRemove);
     
-    Vector<MediaQuery> result;
-    Vector<String> list;
-    mediaString.split(',', list);
-    for (auto& listString : list) {
-        String medium = stripLeadingAndTrailingHTMLSpaces(listString);
-        if (medium.isEmpty()) {
-            if (m_fallbackToDescriptor)
-                continue;
-        } else if (auto query = internalParse(parser, medium)) {
-            result.append(WTFMove(query.value()));
-            continue;
+    // Only continue if exactly one media query is found, as described above.
+    if (result->m_queries.size() != 1)
+        return true;
+    
+    // Remove any media query from the collection of media queries for which
+    // comparing with the media query returns true.
+    bool found = false;
+    
+    // Using signed int here, since for the first value, --i will result in -1.
+    for (int i = 0; i < (int)m_queries.size(); ++i) {
+        if (m_queries[i] == result->m_queries[0]) {
+            m_queries.remove(i);
+            --i;
+            found = true;
         }
-        return false;
     }
-    // ",,,," falls straight through, but is not valid unless fallback
-    if (!m_fallbackToDescriptor && list.isEmpty()) {
-        String strippedMediaString = stripLeadingAndTrailingHTMLSpaces(mediaString);
-        if (!strippedMediaString.isEmpty())
-            return false;
-    }
-    m_queries = WTFMove(result);
-    shrinkToFit();
-    return true;
+    
+    return found;
 }
 
-bool MediaQuerySet::add(const String& queryString)
-{
-    auto parsedQuery = internalParse(queryString);
-    if (!parsedQuery)
-        return false;
-    m_queries.append(WTFMove(parsedQuery.value()));
-    return true;
-}
-
-bool MediaQuerySet::remove(const String& queryString)
-{
-    auto parsedQuery = internalParse(queryString);
-    if (!parsedQuery)
-        return false;
-    return m_queries.removeFirstMatching([&parsedQuery](auto& query) {
-        return query == parsedQuery.value();
-    });
-}
-
 void MediaQuerySet::addMediaQuery(MediaQuery&& mediaQuery)
 {
     m_queries.append(WTFMove(mediaQuery));
@@ -225,8 +189,7 @@
 ExceptionOr<void> MediaList::setMediaText(const String& value)
 {
     CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule);
-    if (!m_mediaQueries->parse(value))
-        return Exception { SYNTAX_ERR };
+    m_mediaQueries->set(value);
     if (m_parentStyleSheet)
         m_parentStyleSheet->didMutate();
     return { };

Modified: trunk/Source/WebCore/css/MediaList.h (208846 => 208847)


--- trunk/Source/WebCore/css/MediaList.h	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/MediaList.h	2016-11-17 17:28:52 UTC (rev 208847)
@@ -39,17 +39,12 @@
     {
         return adoptRef(*new MediaQuerySet);
     }
-    static Ref<MediaQuerySet> create(const String& mediaString)
-    {
-        return adoptRef(*new MediaQuerySet(mediaString, false));
-    }
-    static Ref<MediaQuerySet> createAllowingDescriptionSyntax(const String& mediaString)
-    {
-        return adoptRef(*new MediaQuerySet(mediaString, true));
-    }
+
+    static WEBCORE_EXPORT Ref<MediaQuerySet> create(const String& mediaString);
+
     WEBCORE_EXPORT ~MediaQuerySet();
 
-    bool parse(const String&);
+    bool set(const String&);
     bool add(const String&);
     bool remove(const String&);
 
@@ -68,14 +63,10 @@
 
 private:
     MediaQuerySet();
-    WEBCORE_EXPORT MediaQuerySet(const String& mediaQuery, bool fallbackToDescription);
+    WEBCORE_EXPORT MediaQuerySet(const String& mediaQuery);
     MediaQuerySet(const MediaQuerySet&);
 
-    Optional<MediaQuery> internalParse(CSSParser&, const String&);
-    Optional<MediaQuery> internalParse(const String&);
-
-    unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing should fallback to media description parsing.
-    signed m_lastLine : 31;
+    signed m_lastLine;
     Vector<MediaQuery> m_queries;
 };
 

Modified: trunk/Source/WebCore/css/MediaQueryExp.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/MediaQueryExp.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/MediaQueryExp.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -56,7 +56,7 @@
 
 static inline bool featureWithValidDensity(const String& mediaFeature, const CSSParserToken& token)
 {
-    if ((token.unitType() != CSSPrimitiveValue::UnitTypes::CSS_DPPX && token.unitType() != CSSPrimitiveValue::UnitTypes::CSS_DPI && token.unitType() != CSSPrimitiveValue::UnitTypes::CSS_DPCM) || token.numericValue() <= 0)
+    if (!CSSPrimitiveValue::isResolution(static_cast<CSSPrimitiveValue::UnitTypes>(token.unitType())) || token.numericValue() <= 0)
         return false;
     
     return mediaFeature == MediaFeatureNames::resolution
@@ -108,7 +108,10 @@
     return mediaFeature == MediaFeatureNames::transform3d
     || mediaFeature == MediaFeatureNames::devicePixelRatio
     || mediaFeature == MediaFeatureNames::maxDevicePixelRatio
-    || mediaFeature == MediaFeatureNames::minDevicePixelRatio;
+    || mediaFeature == MediaFeatureNames::minDevicePixelRatio
+    || mediaFeature == MediaFeatureNames::transition
+    || mediaFeature == MediaFeatureNames::animation
+    || mediaFeature == MediaFeatureNames::transform2d;
 }
 
 static inline bool featureWithZeroOrOne(const String& mediaFeature, const CSSParserToken& token)
@@ -334,7 +337,6 @@
         
         m_value = CSSAspectRatioValue::create(numerator.numericValue(), denominator.numericValue());
         m_isValid = true;
-
     }
 }
 

Modified: trunk/Source/WebCore/css/StyleMedia.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/StyleMedia.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/StyleMedia.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -65,9 +65,7 @@
 
     auto rootStyle = document->styleScope().resolver().styleForElement(*documentElement, document->renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
 
-    auto media = MediaQuerySet::create();
-    if (!media->parse(query))
-        return false;
+    auto media = MediaQuerySet::create(query);
 
     return MediaQueryEvaluator { type(), *document, rootStyle.get() }.evaluate(media.get());
 }

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -69,6 +69,7 @@
 #include "CSSSelectorParser.h"
 #include "CSSShadowValue.h"
 #include "CSSStyleSheet.h"
+#include "CSSSupportsParser.h"
 #include "CSSTimingFunctionValue.h"
 #include "CSSTokenizer.h"
 #include "CSSUnicodeRangeValue.h"
@@ -404,6 +405,11 @@
 
 RefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet, const String& string)
 {
+    if (m_context.useNewParser && m_context.mode != UASheetMode) {
+        RefPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(string, m_context, nullptr, CSSParserImpl::KeyframeRules);
+        return downcast<StyleKeyframe>(keyframe.get());
+    }
+
     setStyleSheet(sheet);
     setupParser("@-webkit-keyframe-rule{ ", string, "} ");
     cssyyparse(this);
@@ -410,12 +416,19 @@
     return m_keyframe;
 }
 
-bool CSSParser::parseSupportsCondition(const String& string)
+bool CSSParser::parseSupportsCondition(const String& condition)
 {
+    if (m_context.useNewParser && m_context.mode != UASheetMode) {
+        CSSTokenizer::Scope scope(condition);
+        CSSParserTokenRange range = scope.tokenRange();
+        CSSParserImpl parser(strictCSSParserContext());
+        return CSSSupportsParser::supportsCondition(range, parser) == CSSSupportsParser::Supported;
+    }
+
     m_supportsCondition = false;
     // can't use { because tokenizer state switches from supports to initial state when it sees { token.
     // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
-    setupParser("@-webkit-supports-condition ", string, "} ");
+    setupParser("@-webkit-supports-condition ", condition, "} ");
     cssyyparse(this);
     return m_supportsCondition;
 }
@@ -1440,11 +1453,13 @@
     if (context.useNewParser)
         return CSSParserImpl::parseInlineStyleDeclaration(string, element);
 
-    return CSSParser(context).parseDeclaration(string, nullptr);
+    return CSSParser(context).parseDeclarationDeprecated(string, nullptr);
 }
 
-Ref<ImmutableStyleProperties> CSSParser::parseDeclaration(const String& string, StyleSheetContents* contextStyleSheet)
+Ref<ImmutableStyleProperties> CSSParser::parseDeclarationDeprecated(const String& string, StyleSheetContents* contextStyleSheet)
 {
+    ASSERT(!m_context.useNewParser);
+    
     setStyleSheet(contextStyleSheet);
 
     setupParser("@-webkit-decls{", string, "} ");
@@ -1459,6 +1474,9 @@
 
 bool CSSParser::parseDeclaration(MutableStyleProperties& declaration, const String& string, RefPtr<CSSRuleSourceData>&& ruleSourceData, StyleSheetContents* contextStyleSheet)
 {
+    if (m_context.useNewParser && m_context.mode != UASheetMode)
+        return CSSParserImpl::parseDeclarationList(&declaration, string, m_context);
+
     // Length of the "@-webkit-decls{" prefix.
     static const unsigned prefixLength = 15;
 
@@ -1497,21 +1515,6 @@
     return ok;
 }
 
-std::unique_ptr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
-{
-    if (string.isEmpty())
-        return nullptr;
-
-    ASSERT(!m_mediaQuery);
-
-    // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
-    // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
-    setupParser("@-webkit-mediaquery ", string, "} ");
-    cssyyparse(this);
-
-    return WTFMove(m_mediaQuery);
-}
-
 static inline void filterProperties(bool important, const ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, std::bitset<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenCustomProperties)
 {
     // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
@@ -4943,34 +4946,9 @@
 }
 
 /* static */
-Vector<double> CSSParser::parseKeyframeSelector(const String& selector) {
-    Vector<double> keys;
-    Vector<String> strings;
-    selector.split(',', strings);
-
-    keys.reserveInitialCapacity(strings.size());
-    for (size_t i = 0; i < strings.size(); ++i) {
-        double key = -1;
-        String cur = strings[i].stripWhiteSpace();
-
-        // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number
-        if (equalLettersIgnoringASCIICase(cur, "from"))
-            key = 0;
-        else if (equalLettersIgnoringASCIICase(cur, "to"))
-            key = 1;
-        else if (cur.endsWith('%')) {
-            double k = cur.substring(0, cur.length() - 1).toDouble();
-            if (k >= 0 && k <= 100)
-                key = k / 100;
-        }
-        if (key < 0) {
-            keys.clear();
-            break;
-        }
-        keys.uncheckedAppend(key);
-    }
-
-    return keys;
+std::unique_ptr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& selector)
+{
+    return CSSParserImpl::parseKeyframeKeyList(selector);
 }
 
 bool CSSParser::parseTransformOriginShorthand(RefPtr<CSSPrimitiveValue>& value1, RefPtr<CSSPrimitiveValue>& value2, RefPtr<CSSValue>& value3)

Modified: trunk/Source/WebCore/css/parser/CSSParser.h (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParser.h	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParser.h	2016-11-17 17:28:52 UTC (rev 208847)
@@ -143,7 +143,6 @@
 
     WEBCORE_EXPORT bool parseDeclaration(MutableStyleProperties&, const String&, RefPtr<CSSRuleSourceData>&&, StyleSheetContents* contextStyleSheet);
     static Ref<ImmutableStyleProperties> parseInlineStyleDeclaration(const String&, Element*);
-    std::unique_ptr<MediaQuery> parseMediaQuery(const String&);
 
     void addProperty(CSSPropertyID, RefPtr<CSSValue>&&, bool important, bool implicit = false);
     void rollbackLastProperties(int num);
@@ -207,7 +206,7 @@
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     RefPtr<CSSValue> parseAnimationTrigger();
 #endif
-    static Vector<double> parseKeyframeSelector(const String&);
+    static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&);
 
     bool parseTransformOriginShorthand(RefPtr<CSSPrimitiveValue>&, RefPtr<CSSPrimitiveValue>&, RefPtr<CSSValue>&);
     Optional<double> parseCubicBezierTimingFunctionValue(CSSParserValueList&);
@@ -592,7 +591,9 @@
     bool parseGeneratedImage(CSSParserValueList&, RefPtr<CSSValue>&);
 
     ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
-    Ref<ImmutableStyleProperties> parseDeclaration(const String&, StyleSheetContents* contextStyleSheet);
+    
+    // FIXME-NEWPARSER: Remove once old parser is gone.
+    Ref<ImmutableStyleProperties> parseDeclarationDeprecated(const String&, StyleSheetContents* contextStyleSheet);
 
     RefPtr<CSSBasicShapeInset> parseInsetRoundedCorners(Ref<CSSBasicShapeInset>&&, CSSParserValueList&);
 

Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -34,22 +34,6 @@
 
 namespace WebCore {
 
-template<typename CharacterType> ALWAYS_INLINE static void convertToASCIILowercaseInPlace(CharacterType* characters, unsigned length)
-{
-    for (unsigned i = 0; i < length; ++i)
-        characters[i] = toASCIILower(characters[i]);
-}
-
-// FIXME-NEWPARSER: Would like to get rid of this operation. Blink uses HTMLParser static lowercase
-// string hashing, but we don't have that code in our HTMLParser.
-void convertToASCIILowercaseInPlace(StringView& stringView)
-{
-    if (stringView.is8Bit())
-        WebCore::convertToASCIILowercaseInPlace(const_cast<LChar*>(stringView.characters8()), stringView.length());
-    else
-        WebCore::convertToASCIILowercaseInPlace(const_cast<UChar*>(stringView.characters16()), stringView.length());
-}
-
 bool isValueAllowedInMode(unsigned short id, CSSParserMode mode)
 {
     switch (id) {

Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.h (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParserIdioms.h	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.h	2016-11-17 17:28:52 UTC (rev 208847)
@@ -60,8 +60,6 @@
     return isNameStartCodePoint(c) || isASCIIDigit(c) || c == '-';
 }
 
-void convertToASCIILowercaseInPlace(StringView&);
-
 bool isValueAllowedInMode(unsigned short, CSSParserMode);
 
 URL completeURL(const CSSParserContext&, const String& url);

Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -476,4 +476,23 @@
     }
 }
 
+template<typename CharacterType> ALWAYS_INLINE static void convertToASCIILowercaseInPlace(CharacterType* characters, unsigned length)
+{
+    for (unsigned i = 0; i < length; ++i)
+        characters[i] = toASCIILower(characters[i]);
+}
+
+// FIXME-NEWPARSER: Would like to get rid of this operation. Blink uses HTMLParser static lowercase
+// string hashing, but we don't have that code in our HTMLParser.
+void CSSParserToken::convertToASCIILowercaseInPlace()
+{
+    if (!hasStringBacking())
+        return;
+
+    if (m_valueIs8Bit)
+        WebCore::convertToASCIILowercaseInPlace(static_cast<LChar*>(m_valueDataCharRaw), m_valueLength);
+    else
+        WebCore::convertToASCIILowercaseInPlace(static_cast<UChar*>(m_valueDataCharRaw), m_valueLength);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/parser/CSSParserToken.h (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParserToken.h	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.h	2016-11-17 17:28:52 UTC (rev 208847)
@@ -117,10 +117,12 @@
     StringView value() const
     {
         if (m_valueIs8Bit)
-            return StringView(reinterpret_cast<const LChar*>(m_valueDataCharRaw), m_valueLength);
-        return StringView(reinterpret_cast<const UChar*>(m_valueDataCharRaw), m_valueLength);
+            return StringView(static_cast<const LChar*>(m_valueDataCharRaw), m_valueLength);
+        return StringView(static_cast<const UChar*>(m_valueDataCharRaw), m_valueLength);
     }
 
+    void convertToASCIILowercaseInPlace();
+
     UChar delimiter() const;
     NumericSign numericSign() const;
     NumericValueType numericValueType() const;
@@ -146,7 +148,7 @@
     {
         m_valueLength = string.length();
         m_valueIs8Bit = string.is8Bit();
-        m_valueDataCharRaw = m_valueIs8Bit ? static_cast<const void*>(string.characters8()) : static_cast<const void*>(string.characters16());
+        m_valueDataCharRaw = m_valueIs8Bit ? const_cast<void*>(static_cast<const void*>(string.characters8())) : const_cast<void*>(static_cast<const void*>(string.characters16()));
     }
     unsigned m_type : 6; // CSSParserTokenType
     unsigned m_blockType : 2; // BlockType
@@ -160,7 +162,7 @@
     // tightly with the rest of this object for a smaller object size.
     bool m_valueIs8Bit : 1;
     unsigned m_valueLength;
-    const void* m_valueDataCharRaw; // Either LChar* or UChar*.
+    void* m_valueDataCharRaw; // Either LChar* or UChar*.
 
     union {
         UChar m_delimiter;

Modified: trunk/Source/WebCore/css/parser/CSSParserValues.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSParserValues.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSParserValues.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -238,7 +238,6 @@
 
 CSSParserSelector* CSSParserSelector::parsePseudoElementSelectorFromStringView(StringView& pseudoTypeString)
 {
-    convertToASCIILowercaseInPlace(pseudoTypeString);
     AtomicString name = pseudoTypeString.toAtomicString();
     
     CSSSelector::PseudoElementType pseudoType = CSSSelector::parsePseudoElementType(name);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1894,11 +1894,11 @@
     if (args.peek().type() != IdentToken)
         return nullptr;
     
-    StringView stringView = args.consumeIncludingWhitespace().value();
+    CSSParserToken token = args.consumeIncludingWhitespace();
     if (context.isHTMLDocument)
-        convertToASCIILowercaseInPlace(stringView);
+        token.convertToASCIILowercaseInPlace();
 
-    String attrName = stringView.toString();
+    String attrName = token.value().toString();
     if (!args.atEnd())
         return nullptr;
 

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -388,10 +388,10 @@
     
     // FIXME-NEWPARSER: Avoid having to do this, but the old parser does and we need
     // to be compatible for now.
-    StringView stringView = range.consume().value();
+    CSSParserToken token = range.consume();
     if (m_context.mode == HTMLQuirksMode)
-        convertToASCIILowercaseInPlace(stringView);
-    selector->setValue(stringView.toAtomicString());
+        token.convertToASCIILowercaseInPlace();
+    selector->setValue(token.value().toAtomicString());
 
     return selector;
 }
@@ -408,10 +408,10 @@
     
     // FIXME-NEWPARSER: Avoid having to do this, but the old parser does and we need
     // to be compatible for now.
-    StringView stringView = range.consume().value();
+    CSSParserToken token = range.consume();
     if (m_context.mode == HTMLQuirksMode)
-        convertToASCIILowercaseInPlace(stringView);
-    selector->setValue(stringView.toAtomicString());
+        token.convertToASCIILowercaseInPlace();
+    selector->setValue(token.value().toAtomicString());
 
     return selector;
 }
@@ -513,6 +513,10 @@
         return nullptr;
 
     std::unique_ptr<CSSParserSelector> selector;
+    
+    // FIXME-NEWPARSER: Would like to eliminate this.
+    const_cast<CSSParserToken&>(token).convertToASCIILowercaseInPlace();
+    
     StringView value = token.value();
     
     // FIXME-NEWPARSER: We can't change the pseudoclass/element maps that the old parser

Modified: trunk/Source/WebCore/css/parser/MediaQueryParser.cpp (208846 => 208847)


--- trunk/Source/WebCore/css/parser/MediaQueryParser.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/css/parser/MediaQueryParser.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -121,9 +121,7 @@
             && isRestrictorOrLogicalOperator(token)) {
             m_state = SkipUntilComma;
         } else {
-            StringView stringView = token.value();
-            convertToASCIILowercaseInPlace(stringView);
-            m_mediaQueryData.setMediaType(stringView.toString());
+            m_mediaQueryData.setMediaType(token.value().toString());
             m_state = ReadAnd;
         }
     } else if (type == EOFToken && (!m_querySet->queryVector().size() || m_state != ReadRestrictor))
@@ -168,6 +166,8 @@
 void MediaQueryParser::readFeature(CSSParserTokenType type, const CSSParserToken& token)
 {
     if (type == IdentToken) {
+        // FIXME-NEWPARSER: Find a way to avoid this.
+        const_cast<CSSParserToken&>(token).convertToASCIILowercaseInPlace();
         m_mediaQueryData.setMediaFeature(token.value().toString());
         m_state = ReadFeatureColon;
     } else
@@ -199,7 +199,7 @@
 void MediaQueryParser::readFeatureEnd(CSSParserTokenType type, const CSSParserToken& token)
 {
     if (type == RightParenthesisToken || type == EOFToken) {
-        if (m_mediaQueryData.addExpression())
+        if (type != EOFToken && m_mediaQueryData.addExpression())
             m_state = ReadAnd;
         else
             m_state = SkipUntilComma;

Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (208846 => 208847)


--- trunk/Source/WebCore/dom/DOMImplementation.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -134,7 +134,7 @@
     // FIXME: Title should be set.
     // FIXME: Media could have wrong syntax, in which case we should generate an exception.
     auto sheet = CSSStyleSheet::create(StyleSheetContents::create());
-    sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
+    sheet->setMediaQueries(MediaQuerySet::create(media));
     return sheet;
 }
 

Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (208846 => 208847)


--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -170,11 +170,7 @@
     if (!contentSecurityPolicy.allowInlineStyle(document.url(), m_startTextPosition.m_line, text, hasKnownNonce))
         return;
 
-    RefPtr<MediaQuerySet> mediaQueries;
-    if (element.isHTMLElement())
-        mediaQueries = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
-    else
-        mediaQueries = MediaQuerySet::create(m_media);
+    RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(m_media);
 
     MediaQueryEvaluator screenEval(ASCIILiteral("screen"), true);
     MediaQueryEvaluator printEval(ASCIILiteral("print"), true);

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (208846 => 208847)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -254,7 +254,7 @@
             Optional<RenderStyle> documentStyle;
             if (document().hasLivingRenderTree())
                 documentStyle = Style::resolveForDocument(document());
-            auto media = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
+            auto media = MediaQuerySet::create(m_media);
             mediaQueryMatches = MediaQueryEvaluator { document().frame()->view()->mediaType(), document(), documentStyle ? &*documentStyle : nullptr }.evaluate(media.get());
         }
 
@@ -348,7 +348,7 @@
         originClean = cachedStyleSheet.isCORSSameOrigin();
 
     m_sheet = CSSStyleSheet::create(WTFMove(styleSheet), *this, originClean);
-    m_sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(m_media));
+    m_sheet->setMediaQueries(MediaQuerySet::create(m_media));
     m_sheet->setTitle(title());
 }
 

Modified: trunk/Source/WebCore/html/HTMLSourceElement.cpp (208846 => 208847)


--- trunk/Source/WebCore/html/HTMLSourceElement.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/html/HTMLSourceElement.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -181,7 +181,7 @@
     HTMLElement::parseAttribute(name, value);
     if (name == srcsetAttr || name == sizesAttr || name == mediaAttr || name == typeAttr) {
         if (name == mediaAttr)
-            m_mediaQuerySet = MediaQuerySet::createAllowingDescriptionSyntax(value);
+            m_mediaQuerySet = MediaQuerySet::create(value);
         auto* parent = parentNode();
         if (is<HTMLPictureElement>(parent))
             downcast<HTMLPictureElement>(*parent).sourcesChanged();

Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (208846 => 208847)


--- trunk/Source/WebCore/html/HTMLStyleElement.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -78,7 +78,7 @@
     else if (name == mediaAttr) {
         m_styleSheetOwner.setMedia(value);
         if (sheet()) {
-            sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
+            sheet()->setMediaQueries(MediaQuerySet::create(value));
             if (auto* scope = m_styleSheetOwner.styleScope())
                 scope->didChangeStyleSheetContents();
         } else

Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (208846 => 208847)


--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -204,7 +204,7 @@
             }
             if (match(attributeName, mediaAttr) && m_mediaAttribute.isNull()) {
                 m_mediaAttribute = attributeValue;
-                auto mediaSet = MediaQuerySet::createAllowingDescriptionSyntax(attributeValue);
+                auto mediaSet = MediaQuerySet::create(attributeValue);
                 auto* documentElement = document.documentElement();
                 m_mediaMatched = MediaQueryEvaluator { document.printing() ? "print" : "screen", document, documentElement ? documentElement->computedStyle() : nullptr }.evaluate(mediaSet.get());
             }

Modified: trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp (208846 => 208847)


--- trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp	2016-11-17 17:28:52 UTC (rev 208847)
@@ -62,7 +62,7 @@
 
 static bool mediaAttributeMatches(Document& document, const RenderStyle* renderStyle, const String& attributeValue)
 {
-    auto mediaQueries = MediaQuerySet::createAllowingDescriptionSyntax(attributeValue);
+    auto mediaQueries = MediaQuerySet::create(attributeValue);
     return MediaQueryEvaluator { "screen", document, renderStyle }.evaluate(mediaQueries.get());
 }
 

Modified: trunk/Source/WebKit/mac/ChangeLog (208846 => 208847)


--- trunk/Source/WebKit/mac/ChangeLog	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-11-17 17:28:52 UTC (rev 208847)
@@ -1,3 +1,15 @@
+2016-11-16  Dave Hyatt  <[email protected]>
+
+        [CSS Parser] Add @supports, @keyframe and media query parsing options
+        https://bugs.webkit.org/show_bug.cgi?id=164821
+
+        Reviewed by Sam Weinig and Zalan Bujtas.
+
+        Fix up the create call now that fallback descriptor syntax is gone.
+
+        * DOM/DOM.mm:
+        (-[DOMHTMLLinkElement _mediaQueryMatches]):
+
 2016-11-17  Saam Barati  <[email protected]>
 
         Remove async/await compile time flag and enable tests

Modified: trunk/Source/WebKit/mac/DOM/DOM.mm (208846 => 208847)


--- trunk/Source/WebKit/mac/DOM/DOM.mm	2016-11-17 17:21:43 UTC (rev 208846)
+++ trunk/Source/WebKit/mac/DOM/DOM.mm	2016-11-17 17:28:52 UTC (rev 208847)
@@ -755,7 +755,7 @@
         return true;
 
     Document& document = link.document();
-    auto mediaQuerySet = MediaQuerySet::createAllowingDescriptionSyntax(media);
+    auto mediaQuerySet = MediaQuerySet::create(media);
     return MediaQueryEvaluator { "screen", document, document.renderView() ? &document.renderView()->style() : nullptr }.evaluate(mediaQuerySet.get());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to