Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 #include "core/events/MouseEvent.h" | 50 #include "core/events/MouseEvent.h" |
| 51 #include "core/events/TextEvent.h" | 51 #include "core/events/TextEvent.h" |
| 52 #include "core/events/ThreadLocalEventNames.h" | 52 #include "core/events/ThreadLocalEventNames.h" |
| 53 #include "core/events/TouchEvent.h" | 53 #include "core/events/TouchEvent.h" |
| 54 #include "core/events/WheelEvent.h" | 54 #include "core/events/WheelEvent.h" |
| 55 #include "core/fetch/ImageResource.h" | 55 #include "core/fetch/ImageResource.h" |
| 56 #include "core/html/HTMLDialogElement.h" | 56 #include "core/html/HTMLDialogElement.h" |
| 57 #include "core/html/HTMLFrameElementBase.h" | 57 #include "core/html/HTMLFrameElementBase.h" |
| 58 #include "core/html/HTMLFrameSetElement.h" | 58 #include "core/html/HTMLFrameSetElement.h" |
| 59 #include "core/html/HTMLInputElement.h" | 59 #include "core/html/HTMLInputElement.h" |
| 60 #include "core/loader/EmptyClients.h" | |
|
Rick Byers
2014/02/14 21:27:53
why do you need this new include? Seems odd...
| |
| 60 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
| 61 #include "core/loader/FrameLoaderClient.h" | 62 #include "core/loader/FrameLoaderClient.h" |
| 62 #include "core/page/AutoscrollController.h" | 63 #include "core/page/AutoscrollController.h" |
| 63 #include "core/page/BackForwardClient.h" | 64 #include "core/page/BackForwardClient.h" |
| 64 #include "core/page/Chrome.h" | 65 #include "core/page/Chrome.h" |
| 65 #include "core/page/ChromeClient.h" | 66 #include "core/page/ChromeClient.h" |
| 66 #include "core/page/DragController.h" | 67 #include "core/page/DragController.h" |
| 67 #include "core/page/DragState.h" | 68 #include "core/page/DragState.h" |
| 68 #include "core/page/EditorClient.h" | 69 #include "core/page/EditorClient.h" |
| 69 #include "core/page/FocusController.h" | 70 #include "core/page/FocusController.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 , m_originatingTouchPointTargetKey(0) | 292 , m_originatingTouchPointTargetKey(0) |
| 292 , m_touchPressed(false) | 293 , m_touchPressed(false) |
| 293 , m_scrollGestureHandlingNode(0) | 294 , m_scrollGestureHandlingNode(0) |
| 294 , m_lastHitTestResultOverWidget(false) | 295 , m_lastHitTestResultOverWidget(false) |
| 295 , m_maxMouseMovedDuration(0) | 296 , m_maxMouseMovedDuration(0) |
| 296 , m_baseEventType(PlatformEvent::NoType) | 297 , m_baseEventType(PlatformEvent::NoType) |
| 297 , m_didStartDrag(false) | 298 , m_didStartDrag(false) |
| 298 , m_longTapShouldInvokeContextMenu(false) | 299 , m_longTapShouldInvokeContextMenu(false) |
| 299 , m_syntheticPageScaleFactor(0) | 300 , m_syntheticPageScaleFactor(0) |
| 300 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 301 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 301 , m_lastShowPressTimestamp(0) | 302 , m_lastActiveTimestamp(0) |
| 303 , m_tapDownTriggeredActive(false) | |
| 302 { | 304 { |
| 303 } | 305 } |
| 304 | 306 |
| 305 EventHandler::~EventHandler() | 307 EventHandler::~EventHandler() |
| 306 { | 308 { |
| 307 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 309 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
| 308 } | 310 } |
| 309 | 311 |
| 310 DragState& EventHandler::dragState() | 312 DragState& EventHandler::dragState() |
| 311 { | 313 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 m_scrollGestureHandlingNode = 0; | 349 m_scrollGestureHandlingNode = 0; |
| 348 m_lastHitTestResultOverWidget = false; | 350 m_lastHitTestResultOverWidget = false; |
| 349 m_previousGestureScrolledNode = 0; | 351 m_previousGestureScrolledNode = 0; |
| 350 m_scrollbarHandlingScrollGesture = 0; | 352 m_scrollbarHandlingScrollGesture = 0; |
| 351 m_maxMouseMovedDuration = 0; | 353 m_maxMouseMovedDuration = 0; |
| 352 m_baseEventType = PlatformEvent::NoType; | 354 m_baseEventType = PlatformEvent::NoType; |
| 353 m_didStartDrag = false; | 355 m_didStartDrag = false; |
| 354 m_touchPressed = false; | 356 m_touchPressed = false; |
| 355 m_mouseDownMayStartSelect = false; | 357 m_mouseDownMayStartSelect = false; |
| 356 m_mouseDownMayStartDrag = false; | 358 m_mouseDownMayStartDrag = false; |
| 357 m_lastShowPressTimestamp = 0; | 359 m_lastActiveTimestamp = 0; |
| 358 m_lastDeferredTapElement = 0; | 360 m_lastDeferredTapElement = 0; |
| 361 m_tapDownTriggeredActive = false; | |
| 359 } | 362 } |
| 360 | 363 |
| 361 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) | 364 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) |
| 362 { | 365 { |
| 363 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) | 366 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) |
| 364 return; | 367 return; |
| 365 if (nodeToBeRemoved.isInShadowTree()) { | 368 if (nodeToBeRemoved.isInShadowTree()) { |
| 366 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); | 369 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); |
| 367 } else { | 370 } else { |
| 368 // We don't dispatch click events if the mousedown node is removed | 371 // We don't dispatch click events if the mousedown node is removed |
| (...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2215 | 2218 |
| 2216 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2219 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) |
| 2217 wheelEvent->setDefaultHandled(); | 2220 wheelEvent->setDefaultHandled(); |
| 2218 | 2221 |
| 2219 if (!m_latchedWheelEventNode) | 2222 if (!m_latchedWheelEventNode) |
| 2220 m_previousWheelScrolledNode = stopNode; | 2223 m_previousWheelScrolledNode = stopNode; |
| 2221 } | 2224 } |
| 2222 | 2225 |
| 2223 bool EventHandler::handleGestureShowPress() | 2226 bool EventHandler::handleGestureShowPress() |
| 2224 { | 2227 { |
| 2225 m_lastShowPressTimestamp = WTF::currentTime(); | 2228 if (!m_tapDownTriggeredActive) |
| 2229 m_lastActiveTimestamp = WTF::currentTime(); | |
| 2226 | 2230 |
| 2227 FrameView* view = m_frame->view(); | 2231 FrameView* view = m_frame->view(); |
| 2228 if (!view) | 2232 if (!view) |
| 2229 return false; | 2233 return false; |
| 2230 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | 2234 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) |
| 2231 scrollAnimator->cancelAnimations(); | 2235 scrollAnimator->cancelAnimations(); |
| 2232 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 2236 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
| 2233 if (!areas) | 2237 if (!areas) |
| 2234 return false; | 2238 return false; |
| 2235 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { | 2239 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2247 RefPtr<Frame> subframe = 0; | 2251 RefPtr<Frame> subframe = 0; |
| 2248 switch (gestureEvent.type()) { | 2252 switch (gestureEvent.type()) { |
| 2249 case PlatformEvent::GestureScrollBegin: | 2253 case PlatformEvent::GestureScrollBegin: |
| 2250 case PlatformEvent::GestureScrollUpdate: | 2254 case PlatformEvent::GestureScrollUpdate: |
| 2251 case PlatformEvent::GestureScrollUpdateWithoutPropagation: | 2255 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
| 2252 case PlatformEvent::GestureScrollEnd: | 2256 case PlatformEvent::GestureScrollEnd: |
| 2253 case PlatformEvent::GestureFlingStart: | 2257 case PlatformEvent::GestureFlingStart: |
| 2254 // Handle directly in main frame | 2258 // Handle directly in main frame |
| 2255 break; | 2259 break; |
| 2256 | 2260 |
| 2261 case PlatformEvent::GestureTapDown: | |
| 2262 m_tapDownTriggeredActive = false; | |
| 2257 case PlatformEvent::GestureTap: | 2263 case PlatformEvent::GestureTap: |
| 2258 case PlatformEvent::GestureTapUnconfirmed: | 2264 case PlatformEvent::GestureTapUnconfirmed: |
| 2259 case PlatformEvent::GestureTapDown: | |
| 2260 case PlatformEvent::GestureShowPress: | 2265 case PlatformEvent::GestureShowPress: |
| 2261 case PlatformEvent::GestureTapDownCancel: | 2266 case PlatformEvent::GestureTapDownCancel: |
| 2262 case PlatformEvent::GestureTwoFingerTap: | 2267 case PlatformEvent::GestureTwoFingerTap: |
| 2263 case PlatformEvent::GestureLongPress: | 2268 case PlatformEvent::GestureLongPress: |
| 2264 case PlatformEvent::GestureLongTap: | 2269 case PlatformEvent::GestureLongTap: |
| 2265 case PlatformEvent::GesturePinchBegin: | 2270 case PlatformEvent::GesturePinchBegin: |
| 2266 case PlatformEvent::GesturePinchEnd: | 2271 case PlatformEvent::GesturePinchEnd: |
| 2267 case PlatformEvent::GesturePinchUpdate: | 2272 case PlatformEvent::GesturePinchUpdate: |
| 2268 adjustGesturePosition(gestureEvent, adjustedPoint); | 2273 adjustGesturePosition(gestureEvent, adjustedPoint); |
| 2269 subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent); | 2274 subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2281 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate | 2286 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate |
| 2282 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation | 2287 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation |
| 2283 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { | 2288 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { |
| 2284 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2289 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
| 2285 eventTarget = m_scrollGestureHandlingNode.get(); | 2290 eventTarget = m_scrollGestureHandlingNode.get(); |
| 2286 } | 2291 } |
| 2287 | 2292 |
| 2288 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent; | 2293 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent; |
| 2289 double activeInterval = 0; | 2294 double activeInterval = 0; |
| 2290 bool shouldKeepActiveForMinInterval = false; | 2295 bool shouldKeepActiveForMinInterval = false; |
| 2291 if (gestureEvent.type() == PlatformEvent::GestureShowPress | 2296 if (gestureEvent.type() == PlatformEvent::GestureTapDown) { |
| 2292 || gestureEvent.type() == PlatformEvent::GestureTapUnconfirmed) { | 2297 Page* page = m_frame->page(); |
|
bokan
2014/02/18 19:59:57
Nit: I think this is involved enough that you coul
| |
| 2298 Frame* mainFrame = page ? page->mainFrame() : 0; | |
| 2299 FrameView* frameView = mainFrame ? mainFrame->view() : 0; | |
| 2300 ChromeClient& chromeClient = mainFrame ? mainFrame->chromeClient() : *ne w EmptyChromeClient(); | |
|
Rick Byers
2014/02/14 21:27:53
we should probably avoid creating a fake client (j
| |
| 2301 | |
| 2302 // Only activate on TapDown if page isn't scrollable or pinchable and | |
| 2303 // this isn't the start of a scroll. | |
| 2304 if (frameView && !frameView->isScrollable() && chromeClient.minimumPageS caleFactor() == chromeClient.maximumPageScaleFactor()) { | |
| 2305 IntPoint hitTestPoint = m_frame->view()->windowToContents(adjustedPo int); | |
| 2306 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestReq uest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequest::AllowFrameScrollb ars); | |
| 2307 RenderObject* renderer = result.innerElement()->renderer(); | |
| 2308 | |
| 2309 // If no ancestor is scrollable then this couldn't possibly be the s tart of a scroll. | |
| 2310 bool shouldTapDownTriggerActive = true; | |
| 2311 for (RenderLayer* parent = renderer ? renderer->enclosingLayer() : 0 ; parent && shouldTapDownTriggerActive; parent = parent->parent()) { | |
|
bokan
2014/02/18 19:59:57
I think this will break if your renderer is contai
| |
| 2312 if (parent->scrollsOverflow()) | |
| 2313 shouldTapDownTriggerActive = false; | |
|
bokan
2014/02/18 19:59:57
You can 'break' out of the loop here
| |
| 2314 } | |
| 2315 | |
| 2316 if (shouldTapDownTriggerActive) { | |
| 2317 m_tapDownTriggeredActive = true; | |
| 2318 hitType |= HitTestRequest::Active; | |
| 2319 } | |
| 2320 } | |
| 2321 } else if (gestureEvent.type() == PlatformEvent::GestureShowPress && !m_tapD ownTriggeredActive) { | |
| 2322 hitType |= HitTestRequest::Active; | |
| 2323 } else if (gestureEvent.type() == PlatformEvent::GestureTapUnconfirmed) { | |
| 2293 hitType |= HitTestRequest::Active; | 2324 hitType |= HitTestRequest::Active; |
| 2294 } else if (gestureEvent.type() == PlatformEvent::GestureTapDownCancel) { | 2325 } else if (gestureEvent.type() == PlatformEvent::GestureTapDownCancel) { |
| 2295 hitType |= HitTestRequest::Release; | 2326 hitType |= HitTestRequest::Release; |
| 2296 // A TapDownCancel received when no element is active shouldn't really b e changing hover state. | 2327 // A TapDownCancel received when no element is active shouldn't really b e changing hover state. |
| 2297 if (!m_frame->document()->activeHoverElement()) | 2328 if (!m_frame->document()->activeHoverElement()) |
| 2298 hitType |= HitTestRequest::ReadOnly; | 2329 hitType |= HitTestRequest::ReadOnly; |
| 2299 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { | 2330 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { |
| 2300 hitType |= HitTestRequest::Release; | 2331 hitType |= HitTestRequest::Release; |
| 2301 // If the Tap is received very shortly after ShowPress, we want to delay clearing | 2332 // If the Tap is received very shortly after ShowPress, we want to delay clearing |
| 2302 // of the active state so that it's visible to the user for at least one frame. | 2333 // of the active state so that it's visible to the user for at least one frame. |
| 2303 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp; | 2334 activeInterval = WTF::currentTime() - m_lastActiveTimestamp; |
| 2304 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter val < minimumActiveInterval; | 2335 shouldKeepActiveForMinInterval = m_lastActiveTimestamp && activeInterval < minimumActiveInterval; |
| 2305 if (shouldKeepActiveForMinInterval) | 2336 if (shouldKeepActiveForMinInterval) |
| 2306 hitType |= HitTestRequest::ReadOnly; | 2337 hitType |= HitTestRequest::ReadOnly; |
| 2307 } | 2338 } |
| 2308 else | 2339 else |
| 2309 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; | 2340 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; |
| 2310 | 2341 |
| 2311 if ((!scrollbar && !eventTarget) || !(hitType & HitTestRequest::ReadOnly)) { | 2342 if ((!scrollbar && !eventTarget) || !(hitType & HitTestRequest::ReadOnly)) { |
| 2312 IntPoint hitTestPoint = m_frame->view()->windowToContents(adjustedPoint) ; | 2343 IntPoint hitTestPoint = m_frame->view()->windowToContents(adjustedPoint) ; |
| 2313 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType | HitT estRequest::AllowFrameScrollbars); | 2344 HitTestResult result = hitTestResultAtPoint(hitTestPoint, hitType | HitT estRequest::AllowFrameScrollbars); |
| 2314 | 2345 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2371 return handleGestureTap(gestureEvent, adjustedPoint); | 2402 return handleGestureTap(gestureEvent, adjustedPoint); |
| 2372 case PlatformEvent::GestureShowPress: | 2403 case PlatformEvent::GestureShowPress: |
| 2373 return handleGestureShowPress(); | 2404 return handleGestureShowPress(); |
| 2374 case PlatformEvent::GestureLongPress: | 2405 case PlatformEvent::GestureLongPress: |
| 2375 return handleGestureLongPress(gestureEvent, adjustedPoint); | 2406 return handleGestureLongPress(gestureEvent, adjustedPoint); |
| 2376 case PlatformEvent::GestureLongTap: | 2407 case PlatformEvent::GestureLongTap: |
| 2377 return handleGestureLongTap(gestureEvent, adjustedPoint); | 2408 return handleGestureLongTap(gestureEvent, adjustedPoint); |
| 2378 case PlatformEvent::GestureTwoFingerTap: | 2409 case PlatformEvent::GestureTwoFingerTap: |
| 2379 return handleGestureTwoFingerTap(gestureEvent, adjustedPoint); | 2410 return handleGestureTwoFingerTap(gestureEvent, adjustedPoint); |
| 2380 case PlatformEvent::GestureTapDown: | 2411 case PlatformEvent::GestureTapDown: |
| 2412 if (m_tapDownTriggeredActive) | |
| 2413 m_lastActiveTimestamp = WTF::currentTime(); | |
| 2381 case PlatformEvent::GesturePinchBegin: | 2414 case PlatformEvent::GesturePinchBegin: |
| 2382 case PlatformEvent::GesturePinchEnd: | 2415 case PlatformEvent::GesturePinchEnd: |
| 2383 case PlatformEvent::GesturePinchUpdate: | 2416 case PlatformEvent::GesturePinchUpdate: |
| 2384 case PlatformEvent::GestureTapDownCancel: | 2417 case PlatformEvent::GestureTapDownCancel: |
| 2385 case PlatformEvent::GestureTapUnconfirmed: | 2418 case PlatformEvent::GestureTapUnconfirmed: |
| 2386 case PlatformEvent::GestureFlingStart: | 2419 case PlatformEvent::GestureFlingStart: |
| 2387 break; | 2420 break; |
| 2388 default: | 2421 default: |
| 2389 ASSERT_NOT_REACHED(); | 2422 ASSERT_NOT_REACHED(); |
| 2390 } | 2423 } |
| (...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4014 unsigned EventHandler::accessKeyModifiers() | 4047 unsigned EventHandler::accessKeyModifiers() |
| 4015 { | 4048 { |
| 4016 #if OS(MACOSX) | 4049 #if OS(MACOSX) |
| 4017 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4050 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4018 #else | 4051 #else |
| 4019 return PlatformEvent::AltKey; | 4052 return PlatformEvent::AltKey; |
| 4020 #endif | 4053 #endif |
| 4021 } | 4054 } |
| 4022 | 4055 |
| 4023 } // namespace WebCore | 4056 } // namespace WebCore |
| OLD | NEW |