Title: [143148] trunk
- Revision
- 143148
- Author
- [email protected]
- Date
- 2013-02-17 22:31:19 -0800 (Sun, 17 Feb 2013)
Log Message
WheelEvent should not target text nodes.
https://bugs.webkit.org/show_bug.cgi?id=109939
Reviewed by Darin Adler.
Source/WebCore:
WheelEvent, like other mouse events, should not target text nodes.
EventHandler correctly handles other mouse events by retargeting
events to text nodes' parents; this patch adds that logic to the
WheelEvent handler.
This should allow jQuery to stop working around WebKit's behavior[1].
[1]: https://github.com/jquery/jquery/commit/c61150427fc8ccc8e884df8f221a6c9bb5477929
Test: fast/events/wheelevent-in-text-node.html
* page/EventHandler.cpp:
(WebCore::EventHandler::handleWheelEvent):
If a WheelEvent's hit test lands on a text node, retarget the
event to the text node's parent. Do this before latching the node.
LayoutTests:
* fast/events/wheelevent-in-text-node-expected.txt: Added.
* fast/events/wheelevent-in-text-node.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (143147 => 143148)
--- trunk/LayoutTests/ChangeLog 2013-02-18 06:28:54 UTC (rev 143147)
+++ trunk/LayoutTests/ChangeLog 2013-02-18 06:31:19 UTC (rev 143148)
@@ -1,3 +1,13 @@
+2013-02-17 Mike West <[email protected]>
+
+ WheelEvent should not target text nodes.
+ https://bugs.webkit.org/show_bug.cgi?id=109939
+
+ Reviewed by Darin Adler.
+
+ * fast/events/wheelevent-in-text-node-expected.txt: Added.
+ * fast/events/wheelevent-in-text-node.html: Added.
+
2013-02-17 Philip Rogers <[email protected]>
Fix non-root SVG viewport under zoom
Added: trunk/LayoutTests/fast/events/wheelevent-in-text-node-expected.txt (0 => 143148)
--- trunk/LayoutTests/fast/events/wheelevent-in-text-node-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/wheelevent-in-text-node-expected.txt 2013-02-18 06:31:19 UTC (rev 143148)
@@ -0,0 +1,6 @@
+'Real' MouseWheel events should not be dispatched on the text node, but instead on its parent.
+PASS theEvent.target.nodeName is "DIV"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is a div containing text. Wheel events originating on the text node should target the div.
Added: trunk/LayoutTests/fast/events/wheelevent-in-text-node.html (0 => 143148)
--- trunk/LayoutTests/fast/events/wheelevent-in-text-node.html (rev 0)
+++ trunk/LayoutTests/fast/events/wheelevent-in-text-node.html 2013-02-18 06:31:19 UTC (rev 143148)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script>
+ window.jsTestIsAsync = true;
+
+ function test() {
+ var div = document.querySelector('div');
+ if (window.eventSender) {
+ eventSender.mouseMoveTo(div.offsetLeft + 5, div.offsetTop + 5);
+ eventSender.mouseScrollBy(0,120);
+ } else {
+ debug("FAIL: This test requires window.eventSender.");
+ finishJSTest();
+ }
+ }
+
+ function wheelHandler(e) {
+ window.theEvent = e;
+
+ debug("'Real' MouseWheel events should not be dispatched on the text node, but instead on its parent.");
+ shouldBeEqualToString('theEvent.target.nodeName', 'DIV');
+ finishJSTest();
+ }
+
+ window._onload_ = function () {
+ var div = document.querySelector('div');
+ div.addEventListener('mousewheel', wheelHandler);
+ test();
+ };
+ </script>
+ <script src=""
+</head>
+<body>
+ <div>This is a div containing text. Wheel events originating on the text
+ node should target the div.</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (143147 => 143148)
--- trunk/Source/WebCore/ChangeLog 2013-02-18 06:28:54 UTC (rev 143147)
+++ trunk/Source/WebCore/ChangeLog 2013-02-18 06:31:19 UTC (rev 143148)
@@ -1,3 +1,26 @@
+2013-02-17 Mike West <[email protected]>
+
+ WheelEvent should not target text nodes.
+ https://bugs.webkit.org/show_bug.cgi?id=109939
+
+ Reviewed by Darin Adler.
+
+ WheelEvent, like other mouse events, should not target text nodes.
+ EventHandler correctly handles other mouse events by retargeting
+ events to text nodes' parents; this patch adds that logic to the
+ WheelEvent handler.
+
+ This should allow jQuery to stop working around WebKit's behavior[1].
+
+ [1]: https://github.com/jquery/jquery/commit/c61150427fc8ccc8e884df8f221a6c9bb5477929
+
+ Test: fast/events/wheelevent-in-text-node.html
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleWheelEvent):
+ If a WheelEvent's hit test lands on a text node, retarget the
+ event to the text node's parent. Do this before latching the node.
+
2013-02-17 Filip Pizlo <[email protected]>
Move all Structure out-of-line inline methods to StructureInlines.h
Modified: trunk/Source/WebCore/page/EventHandler.cpp (143147 => 143148)
--- trunk/Source/WebCore/page/EventHandler.cpp 2013-02-18 06:28:54 UTC (rev 143147)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2013-02-18 06:31:19 UTC (rev 143148)
@@ -2323,22 +2323,28 @@
setFrameWasScrolledByUser();
LayoutPoint vPoint = view->windowToContents(e.position());
- Node* node;
- bool isOverWidget;
-
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestResult result(vPoint);
doc->renderView()->hitTest(request, result);
bool useLatchedWheelEventNode = e.useLatchedEventNode();
+ Node* node = result.innerNode();
+ // Wheel events should not dispatch to text nodes.
+ if (node && node->isTextNode()) {
+ AncestorChainWalker walker(node);
+ walker.parent();
+ node = walker.get();
+ }
+
+ bool isOverWidget;
if (useLatchedWheelEventNode) {
if (!m_latchedWheelEventNode) {
- m_latchedWheelEventNode = result.innerNode();
+ m_latchedWheelEventNode = node;
m_widgetIsLatched = result.isOverWidget();
- }
+ } else
+ node = m_latchedWheelEventNode.get();
- node = m_latchedWheelEventNode.get();
isOverWidget = m_widgetIsLatched;
} else {
if (m_latchedWheelEventNode)
@@ -2346,7 +2352,6 @@
if (m_previousWheelScrolledNode)
m_previousWheelScrolledNode = 0;
- node = result.innerNode();
isOverWidget = result.isOverWidget();
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes