Take pageScaleFactor into account for MouseRelatedEvents.
authorjknotten@chromium.org <jknotten@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Sep 2011 16:55:52 +0000 (16:55 +0000)
committerjknotten@chromium.org <jknotten@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Sep 2011 16:55:52 +0000 (16:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67592

Source/WebCore:

Reviewed by Dimitri Glazkov.

Test: fast/events/page-scaled-mouse-click.html

* dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::MouseRelatedEvent):

LayoutTests:

Mouse-related events currently take account of the zoom factor, but they
also need to take account of the page scale factor so that pageX and pageY
event coordinates are properly determined.

Reviewed by Dimitri Glazkov.

* fast/events/page-scaled-mouse-click-expected.txt: Added.
* fast/events/page-scaled-mouse-click.html: Added.
* fast/events/script-tests/page-scaled-mouse-click.js: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/page-scaled-mouse-click-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/page-scaled-mouse-click.html [new file with mode: 0644]
LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/MouseRelatedEvent.cpp

index a58804b..f31bed8 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-05  John Knottenbelt  <jknotten@chromium.org>
+
+        Take pageScaleFactor into account for MouseRelatedEvents.
+        https://bugs.webkit.org/show_bug.cgi?id=67592
+
+        Mouse-related events currently take account of the zoom factor, but they
+        also need to take account of the page scale factor so that pageX and pageY
+        event coordinates are properly determined.
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/events/page-scaled-mouse-click-expected.txt: Added.
+        * fast/events/page-scaled-mouse-click.html: Added.
+        * fast/events/script-tests/page-scaled-mouse-click.js: Added.
+
 2011-09-05  Balazs Kelemen  <kbalazs@webkit.org>
 
         D'oh! Missed the name of the test in the previous gardening.
diff --git a/LayoutTests/fast/events/page-scaled-mouse-click-expected.txt b/LayoutTests/fast/events/page-scaled-mouse-click-expected.txt
new file mode 100644 (file)
index 0000000..e3f1b7a
--- /dev/null
@@ -0,0 +1,11 @@
+This tests that page scaling does not affect mouse event pageX and pageY coordinates.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS eventLog is "click(10, 10)"
+PASS eventLog is "click(20, 20)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/page-scaled-mouse-click.html b/LayoutTests/fast/events/page-scaled-mouse-click.html
new file mode 100644 (file)
index 0000000..0228f1b
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/page-scaled-mouse-click.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js b/LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js
new file mode 100644 (file)
index 0000000..e01e516
--- /dev/null
@@ -0,0 +1,54 @@
+description("This tests that page scaling does not affect mouse event pageX and pageY coordinates.");
+
+var div = document.createElement("div");
+div.style.width = "100px";
+div.style.height = "100px";
+div.style.backgroundColor = "blue";
+
+var eventLog = "";
+
+function appendEventLog() {
+    var msg = event.type + "(" + event.pageX + ", " + event.pageY + ")";
+
+    if (window.eventSender) {
+        eventLog += msg;
+    } else {
+        debug(msg);
+    }
+}
+
+function clearEventLog() {
+    eventLog = "";
+}
+
+div.addEventListener("click", appendEventLog, false);
+document.body.insertBefore(div, document.body.firstChild);
+
+function sendEvents(button) {
+    if (!window.eventSender) {
+        debug("This test requires DumpRenderTree.  Click on the blue rect with the left mouse button to log the mouse coordinates.")
+        return;
+    }
+    eventSender.mouseDown(button);
+    eventSender.mouseUp(button);
+}
+
+function testEvents(button, expectedString) {
+    sendEvents(button);
+    shouldBeEqualToString("eventLog", expectedString);
+    clearEventLog();
+}
+
+if (window.eventSender) {
+    eventSender.mouseMoveTo(10, 10);
+    testEvents(0, "click(10, 10)");
+
+    eventSender.scalePageBy(0.5, 0, 0);
+
+    // We are clicking in the same position on screen, but we have scaled the page out by 50%,
+    // we therefore expect the page-relative coordinates of the mouse event (pageX, pageY)
+    // to be doubled.
+    testEvents(0, "click(20, 20)");
+}
+
+var successfullyParsed = true;
index 76c67cb..54cddc7 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-05  John Knottenbelt  <jknotten@chromium.org>
+
+        Take pageScaleFactor into account for MouseRelatedEvents.
+        https://bugs.webkit.org/show_bug.cgi?id=67592
+
+        Reviewed by Dimitri Glazkov.
+
+        Test: fast/events/page-scaled-mouse-click.html
+
+        * dom/MouseRelatedEvent.cpp:
+        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
+
 2011-09-02  Pavel Podivilov  <podivilov@chromium.org>
 
         Web Inspector: rename RawSourceCode.reload to contentEdited.
index 216fe28..2d81935 100644 (file)
@@ -67,7 +67,7 @@ MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubb
         if (FrameView* frameView = frame->view()) {
             scrollPosition = frameView->scrollPosition();
             adjustedPageLocation = frameView->windowToContents(windowLocation);
-            float pageZoom = frame->pageZoomFactor();
+            float pageZoom = frame->pageZoomFactor() * frame->pageScaleFactor();
             if (pageZoom != 1.0f) {
                 // Adjust our pageX and pageY to account for the page zoom.
                 adjustedPageLocation.scale(1 / pageZoom, 1 / pageZoom);