Add pointer/hover media queries
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jan 2015 04:15:56 +0000 (04:15 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jan 2015 04:15:56 +0000 (04:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134822

Patch by Benjamin Poulain <bpoulain@apple.com> on 2015-01-23
Reviewed by Antti Koivisto.

Source/WebCore:

Media Queries Level 4 introduces two types of Interaction Media Features:
"pointer" and "hover". Those media features are useful for adapting the design
to the type of input:
    http://dev.w3.org/csswg/mediaqueries-4/#mf-interaction

This implementation is trivial: just #ifdef the return value depending on
the support for touch events.
In the future we should move that to a client interface but let's start easy
for now.

Tests: fast/media/mq-any-hover-cssom.html
       fast/media/mq-any-hover-invalid.html
       fast/media/mq-any-hover-matchMedia.html
       fast/media/mq-any-hover-styling.html
       fast/media/mq-any-pointer-cssom.html
       fast/media/mq-any-pointer-invalid.html
       fast/media/mq-any-pointer-matchMedia.html
       fast/media/mq-any-pointer-styling.html
       fast/media/mq-hover-cssom.html
       fast/media/mq-hover-invalid.html
       fast/media/mq-hover-matchMedia.html
       fast/media/mq-hover-styling.html
       fast/media/mq-pointer-cssom.html
       fast/media/mq-pointer-invalid.html
       fast/media/mq-pointer-matchMedia.html
       fast/media/mq-pointer-styling.html

* css/CSSValueKeywords.in:
* css/MediaFeatureNames.h:
* css/MediaQueryEvaluator.cpp:
(WebCore::hoverMediaFeatureEval):
(WebCore::any_hoverMediaFeatureEval):
(WebCore::pointerMediaFeatureEval):
(WebCore::any_pointerMediaFeatureEval):
(WebCore::leastCapablePrimaryPointerDeviceType): Deleted.
* css/MediaQueryExp.cpp:
(WebCore::featureWithCSSValueID):
(WebCore::featureWithZeroOrOne):
(WebCore::featureWithoutValue):
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoon):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* page/Settings.in:

LayoutTests:

* fast/media/mq-any-hover-cssom-expected.txt: Added.
* fast/media/mq-any-hover-cssom.html: Added.
* fast/media/mq-any-hover-invalid-expected.txt: Added.
* fast/media/mq-any-hover-invalid.html: Added.
* fast/media/mq-any-hover-matchMedia-expected.txt: Added.
* fast/media/mq-any-hover-matchMedia.html: Added.
* fast/media/mq-any-hover-styling-expected.txt: Added.
* fast/media/mq-any-hover-styling.html: Added.
* fast/media/mq-any-pointer-cssom-expected.txt: Added.
* fast/media/mq-any-pointer-cssom.html: Added.
* fast/media/mq-any-pointer-invalid-expected.txt: Added.
* fast/media/mq-any-pointer-invalid.html: Added.
* fast/media/mq-any-pointer-matchMedia-expected.txt: Added.
* fast/media/mq-any-pointer-matchMedia.html: Added.
* fast/media/mq-any-pointer-styling-expected.txt: Added.
* fast/media/mq-any-pointer-styling.html: Added.
* fast/media/mq-hover-cssom-expected.txt: Added.
* fast/media/mq-hover-cssom.html: Added.
* fast/media/mq-hover-invalid-expected.txt: Added.
* fast/media/mq-hover-invalid.html: Added.
* fast/media/mq-hover-matchMedia-expected.txt: Added.
* fast/media/mq-hover-matchMedia.html: Added.
* fast/media/mq-hover-styling-expected.txt: Added.
* fast/media/mq-hover-styling.html: Added.
* fast/media/mq-pointer-cssom-expected.txt: Added.
* fast/media/mq-pointer-cssom.html: Added.
* fast/media/mq-pointer-expected.txt:
* fast/media/mq-pointer-invalid-expected.txt: Added.
* fast/media/mq-pointer-invalid.html: Added.
* fast/media/mq-pointer-matchMedia-expected.txt: Added.
* fast/media/mq-pointer-matchMedia.html: Added.
* fast/media/mq-pointer-styling-expected.txt: Added.
* fast/media/mq-pointer-styling.html: Added.
* fast/media/mq-pointer.html:
* platform/ios-simulator/fast/media/mq-any-hover-matchMedia-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-any-hover-styling-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-any-pointer-matchMedia-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-any-pointer-styling-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-hover-matchMedia-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-hover-styling-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-pointer-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-pointer-matchMedia-expected.txt: Added.
* platform/ios-simulator/fast/media/mq-pointer-styling-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179055 268f45cc-cd09-0410-ab3c-d52691b4dbfc

51 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/media/mq-any-hover-cssom-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-cssom.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-invalid-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-invalid.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-matchMedia.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-styling-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-hover-styling.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-cssom-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-cssom.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-invalid-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-invalid.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-matchMedia.html [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-styling-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-any-pointer-styling.html [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-cssom-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-cssom.html [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-invalid-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-invalid.html [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-matchMedia.html [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-styling-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-hover-styling.html [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-cssom-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-cssom.html [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-expected.txt
LayoutTests/fast/media/mq-pointer-invalid-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-invalid.html [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-matchMedia.html [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-styling-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer-styling.html [new file with mode: 0644]
LayoutTests/fast/media/mq-pointer.html
LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-styling-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-styling-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-hover-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-hover-styling-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-pointer-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-pointer-matchMedia-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/media/mq-pointer-styling-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/MediaFeatureNames.h
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/MediaQueryExp.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/Settings.in

index 69e9edd..91721b3 100644 (file)
@@ -1,3 +1,54 @@
+2015-01-23  Benjamin Poulain  <bpoulain@apple.com>
+
+        Add pointer/hover media queries
+        https://bugs.webkit.org/show_bug.cgi?id=134822
+
+        Reviewed by Antti Koivisto.
+
+        * fast/media/mq-any-hover-cssom-expected.txt: Added.
+        * fast/media/mq-any-hover-cssom.html: Added.
+        * fast/media/mq-any-hover-invalid-expected.txt: Added.
+        * fast/media/mq-any-hover-invalid.html: Added.
+        * fast/media/mq-any-hover-matchMedia-expected.txt: Added.
+        * fast/media/mq-any-hover-matchMedia.html: Added.
+        * fast/media/mq-any-hover-styling-expected.txt: Added.
+        * fast/media/mq-any-hover-styling.html: Added.
+        * fast/media/mq-any-pointer-cssom-expected.txt: Added.
+        * fast/media/mq-any-pointer-cssom.html: Added.
+        * fast/media/mq-any-pointer-invalid-expected.txt: Added.
+        * fast/media/mq-any-pointer-invalid.html: Added.
+        * fast/media/mq-any-pointer-matchMedia-expected.txt: Added.
+        * fast/media/mq-any-pointer-matchMedia.html: Added.
+        * fast/media/mq-any-pointer-styling-expected.txt: Added.
+        * fast/media/mq-any-pointer-styling.html: Added.
+        * fast/media/mq-hover-cssom-expected.txt: Added.
+        * fast/media/mq-hover-cssom.html: Added.
+        * fast/media/mq-hover-invalid-expected.txt: Added.
+        * fast/media/mq-hover-invalid.html: Added.
+        * fast/media/mq-hover-matchMedia-expected.txt: Added.
+        * fast/media/mq-hover-matchMedia.html: Added.
+        * fast/media/mq-hover-styling-expected.txt: Added.
+        * fast/media/mq-hover-styling.html: Added.
+        * fast/media/mq-pointer-cssom-expected.txt: Added.
+        * fast/media/mq-pointer-cssom.html: Added.
+        * fast/media/mq-pointer-expected.txt:
+        * fast/media/mq-pointer-invalid-expected.txt: Added.
+        * fast/media/mq-pointer-invalid.html: Added.
+        * fast/media/mq-pointer-matchMedia-expected.txt: Added.
+        * fast/media/mq-pointer-matchMedia.html: Added.
+        * fast/media/mq-pointer-styling-expected.txt: Added.
+        * fast/media/mq-pointer-styling.html: Added.
+        * fast/media/mq-pointer.html:
+        * platform/ios-simulator/fast/media/mq-any-hover-matchMedia-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-any-hover-styling-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-any-pointer-matchMedia-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-any-pointer-styling-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-hover-matchMedia-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-hover-styling-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-pointer-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-pointer-matchMedia-expected.txt: Added.
+        * platform/ios-simulator/fast/media/mq-pointer-styling-expected.txt: Added.
+
 2015-01-23  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r179051.
diff --git a/LayoutTests/fast/media/mq-any-hover-cssom-expected.txt b/LayoutTests/fast/media/mq-any-hover-cssom-expected.txt
new file mode 100644 (file)
index 0000000..8954d5f
--- /dev/null
@@ -0,0 +1,29 @@
+Test the CSSOM serialization of the any-hover media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: on-demand)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: on-demand)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-hover: hover)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-hover-cssom.html b/LayoutTests/fast/media/mq-any-hover-cssom.html
new file mode 100644 (file)
index 0000000..0558b22
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test the CSSOM serialization of the any-hover media feature.")
+
+    var testCases = [
+        // Case.
+        ["(any-hover)", "(any-hover)"],
+        ["(    any-hover)", "(any-hover)"],
+        ["(any-hover    )", "(any-hover)"],
+        ["(    any-hover    )", "(any-hover)"],
+        ["(any-hover: hover)", "(any-hover: hover)"],
+        ["(any-hover: Hover)", "(any-hover: hover)"],
+        ["(any-hover: HOVER)", "(any-hover: hover)"],
+        ["(Any-Hover: hover)", "(any-hover: hover)"],
+        ["(ANY-HOVER: hover)", "(any-hover: hover)"],
+        ["(Any-Hover: Hover)", "(any-hover: hover)"],
+        ["(any-hover: ON-DEMAND)", "(any-hover: on-demand)"],
+        ["(Any-Hover: On-demand)", "(any-hover: on-demand)"],
+        ["(any-hover: NONE)", "(any-hover: none)"],
+        ["(Any-Hover: None)", "(any-hover: none)"],
+
+        // Spacing.
+        ["(any-hover:hover)", "(any-hover: hover)"],
+        ["(any-hover: hover)", "(any-hover: hover)"],
+        ["(any-hover :hover)", "(any-hover: hover)"],
+        ["(any-hover : hover)", "(any-hover: hover)"],
+        ["(     any-hover    : hover     )", "(any-hover: hover)"],
+        ["(any-hover\t:\thover)", "(any-hover: hover)"],
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        targetStyle.innerText = "@media " + testCase[0] + " { }";
+        shouldBeEqualToString("document.styleSheets[1].cssRules[0].media.mediaText", testCase[1]);
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-hover-invalid-expected.txt b/LayoutTests/fast/media/mq-any-hover-invalid-expected.txt
new file mode 100644 (file)
index 0000000..f2d6eb8
--- /dev/null
@@ -0,0 +1,23 @@
+Test invalid input with the any-hover media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.matchMedia("(any-hover:)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: )").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: WebKit)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: fine)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: portrait)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: \"None\")").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-hover: 'None')").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-hover-invalid.html b/LayoutTests/fast/media/mq-any-hover-invalid.html
new file mode 100644 (file)
index 0000000..fc2fece
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test invalid input with the any-hover media feature.")
+
+    var testCases = [
+        "any-hover:",
+        "any-hover: ",
+        "any-hover: WebKit",
+        "any-hover: fine",
+        "any-hover: portrait",
+        "any-hover: \\\"None\\\"",
+        "any-hover: 'None'",
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        var testString = 'window.matchMedia("(' + testCase + ')").matches';
+        shouldBeFalse('window.matchMedia("(' + testCase + ')").matches');
+
+        targetStyle.innerText = "@media " + testCase + " { }";
+        shouldBe("document.styleSheets[1].cssRules[0].media.length", "0");
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-hover-matchMedia-expected.txt b/LayoutTests/fast/media/mq-any-hover-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..c850f5b
--- /dev/null
@@ -0,0 +1,19 @@
+Test the any-hover media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(any-hover)").matches = true
+window.matchMedia("(any-hover: hover)").matches = true
+window.matchMedia("(any-hover: on-demand)").matches = false
+window.matchMedia("(any-hover: none)").matches = false
+window.matchMedia("(any-hover: Hover)").matches = true
+window.matchMedia("(any-hover: On-demand)").matches = false
+window.matchMedia("(any-hover: None)").matches = false
+window.matchMedia("(Any-Hover: hover)").matches = true
+window.matchMedia("(Any-Hover: on-demand)").matches = false
+window.matchMedia("(Any-Hover: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-hover-matchMedia.html b/LayoutTests/fast/media/mq-any-hover-matchMedia.html
new file mode 100644 (file)
index 0000000..362e0b2
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+    description("Test the any-hover media feature with machMedia.")
+
+    function testHoverCondition(condition) {
+        var testString = 'window.matchMedia("(' + condition + ')").matches';
+        debug(testString + " = " + eval(testString));
+    }
+
+    testHoverCondition("any-hover");
+
+    testHoverCondition("any-hover: hover");
+    testHoverCondition("any-hover: on-demand");
+    testHoverCondition("any-hover: none");
+
+    testHoverCondition("any-hover: Hover");
+    testHoverCondition("any-hover: On-demand");
+    testHoverCondition("any-hover: None");
+
+    testHoverCondition("Any-Hover: hover");
+    testHoverCondition("Any-Hover: on-demand");
+    testHoverCondition("Any-Hover: none");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-hover-styling-expected.txt b/LayoutTests/fast/media/mq-any-hover-styling-expected.txt
new file mode 100644 (file)
index 0000000..5089099
--- /dev/null
@@ -0,0 +1,13 @@
+Test the any-hover media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 255)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-hover-styling.html b/LayoutTests/fast/media/mq-any-hover-styling.html
new file mode 100644 (file)
index 0000000..158ff31
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="target"></div>
+<style>
+    #target {
+        color: red;
+        background-color: black;
+        width: 100px;
+        height: 100px;
+        display: none;
+    }
+    @media (any-hover) {
+        #target {
+            color: green;
+        }
+    }
+    @media (any-hover: hover) {
+        #target {
+            background-color: blue;
+        }
+    }
+    @media (any-hover: on-demand) {
+        #target {
+            width: 10px;
+        }
+    }
+    @media (any-hover: none) {
+        #target {
+            height: 10px;
+        }
+    }
+</style>
+
+<script>
+    description("Test the any-hover media feature to guard style rules.")
+
+    var target = document.getElementById('target');
+
+    function displayProperty(property) {
+        var testString = 'getComputedStyle(target)["' + property + '"]';
+        debug(testString + " = " + eval(testString));
+    }
+
+    displayProperty("color");
+    displayProperty("background-color");
+    displayProperty("width");
+    displayProperty("height");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-pointer-cssom-expected.txt b/LayoutTests/fast/media/mq-any-pointer-cssom-expected.txt
new file mode 100644 (file)
index 0000000..7aa9753
--- /dev/null
@@ -0,0 +1,29 @@
+Test the CSSOM serialization of the any-pointer media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: coarse)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: coarse)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(any-pointer: fine)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-pointer-cssom.html b/LayoutTests/fast/media/mq-any-pointer-cssom.html
new file mode 100644 (file)
index 0000000..7d35afa
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test the CSSOM serialization of the any-pointer media feature.")
+
+    var testCases = [
+        // Case.
+        ["(any-pointer)", "(any-pointer)"],
+        ["(    any-pointer)", "(any-pointer)"],
+        ["(any-pointer    )", "(any-pointer)"],
+        ["(    any-pointer    )", "(any-pointer)"],
+        ["(any-pointer: fine)", "(any-pointer: fine)"],
+        ["(any-pointer: Fine)", "(any-pointer: fine)"],
+        ["(any-pointer: FINE)", "(any-pointer: fine)"],
+        ["(Any-Pointer: fine)", "(any-pointer: fine)"],
+        ["(ANY-POINTER: fine)", "(any-pointer: fine)"],
+        ["(Any-Pointer: Fine)", "(any-pointer: fine)"],
+        ["(any-pointer: COARSE)", "(any-pointer: coarse)"],
+        ["(Any-Pointer: Coarse)", "(any-pointer: coarse)"],
+        ["(any-pointer: NONE)", "(any-pointer: none)"],
+        ["(Any-Pointer: None)", "(any-pointer: none)"],
+
+        // Spacing.
+        ["(any-pointer:fine)", "(any-pointer: fine)"],
+        ["(any-pointer: fine)", "(any-pointer: fine)"],
+        ["(any-pointer :fine)", "(any-pointer: fine)"],
+        ["(any-pointer : fine)", "(any-pointer: fine)"],
+        ["(     any-pointer    : fine     )", "(any-pointer: fine)"],
+        ["(any-pointer\t:\tfine)", "(any-pointer: fine)"],
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        targetStyle.innerText = "@media " + testCase[0] + " { }";
+        shouldBeEqualToString("document.styleSheets[1].cssRules[0].media.mediaText", testCase[1]);
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-pointer-invalid-expected.txt b/LayoutTests/fast/media/mq-any-pointer-invalid-expected.txt
new file mode 100644 (file)
index 0000000..e400776
--- /dev/null
@@ -0,0 +1,25 @@
+Test invalid input with the any-pointer media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.matchMedia("(any-pointer:)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: )").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: WebKit)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: pointer)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: hover)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: portrait)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: \"None\")").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(any-pointer: 'None')").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-pointer-invalid.html b/LayoutTests/fast/media/mq-any-pointer-invalid.html
new file mode 100644 (file)
index 0000000..3cb1af9
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test invalid input with the any-pointer media feature.")
+
+    var testCases = [
+        "any-pointer:",
+        "any-pointer: ",
+        "any-pointer: WebKit",
+        "any-pointer: pointer",
+        "any-pointer: hover",
+        "any-pointer: portrait",
+        "any-pointer: \\\"None\\\"",
+        "any-pointer: 'None'",
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        var testString = 'window.matchMedia("(' + testCase + ')").matches';
+        shouldBeFalse('window.matchMedia("(' + testCase + ')").matches');
+
+        targetStyle.innerText = "@media " + testCase + " { }";
+        shouldBe("document.styleSheets[1].cssRules[0].media.length", "0");
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-pointer-matchMedia-expected.txt b/LayoutTests/fast/media/mq-any-pointer-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..b961cc6
--- /dev/null
@@ -0,0 +1,19 @@
+Test the any-pointer media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(any-pointer)").matches = true
+window.matchMedia("(any-pointer: fine)").matches = true
+window.matchMedia("(any-pointer: coarse)").matches = false
+window.matchMedia("(any-pointer: none)").matches = false
+window.matchMedia("(any-pointer: Fine)").matches = true
+window.matchMedia("(any-pointer: Coarse)").matches = false
+window.matchMedia("(any-pointer: None)").matches = false
+window.matchMedia("(Any-Pointer: fine)").matches = true
+window.matchMedia("(Any-Pointer: coarse)").matches = false
+window.matchMedia("(Any-Pointer: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-pointer-matchMedia.html b/LayoutTests/fast/media/mq-any-pointer-matchMedia.html
new file mode 100644 (file)
index 0000000..4493f21
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+    description("Test the any-pointer media feature with machMedia.")
+
+    function testPointerCondition(condition) {
+        var testString = 'window.matchMedia("(' + condition + ')").matches';
+        debug(testString + " = " + eval(testString));
+    }
+
+    testPointerCondition("any-pointer");
+
+    testPointerCondition("any-pointer: fine");
+    testPointerCondition("any-pointer: coarse");
+    testPointerCondition("any-pointer: none");
+
+    testPointerCondition("any-pointer: Fine");
+    testPointerCondition("any-pointer: Coarse");
+    testPointerCondition("any-pointer: None");
+
+    testPointerCondition("Any-Pointer: fine");
+    testPointerCondition("Any-Pointer: coarse");
+    testPointerCondition("Any-Pointer: none");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-any-pointer-styling-expected.txt b/LayoutTests/fast/media/mq-any-pointer-styling-expected.txt
new file mode 100644 (file)
index 0000000..648df0a
--- /dev/null
@@ -0,0 +1,13 @@
+Test the any-pointer media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 255)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-any-pointer-styling.html b/LayoutTests/fast/media/mq-any-pointer-styling.html
new file mode 100644 (file)
index 0000000..de994bc
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="target"></div>
+<style>
+    #target {
+        color: red;
+        background-color: black;
+        width: 100px;
+        height: 100px;
+        display: none;
+    }
+    @media (any-pointer) {
+        #target {
+            color: green;
+        }
+    }
+    @media (any-pointer: fine) {
+        #target {
+            background-color: blue;
+        }
+    }
+    @media (any-pointer: coarse) {
+        #target {
+            width: 10px;
+        }
+    }
+    @media (any-pointer: none) {
+        #target {
+            height: 10px;
+        }
+    }
+</style>
+
+<script>
+    description("Test the any-pointer media feature to guard style rules.")
+
+    var target = document.getElementById('target');
+
+    function displayProperty(property) {
+        var testString = 'getComputedStyle(target)["' + property + '"]';
+        debug(testString + " = " + eval(testString));
+    }
+
+    displayProperty("color");
+    displayProperty("background-color");
+    displayProperty("width");
+    displayProperty("height");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-hover-cssom-expected.txt b/LayoutTests/fast/media/mq-hover-cssom-expected.txt
new file mode 100644 (file)
index 0000000..1dcc63b
--- /dev/null
@@ -0,0 +1,29 @@
+Test the CSSOM serialization of the hover media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: on-demand)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: on-demand)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(hover: hover)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-hover-cssom.html b/LayoutTests/fast/media/mq-hover-cssom.html
new file mode 100644 (file)
index 0000000..7437ad3
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test the CSSOM serialization of the hover media feature.")
+
+    var testCases = [
+        // Case.
+        ["(hover)", "(hover)"],
+        ["(    hover)", "(hover)"],
+        ["(hover    )", "(hover)"],
+        ["(    hover    )", "(hover)"],
+        ["(hover: hover)", "(hover: hover)"],
+        ["(hover: Hover)", "(hover: hover)"],
+        ["(hover: HOVER)", "(hover: hover)"],
+        ["(Hover: hover)", "(hover: hover)"],
+        ["(HOVER: hover)", "(hover: hover)"],
+        ["(Hover: Hover)", "(hover: hover)"],
+        ["(hover: ON-DEMAND)", "(hover: on-demand)"],
+        ["(Hover: On-demand)", "(hover: on-demand)"],
+        ["(hover: NONE)", "(hover: none)"],
+        ["(Hover: None)", "(hover: none)"],
+
+        // Spacing.
+        ["(hover:hover)", "(hover: hover)"],
+        ["(hover: hover)", "(hover: hover)"],
+        ["(hover :hover)", "(hover: hover)"],
+        ["(hover : hover)", "(hover: hover)"],
+        ["(     hover    : hover     )", "(hover: hover)"],
+        ["(hover\t:\thover)", "(hover: hover)"],
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        targetStyle.innerText = "@media " + testCase[0] + " { }";
+        shouldBeEqualToString("document.styleSheets[1].cssRules[0].media.mediaText", testCase[1]);
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-hover-invalid-expected.txt b/LayoutTests/fast/media/mq-hover-invalid-expected.txt
new file mode 100644 (file)
index 0000000..17d369c
--- /dev/null
@@ -0,0 +1,23 @@
+Test invalid input with the hover media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.matchMedia("(hover:)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: )").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: WebKit)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: fine)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: portrait)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: \"None\")").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(hover: 'None')").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-hover-invalid.html b/LayoutTests/fast/media/mq-hover-invalid.html
new file mode 100644 (file)
index 0000000..c724d10
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test invalid input with the hover media feature.")
+
+    var testCases = [
+        "hover:",
+        "hover: ",
+        "hover: WebKit",
+        "hover: fine",
+        "hover: portrait",
+        "hover: \\\"None\\\"",
+        "hover: 'None'",
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        var testString = 'window.matchMedia("(' + testCase + ')").matches';
+        shouldBeFalse('window.matchMedia("(' + testCase + ')").matches');
+
+        targetStyle.innerText = "@media " + testCase + " { }";
+        shouldBe("document.styleSheets[1].cssRules[0].media.length", "0");
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-hover-matchMedia-expected.txt b/LayoutTests/fast/media/mq-hover-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..5ba6f41
--- /dev/null
@@ -0,0 +1,19 @@
+Test the hover media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(hover)").matches = true
+window.matchMedia("(hover: hover)").matches = true
+window.matchMedia("(hover: on-demand)").matches = false
+window.matchMedia("(hover: none)").matches = false
+window.matchMedia("(hover: Hover)").matches = true
+window.matchMedia("(hover: On-demand)").matches = false
+window.matchMedia("(hover: None)").matches = false
+window.matchMedia("(Hover: hover)").matches = true
+window.matchMedia("(Hover: on-demand)").matches = false
+window.matchMedia("(Hover: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-hover-matchMedia.html b/LayoutTests/fast/media/mq-hover-matchMedia.html
new file mode 100644 (file)
index 0000000..75bae33
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+    description("Test the hover media feature with machMedia.")
+
+    function testHoverCondition(condition) {
+        var testString = 'window.matchMedia("(' + condition + ')").matches';
+        debug(testString + " = " + eval(testString));
+    }
+
+    testHoverCondition("hover");
+
+    testHoverCondition("hover: hover");
+    testHoverCondition("hover: on-demand");
+    testHoverCondition("hover: none");
+
+    testHoverCondition("hover: Hover");
+    testHoverCondition("hover: On-demand");
+    testHoverCondition("hover: None");
+
+    testHoverCondition("Hover: hover");
+    testHoverCondition("Hover: on-demand");
+    testHoverCondition("Hover: none");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-hover-styling-expected.txt b/LayoutTests/fast/media/mq-hover-styling-expected.txt
new file mode 100644 (file)
index 0000000..55d92c3
--- /dev/null
@@ -0,0 +1,13 @@
+Test the hover media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 255)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-hover-styling.html b/LayoutTests/fast/media/mq-hover-styling.html
new file mode 100644 (file)
index 0000000..0a7c590
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="target"></div>
+<style>
+    #target {
+        color: red;
+        background-color: black;
+        width: 100px;
+        height: 100px;
+        display: none;
+    }
+    @media (hover) {
+        #target {
+            color: green;
+        }
+    }
+    @media (hover: hover) {
+        #target {
+            background-color: blue;
+        }
+    }
+    @media (hover: on-demand) {
+        #target {
+            width: 10px;
+        }
+    }
+    @media (hover: none) {
+        #target {
+            height: 10px;
+        }
+    }
+</style>
+
+<script>
+    description("Test the hover media feature to guard style rules.")
+
+    var target = document.getElementById('target');
+
+    function displayProperty(property) {
+        var testString = 'getComputedStyle(target)["' + property + '"]';
+        debug(testString + " = " + eval(testString));
+    }
+
+    displayProperty("color");
+    displayProperty("background-color");
+    displayProperty("width");
+    displayProperty("height");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-pointer-cssom-expected.txt b/LayoutTests/fast/media/mq-pointer-cssom-expected.txt
new file mode 100644 (file)
index 0000000..4a4e331
--- /dev/null
@@ -0,0 +1,29 @@
+Test the CSSOM serialization of the pointer media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: coarse)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: coarse)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: none)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS document.styleSheets[1].cssRules[0].media.mediaText is "(pointer: fine)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-pointer-cssom.html b/LayoutTests/fast/media/mq-pointer-cssom.html
new file mode 100644 (file)
index 0000000..370eee0
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test the CSSOM serialization of the pointer media feature.")
+
+    var testCases = [
+        // Case.
+        ["(pointer)", "(pointer)"],
+        ["(    pointer)", "(pointer)"],
+        ["(pointer    )", "(pointer)"],
+        ["(    pointer    )", "(pointer)"],
+        ["(pointer: fine)", "(pointer: fine)"],
+        ["(pointer: Fine)", "(pointer: fine)"],
+        ["(pointer: FINE)", "(pointer: fine)"],
+        ["(Pointer: fine)", "(pointer: fine)"],
+        ["(POINTER: fine)", "(pointer: fine)"],
+        ["(Pointer: Fine)", "(pointer: fine)"],
+        ["(pointer: COARSE)", "(pointer: coarse)"],
+        ["(Pointer: Coarse)", "(pointer: coarse)"],
+        ["(pointer: NONE)", "(pointer: none)"],
+        ["(Pointer: None)", "(pointer: none)"],
+
+        // Spacing.
+        ["(pointer:fine)", "(pointer: fine)"],
+        ["(pointer: fine)", "(pointer: fine)"],
+        ["(pointer :fine)", "(pointer: fine)"],
+        ["(pointer : fine)", "(pointer: fine)"],
+        ["(     pointer    : fine     )", "(pointer: fine)"],
+        ["(pointer\t:\tfine)", "(pointer: fine)"],
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        targetStyle.innerText = "@media " + testCase[0] + " { }";
+        shouldBeEqualToString("document.styleSheets[1].cssRules[0].media.mediaText", testCase[1]);
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index cf7a695..e871aaa 100644 (file)
@@ -1,27 +1,14 @@
 Test the (pointer) and (hover) media features. See Bug 87403 for details.
 
-------------- default configuration -------------
-Query "(pointer)": false
-Query "(Pointer)": false
+Query "(pointer)": true
+Query "(Pointer)": true
 Query "(pointer:none)": false
 Query "(pointer:coarse)": false
 Query "(pointer:coARse)": false
 Query "(pointer:bogusvalue)": false
-Query "(pointer:fine)": false
-Query "(hover)": false
+Query "(pointer:fine)": true
+Query "(hover)": true
 Query "(hover:0)": false
 Query "(hover:1)": false
 Query "(hover:bogusvalue)": false
-------------- with touch screen -------------
-Query "(pointer)": true
-Query "(Pointer)": true
-Query "(pointer:none)": false
-Query "(pointer:coarse)": true
-Query "(pointer:coARse)": true
-Query "(pointer:bogusvalue)": false
-Query "(pointer:fine)": false
-Query "(hover)": false
-Query "(hover:0)": true
-Query "(hover:1)": false
-Query "(hover:bogusvalue)": false
 
diff --git a/LayoutTests/fast/media/mq-pointer-invalid-expected.txt b/LayoutTests/fast/media/mq-pointer-invalid-expected.txt
new file mode 100644 (file)
index 0000000..229c8b4
--- /dev/null
@@ -0,0 +1,25 @@
+Test invalid input with the pointer media feature.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.matchMedia("(pointer:)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: )").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: WebKit)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: pointer)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: hover)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: portrait)").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: \"None\")").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS window.matchMedia("(pointer: 'None')").matches is false
+PASS document.styleSheets[1].cssRules[0].media.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-pointer-invalid.html b/LayoutTests/fast/media/mq-pointer-invalid.html
new file mode 100644 (file)
index 0000000..717e846
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<style id="target-style"></style>
+
+<script>
+    description("Test invalid input with the pointer media feature.")
+
+    var testCases = [
+        "pointer:",
+        "pointer: ",
+        "pointer: WebKit",
+        "pointer: pointer",
+        "pointer: hover",
+        "pointer: portrait",
+        "pointer: \\\"None\\\"",
+        "pointer: 'None'",
+    ];
+
+    var targetStyle = document.getElementById('target-style');
+    for (var testCase of testCases) {
+        var testString = 'window.matchMedia("(' + testCase + ')").matches';
+        shouldBeFalse('window.matchMedia("(' + testCase + ')").matches');
+
+        targetStyle.innerText = "@media " + testCase + " { }";
+        shouldBe("document.styleSheets[1].cssRules[0].media.length", "0");
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-pointer-matchMedia-expected.txt b/LayoutTests/fast/media/mq-pointer-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..0a814a1
--- /dev/null
@@ -0,0 +1,19 @@
+Test the pointer media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(pointer)").matches = true
+window.matchMedia("(pointer: fine)").matches = true
+window.matchMedia("(pointer: coarse)").matches = false
+window.matchMedia("(pointer: none)").matches = false
+window.matchMedia("(pointer: Fine)").matches = true
+window.matchMedia("(pointer: Coarse)").matches = false
+window.matchMedia("(pointer: None)").matches = false
+window.matchMedia("(Pointer: fine)").matches = true
+window.matchMedia("(Pointer: coarse)").matches = false
+window.matchMedia("(Pointer: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-pointer-matchMedia.html b/LayoutTests/fast/media/mq-pointer-matchMedia.html
new file mode 100644 (file)
index 0000000..5748434
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+    description("Test the pointer media feature with machMedia.")
+
+    function testPointerCondition(condition) {
+        var testString = 'window.matchMedia("(' + condition + ')").matches';
+        debug(testString + " = " + eval(testString));
+    }
+
+    testPointerCondition("pointer");
+
+    testPointerCondition("pointer: fine");
+    testPointerCondition("pointer: coarse");
+    testPointerCondition("pointer: none");
+
+    testPointerCondition("pointer: Fine");
+    testPointerCondition("pointer: Coarse");
+    testPointerCondition("pointer: None");
+
+    testPointerCondition("Pointer: fine");
+    testPointerCondition("Pointer: coarse");
+    testPointerCondition("Pointer: none");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-pointer-styling-expected.txt b/LayoutTests/fast/media/mq-pointer-styling-expected.txt
new file mode 100644 (file)
index 0000000..44f4936
--- /dev/null
@@ -0,0 +1,13 @@
+Test the pointer media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 255)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/media/mq-pointer-styling.html b/LayoutTests/fast/media/mq-pointer-styling.html
new file mode 100644 (file)
index 0000000..4f16f8d
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="target"></div>
+<style>
+    #target {
+        color: red;
+        background-color: black;
+        width: 100px;
+        height: 100px;
+        display: none;
+    }
+    @media (pointer) {
+        #target {
+            color: green;
+        }
+    }
+    @media (pointer: fine) {
+        #target {
+            background-color: blue;
+        }
+    }
+    @media (pointer: coarse) {
+        #target {
+            width: 10px;
+        }
+    }
+    @media (pointer: none) {
+        #target {
+            height: 10px;
+        }
+    }
+</style>
+
+<script>
+    description("Test the pointer media feature to guard style rules.")
+
+    var target = document.getElementById('target');
+
+    function displayProperty(property) {
+        var testString = 'getComputedStyle(target)["' + property + '"]';
+        debug(testString + " = " + eval(testString));
+    }
+
+    displayProperty("color");
+    displayProperty("background-color");
+    displayProperty("width");
+    displayProperty("height");
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 9ad01a6..d14aeb7 100644 (file)
 
     function runTests()
     {
-        log("------------- default configuration -------------");
         testQueries();
-
-        if (window.internals) {
-            internals.settings.setDeviceSupportsTouch(true);
-
-            log("------------- with touch screen -------------");
-            testQueries();
-        }
     }
 
 </script>
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-matchMedia-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..7fd057b
--- /dev/null
@@ -0,0 +1,19 @@
+Test the any-hover media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(any-hover)").matches = false
+window.matchMedia("(any-hover: hover)").matches = false
+window.matchMedia("(any-hover: on-demand)").matches = false
+window.matchMedia("(any-hover: none)").matches = true
+window.matchMedia("(any-hover: Hover)").matches = false
+window.matchMedia("(any-hover: On-demand)").matches = false
+window.matchMedia("(any-hover: None)").matches = true
+window.matchMedia("(Any-Hover: hover)").matches = false
+window.matchMedia("(Any-Hover: on-demand)").matches = false
+window.matchMedia("(Any-Hover: none)").matches = true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-styling-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-any-hover-styling-expected.txt
new file mode 100644 (file)
index 0000000..954cca9
--- /dev/null
@@ -0,0 +1,13 @@
+Test the any-hover media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(255, 0, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 0)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 10px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-matchMedia-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..4e6a236
--- /dev/null
@@ -0,0 +1,19 @@
+Test the any-pointer media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(any-pointer)").matches = true
+window.matchMedia("(any-pointer: fine)").matches = false
+window.matchMedia("(any-pointer: coarse)").matches = true
+window.matchMedia("(any-pointer: none)").matches = false
+window.matchMedia("(any-pointer: Fine)").matches = false
+window.matchMedia("(any-pointer: Coarse)").matches = true
+window.matchMedia("(any-pointer: None)").matches = false
+window.matchMedia("(Any-Pointer: fine)").matches = false
+window.matchMedia("(Any-Pointer: coarse)").matches = true
+window.matchMedia("(Any-Pointer: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-styling-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-any-pointer-styling-expected.txt
new file mode 100644 (file)
index 0000000..88c888c
--- /dev/null
@@ -0,0 +1,13 @@
+Test the any-pointer media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 0)
+getComputedStyle(target)["width"] = 10px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-hover-matchMedia-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-hover-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..706fc9f
--- /dev/null
@@ -0,0 +1,19 @@
+Test the hover media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(hover)").matches = false
+window.matchMedia("(hover: hover)").matches = false
+window.matchMedia("(hover: on-demand)").matches = false
+window.matchMedia("(hover: none)").matches = true
+window.matchMedia("(hover: Hover)").matches = false
+window.matchMedia("(hover: On-demand)").matches = false
+window.matchMedia("(hover: None)").matches = true
+window.matchMedia("(Hover: hover)").matches = false
+window.matchMedia("(Hover: on-demand)").matches = false
+window.matchMedia("(Hover: none)").matches = true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-hover-styling-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-hover-styling-expected.txt
new file mode 100644 (file)
index 0000000..1a802ae
--- /dev/null
@@ -0,0 +1,13 @@
+Test the hover media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(255, 0, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 0)
+getComputedStyle(target)["width"] = 100px
+getComputedStyle(target)["height"] = 10px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-expected.txt
new file mode 100644 (file)
index 0000000..24247d3
--- /dev/null
@@ -0,0 +1,14 @@
+Test the (pointer) and (hover) media features. See Bug 87403 for details.
+
+Query "(pointer)": true
+Query "(Pointer)": true
+Query "(pointer:none)": false
+Query "(pointer:coarse)": true
+Query "(pointer:coARse)": true
+Query "(pointer:bogusvalue)": false
+Query "(pointer:fine)": false
+Query "(hover)": false
+Query "(hover:0)": false
+Query "(hover:1)": false
+Query "(hover:bogusvalue)": false
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-matchMedia-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-matchMedia-expected.txt
new file mode 100644 (file)
index 0000000..066c50d
--- /dev/null
@@ -0,0 +1,19 @@
+Test the pointer media feature with machMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+window.matchMedia("(pointer)").matches = true
+window.matchMedia("(pointer: fine)").matches = false
+window.matchMedia("(pointer: coarse)").matches = true
+window.matchMedia("(pointer: none)").matches = false
+window.matchMedia("(pointer: Fine)").matches = false
+window.matchMedia("(pointer: Coarse)").matches = true
+window.matchMedia("(pointer: None)").matches = false
+window.matchMedia("(Pointer: fine)").matches = false
+window.matchMedia("(Pointer: coarse)").matches = true
+window.matchMedia("(Pointer: none)").matches = false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-styling-expected.txt b/LayoutTests/platform/ios-simulator/fast/media/mq-pointer-styling-expected.txt
new file mode 100644 (file)
index 0000000..19f96e9
--- /dev/null
@@ -0,0 +1,13 @@
+Test the pointer media feature to guard style rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getComputedStyle(target)["color"] = rgb(0, 128, 0)
+getComputedStyle(target)["background-color"] = rgb(0, 0, 0)
+getComputedStyle(target)["width"] = 10px
+getComputedStyle(target)["height"] = 100px
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 108faaf..7e17c42 100644 (file)
@@ -1,3 +1,54 @@
+2015-01-23  Benjamin Poulain  <bpoulain@apple.com>
+
+        Add pointer/hover media queries
+        https://bugs.webkit.org/show_bug.cgi?id=134822
+
+        Reviewed by Antti Koivisto.
+
+        Media Queries Level 4 introduces two types of Interaction Media Features:
+        "pointer" and "hover". Those media features are useful for adapting the design
+        to the type of input:
+            http://dev.w3.org/csswg/mediaqueries-4/#mf-interaction
+
+        This implementation is trivial: just #ifdef the return value depending on
+        the support for touch events.
+        In the future we should move that to a client interface but let's start easy
+        for now.
+
+        Tests: fast/media/mq-any-hover-cssom.html
+               fast/media/mq-any-hover-invalid.html
+               fast/media/mq-any-hover-matchMedia.html
+               fast/media/mq-any-hover-styling.html
+               fast/media/mq-any-pointer-cssom.html
+               fast/media/mq-any-pointer-invalid.html
+               fast/media/mq-any-pointer-matchMedia.html
+               fast/media/mq-any-pointer-styling.html
+               fast/media/mq-hover-cssom.html
+               fast/media/mq-hover-invalid.html
+               fast/media/mq-hover-matchMedia.html
+               fast/media/mq-hover-styling.html
+               fast/media/mq-pointer-cssom.html
+               fast/media/mq-pointer-invalid.html
+               fast/media/mq-pointer-matchMedia.html
+               fast/media/mq-pointer-styling.html
+
+        * css/CSSValueKeywords.in:
+        * css/MediaFeatureNames.h:
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::hoverMediaFeatureEval):
+        (WebCore::any_hoverMediaFeatureEval):
+        (WebCore::pointerMediaFeatureEval):
+        (WebCore::any_pointerMediaFeatureEval):
+        (WebCore::leastCapablePrimaryPointerDeviceType): Deleted.
+        * css/MediaQueryExp.cpp:
+        (WebCore::featureWithCSSValueID):
+        (WebCore::featureWithZeroOrOne):
+        (WebCore::featureWithoutValue):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::dispatchFakeMouseMoveEventSoon):
+        (WebCore::EventHandler::fakeMouseMoveEventTimerFired):
+        * page/Settings.in:
+
 2015-01-23  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r179051.
