Title: [208321] trunk
Revision
208321
Author
mmaxfi...@apple.com
Date
2016-11-02 20:25:28 -0700 (Wed, 02 Nov 2016)

Log Message

CSS.supports("font-variation-settings", "'wght' 500") erroneously returns false
https://bugs.webkit.org/show_bug.cgi?id=164244

Reviewed by Michael Catanzaro.

Source/WebCore:

Because we weren't passing a Document into CSSParserContext's constructor,
there was no way for our parser to know whether the runtime switch was on
or not. Instead, we can use the CallWith attribute in the IDL file to pass
in a Document.

Test: fast/text/variations/css-supports-runtime-switch.html

* css/DOMCSSNamespace.cpp:
(WebCore::DOMCSSNamespace::supports):
* css/DOMCSSNamespace.h:
* css/DOMCSSNamespace.idl:

LayoutTests:

* fast/text/variations/css-supports-runtime-switch-expected.txt: Added.
* fast/text/variations/css-supports-runtime-switch.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208320 => 208321)


--- trunk/LayoutTests/ChangeLog	2016-11-03 03:20:53 UTC (rev 208320)
+++ trunk/LayoutTests/ChangeLog	2016-11-03 03:25:28 UTC (rev 208321)
@@ -1,3 +1,13 @@
+2016-11-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        CSS.supports("font-variation-settings", "'wght' 500") erroneously returns false
+        https://bugs.webkit.org/show_bug.cgi?id=164244
+
+        Reviewed by Michael Catanzaro.
+
+        * fast/text/variations/css-supports-runtime-switch-expected.txt: Added.
+        * fast/text/variations/css-supports-runtime-switch.html: Added.
+
 2016-11-02  Yusuke Suzuki  <utatane....@gmail.com>
 
         [DOMJIT] Add DOMJIT::Signature

Added: trunk/LayoutTests/css3/css-supports-document-parser-context-expected.txt (0 => 208321)


--- trunk/LayoutTests/css3/css-supports-document-parser-context-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/css-supports-document-parser-context-expected.txt	2016-11-03 03:25:28 UTC (rev 208321)
@@ -0,0 +1,11 @@
+Makes sure that CSS.supports() is parsed within the context of the owning document.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.test1 is false
+PASS document.test2 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/css3/css-supports-document-parser-context.html (0 => 208321)


--- trunk/LayoutTests/css3/css-supports-document-parser-context.html	                        (rev 0)
+++ trunk/LayoutTests/css3/css-supports-document-parser-context.html	2016-11-03 03:25:28 UTC (rev 208321)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Makes sure that CSS.supports() is parsed within the context of the owning document.")
+
+document.test1 = undefined;
+document.test2 = undefined;
+
+window.jsTestIsAsync = true;
+</script>
+<iframe id="frame1" src=""
+<iframe id="frame2" src=""
+<script>
+var frame1 = document.getElementById("frame1");
+var frame2 = document.getElementById("frame2");
+
+var counter = 0;
+function listener() {
+	++counter;
+	if (counter == 2) {
+		shouldBeFalse("document.test1");
+		shouldBeTrue("document.test2");
+		finishJSTest();
+	}
+}
+frame1.addEventListener("load", listener);
+frame2.addEventListener("load", listener);
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/css3/resources/css-supports-document-parser-context-nonstrict.html (0 => 208321)


--- trunk/LayoutTests/css3/resources/css-supports-document-parser-context-nonstrict.html	                        (rev 0)
+++ trunk/LayoutTests/css3/resources/css-supports-document-parser-context-nonstrict.html	2016-11-03 03:25:28 UTC (rev 208321)
@@ -0,0 +1,12 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+shouldBeTrue("CSS.supports('color', '-webkit-focus-ring-color')");
+window.parent.document.test2 = CSS.supports('color', '-webkit-focus-ring-color');
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/css3/resources/css-supports-document-parser-context-strict.html (0 => 208321)


