| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 m_nodeUnderMouse = nullptr; | 192 m_nodeUnderMouse = nullptr; |
| 193 m_lastNodeUnderMouse = nullptr; | 193 m_lastNodeUnderMouse = nullptr; |
| 194 m_lastScrollbarUnderMouse = nullptr; | 194 m_lastScrollbarUnderMouse = nullptr; |
| 195 m_clickCount = 0; | 195 m_clickCount = 0; |
| 196 m_clickNode = nullptr; | 196 m_clickNode = nullptr; |
| 197 m_dragTarget = nullptr; | 197 m_dragTarget = nullptr; |
| 198 m_shouldOnlyFireDragOverEvent = false; | 198 m_shouldOnlyFireDragOverEvent = false; |
| 199 m_mousePositionIsUnknown = true; | 199 m_mousePositionIsUnknown = true; |
| 200 m_lastKnownMousePosition = IntPoint(); | 200 m_lastKnownMousePosition = IntPoint(); |
| 201 m_lastKnownMouseGlobalPosition = IntPoint(); | 201 m_lastKnownMouseGlobalPosition = IntPoint(); |
| 202 m_lastMouseDownUserGestureToken.clear(); | |
| 203 m_mousePressNode = nullptr; | 202 m_mousePressNode = nullptr; |
| 204 m_mousePressed = false; | 203 m_mousePressed = false; |
| 205 m_capturesDragging = false; | 204 m_capturesDragging = false; |
| 206 m_capturingMouseEventsNode = nullptr; | 205 m_capturingMouseEventsNode = nullptr; |
| 207 m_latchedWheelEventNode = nullptr; | 206 m_latchedWheelEventNode = nullptr; |
| 208 m_previousWheelScrolledNode = nullptr; | 207 m_previousWheelScrolledNode = nullptr; |
| 209 m_targetForTouchID.clear(); | 208 m_targetForTouchID.clear(); |
| 210 m_touchSequenceDocument.clear(); | 209 m_touchSequenceDocument.clear(); |
| 211 m_touchSequenceUserGestureToken.clear(); | |
| 212 m_scrollGestureHandlingNode = nullptr; | 210 m_scrollGestureHandlingNode = nullptr; |
| 213 m_lastGestureScrollOverWidget = false; | 211 m_lastGestureScrollOverWidget = false; |
| 214 m_previousGestureScrolledNode = nullptr; | 212 m_previousGestureScrolledNode = nullptr; |
| 215 m_scrollbarHandlingScrollGesture = nullptr; | 213 m_scrollbarHandlingScrollGesture = nullptr; |
| 216 m_maxMouseMovedDuration = 0; | 214 m_maxMouseMovedDuration = 0; |
| 217 m_didStartDrag = false; | 215 m_didStartDrag = false; |
| 218 m_touchPressed = false; | 216 m_touchPressed = false; |
| 219 m_mouseDownMayStartSelect = false; | 217 m_mouseDownMayStartSelect = false; |
| 220 m_mouseDownMayStartDrag = false; | 218 m_mouseDownMayStartDrag = false; |
| 221 m_lastShowPressTimestamp = 0; | 219 m_lastShowPressTimestamp = 0; |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 // FIXME(sky): remove | 986 // FIXME(sky): remove |
| 989 return windowPoint; | 987 return windowPoint; |
| 990 } | 988 } |
| 991 | 989 |
| 992 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) | 990 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) |
| 993 { | 991 { |
| 994 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 992 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 995 | 993 |
| 996 RefPtr<FrameView> protector(m_frame->view()); | 994 RefPtr<FrameView> protector(m_frame->view()); |
| 997 | 995 |
| 998 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | |
| 999 m_frame->eventHandler().m_lastMouseDownUserGestureToken = gestureIndicator.c
urrentToken(); | |
| 1000 | |
| 1001 cancelFakeMouseMoveEvent(); | 996 cancelFakeMouseMoveEvent(); |
| 1002 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 997 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 1003 m_capturingMouseEventsNode = nullptr; | 998 m_capturingMouseEventsNode = nullptr; |
| 1004 m_mousePressed = true; | 999 m_mousePressed = true; |
| 1005 m_capturesDragging = true; | 1000 m_capturesDragging = true; |
| 1006 setLastKnownMousePosition(mouseEvent); | 1001 setLastKnownMousePosition(mouseEvent); |
| 1007 m_mouseDownTimestamp = mouseEvent.timestamp(); | 1002 m_mouseDownTimestamp = mouseEvent.timestamp(); |
| 1008 m_mouseDownMayStartDrag = false; | 1003 m_mouseDownMayStartDrag = false; |
| 1009 m_mouseDownMayStartSelect = false; | 1004 m_mouseDownMayStartSelect = false; |
| 1010 m_mouseDownMayStartAutoscroll = false; | 1005 m_mouseDownMayStartAutoscroll = false; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 } | 1193 } |
| 1199 | 1194 |
| 1200 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) | 1195 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) |
| 1201 { | 1196 { |
| 1202 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); | 1197 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); |
| 1203 | 1198 |
| 1204 RefPtr<FrameView> protector(m_frame->view()); | 1199 RefPtr<FrameView> protector(m_frame->view()); |
| 1205 | 1200 |
| 1206 m_frame->selection().setCaretBlinkingSuspended(false); | 1201 m_frame->selection().setCaretBlinkingSuspended(false); |
| 1207 | 1202 |
| 1208 OwnPtr<UserGestureIndicator> gestureIndicator; | |
| 1209 | |
| 1210 if (m_frame->eventHandler().m_lastMouseDownUserGestureToken) | |
| 1211 gestureIndicator = adoptPtr(new UserGestureIndicator(m_frame->eventHandl
er().m_lastMouseDownUserGestureToken.release())); | |
| 1212 else | |
| 1213 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); | |
| 1214 | |
| 1215 m_mousePressed = false; | 1203 m_mousePressed = false; |
| 1216 setLastKnownMousePosition(mouseEvent); | 1204 setLastKnownMousePosition(mouseEvent); |
| 1217 | 1205 |
| 1218 if (m_lastScrollbarUnderMouse) { | 1206 if (m_lastScrollbarUnderMouse) { |
| 1219 invalidateClick(); | 1207 invalidateClick(); |
| 1220 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); | 1208 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); |
| 1221 bool setUnder = false; | 1209 bool setUnder = false; |
| 1222 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), m_clickCount, mouseEvent, setUnder); | 1210 return !dispatchMouseEvent(EventTypeNames::mouseup, m_lastNodeUnderMouse
.get(), m_clickCount, mouseEvent, setUnder); |
| 1223 } | 1211 } |
| 1224 | 1212 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 ASSERT_NOT_REACHED(); | 1628 ASSERT_NOT_REACHED(); |
| 1641 return false; | 1629 return false; |
| 1642 } | 1630 } |
| 1643 } | 1631 } |
| 1644 | 1632 |
| 1645 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
edEvent) | 1633 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
edEvent) |
| 1646 { | 1634 { |
| 1647 RefPtr<FrameView> protector(m_frame->view()); | 1635 RefPtr<FrameView> protector(m_frame->view()); |
| 1648 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 1636 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
| 1649 | 1637 |
| 1650 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | |
| 1651 | |
| 1652 unsigned modifierFlags = 0; | 1638 unsigned modifierFlags = 0; |
| 1653 if (gestureEvent.altKey()) | 1639 if (gestureEvent.altKey()) |
| 1654 modifierFlags |= PlatformEvent::AltKey; | 1640 modifierFlags |= PlatformEvent::AltKey; |
| 1655 if (gestureEvent.ctrlKey()) | 1641 if (gestureEvent.ctrlKey()) |
| 1656 modifierFlags |= PlatformEvent::CtrlKey; | 1642 modifierFlags |= PlatformEvent::CtrlKey; |
| 1657 if (gestureEvent.metaKey()) | 1643 if (gestureEvent.metaKey()) |
| 1658 modifierFlags |= PlatformEvent::MetaKey; | 1644 modifierFlags |= PlatformEvent::MetaKey; |
| 1659 if (gestureEvent.shiftKey()) | 1645 if (gestureEvent.shiftKey()) |
| 1660 modifierFlags |= PlatformEvent::ShiftKey; | 1646 modifierFlags |= PlatformEvent::ShiftKey; |
| 1661 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); | 1647 PlatformEvent::Modifiers modifiers = static_cast<PlatformEvent::Modifiers>(m
odifierFlags); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 | 2055 |
| 2070 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 2056 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
| 2071 capsLockStateMayHaveChanged(); | 2057 capsLockStateMayHaveChanged(); |
| 2072 | 2058 |
| 2073 // Check for cases where we are too early for events -- possible unmatched k
ey up | 2059 // Check for cases where we are too early for events -- possible unmatched k
ey up |
| 2074 // from pressing return in the location bar. | 2060 // from pressing return in the location bar. |
| 2075 RefPtr<Node> node = eventTargetNodeForDocument(m_frame->document()); | 2061 RefPtr<Node> node = eventTargetNodeForDocument(m_frame->document()); |
| 2076 if (!node) | 2062 if (!node) |
| 2077 return false; | 2063 return false; |
| 2078 | 2064 |
| 2079 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | |
| 2080 | |
| 2081 // FIXME: it would be fair to let an input method handle KeyUp events before
DOM dispatch. | 2065 // FIXME: it would be fair to let an input method handle KeyUp events before
DOM dispatch. |
| 2082 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type()
== PlatformEvent::Char) | 2066 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type()
== PlatformEvent::Char) |
| 2083 return !node->dispatchKeyEvent(initialKeyEvent); | 2067 return !node->dispatchKeyEvent(initialKeyEvent); |
| 2084 | 2068 |
| 2085 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; | 2069 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; |
| 2086 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) | 2070 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) |
| 2087 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); | 2071 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); |
| 2088 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame-
>document()->domWindow()); | 2072 RefPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEvent, m_frame-
>document()->domWindow()); |
| 2089 | 2073 |
| 2090 keydown->setTarget(node); | 2074 keydown->setTarget(node); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2272 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) | 2256 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) |
| 2273 allTouchReleased = false; | 2257 allTouchReleased = false; |
| 2274 } | 2258 } |
| 2275 if (freshTouchEvents) { | 2259 if (freshTouchEvents) { |
| 2276 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should | 2260 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should |
| 2277 // have cleared the active document when we saw the last release. But we | 2261 // have cleared the active document when we saw the last release. But we |
| 2278 // have some tests that violate this, ClusterFuzz could trigger it, and | 2262 // have some tests that violate this, ClusterFuzz could trigger it, and |
| 2279 // there may be cases where the browser doesn't reliably release all | 2263 // there may be cases where the browser doesn't reliably release all |
| 2280 // touches. http://crbug.com/345372 tracks this. | 2264 // touches. http://crbug.com/345372 tracks this. |
| 2281 m_touchSequenceDocument.clear(); | 2265 m_touchSequenceDocument.clear(); |
| 2282 m_touchSequenceUserGestureToken.clear(); | |
| 2283 } | 2266 } |
| 2284 | 2267 |
| 2285 OwnPtr<UserGestureIndicator> gestureIndicator; | |
| 2286 | |
| 2287 if (m_touchSequenceUserGestureToken) | |
| 2288 gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUser
GestureToken.release())); | |
| 2289 else | |
| 2290 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); | |
| 2291 | |
| 2292 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); | |
| 2293 | |
| 2294 ASSERT(m_frame->view()); | 2268 ASSERT(m_frame->view()); |
| 2295 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { | 2269 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { |
| 2296 // If the active touch document has no frame or view, it's probably bein
g destroyed | 2270 // If the active touch document has no frame or view, it's probably bein
g destroyed |
| 2297 // so we can't dispatch events. | 2271 // so we can't dispatch events. |
| 2298 return false; | 2272 return false; |
| 2299 } | 2273 } |
| 2300 | 2274 |
| 2301 // First do hit tests for any new touch points. | 2275 // First do hit tests for any new touch points. |
| 2302 for (i = 0; i < points.size(); ++i) { | 2276 for (i = 0; i < points.size(); ++i) { |
| 2303 const PlatformTouchPoint& point = points[i]; | 2277 const PlatformTouchPoint& point = points[i]; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2345 if (effectiveTouchAction != TouchActionAuto) | 2319 if (effectiveTouchAction != TouchActionAuto) |
| 2346 m_frame->page()->chrome().client().setTouchAction(effectiveTouch
Action); | 2320 m_frame->page()->chrome().client().setTouchAction(effectiveTouch
Action); |
| 2347 } | 2321 } |
| 2348 } | 2322 } |
| 2349 | 2323 |
| 2350 m_touchPressed = !allTouchReleased; | 2324 m_touchPressed = !allTouchReleased; |
| 2351 | 2325 |
| 2352 // If there's no document receiving touch events, then we can skip all the | 2326 // If there's no document receiving touch events, then we can skip all the |
| 2353 // rest of this work. | 2327 // rest of this work. |
| 2354 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frame()) { | 2328 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frame()) { |
| 2355 if (allTouchReleased) { | 2329 if (allTouchReleased) |
| 2356 m_touchSequenceDocument.clear(); | 2330 m_touchSequenceDocument.clear(); |
| 2357 m_touchSequenceUserGestureToken.clear(); | |
| 2358 } | |
| 2359 return false; | 2331 return false; |
| 2360 } | 2332 } |
| 2361 | 2333 |
| 2362 // Build up the lists to use for the 'touches', 'targetTouches' and | 2334 // Build up the lists to use for the 'touches', 'targetTouches' and |
| 2363 // 'changedTouches' attributes in the JS event. See | 2335 // 'changedTouches' attributes in the JS event. See |
| 2364 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 2336 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 2365 // lists fit together. | 2337 // lists fit together. |
| 2366 | 2338 |
| 2367 // Holds the complete set of touches on the screen. | 2339 // Holds the complete set of touches on the screen. |
| 2368 RefPtr<TouchList> touches = TouchList::create(); | 2340 RefPtr<TouchList> touches = TouchList::create(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609 | 2427 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609 |
| 2456 // for further discussion about the TouchStationary state. | 2428 // for further discussion about the TouchStationary state. |
| 2457 if (pointState != PlatformTouchPoint::TouchStationary && knownTarget) { | 2429 if (pointState != PlatformTouchPoint::TouchStationary && knownTarget) { |
| 2458 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); | 2430 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); |
| 2459 if (!changedTouches[pointState].m_touches) | 2431 if (!changedTouches[pointState].m_touches) |
| 2460 changedTouches[pointState].m_touches = TouchList::create(); | 2432 changedTouches[pointState].m_touches = TouchList::create(); |
| 2461 changedTouches[pointState].m_touches->append(touch); | 2433 changedTouches[pointState].m_touches->append(touch); |
| 2462 changedTouches[pointState].m_targets.add(touchTarget); | 2434 changedTouches[pointState].m_targets.add(touchTarget); |
| 2463 } | 2435 } |
| 2464 } | 2436 } |
| 2465 if (allTouchReleased) { | 2437 if (allTouchReleased) |
| 2466 m_touchSequenceDocument.clear(); | 2438 m_touchSequenceDocument.clear(); |
| 2467 m_touchSequenceUserGestureToken.clear(); | |
| 2468 } | |
| 2469 | 2439 |
| 2470 // Now iterate the changedTouches list and m_targets within it, sending | 2440 // Now iterate the changedTouches list and m_targets within it, sending |
| 2471 // events to the targets as required. | 2441 // events to the targets as required. |
| 2472 bool swallowedEvent = false; | 2442 bool swallowedEvent = false; |
| 2473 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { | 2443 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { |
| 2474 if (!changedTouches[state].m_touches) | 2444 if (!changedTouches[state].m_touches) |
| 2475 continue; | 2445 continue; |
| 2476 | 2446 |
| 2477 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); | 2447 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); |
| 2478 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 2448 const EventTargetSet& targetsForState = changedTouches[state].m_targets; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 | 2526 |
| 2557 void EventHandler::focusDocumentView() | 2527 void EventHandler::focusDocumentView() |
| 2558 { | 2528 { |
| 2559 Page* page = m_frame->page(); | 2529 Page* page = m_frame->page(); |
| 2560 if (!page) | 2530 if (!page) |
| 2561 return; | 2531 return; |
| 2562 page->focusController().focusDocumentView(m_frame); | 2532 page->focusController().focusDocumentView(m_frame); |
| 2563 } | 2533 } |
| 2564 | 2534 |
| 2565 } // namespace blink | 2535 } // namespace blink |
| OLD | NEW |