OLD | NEW |
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 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 if (gestureEvent.altKey()) | 2219 if (gestureEvent.altKey()) |
2220 modifierFlags |= PlatformEvent::AltKey; | 2220 modifierFlags |= PlatformEvent::AltKey; |
2221 if (gestureEvent.ctrlKey()) | 2221 if (gestureEvent.ctrlKey()) |
2222 modifierFlags |= PlatformEvent::CtrlKey; | 2222 modifierFlags |= PlatformEvent::CtrlKey; |
2223 if (gestureEvent.metaKey()) | 2223 if (gestureEvent.metaKey()) |
2224 modifierFlags |= PlatformEvent::MetaKey; | 2224 modifierFlags |= PlatformEvent::MetaKey; |
2225 if (gestureEvent.shiftKey()) | 2225 if (gestureEvent.shiftKey()) |
2226 modifierFlags |= PlatformEvent::ShiftKey; | 2226 modifierFlags |= PlatformEvent::ShiftKey; |
2227 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); | 2227 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); |
2228 | 2228 |
| 2229 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
| 2230 |
2229 // We use the adjusted position so the application isn't surprised to see a
event with | 2231 // We use the adjusted position so the application isn't surprised to see a
event with |
2230 // co-ordinates outside the target's bounds. | 2232 // co-ordinates outside the target's bounds. |
2231 IntPoint adjustedPoint = m_frame->view()->windowToContents(gestureEvent.posi
tion()); | 2233 IntPoint adjustedPoint = m_frame->view()->windowToContents(gestureEvent.posi
tion()); |
2232 | 2234 |
2233 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because | |
2234 // touch adjustment sometimes returns a different node than what hit testing
would return | |
2235 // for the same point. | |
2236 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 | |
2237 HitTestResult newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitT
estRequest::ReadOnly); | |
2238 | |
2239 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), | 2235 PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(
), |
2240 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 2236 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
2241 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2237 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2242 dispatchMouseEvent(EventTypeNames::mousemove, newHitTest.targetNode(), 0, fa
keMouseMove, true); | 2238 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0,
fakeMouseMove, true); |
2243 | 2239 |
2244 // Do a new hit-test in case the mousemove event changed the DOM. | 2240 // Do a new hit-test in case the mousemove event changed the DOM. |
| 2241 // Note that if the original hit test wasn't over an element (eg. was over a
scrollbar) we |
| 2242 // don't want to re-hit-test because it may be in the wrong frame (and there
's no way the page |
| 2243 // could have seen the event anyway). |
2245 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2244 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
2246 newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestRequest::Re
adOnly); | 2245 if (currentHitTest.innerNode()) |
2247 m_clickNode = newHitTest.targetNode(); | 2246 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestReq
uest::ReadOnly); |
| 2247 m_clickNode = currentHitTest.innerNode(); |
2248 if (m_clickNode && m_clickNode->isTextNode()) | 2248 if (m_clickNode && m_clickNode->isTextNode()) |
2249 m_clickNode = NodeRenderingTraversal::parent(m_clickNode.get()); | 2249 m_clickNode = NodeRenderingTraversal::parent(m_clickNode.get()); |
2250 | 2250 |
2251 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition(
), | 2251 PlatformMouseEvent fakeMouseDown(adjustedPoint, gestureEvent.globalPosition(
), |
2252 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), | 2252 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), |
2253 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2253 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2254 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
newHitTest.targetNode(), gestureEvent.tapCount(), fakeMouseDown, true); | 2254 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown,
currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown, true); |
2255 if (!swallowMouseDownEvent) | 2255 if (!swallowMouseDownEvent) |
2256 swallowMouseDownEvent = handleMouseFocus(fakeMouseDown); | 2256 swallowMouseDownEvent = handleMouseFocus(fakeMouseDown); |
2257 if (!swallowMouseDownEvent) | 2257 if (!swallowMouseDownEvent) |
2258 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, newHitTest)); | 2258 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul
ts(fakeMouseDown, currentHitTest)); |
2259 | 2259 |
2260 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 | 2260 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug.
com/398920 |
2261 newHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestRequest::Re
adOnly); | 2261 if (currentHitTest.innerNode()) |
| 2262 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, HitTestReq
uest::ReadOnly); |
2262 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), | 2263 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), |
2263 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), | 2264 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), |
2264 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); | 2265 modifiers, PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); |
2265 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, newH
itTest.targetNode(), gestureEvent.tapCount(), fakeMouseUp, false); | 2266 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr
entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp, false); |
2266 | 2267 |
2267 bool swallowClickEvent = false; | 2268 bool swallowClickEvent = false; |
2268 if (m_clickNode) { | 2269 if (m_clickNode) { |
2269 if (newHitTest.targetNode()) { | 2270 if (currentHitTest.innerNode()) { |
2270 Node* clickTargetNode = newHitTest.targetNode()->commonAncestor(*m_c
lickNode, parentForClickEvent); | 2271 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(*
m_clickNode, parentForClickEvent); |
2271 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, click
TargetNode, gestureEvent.tapCount(), fakeMouseUp, true); | 2272 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, click
TargetNode, gestureEvent.tapCount(), fakeMouseUp, true); |
2272 } | 2273 } |
2273 m_clickNode = nullptr; | 2274 m_clickNode = nullptr; |
2274 } | 2275 } |
2275 | 2276 |
2276 if (!swallowMouseUpEvent) | 2277 if (!swallowMouseUpEvent) |
2277 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, newHitTest)); | 2278 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul
ts(fakeMouseUp, currentHitTest)); |
2278 | 2279 |
2279 return swallowMouseDownEvent | swallowMouseUpEvent | swallowClickEvent; | 2280 return swallowMouseDownEvent | swallowMouseUpEvent | swallowClickEvent; |
2280 } | 2281 } |
2281 | 2282 |
2282 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) | 2283 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults&
targetedEvent) |
2283 { | 2284 { |
2284 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2285 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2285 IntPoint adjustedPoint = gestureEvent.position(); | 2286 IntPoint adjustedPoint = gestureEvent.position(); |
2286 | 2287 |
2287 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the | 2288 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests
here (re-using the |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 IntSize touchRadius = gestureEvent.area(); | 2587 IntSize touchRadius = gestureEvent.area(); |
2587 touchRadius.scale(1.f / 2); | 2588 touchRadius.scale(1.f / 2); |
2588 // FIXME: We should not do a rect-based hit-test if touch adjustment is disa
bled. | 2589 // FIXME: We should not do a rect-based hit-test if touch adjustment is disa
bled. |
2589 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, touchRadius); | 2590 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H
itTestRequest::ReadOnly, touchRadius); |
2590 | 2591 |
2591 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the | 2592 // Adjust the location of the gesture to the most likely nearby node, as app
ropriate for the |
2592 // type of event. | 2593 // type of event. |
2593 PlatformGestureEvent adjustedEvent = gestureEvent; | 2594 PlatformGestureEvent adjustedEvent = gestureEvent; |
2594 applyTouchAdjustment(&adjustedEvent, &hitTestResult); | 2595 applyTouchAdjustment(&adjustedEvent, &hitTestResult); |
2595 | 2596 |
| 2597 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa
ry because |
| 2598 // rect-based hit testing and touch adjustment sometimes return a different
node than |
| 2599 // what a point-based hit test would return for the same point. |
| 2600 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h
ttp://crbug.com/398914 |
| 2601 if (shouldApplyTouchAdjustment(gestureEvent)) { |
| 2602 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); |
| 2603 if (!hitFrame) |
| 2604 hitFrame = m_frame; |
| 2605 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->windowT
oContents(adjustedEvent.position()), hitType | HitTestRequest::ReadOnly); |
| 2606 } |
| 2607 |
2596 // Now apply hover/active state to the final target. | 2608 // Now apply hover/active state to the final target. |
2597 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't
because we | 2609 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't
because we |
2598 // aren't passing a PlatformMouseEvent. | 2610 // aren't passing a PlatformMouseEvent. |
2599 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); | 2611 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); |
2600 if (!request.readOnly()) | 2612 if (!request.readOnly()) |
2601 m_frame->document()->updateHoverActiveState(request, hitTestResult.inner
Element()); | 2613 m_frame->document()->updateHoverActiveState(request, hitTestResult.inner
Element()); |
2602 | 2614 |
2603 if (shouldKeepActiveForMinInterval) { | 2615 if (shouldKeepActiveForMinInterval) { |
2604 m_lastDeferredTapElement = hitTestResult.innerElement(); | 2616 m_lastDeferredTapElement = hitTestResult.innerElement(); |
2605 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterva
l, FROM_HERE); | 2617 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterva
l, FROM_HERE); |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3860 unsigned EventHandler::accessKeyModifiers() | 3872 unsigned EventHandler::accessKeyModifiers() |
3861 { | 3873 { |
3862 #if OS(MACOSX) | 3874 #if OS(MACOSX) |
3863 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3875 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3864 #else | 3876 #else |
3865 return PlatformEvent::AltKey; | 3877 return PlatformEvent::AltKey; |
3866 #endif | 3878 #endif |
3867 } | 3879 } |
3868 | 3880 |
3869 } // namespace blink | 3881 } // namespace blink |
OLD | NEW |