index 7d456a8..4709aa8 100644 (file)
@@ -1030,6 +1030,11 @@ alphabetic
 coarse
 fine
 
+// (hover:) media feature.
+// none
+hover
+on-demand
+
 // blend modes
 // normal
 multiply
index 514790b..512af90 100644 (file)
@@ -32,6 +32,8 @@ namespace WebCore {
 #endif
 
 #define CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(macro) \
+    macro(any_hover, "any-hover") \
+    macro(any_pointer, "any-pointer") \
     macro(color, "color") \
     macro(color_index, "color-index") \
     macro(grid, "grid") \
index 5bfb41f..2a0081c 100644 (file)
@@ -647,64 +647,45 @@ static bool video_playable_inlineMediaFeatureEval(CSSValue*, const CSSToLengthCo
     return !isRunningOnIPhoneOrIPod() || frame->settings().mediaPlaybackAllowsInline();
 }
 
-enum PointerDeviceType { TouchPointer, MousePointer, NoPointer, UnknownPointer };
-
-static PointerDeviceType leastCapablePrimaryPointerDeviceType(Frame* frame)
+static bool hoverMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix)
 {
-    if (frame->settings().deviceSupportsTouch())
-        return TouchPointer;
-
-    // FIXME: We should also try to determine if we know we have a mouse.
-    // When we do this, we'll also need to differentiate between known not to
-    // have mouse or touch screen (NoPointer) and unknown (UnknownPointer).
-    // We could also take into account other preferences like accessibility
-    // settings to decide which of the available pointers should be considered
-    // "primary".
-
-    return UnknownPointer;
-}
-
-static bool hoverMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
-{
-    PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame);
-
-    // If we're on a port that hasn't explicitly opted into providing pointer device information
-    // (or otherwise can't be confident in the pointer hardware available), then behave exactly
-    // as if this feature feature isn't supported.
-    if (pointer == UnknownPointer)
+    if (!is<CSSPrimitiveValue>(value)) {
+#if ENABLE(TOUCH_EVENTS)
         return false;
-
-    float number = 1;
-    if (value) {
-        if (!numberValue(value, number))
-            return false;
+#else
+        return true;
+#endif
     }
 
-    return (pointer == NoPointer && !number)
-        || (pointer == TouchPointer && !number)
-        || (pointer == MousePointer && number == 1);
+    int hoverCSSKeywordID = downcast<CSSPrimitiveValue>(*value).getValueID();
+#if ENABLE(TOUCH_EVENTS)
+    return hoverCSSKeywordID == CSSValueNone;
+#else
+    return hoverCSSKeywordID == CSSValueHover;
+#endif
 }
 
