OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/input/GestureManager.h" | 5 #include "core/input/GestureManager.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/DocumentUserGestureToken.h" | 8 #include "core/dom/DocumentUserGestureToken.h" |
9 #include "core/editing/SelectionController.h" | 9 #include "core/editing/SelectionController.h" |
10 #include "core/events/GestureEvent.h" | 10 #include "core/events/GestureEvent.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 bool hitTestContainsLinks = hitTestResult.URLElement() || | 311 bool hitTestContainsLinks = hitTestResult.URLElement() || |
312 !hitTestResult.absoluteImageURL().isNull() || | 312 !hitTestResult.absoluteImageURL().isNull() || |
313 !hitTestResult.absoluteMediaURL().isNull(); | 313 !hitTestResult.absoluteMediaURL().isNull(); |
314 | 314 |
315 if (!hitTestContainsLinks && | 315 if (!hitTestContainsLinks && |
316 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) { | 316 m_mouseEventManager->handleDragDropIfPossible(targetedEvent)) { |
317 m_longTapShouldInvokeContextMenu = true; | 317 m_longTapShouldInvokeContextMenu = true; |
318 return WebInputEventResult::HandledSystem; | 318 return WebInputEventResult::HandledSystem; |
319 } | 319 } |
320 | 320 |
321 if (m_selectionController->handleGestureLongPress(gestureEvent, | 321 Node* innerNode = hitTestResult.innerNode(); |
| 322 if (innerNode && innerNode->layoutObject() && |
| 323 m_selectionController->handleGestureLongPress(gestureEvent, |
322 hitTestResult)) { | 324 hitTestResult)) { |
323 m_mouseEventManager->focusDocumentView(); | 325 m_mouseEventManager->focusDocumentView(); |
324 return WebInputEventResult::HandledSystem; | 326 return WebInputEventResult::HandledSystem; |
325 } | 327 } |
326 | 328 |
327 return sendContextMenuEventForGesture(targetedEvent); | 329 return sendContextMenuEventForGesture(targetedEvent); |
328 } | 330 } |
329 | 331 |
330 WebInputEventResult GestureManager::handleGestureLongTap( | 332 WebInputEventResult GestureManager::handleGestureLongTap( |
331 const GestureEventWithHitTestResults& targetedEvent) { | 333 const GestureEventWithHitTestResults& targetedEvent) { |
332 #if !OS(ANDROID) | 334 #if !OS(ANDROID) |
333 if (m_longTapShouldInvokeContextMenu) { | 335 if (m_longTapShouldInvokeContextMenu) { |
334 m_longTapShouldInvokeContextMenu = false; | 336 m_longTapShouldInvokeContextMenu = false; |
335 m_selectionController->handleGestureLongTap(targetedEvent); | 337 Node* innerNode = targetedEvent.hitTestResult().innerNode(); |
| 338 if (innerNode && innerNode->layoutObject()) |
| 339 m_selectionController->handleGestureLongTap(targetedEvent); |
336 return sendContextMenuEventForGesture(targetedEvent); | 340 return sendContextMenuEventForGesture(targetedEvent); |
337 } | 341 } |
338 #endif | 342 #endif |
339 return WebInputEventResult::NotHandled; | 343 return WebInputEventResult::NotHandled; |
340 } | 344 } |
341 | 345 |
342 WebInputEventResult GestureManager::handleGestureTwoFingerTap( | 346 WebInputEventResult GestureManager::handleGestureTwoFingerTap( |
343 const GestureEventWithHitTestResults& targetedEvent) { | 347 const GestureEventWithHitTestResults& targetedEvent) { |
344 m_selectionController->handleGestureTwoFingerTap(targetedEvent); | 348 Node* innerNode = targetedEvent.hitTestResult().innerNode(); |
| 349 if (innerNode && innerNode->layoutObject()) |
| 350 m_selectionController->handleGestureTwoFingerTap(targetedEvent); |
345 return sendContextMenuEventForGesture(targetedEvent); | 351 return sendContextMenuEventForGesture(targetedEvent); |
346 } | 352 } |
347 | 353 |
348 WebInputEventResult GestureManager::sendContextMenuEventForGesture( | 354 WebInputEventResult GestureManager::sendContextMenuEventForGesture( |
349 const GestureEventWithHitTestResults& targetedEvent) { | 355 const GestureEventWithHitTestResults& targetedEvent) { |
350 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 356 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
351 unsigned modifiers = gestureEvent.getModifiers(); | 357 unsigned modifiers = gestureEvent.getModifiers(); |
352 | 358 |
353 if (!m_suppressMouseEventsFromGestures) { | 359 if (!m_suppressMouseEventsFromGestures) { |
354 // Send MouseMoved event prior to handling (https://crbug.com/485290). | 360 // Send MouseMoved event prior to handling (https://crbug.com/485290). |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 return nullptr; | 408 return nullptr; |
403 | 409 |
404 return &m_frame->page()->frameHost(); | 410 return &m_frame->page()->frameHost(); |
405 } | 411 } |
406 | 412 |
407 double GestureManager::getLastShowPressTimestamp() const { | 413 double GestureManager::getLastShowPressTimestamp() const { |
408 return m_lastShowPressTimestamp; | 414 return m_lastShowPressTimestamp; |
409 } | 415 } |
410 | 416 |
411 } // namespace blink | 417 } // namespace blink |
OLD | NEW |