Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 429793004: Re-add extra hit-tests on GestureTap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix patch Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/events/touch/gesture/resources/event-delegator.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 if (gestureEvent.ctrlKey()) 2220 if (gestureEvent.ctrlKey())
2221 modifierFlags |= PlatformEvent::CtrlKey; 2221 modifierFlags |= PlatformEvent::CtrlKey;
2222 if (gestureEvent.metaKey()) 2222 if (gestureEvent.metaKey())
2223 modifierFlags |= PlatformEvent::MetaKey; 2223 modifierFlags |= PlatformEvent::MetaKey;
2224 if (gestureEvent.shiftKey()) 2224 if (gestureEvent.shiftKey())
2225 modifierFlags |= PlatformEvent::ShiftKey; 2225 modifierFlags |= PlatformEvent::ShiftKey;
2226 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m odifierFlags); 2226 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m odifierFlags);
2227 2227
2228 // We use the adjusted position so the application isn't surprised to see a event with 2228 // We use the adjusted position so the application isn't surprised to see a event with
2229 // co-ordinates outside the target's bounds. 2229 // co-ordinates outside the target's bounds.
2230 IntPoint adjustedPoint = gestureEvent.position(); 2230 IntPoint adjustedPoint = m_frame->view()->windowToContents(gestureEvent.posi tion());
2231
2232 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because
2233 // touch adjustment sometimes returns a different node than what hit testing would return
2234 // for the same point.
2235 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914
2236 HitTestResult newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitT estRequest::ReadOnly);
2231 2237
2232 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition( ), 2238 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition( ),
2233 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, 2239 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2234 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2240 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2235 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.targetNode(), 0, fakeMouseMove, true); 2241 dispatchMouseEvent(EventTypeNames::mousemove, newHitTest.targetNode(), 0, fa keMouseMove, true);
2242
2243 // Do a new hit-test in case the mousemove event changed the DOM.
2244 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
2245 newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestRequest::Re adOnly);
2246 m_clickNode = newHitTest.targetNode();
2247 if (m_clickNode && m_clickNode->isTextNode())
2248 m_clickNode = NodeRenderingTraversal::parent(m_clickNode.get());
2236 2249
2237 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition( ), 2250 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition( ),
2238 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), 2251 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
2239 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2252 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2240 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, targetedEvent.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true); 2253 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true);
2241 if (!swallowMouseDownEvent) 2254 if (!swallowMouseDownEvent)
2242 swallowMouseDownEvent = handleMouseFocus(fakeMouseDown); 2255 swallowMouseDownEvent = handleMouseFocus(fakeMouseDown);
2243 if (!swallowMouseDownEvent) 2256 if (!swallowMouseDownEvent)
2244 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, targetedEvent.hitTestResult())); 2257 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, newHitTest));
2245 2258
2259 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
2260 newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestRequest::Re adOnly);
2246 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), 2261 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(),
2247 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), 2262 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(),
2248 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2263 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2249 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, targ etedEvent.targetNode(), gestureEvent.tapCount(), fakeMouseUp, false); 2264 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, newH itTest.targetNode(), gestureEvent.tapCount(), fakeMouseUp, false);
2250 bool swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, targeted Event.targetNode(), gestureEvent.tapCount(), fakeMouseUp, true); 2265
2266 bool swallowClickEvent = false;
2267 if (m_clickNode) {
2268 Node* clickTargetNode = newHitTest.targetNode()->commonAncestor(*m_click Node, parentForClickEvent);
2269 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTarg etNode, gestureEvent.tapCount(), fakeMouseUp, true);
2270 m_clickNode = nullptr;
2271 }
2272
2251 if (!swallowMouseUpEvent) 2273 if (!swallowMouseUpEvent)
2252 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul ts(fakeMouseUp, targetedEvent.hitTestResult())); 2274 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul ts(fakeMouseUp, newHitTest));
2253 2275
2254 return swallowMouseDownEvent | swallowMouseUpEvent | swallowClickEvent; 2276 return swallowMouseDownEvent | swallowMouseUpEvent | swallowClickEvent;
2255 } 2277 }
2256 2278
2257 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults& targetedEvent) 2279 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults& targetedEvent)
2258 { 2280 {
2259 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 2281 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2260 IntPoint adjustedPoint = gestureEvent.position(); 2282 IntPoint adjustedPoint = gestureEvent.position();
2261 2283
2262 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the 2284 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 unsigned EventHandler::accessKeyModifiers() 3852 unsigned EventHandler::accessKeyModifiers()
3831 { 3853 {
3832 #if OS(MACOSX) 3854 #if OS(MACOSX)
3833 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3855 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3834 #else 3856 #else
3835 return PlatformEvent::AltKey; 3857 return PlatformEvent::AltKey;
3836 #endif 3858 #endif
3837 } 3859 }
3838 3860
3839 } // namespace blink 3861 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/touch/gesture/resources/event-delegator.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698