Chromium Code Reviews| 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/PointerEventManager.h" | 5 #include "core/input/PointerEventManager.h" |
| 6 | 6 |
| 7 #include "core/dom/shadow/FlatTreeTraversal.h" | 7 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 8 #include "core/events/MouseEvent.h" | 8 #include "core/events/MouseEvent.h" |
| 9 #include "core/input/EventHandler.h" | 9 #include "core/input/EventHandler.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 inline size_t toPointerTypeIndex(WebPointerProperties::PointerType t) { return s tatic_cast<size_t>(t); } | |
|
dtapuska
2016/04/08 17:50:29
I'd remove the inline. The compiler will handle th
Navid Zolghadr
2016/04/08 18:57:00
Done.
| |
| 16 | |
| 15 const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint::Touch State state) | 17 const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint::Touch State state) |
| 16 { | 18 { |
| 17 switch (state) { | 19 switch (state) { |
| 18 case PlatformTouchPoint::TouchReleased: | 20 case PlatformTouchPoint::TouchReleased: |
| 19 return EventTypeNames::pointerup; | 21 return EventTypeNames::pointerup; |
| 20 case PlatformTouchPoint::TouchCancelled: | 22 case PlatformTouchPoint::TouchCancelled: |
| 21 return EventTypeNames::pointercancel; | 23 return EventTypeNames::pointercancel; |
| 22 case PlatformTouchPoint::TouchPressed: | 24 case PlatformTouchPoint::TouchPressed: |
| 23 return EventTypeNames::pointerdown; | 25 return EventTypeNames::pointerdown; |
| 24 case PlatformTouchPoint::TouchMoved: | 26 case PlatformTouchPoint::TouchMoved: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // Pointer event type does not matter as it will be overridden in the sendNo deTransitionEvents | 110 // Pointer event type does not matter as it will be overridden in the sendNo deTransitionEvents |
| 109 PointerEvent* pointerEvent = | 111 PointerEvent* pointerEvent = |
| 110 m_pointerEventFactory.create(EventTypeNames::mouseout, mouseEvent, | 112 m_pointerEventFactory.create(EventTypeNames::mouseout, mouseEvent, |
| 111 nullptr, view); | 113 nullptr, view); |
| 112 | 114 |
| 113 // TODO(crbug/545647): This state should reset with pointercancel too. | 115 // TODO(crbug/545647): This state should reset with pointercancel too. |
| 114 // This function also gets called for compat mouse events of touch at this | 116 // This function also gets called for compat mouse events of touch at this |
| 115 // stage. So if the event is not frame boundary transition it is only a | 117 // stage. So if the event is not frame boundary transition it is only a |
| 116 // compatibility mouse event and we do not need to change pointer event | 118 // compatibility mouse event and we do not need to change pointer event |
| 117 // behavior regarding preventMouseEvent state in that case. | 119 // behavior regarding preventMouseEvent state in that case. |
| 118 if (isFrameBoundaryTransition && pointerEvent->buttons() == 0) { | 120 if (isFrameBoundaryTransition && pointerEvent->buttons() == 0 |
| 119 m_preventMouseEventForPointerTypeMouse = false; | 121 && pointerEvent->isPrimary()) { |
| 122 m_preventMouseEventForPointerType[toPointerTypeIndex( | |
| 123 mouseEvent.pointerProperties().pointerType)] = false; | |
| 120 } | 124 } |
| 121 | 125 |
| 122 processCaptureAndPositionOfPointerEvent(pointerEvent, enteredNode, | 126 processCaptureAndPositionOfPointerEvent(pointerEvent, enteredNode, |
| 123 exitedNode, mouseEvent, true, isFrameBoundaryTransition); | 127 exitedNode, mouseEvent, true, isFrameBoundaryTransition); |
| 124 } | 128 } |
| 125 | 129 |
| 126 void PointerEventManager::sendNodeTransitionEvents( | 130 void PointerEventManager::sendNodeTransitionEvents( |
| 127 EventTarget* exitedTarget, | 131 EventTarget* exitedTarget, |
| 128 EventTarget* enteredTarget, | 132 EventTarget* enteredTarget, |
| 129 PointerEvent* pointerEvent, | 133 PointerEvent* pointerEvent, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 Node* relatedTarget, | 352 Node* relatedTarget, |
| 349 AbstractView* view, | 353 AbstractView* view, |
| 350 Node* lastNodeUnderMouse) | 354 Node* lastNodeUnderMouse) |
| 351 { | 355 { |
| 352 PointerEvent* pointerEvent = | 356 PointerEvent* pointerEvent = |
| 353 m_pointerEventFactory.create(mouseEventType, mouseEvent, | 357 m_pointerEventFactory.create(mouseEventType, mouseEvent, |
| 354 relatedTarget, view); | 358 relatedTarget, view); |
| 355 | 359 |
| 356 // This is for when the mouse is released outside of the page. | 360 // This is for when the mouse is released outside of the page. |
| 357 if (pointerEvent->type() == EventTypeNames::pointermove | 361 if (pointerEvent->type() == EventTypeNames::pointermove |
| 358 && !pointerEvent->buttons()) { | 362 && !pointerEvent->buttons() |
| 359 m_preventMouseEventForPointerTypeMouse = false; | 363 && pointerEvent->isPrimary()) { |
| 364 m_preventMouseEventForPointerType[toPointerTypeIndex( | |
| 365 mouseEvent.pointerProperties().pointerType)] = false; | |
| 360 } | 366 } |
| 361 | 367 |
| 362 processCaptureAndPositionOfPointerEvent(pointerEvent, target, | 368 processCaptureAndPositionOfPointerEvent(pointerEvent, target, |
| 363 lastNodeUnderMouse, mouseEvent, true, true); | 369 lastNodeUnderMouse, mouseEvent, true, true); |
| 364 | 370 |
| 365 EventTarget* effectiveTarget = | 371 EventTarget* effectiveTarget = |
| 366 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()); | 372 getEffectiveTargetForPointerEvent(target, pointerEvent->pointerId()); |
| 367 | 373 |
| 368 WebInputEventResult result = | 374 WebInputEventResult result = |
| 369 dispatchPointerEvent(effectiveTarget, pointerEvent); | 375 dispatchPointerEvent(effectiveTarget, pointerEvent); |
| 370 | 376 |
| 371 if (result != WebInputEventResult::NotHandled | 377 if (result != WebInputEventResult::NotHandled |
| 372 && pointerEvent->type() == EventTypeNames::pointerdown) | 378 && pointerEvent->type() == EventTypeNames::pointerdown |
| 373 m_preventMouseEventForPointerTypeMouse = true; | 379 && pointerEvent->isPrimary()) { |
| 380 m_preventMouseEventForPointerType[toPointerTypeIndex( | |
| 381 mouseEvent.pointerProperties().pointerType)] = true; | |
| 382 } | |
| 374 | 383 |
| 375 if (!m_preventMouseEventForPointerTypeMouse) { | 384 if (pointerEvent->isPrimary() && !m_preventMouseEventForPointerType[toPointe rTypeIndex( |
| 385 mouseEvent.pointerProperties().pointerType)]) { | |
| 376 result = EventHandler::mergeEventResult(result, | 386 result = EventHandler::mergeEventResult(result, |
| 377 dispatchMouseEvent(effectiveTarget, mouseEventType, mouseEvent, | 387 dispatchMouseEvent(effectiveTarget, mouseEventType, mouseEvent, |
| 378 nullptr, clickCount)); | 388 nullptr, clickCount)); |
| 379 } | 389 } |
| 380 | 390 |
| 381 if (pointerEvent->buttons() == 0) { | 391 if (pointerEvent->buttons() == 0) { |
| 382 releasePointerCapture(pointerEvent->pointerId()); | 392 releasePointerCapture(pointerEvent->pointerId()); |
| 383 m_preventMouseEventForPointerTypeMouse = false; | 393 if (pointerEvent->isPrimary()) { |
| 394 m_preventMouseEventForPointerType[toPointerTypeIndex( | |
| 395 mouseEvent.pointerProperties().pointerType)] = false; | |
| 396 } | |
| 384 } | 397 } |
| 385 | 398 |
| 386 return result; | 399 return result; |
| 387 } | 400 } |
| 388 | 401 |
| 389 PointerEventManager::PointerEventManager() | 402 PointerEventManager::PointerEventManager() |
| 390 { | 403 { |
| 391 clear(); | 404 clear(); |
| 392 } | 405 } |
| 393 | 406 |
| 394 PointerEventManager::~PointerEventManager() | 407 PointerEventManager::~PointerEventManager() |
| 395 { | 408 { |
| 396 } | 409 } |
| 397 | 410 |
| 398 void PointerEventManager::clear() | 411 void PointerEventManager::clear() |
| 399 { | 412 { |
| 400 m_preventMouseEventForPointerTypeMouse = false; | 413 for (auto& entry : m_preventMouseEventForPointerType) |
| 414 entry = false; | |
| 401 m_pointerEventFactory.clear(); | 415 m_pointerEventFactory.clear(); |
| 402 m_nodeUnderPointer.clear(); | 416 m_nodeUnderPointer.clear(); |
| 403 m_pointerCaptureTarget.clear(); | 417 m_pointerCaptureTarget.clear(); |
| 404 m_pendingPointerCaptureTarget.clear(); | 418 m_pendingPointerCaptureTarget.clear(); |
| 405 } | 419 } |
| 406 | 420 |
| 407 void PointerEventManager::processCaptureAndPositionOfPointerEvent( | 421 void PointerEventManager::processCaptureAndPositionOfPointerEvent( |
| 408 PointerEvent* pointerEvent, | 422 PointerEvent* pointerEvent, |
| 409 EventTarget* hitTestTarget, | 423 EventTarget* hitTestTarget, |
| 410 EventTarget* lastNodeUnderMouse, | 424 EventTarget* lastNodeUnderMouse, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 | 584 |
| 571 DEFINE_TRACE(PointerEventManager) | 585 DEFINE_TRACE(PointerEventManager) |
| 572 { | 586 { |
| 573 visitor->trace(m_nodeUnderPointer); | 587 visitor->trace(m_nodeUnderPointer); |
| 574 visitor->trace(m_pointerCaptureTarget); | 588 visitor->trace(m_pointerCaptureTarget); |
| 575 visitor->trace(m_pendingPointerCaptureTarget); | 589 visitor->trace(m_pendingPointerCaptureTarget); |
| 576 } | 590 } |
| 577 | 591 |
| 578 | 592 |
| 579 } // namespace blink | 593 } // namespace blink |
| OLD | NEW |