Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: third_party/WebKit/Source/core/input/PointerEventManager.cpp

Issue 2860663006: Remove WebTouchEvent from TouchEventManager APIs (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 WebPointerProperties::PointerAction PointerEventActionForTouchPointState(
33 WebTouchPoint::State state) {
34 switch (state) {
35 case WebTouchPoint::kStateReleased:
36 return WebPointerProperties::PointerAction::kPointerUp;
37 case WebTouchPoint::kStateCancelled:
38 return WebPointerProperties::PointerAction::kPointerCancel;
39 case WebTouchPoint::kStatePressed:
40 return WebPointerProperties::PointerAction::kPointerDown;
41 case WebTouchPoint::kStateMoved:
42 return WebPointerProperties::PointerAction::kPointerMove;
43 case WebTouchPoint::kStateStationary:
44 return WebPointerProperties::PointerAction::kPointerUndefined;
45 default:
46 NOTREACHED();
47 return WebPointerProperties::PointerAction::kPointerUndefined;
48 }
49 }
50
51 WebPointerEvent CreateWebPointerEventFromTouchPoint(
use mustaq_at_chromium.org 2017/05/08 17:07:30 We will ultimately need conversion methods from/to
Navid Zolghadr 2017/06/08 16:38:26 I moved it to the WebPointerEvent constructor.
52 const WebTouchEvent& touch_event,
53 size_t point_index) {
54 const auto& touch_point = touch_event.touches[point_index];
55 WebPointerEvent touch_pointer_event(
56 PointerEventActionForTouchPointState(touch_point.state),
57 touch_point.screen_position, touch_point.position, touch_point.radius_x,
58 touch_point.radius_y);
59 // WebPointerProperties attributes
60 touch_pointer_event.id = touch_point.id;
61 touch_pointer_event.force = touch_point.force;
62 touch_pointer_event.tilt_x = touch_point.tilt_x;
63 touch_pointer_event.tilt_y = touch_point.tilt_y;
64 touch_pointer_event.tangential_pressure = touch_point.tangential_pressure;
65 touch_pointer_event.twist = touch_point.twist;
66 touch_pointer_event.button = touch_point.button;
67 touch_pointer_event.pointer_type = touch_point.pointer_type;
68 touch_pointer_event.movement_x = touch_point.movement_x;
69 touch_pointer_event.movement_y = touch_point.movement_y;
70 // WebInutEvent attributes
71 touch_pointer_event.SetFrameScale(touch_event.FrameScale());
72 touch_pointer_event.SetFrameTranslate(touch_event.FrameTranslate());
73 touch_pointer_event.SetTimeStampSeconds(touch_event.TimeStampSeconds());
74 touch_pointer_event.SetType(touch_event.GetType());
75 touch_pointer_event.SetModifiers(touch_event.GetModifiers());
76 // WebTouchEvent attributes
77 touch_pointer_event.dispatch_type = touch_event.dispatch_type;
78 touch_pointer_event.moved_beyond_slop_region =
79 touch_event.moved_beyond_slop_region;
80 touch_pointer_event.touch_start_or_first_touch_move =
81 touch_event.touch_start_or_first_touch_move;
82 // WebTouchPoint attributes
83 touch_pointer_event.rotation_angle = touch_point.rotation_angle;
84
85 return touch_pointer_event;
86 }
87
88 Vector<WebPointerEvent> GetCoalescedWebPointerEventsWithNoTransformation(
89 const Vector<WebTouchEvent>& coalesced_events,
90 int id) {
91 Vector<WebPointerEvent> related_pointer_events;
92 for (const auto& touch_event : coalesced_events) {
93 for (unsigned i = 0; i < touch_event.touches_length; ++i) {
94 if (touch_event.touches[i].id == id &&
95 touch_event.touches[i].state != WebTouchPoint::kStateStationary) {
96 related_pointer_events.push_back(
97 CreateWebPointerEventFromTouchPoint(touch_event, i));
98 }
99 }
100 }
101 return related_pointer_events;
102 }
103
32 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints( 104 Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints(
33 const Vector<WebTouchEvent>& coalesced_events, 105 const Vector<WebTouchEvent>& coalesced_events,
34 int id) { 106 int id) {
35 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points; 107 Vector<std::pair<WebTouchPoint, TimeTicks>> related_points;
36 for (const auto& touch_event : coalesced_events) { 108 for (const auto& touch_event : coalesced_events) {
37 for (unsigned i = 0; i < touch_event.touches_length; ++i) { 109 for (unsigned i = 0; i < touch_event.touches_length; ++i) {
38 if (touch_event.touches[i].id == id && 110 if (touch_event.touches[i].id == id &&
39 touch_event.touches[i].state != WebTouchPoint::kStateStationary) { 111 touch_event.touches[i].state != WebTouchPoint::kStateStationary) {
40 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>( 112 related_points.push_back(std::pair<WebTouchPoint, TimeTicks>(
41 touch_event.TouchPointInRootFrame(i), 113 touch_event.TouchPointInRootFrame(i),
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (event.GetType() == WebInputEvent::kTouchEnd && 383 if (event.GetType() == WebInputEvent::kTouchEnd &&
312 !in_canceled_state_for_pointer_type_touch_ && !touch_infos.IsEmpty() && 384 !in_canceled_state_for_pointer_type_touch_ && !touch_infos.IsEmpty() &&
313 touch_infos[0].target_frame) { 385 touch_infos[0].target_frame) {
314 possible_gesture_token = DocumentUserGestureToken::Create( 386 possible_gesture_token = DocumentUserGestureToken::Create(
315 touch_infos[0].target_frame->GetDocument()); 387 touch_infos[0].target_frame->GetDocument());
316 } 388 }
317 UserGestureIndicator holder(possible_gesture_token); 389 UserGestureIndicator holder(possible_gesture_token);
318 390
319 DispatchTouchPointerEvents(event, coalesced_events, touch_infos); 391 DispatchTouchPointerEvents(event, coalesced_events, touch_infos);
320 392
321 return touch_event_manager_->HandleTouchEvent(event, touch_infos); 393 Vector<WebCoalescedPointerEvent> touch_pointer_events;
394 for (size_t i = 0; i < event.touches_length; ++i) {
395 Vector<WebPointerEvent> coalesced_pointer_events;
396 touch_pointer_events.push_back(WebCoalescedPointerEvent(
397 CreateWebPointerEventFromTouchPoint(event, i),
398 GetCoalescedWebPointerEventsWithNoTransformation(coalesced_events,
399 event.touches[i].id)));
400 }
401 return touch_event_manager_->HandleTouchEvent(touch_pointer_events,
402 touch_infos);
322 } 403 }
323 404
324 void PointerEventManager::ComputeTouchTargets( 405 void PointerEventManager::ComputeTouchTargets(
325 const WebTouchEvent& event, 406 const WebTouchEvent& event,
326 HeapVector<TouchEventManager::TouchInfo>& touch_infos) { 407 HeapVector<TouchEventManager::TouchInfo>& touch_infos) {
327 for (unsigned touch_point = 0; touch_point < event.touches_length; 408 for (unsigned touch_point = 0; touch_point < event.touches_length;
328 ++touch_point) { 409 ++touch_point) {
329 TouchEventManager::TouchInfo touch_info; 410 TouchEventManager::TouchInfo touch_info;
330 touch_info.point = event.TouchPointInRootFrame(touch_point); 411 touch_info.point = event.TouchPointInRootFrame(touch_point);
331 412
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 if (first_id > unique_touch_event_id) 798 if (first_id > unique_touch_event_id)
718 return false; 799 return false;
719 touch_ids_for_canceled_pointerdowns_.TakeFirst(); 800 touch_ids_for_canceled_pointerdowns_.TakeFirst();
720 if (first_id == unique_touch_event_id) 801 if (first_id == unique_touch_event_id)
721 return true; 802 return true;
722 } 803 }
723 return false; 804 return false;
724 } 805 }
725 806
726 } // namespace blink 807 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698