-static bool pointerMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
+static bool any_hoverMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& cssToLengthConversionData, Frame* frame, MediaFeaturePrefix prefix)
 {
-    PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame);
-
-    // If we're on a port that hasn't explicitly opted into providing pointer device information
-    // (or otherwise can't be confident in the pointer hardware available), then behave exactly
-    // as if this feature feature isn't supported.
-    if (pointer == UnknownPointer)
-        return false;
+    return hoverMediaFeatureEval(value, cssToLengthConversionData, frame, prefix);
+}
 
-    if (!value)
-        return pointer != NoPointer;
+static bool pointerMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix)
+{
+    if (!is<CSSPrimitiveValue>(value))
+        return true;
 
-    if (!is<CSSPrimitiveValue>(*value))
-        return false;
+    int pointerCSSKeywordID = downcast<CSSPrimitiveValue>(*value).getValueID();
+#if ENABLE(TOUCH_EVENTS)
+    return pointerCSSKeywordID == CSSValueCoarse;
+#else
+    return pointerCSSKeywordID == CSSValueFine;
+#endif
+}
 
-    const CSSValueID id = downcast<CSSPrimitiveValue>(*value).getValueID();
-    return (pointer == NoPointer && id == CSSValueNone)
-        || (pointer == TouchPointer && id == CSSValueCoarse)
-        || (pointer == MousePointer && id == CSSValueFine);
+static bool any_pointerMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& cssToLengthConversionData, Frame* frame, MediaFeaturePrefix prefix)
+{
+    return pointerMediaFeatureEval(value, cssToLengthConversionData, frame, prefix);
 }
 
 // FIXME: Remove unnecessary '&' from the following 'ADD_TO_FUNCTIONMAP' definition
