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/DocumentUserGestureToken.h" | 7 #include "core/dom/DocumentUserGestureToken.h" |
8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
9 #include "core/dom/shadow/FlatTreeTraversal.h" | 9 #include "core/dom/shadow/FlatTreeTraversal.h" |
10 #include "core/events/MouseEvent.h" | 10 #include "core/events/MouseEvent.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "public/platform/WebTouchEvent.h" | 22 #include "public/platform/WebTouchEvent.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { | 28 size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { |
29 return static_cast<size_t>(t); | 29 return static_cast<size_t>(t); |
30 } | 30 } |
31 | 31 |
32 bool IsInDocument(EventTarget* n) { | |
33 return n && n->ToNode() && n->ToNode()->isConnected(); | |
34 } | |
35 | |
36 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( | 32 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( |
37 const Vector<WebTouchEvent>& coalesced_events, | 33 const Vector<WebTouchEvent>& coalesced_events, |
38 int id) { | 34 int id) { |
39 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; | 35 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; |
40 for (const auto& touch_event : coalesced_events) { | 36 for (const auto& touch_event : coalesced_events) { |
41 for (unsigned i = 0; i < touch_event.touches_length; ++i) { | 37 for (unsigned i = 0; i < touch_event.touches_length; ++i) { |
42 if (touch_event.touches[i].id == id && | 38 if (touch_event.touches[i].id == id && |
43 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { | 39 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { |
44 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( | 40 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( |
45 touch_event.TouchPointInRootFrame(i), | 41 touch_event.TouchPointInRootFrame(i), |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 prevent_mouse_event_for_pointer_type_[ToPointerTypeIndex( | 485 prevent_mouse_event_for_pointer_type_[ToPointerTypeIndex( |
490 mouse_event.pointer_type)] = true; | 486 mouse_event.pointer_type)] = true; |
491 } | 487 } |
492 | 488 |
493 if (pointer_event->isPrimary() && | 489 if (pointer_event->isPrimary() && |
494 !prevent_mouse_event_for_pointer_type_[ToPointerTypeIndex( | 490 !prevent_mouse_event_for_pointer_type_[ToPointerTypeIndex( |
495 mouse_event.pointer_type)]) { | 491 mouse_event.pointer_type)]) { |
496 EventTarget* mouse_target = effective_target; | 492 EventTarget* mouse_target = effective_target; |
497 // Event path could be null if pointer event is not dispatched and | 493 // Event path could be null if pointer event is not dispatched and |
498 // that happens for example when pointer event feature is not enabled. | 494 // that happens for example when pointer event feature is not enabled. |
499 if (!IsInDocument(mouse_target) && pointer_event->HasEventPath()) { | 495 if (!EventHandlingUtil::IsInDocument(mouse_target) && |
| 496 pointer_event->HasEventPath()) { |
500 for (const auto& context : | 497 for (const auto& context : |
501 pointer_event->GetEventPath().NodeEventContexts()) { | 498 pointer_event->GetEventPath().NodeEventContexts()) { |
502 if (IsInDocument(context.GetNode())) { | 499 if (EventHandlingUtil::IsInDocument(context.GetNode())) { |
503 mouse_target = context.GetNode(); | 500 mouse_target = context.GetNode(); |
504 break; | 501 break; |
505 } | 502 } |
506 } | 503 } |
507 } | 504 } |
508 result = EventHandlingUtil::MergeEventResult( | 505 result = EventHandlingUtil::MergeEventResult( |
509 result, mouse_event_manager_->DispatchMouseEvent( | 506 result, mouse_event_manager_->DispatchMouseEvent( |
510 mouse_target, mouse_event_type, mouse_event, | 507 mouse_target, mouse_event_type, mouse_event, |
511 canvas_region_id, nullptr)); | 508 canvas_region_id, nullptr)); |
512 } | 509 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (first_id > unique_touch_event_id) | 713 if (first_id > unique_touch_event_id) |
717 return false; | 714 return false; |
718 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 715 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
719 if (first_id == unique_touch_event_id) | 716 if (first_id == unique_touch_event_id) |
720 return true; | 717 return true; |
721 } | 718 } |
722 return false; | 719 return false; |
723 } | 720 } |
724 | 721 |
725 } // namespace blink | 722 } // namespace blink |
OLD | NEW |