--- trunk/LayoutTests/css3/resources/css-supports-document-parser-context-strict.html	                        (rev 0)
+++ trunk/LayoutTests/css3/resources/css-supports-document-parser-context-strict.html	2016-11-03 03:25:28 UTC (rev 208321)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+shouldBeFalse("CSS.supports('color', '-webkit-focus-ring-color')");
+window.parent.document.test1 = CSS.supports('color', '-webkit-focus-ring-color');
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (208320 => 208321)


--- trunk/Source/WebCore/ChangeLog	2016-11-03 03:20:53 UTC (rev 208320)
+++ trunk/Source/WebCore/ChangeLog	2016-11-03 03:25:28 UTC (rev 208321)
@@ -1,3 +1,22 @@
+2016-11-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        CSS.supports("font-variation-settings", "'wght' 500") erroneously returns false
+        https://bugs.webkit.org/show_bug.cgi?id=164244
+
+        Reviewed by Michael Catanzaro.
+
+        Because we weren't passing a Document into CSSParserContext's constructor,
+        there was no way for our parser to know whether the runtime switch was on
+        or not. Instead, we can use the CallWith attribute in the IDL file to pass
+        in a Document.
+
+        Test: fast/text/variations/css-supports-runtime-switch.html
+
+        * css/DOMCSSNamespace.cpp:
+        (WebCore::DOMCSSNamespace::supports):
+        * css/DOMCSSNamespace.h:
+        * css/DOMCSSNamespace.idl:
+
 2016-11-02  Yusuke Suzuki  <utatane....@gmail.com>
 
         [DOMJIT] Add DOMJIT::Signature

Modified: trunk/Source/WebCore/css/DOMCSSNamespace.cpp (208320 => 208321)


--- trunk/Source/WebCore/css/DOMCSSNamespace.cpp	2016-11-03 03:20:53 UTC (rev 208320)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.cpp	2016-11-03 03:25:28 UTC (rev 208321)
@@ -52,7 +52,7 @@
     return newValue;
 }
 
-bool DOMCSSNamespace::supports(const String& property, const String& value)
+bool DOMCSSNamespace::supports(Document& document, const String& property, const String& value)
 {
     CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace());
 
@@ -69,12 +69,12 @@
         return false;
 
     auto dummyStyle = MutableStyleProperties::create();
-    return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, HTMLStandardMode, nullptr) != CSSParser::ParseResult::Error;
+    return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, document, nullptr) != CSSParser::ParseResult::Error;
 }
 
-bool DOMCSSNamespace::supports(const String& conditionText)
+bool DOMCSSNamespace::supports(Document& document, const String& conditionText)
 {
-    CSSParserContext context(HTMLStandardMode);
+    CSSParserContext context(document);
     CSSParser parser(context);
     return parser.parseSupportsCondition(conditionText);
 }

Modified: trunk/Source/WebCore/css/DOMCSSNamespace.h (208320 => 208321)


--- trunk/Source/WebCore/css/DOMCSSNamespace.h	2016-11-03 03:20:53 UTC (rev 208320)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.h	2016-11-03 03:25:28 UTC (rev 208321)
@@ -34,10 +34,12 @@
 
 namespace WebCore {
 
+class Document;
+
 class DOMCSSNamespace final : public RefCounted<DOMCSSNamespace> {
 public:
-    static bool supports(const String& property, const String& value);
-    static bool supports(const String& conditionText);
+    static bool supports(Document&, const String& property, const String& value);
+    static bool supports(Document&, const String& conditionText);
     static String escape(const String& ident);
 };
 

Modified: trunk/Source/WebCore/css/DOMCSSNamespace.idl (208320 => 208321)


--- trunk/Source/WebCore/css/DOMCSSNamespace.idl	2016-11-03 03:20:53 UTC (rev 208320)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.idl	2016-11-03 03:25:28 UTC (rev 208321)
@@ -31,7 +31,7 @@
     InterfaceName=CSS,
     ImplementationLacksVTable,
 ] interface DOMCSSNamespace {
-    static boolean supports(DOMString property, DOMString value);
-    static boolean supports(DOMString conditionText);
+    [CallWith=Document] static boolean supports(DOMString property, DOMString value);
+    [CallWith=Document] static boolean supports(DOMString conditionText);
     static DOMString escape(DOMString ident);
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to