index 37bed75..c80d974 100644 (file)
@@ -47,6 +47,9 @@ static inline bool featureWithCSSValueID(const AtomicString& mediaFeature, const
 #if ENABLE(VIEW_MODE_CSS_MEDIA)
         || mediaFeature == MediaFeatureNames::view_modeMediaFeature
 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
+        || mediaFeature == MediaFeatureNames::any_hoverMediaFeature
+        || mediaFeature == MediaFeatureNames::any_pointerMediaFeature
+        || mediaFeature == MediaFeatureNames::hoverMediaFeature
         || mediaFeature == MediaFeatureNames::inverted_colorsMediaFeature
         || mediaFeature == MediaFeatureNames::pointerMediaFeature;
 }
@@ -114,8 +117,7 @@ static inline bool featureWithZeroOrOne(const AtomicString& mediaFeature, const
     if (!value->isInt || !(value->fValue == 1 || !value->fValue))
         return false;
 
-    return mediaFeature == MediaFeatureNames::gridMediaFeature
-        || mediaFeature == MediaFeatureNames::hoverMediaFeature;
+    return mediaFeature == MediaFeatureNames::gridMediaFeature;
 }
 
 static inline bool featureWithAspectRatio(const AtomicString& mediaFeature)
@@ -131,7 +133,9 @@ static inline bool featureWithAspectRatio(const AtomicString& mediaFeature)
 static inline bool featureWithoutValue(const AtomicString& mediaFeature)
 {
     // Media features that are prefixed by min/max cannot be used without a value.
-    return mediaFeature == MediaFeatureNames::monochromeMediaFeature
+    return mediaFeature == MediaFeatureNames::any_hoverMediaFeature
+        || mediaFeature == MediaFeatureNames::any_pointerMediaFeature
+        || mediaFeature == MediaFeatureNames::monochromeMediaFeature
         || mediaFeature == MediaFeatureNames::colorMediaFeature
         || mediaFeature == MediaFeatureNames::color_indexMediaFeature
         || mediaFeature == MediaFeatureNames::gridMediaFeature
index 9c691f5..6061a39 100644 (file)
@@ -2898,9 +2898,6 @@ void EventHandler::dispatchFakeMouseMoveEventSoon()
     if (m_mousePositionIsUnknown)
         return;
 
-    if (!m_frame.settings().deviceSupportsMouse())
-        return;
-
     if (Page* page = m_frame.page()) {
         if (!page->chrome().client().shouldDispatchFakeMouseMoveEvents())
             return;
@@ -2947,9 +2944,6 @@ void EventHandler::fakeMouseMoveEventTimerFired()
 {
     ASSERT(!m_mousePressed);
 
-    if (!m_frame.settings().deviceSupportsMouse())
-        return;
-
     FrameView* view = m_frame.view();
     if (!view)
         return;
index cb364db..6242d33 100644 (file)
@@ -147,8 +147,6 @@ shouldRespectImageOrientation initial=defaultShouldRespectImageOrientation
 imageSubsamplingEnabled initial=defaultImageSubsamplingEnabled
 wantsBalancedSetDefersLoadingBehavior initial=false
 requestAnimationFrameEnabled initial=true
-deviceSupportsTouch initial=false
-deviceSupportsMouse initial=true
 
 fixedPositionCreatesStackingContext initial=defaultFixedPositionCreatesStackingContext
 syncXHRInDocumentsEnabled initial=true