Title: [86776] trunk
- Revision
- 86776
- Author
- [email protected]
- Date
- 2011-05-18 10:47:25 -0700 (Wed, 18 May 2011)
Log Message
2011-05-18 Erik Arvidsson <[email protected]>
Reviewed by Ojan Vafai.
event.clientX/clientY is 0/0 in a click generated through a label
https://bugs.webkit.org/show_bug.cgi?id=56606
This tests that clicking on a label for an input generates a click event on the input
with the same coordinates as the original click.
* fast/events/simulated-click-coords-expected.txt: Added.
* fast/events/simulated-click-coords.html: Added.
2011-05-18 Erik Arvidsson <[email protected]>
Reviewed by Ojan Vafai.
event.clientX/clientY is 0/0 in a click generated through a label
https://bugs.webkit.org/show_bug.cgi?id=56606
This copies the coordinates from the underlying event to the simulated mouse event if the underlying event
is a mouse event.
This makes us match Firefox and IE.
Test: fast/events/simulated-click-coords.html
* dom/MouseEvent.cpp:
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (86775 => 86776)
--- trunk/LayoutTests/ChangeLog 2011-05-18 17:33:48 UTC (rev 86775)
+++ trunk/LayoutTests/ChangeLog 2011-05-18 17:47:25 UTC (rev 86776)
@@ -1,3 +1,16 @@
+2011-05-18 Erik Arvidsson <[email protected]>
+
+ Reviewed by Ojan Vafai.
+
+ event.clientX/clientY is 0/0 in a click generated through a label
+ https://bugs.webkit.org/show_bug.cgi?id=56606
+
+ This tests that clicking on a label for an input generates a click event on the input
+ with the same coordinates as the original click.
+
+ * fast/events/simulated-click-coords-expected.txt: Added.
+ * fast/events/simulated-click-coords.html: Added.
+
2011-05-18 Rob Buis <[email protected]>
Reviewed by Nikolas Zimmermann.
Added: trunk/LayoutTests/fast/events/simulated-click-coords-expected.txt (0 => 86776)
--- trunk/LayoutTests/fast/events/simulated-click-coords-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/simulated-click-coords-expected.txt 2011-05-18 17:47:25 UTC (rev 86776)
@@ -0,0 +1,14 @@
+Ensure that simulated click on label elements uses the original mouse coordinates.
+
+ Click Me
+PASS: event.clientX is same for both real and simulated event.
+PASS: event.clientY is same for both real and simulated event.
+PASS: event.layerX is same for both real and simulated event.
+PASS: event.layerY is same for both real and simulated event.
+PASS: event.pageX is same for both real and simulated event.
+PASS: event.pageY is same for both real and simulated event.
+PASS: event.screenX is same for both real and simulated event.
+PASS: event.screenY is same for both real and simulated event.
+PASS: event.x is same for both real and simulated event.
+PASS: event.y is same for both real and simulated event.
+
Property changes on: trunk/LayoutTests/fast/events/simulated-click-coords-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/simulated-click-coords.html (0 => 86776)
--- trunk/LayoutTests/fast/events/simulated-click-coords.html (rev 0)
+++ trunk/LayoutTests/fast/events/simulated-click-coords.html 2011-05-18 17:47:25 UTC (rev 86776)
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<p>Ensure that simulated click on label elements uses the original mouse coordinates.</p>
+<input type="checkbox" id="target" _onclick_="validateEventProperties(event)">
+<label for="" _onclick_="storeEvent(event)">Click Me</label>
+<pre id="out"></pre>
+<script>
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function clickOn(element)
+{
+ if (!window.eventSender)
+ return;
+
+ var x = element.offsetLeft + element.offsetWidth / 2;
+ var y = element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+function print(s)
+{
+ document.getElementById('out').textContent += s + '\n';
+}
+
+var realClickEvent, simulatedEvent;
+
+function storeEvent(event)
+{
+ realClickEvent = event;
+}
+
+function validateEventProperty(name)
+{
+ if (realClickEvent[name] === simulatedEvent[name])
+ print('PASS: event.' + name + ' is same for both real and simulated event.');
+ else
+ print('FAIL: event.' + name + ' is ' + simulatedEvent[name] + ', expected ' + realClickEvent[name]);
+}
+
+function validateEventProperties(event)
+{
+ simulatedEvent = event;
+
+ validateEventProperty('clientX');
+ validateEventProperty('clientY');
+ validateEventProperty('layerX');
+ validateEventProperty('layerY');
+ validateEventProperty('pageX');
+ validateEventProperty('pageY');
+ validateEventProperty('screenX');
+ validateEventProperty('screenY');
+ validateEventProperty('x');
+ validateEventProperty('y');
+}
+
+clickOn(document.querySelector('label'));
+
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/simulated-click-coords.html
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/Source/WebCore/ChangeLog (86775 => 86776)
--- trunk/Source/WebCore/ChangeLog 2011-05-18 17:33:48 UTC (rev 86775)
+++ trunk/Source/WebCore/ChangeLog 2011-05-18 17:47:25 UTC (rev 86776)
@@ -1,3 +1,20 @@
+2011-05-18 Erik Arvidsson <[email protected]>
+
+ Reviewed by Ojan Vafai.
+
+ event.clientX/clientY is 0/0 in a click generated through a label
+ https://bugs.webkit.org/show_bug.cgi?id=56606
+
+ This copies the coordinates from the underlying event to the simulated mouse event if the underlying event
+ is a mouse event.
+
+ This makes us match Firefox and IE.
+
+ Test: fast/events/simulated-click-coords.html
+
+ * dom/MouseEvent.cpp:
+ (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
+
2011-05-18 Nikolas Zimmermann <[email protected]>
Not reviewed. Sorted XCode project file.
Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (86775 => 86776)
--- trunk/Source/WebCore/dom/MouseEvent.cpp 2011-05-18 17:33:48 UTC (rev 86775)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp 2011-05-18 17:47:25 UTC (rev 86776)
@@ -150,6 +150,13 @@
m_metaKey = keyStateEvent->metaKey();
}
setUnderlyingEvent(underlyingEvent);
+
+ if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
+ MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
+ m_screenX = mouseEvent->screenX();
+ m_screenY = mouseEvent->screenY();
+ initCoordinates(mouseEvent->clientX(), mouseEvent->clientY());
+ }
}
MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtr<MouseEvent> mouseEvent)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes