Title: [97988] trunk
Revision
97988
Author
jknot...@chromium.org
Date
2011-10-20 09:45:30 -0700 (Thu, 20 Oct 2011)

Log Message

Touch events should take page scale into account
https://bugs.webkit.org/show_bug.cgi?id=69798

Reviewed by Adam Barth.

Source/WebCore:

Test: fast/events/touch/page-scaled-touch-gesture-click.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleTouchEvent):

LayoutTests:

* fast/events/touch/page-scaled-touch-gesture-click-expected.txt: Added.
* fast/events/touch/page-scaled-touch-gesture-click.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97987 => 97988)


--- trunk/LayoutTests/ChangeLog	2011-10-20 16:41:51 UTC (rev 97987)
+++ trunk/LayoutTests/ChangeLog	2011-10-20 16:45:30 UTC (rev 97988)
@@ -1,3 +1,13 @@
+2011-10-20  John Knottenbelt  <jknot...@chromium.org>
+
+        Touch events should take page scale into account
+        https://bugs.webkit.org/show_bug.cgi?id=69798
+
+        Reviewed by Adam Barth.
+
+        * fast/events/touch/page-scaled-touch-gesture-click-expected.txt: Added.
+        * fast/events/touch/page-scaled-touch-gesture-click.html: Added.
+
 2011-10-20  Leandro Pereira  <lean...@profusion.mobi>
 
         Unreviewed. Add part of EFL baselines for the fast/ suite.

Added: trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click-expected.txt (0 => 97988)


--- trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click-expected.txt	2011-10-20 16:45:30 UTC (rev 97988)
@@ -0,0 +1,39 @@
+This tests basic single touch gesture generation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+have received: 1 touch events
+have received: 2 touch events
+PASS event.type is "mousemove"
+PASS event.clientX is 20
+PASS event.clientY is 24
+PASS event.shiftKey is true
+PASS event.altKey is true
+PASS event.ctrlKey is false
+PASS event.metaKey is false
+PASS event.type is "mousedown"
+PASS event.clientX is 20
+PASS event.clientY is 24
+PASS event.shiftKey is true
+PASS event.altKey is true
+PASS event.ctrlKey is false
+PASS event.metaKey is false
+PASS event.type is "mouseup"
+PASS event.clientX is 20
+PASS event.clientY is 24
+PASS event.shiftKey is true
+PASS event.altKey is true
+PASS event.ctrlKey is false
+PASS event.metaKey is false
+PASS event.type is "click"
+PASS event.clientX is 20
+PASS event.clientY is 24
+PASS event.shiftKey is true
+PASS event.altKey is true
+PASS event.ctrlKey is false
+PASS event.metaKey is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click.html (0 => 97988)


--- trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/page-scaled-touch-gesture-click.html	2011-10-20 16:45:30 UTC (rev 97988)
@@ -0,0 +1,121 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<style type="text/css">
+#touchtarget {
+  width: 100px;
+  height: 100px;
+  background: blue;
+}
+</style>
+</head>
+<body _onload_="runTest();">
+<div id="touchtarget">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+var clickEventsReceived = 0;
+var expectedMouseEvents = 4;
+var touchEventsReceived = 0;
+var mouseEventsReceived = 0;
+var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
+
+function gestureEventCallback(event)
+{
+    if (window.eventSender) {
+        shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
+        shouldBe('event.clientX', '20');
+        shouldBe('event.clientY', '24');
+        shouldBe("event.shiftKey", "true");
+        shouldBe("event.altKey", "true");
+        shouldBe("event.ctrlKey", "false");
+        shouldBe("event.metaKey", "false");
+        mouseEventsReceived++;
+    } else {
+        debug(event.type);
+        debug(event.clientX);
+        debug(event.clientY);
+    }
+}
+
+// Because we may not have a gesture recognizer, we send a key press
+// event to end the test without temporal flakiness.
+function quitKeyToEndTest(event) {
+    endTest();
+}
+
+// Log that we still got the touch events.
+function touchEventCallback(event) {
+    touchEventsReceived++;
+    debug('have received: ' + touchEventsReceived + ' touch events');
+    return true;
+}
+
+function singleTouchSequence()
+{
+    eventSender.clearTouchPoints();
+    // Coordinates passed to eventSender.addTouchPoint are in screen pixels,
+    // relative to the top left of the window.
+    eventSender.addTouchPoint(10, 12);
+    eventSender.touchStart();
+
+    // Insert some delay. NB: this value depends on minClickDownTime,
+    // maxClickDownTime from GestureRecognizerChromium.cpp
+    eventSender.leapForward(20);
+    eventSender.setTouchModifier("shift", true);
+    eventSender.setTouchModifier("alt", true);
+
+    eventSender.releaseTouchPoint(0);
+    eventSender.touchEnd();
+}
+
+function endTest()
+{
+    if (mouseEventsReceived < expectedMouseEvents) {
+        debug('Gesture manager not implemented on this platform.');
+    }
+    // Bail.
+    successfullyParsed = true;
+    isSuccessfullyParsed();
+    layoutTestController.notifyDone();
+}
+
+function runTest() {
+    if (window.eventSender) {
+        eventSender.scalePageBy(0.5, 0, 0);
+    }
+
+    var div = document.getElementById('touchtarget');
+    div.addEventListener("mousedown", gestureEventCallback, false);
+    div.addEventListener("click", gestureEventCallback, false);
+    div.addEventListener("mouseup", gestureEventCallback, false);
+    div.addEventListener("mousemove", gestureEventCallback, false);
+    document.addEventListener("keydown", quitKeyToEndTest, false);
+    div.addEventListener("touchstart", touchEventCallback, false);
+    div.addEventListener("touchmove", touchEventCallback, false);
+    div.addEventListener("touchend", touchEventCallback, false);
+
+    if (window.layoutTestController)
+        layoutTestController.waitUntilDone();
+
+    if (window.eventSender) {
+        description("This tests basic single touch gesture generation.");
+        if (eventSender.clearTouchPoints) {
+            singleTouchSequence();
+            eventSender.leapForward(10);
+            eventSender.keyDown(' ');
+        } else {
+            endTest();
+        }
+    } else {
+        debug("This test requires DumpRenderTree.  Tap on the blue rect to log.")
+    }
+}
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (97987 => 97988)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 16:41:51 UTC (rev 97987)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 16:45:30 UTC (rev 97988)
@@ -1,3 +1,15 @@
+2011-10-20  John Knottenbelt  <jknot...@chromium.org>
+
+        Touch events should take page scale into account
+        https://bugs.webkit.org/show_bug.cgi?id=69798
+
+        Reviewed by Adam Barth.
+
+        Test: fast/events/touch/page-scaled-touch-gesture-click.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTouchEvent):
+
 2011-10-20  Andreas Kling  <kl...@webkit.org>
 
         CSSMutableStyleDeclaration: Simplify setNeedsStyleRecalc().

Modified: trunk/Source/WebCore/page/EventHandler.cpp (97987 => 97988)


--- trunk/Source/WebCore/page/EventHandler.cpp	2011-10-20 16:41:51 UTC (rev 97987)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2011-10-20 16:45:30 UTC (rev 97988)
@@ -3228,9 +3228,11 @@
             pagePoint = documentPointForWindowPoint(doc->frame(), point.pos());
         }
 
-        int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor());
-        int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor());
+        float scaleFactor = m_frame->pageZoomFactor() * m_frame->frameScaleFactor();
 
+        int adjustedPageX = lroundf(pagePoint.x() / scaleFactor);
+        int adjustedPageY = lroundf(pagePoint.y() / scaleFactor);
+
         // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
         unsigned touchPointTargetKey = point.id() + 1;
         RefPtr<EventTarget> touchTarget;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to