Title: [164871] trunk
Revision
164871
Author
[email protected]
Date
2014-02-28 10:44:10 -0800 (Fri, 28 Feb 2014)

Log Message

MouseEvent.offsetX/Y should just return 0,0 for simulated clicks.
<https://webkit.org/b/129477>

Source/WebCore:

There's no need to compute the exact target-relative coordinates for
simulated mouse events, e.g those fired by HTMLElement.click().

The offsetX/Y properties are not supported by Firefox.

Test: fast/events/relative-offset-of-simulated-click.html

Reviewed by Alexey Proskuryakov.

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

LayoutTests:

Add a test documenting the behavior of offsetX/Y on the simulated
mouse events that get sent by HTMLElement.click().

Reviewed by Alexey Proskuryakov.

* fast/events/relative-offset-of-simulated-click-expected.txt: Added.
* fast/events/relative-offset-of-simulated-click.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (164870 => 164871)


--- trunk/LayoutTests/ChangeLog	2014-02-28 18:36:03 UTC (rev 164870)
+++ trunk/LayoutTests/ChangeLog	2014-02-28 18:44:10 UTC (rev 164871)
@@ -1,3 +1,16 @@
+2014-02-28  Andreas Kling  <[email protected]>
+
+        MouseEvent.offsetX/Y should just return 0,0 for simulated clicks.
+        <https://webkit.org/b/129477>
+
+        Add a test documenting the behavior of offsetX/Y on the simulated
+        mouse events that get sent by HTMLElement.click().
+
+        Reviewed by Alexey Proskuryakov.
+
+        * fast/events/relative-offset-of-simulated-click-expected.txt: Added.
+        * fast/events/relative-offset-of-simulated-click.html: Added.
+
 2014-02-27  Sergio Villar Senin  <[email protected]>
 
         [CSS Grid Layout] Fix positioning grid items using named grid lines/areas

Added: trunk/LayoutTests/fast/events/relative-offset-of-simulated-click-expected.txt (0 => 164871)


--- trunk/LayoutTests/fast/events/relative-offset-of-simulated-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/relative-offset-of-simulated-click-expected.txt	2014-02-28 18:44:10 UTC (rev 164871)
@@ -0,0 +1,18 @@
+This test documents the behavior of MouseEvent.offsetX/Y in response to HTMLElement.click().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Simulated click with .click():
+PASS event.offsetX is 0
+PASS event.offsetY is 0
+Click with mouse at 0,0:
+PASS event.offsetX is 0
+PASS event.offsetY is 0
+Click with mouse at 40,50:
+PASS event.offsetX is 40
+PASS event.offsetY is 50
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/relative-offset-of-simulated-click.html (0 => 164871)


--- trunk/LayoutTests/fast/events/relative-offset-of-simulated-click.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/relative-offset-of-simulated-click.html	2014-02-28 18:44:10 UTC (rev 164871)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("This test documents the behavior of MouseEvent.offsetX/Y in response to HTMLElement.click().");
+
+var testDiv = document.createElement("div");
+testDiv.setAttribute("style", "background: green; width: 100px; height: 100px; position: absolute; top: 100px; left: 100px;");
+document.body.appendChild(testDiv);
+
+testDiv.addEventListener("click", function(e) {
+    event = e;
+    shouldBe("event.offsetX", expectedX);
+    shouldBe("event.offsetY", expectedY);
+});
+
+debug("Simulated click with .click():");
+expectedX = "0";
+expectedY = "0";
+testDiv.click();
+
+if (!window.eventSender)
+    debug("This part of the test requires eventSender!");
+else {
+    debug("Click with mouse at 0,0:");
+    expectedX = "0";
+    expectedY = "0";
+    eventSender.mouseMoveTo(100, 100);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    debug("Click with mouse at 40,50:");
+    expectedX = "40";
+    expectedY = "50";
+    eventSender.mouseMoveTo(140, 150);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+testDiv.remove();
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (164870 => 164871)


--- trunk/Source/WebCore/ChangeLog	2014-02-28 18:36:03 UTC (rev 164870)
+++ trunk/Source/WebCore/ChangeLog	2014-02-28 18:44:10 UTC (rev 164871)
@@ -1,3 +1,21 @@
+2014-02-28  Andreas Kling  <[email protected]>
+
+        MouseEvent.offsetX/Y should just return 0,0 for simulated clicks.
+        <https://webkit.org/b/129477>
+
+        There's no need to compute the exact target-relative coordinates for
+        simulated mouse events, e.g those fired by HTMLElement.click().
+
+        The offsetX/Y properties are not supported by Firefox.
+
+        Test: fast/events/relative-offset-of-simulated-click.html
+
+        Reviewed by Alexey Proskuryakov.
+
+        * dom/MouseRelatedEvent.cpp:
+        (WebCore::MouseRelatedEvent::offsetX):
+        (WebCore::MouseRelatedEvent::offsetY):
+
 2014-02-27  Sergio Villar Senin  <[email protected]>
 
         [CSS Grid Layout] Fix positioning grid items using named grid lines/areas

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (164870 => 164871)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2014-02-28 18:36:03 UTC (rev 164870)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2014-02-28 18:44:10 UTC (rev 164871)
@@ -208,6 +208,8 @@
 
 int MouseRelatedEvent::offsetX()
 {
+    if (isSimulated())
+        return 0;
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
     return roundToInt(m_offsetLocation.x());
@@ -215,6 +217,8 @@
 
 int MouseRelatedEvent::offsetY()
 {
+    if (isSimulated())
+        return 0;
     if (!m_hasCachedRelativePosition)
         computeRelativePosition();
     return roundToInt(m_offsetLocation.y());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to