Title: [94536] trunk
Revision
94536
Author
[email protected]
Date
2011-09-05 09:55:52 -0700 (Mon, 05 Sep 2011)

Log Message

Take pageScaleFactor into account for MouseRelatedEvents.
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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94535 => 94536)


--- trunk/LayoutTests/ChangeLog	2011-09-05 16:51:29 UTC (rev 94535)
+++ trunk/LayoutTests/ChangeLog	2011-09-05 16:55:52 UTC (rev 94536)
@@ -1,3 +1,18 @@
+2011-09-05  John Knottenbelt  <[email protected]>
+
+        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  <[email protected]>
 
         D'oh! Missed the name of the test in the previous gardening.

Added: trunk/LayoutTests/fast/events/page-scaled-mouse-click-expected.txt (0 => 94536)


--- trunk/LayoutTests/fast/events/page-scaled-mouse-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/page-scaled-mouse-click-expected.txt	2011-09-05 16:55:52 UTC (rev 94536)
@@ -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
+

Added: trunk/LayoutTests/fast/events/page-scaled-mouse-click.html (0 => 94536)


--- trunk/LayoutTests/fast/events/page-scaled-mouse-click.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/page-scaled-mouse-click.html	2011-09-05 16:55:52 UTC (rev 94536)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js (0 => 94536)


--- trunk/LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js	                        (rev 0)
+++ trunk/LayoutTests/fast/events/script-tests/page-scaled-mouse-click.js	2011-09-05 16:55:52 UTC (rev 94536)
@@ -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;

Modified: trunk/Source/WebCore/ChangeLog (94535 => 94536)


--- trunk/Source/WebCore/ChangeLog	2011-09-05 16:51:29 UTC (rev 94535)
+++ trunk/Source/WebCore/ChangeLog	2011-09-05 16:55:52 UTC (rev 94536)
@@ -1,3 +1,15 @@
+2011-09-05  John Knottenbelt  <[email protected]>
+
+        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  <[email protected]>
 
         Web Inspector: rename RawSourceCode.reload to contentEdited.

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (94535 => 94536)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2011-09-05 16:51:29 UTC (rev 94535)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2011-09-05 16:55:52 UTC (rev 94536)
@@ -67,7 +67,7 @@
         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);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to