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 15 matching lines...) Expand all Loading... |
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) { | 32 bool IsInDocument(EventTarget* n) { |
33 return n && n->ToNode() && n->ToNode()->isConnected(); | 33 return n && n->ToNode() && n->ToNode()->isConnected(); |
34 } | 34 } |
35 | 35 |
36 Vector<WebTouchPoint> GetCoalescedPoints( | 36 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( |
37 const Vector<WebTouchEvent>& coalesced_events, | 37 const Vector<WebTouchEvent>& coalesced_events, |
38 int id) { | 38 int id) { |
39 Vector<WebTouchPoint> related_points; | 39 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; |
40 for (const auto& touch_event : coalesced_events) { | 40 for (const auto& touch_event : coalesced_events) { |
41 for (unsigned i = 0; i < touch_event.touches_length; ++i) { | 41 for (unsigned i = 0; i < touch_event.touches_length; ++i) { |
42 if (touch_event.touches[i].id == id && | 42 if (touch_event.touches[i].id == id && |
43 touch_event.touches[i].state != WebTouchPoint::kStateStationary) | 43 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { |
44 related_points.push_back(touch_event.TouchPointInRootFrame(i)); | 44 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( |
| 45 touch_event.TouchPointInRootFrame(i), |
| 46 TimeTicks::FromSeconds(touch_event.TimeStampSeconds()))); |
| 47 } |
45 } | 48 } |
46 } | 49 } |
47 return related_points; | 50 return related_points; |
48 } | 51 } |
49 | 52 |
50 } // namespace | 53 } // namespace |
51 | 54 |
52 PointerEventManager::PointerEventManager(LocalFrame& frame, | 55 PointerEventManager::PointerEventManager(LocalFrame& frame, |
53 MouseEventManager& mouse_event_manager) | 56 MouseEventManager& mouse_event_manager) |
54 : frame_(frame), | 57 : frame_(frame), |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // required. | 388 // required. |
386 for (auto touch_info : touch_infos) { | 389 for (auto touch_info : touch_infos) { |
387 const WebTouchPoint& touch_point = touch_info.point; | 390 const WebTouchPoint& touch_point = touch_info.point; |
388 // Do not send pointer events for stationary touches or null targetFrame | 391 // Do not send pointer events for stationary touches or null targetFrame |
389 if (touch_info.touch_node && touch_info.target_frame && | 392 if (touch_info.touch_node && touch_info.target_frame && |
390 touch_point.state != WebTouchPoint::kStateStationary && | 393 touch_point.state != WebTouchPoint::kStateStationary && |
391 !in_canceled_state_for_pointer_type_touch_) { | 394 !in_canceled_state_for_pointer_type_touch_) { |
392 PointerEvent* pointer_event = pointer_event_factory_.Create( | 395 PointerEvent* pointer_event = pointer_event_factory_.Create( |
393 touch_point, GetCoalescedPoints(coalesced_events, touch_point.id), | 396 touch_point, GetCoalescedPoints(coalesced_events, touch_point.id), |
394 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), | 397 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), |
| 398 TimeTicks::FromSeconds(event.TimeStampSeconds()), |
395 touch_info.target_frame, | 399 touch_info.target_frame, |
396 touch_info.touch_node | 400 touch_info.touch_node |
397 ? touch_info.touch_node->GetDocument().domWindow() | 401 ? touch_info.touch_node->GetDocument().domWindow() |
398 : nullptr); | 402 : nullptr); |
399 | 403 |
400 WebInputEventResult result = | 404 WebInputEventResult result = |
401 SendTouchPointerEvent(touch_info.touch_node, pointer_event); | 405 SendTouchPointerEvent(touch_info.touch_node, pointer_event); |
402 | 406 |
403 // If a pointerdown has been canceled, queue the unique id to allow | 407 // If a pointerdown has been canceled, queue the unique id to allow |
404 // suppressing mouse events from gesture events. For mouse events | 408 // suppressing mouse events from gesture events. For mouse events |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 if (first_id > unique_touch_event_id) | 715 if (first_id > unique_touch_event_id) |
712 return false; | 716 return false; |
713 touch_ids_for_canceled_pointerdowns_.TakeFirst(); | 717 touch_ids_for_canceled_pointerdowns_.TakeFirst(); |
714 if (first_id == unique_touch_event_id) | 718 if (first_id == unique_touch_event_id) |
715 return true; | 719 return true; |
716 } | 720 } |
717 return false; | 721 return false; |
718 } | 722 } |
719 | 723 |
720 } // namespace blink | 724 } // namespace blink |
OLD | NEW |