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

Side by Side Diff: ui/events/gestures/motion_event_aura.cc

Issue 510793003: Remove ui::TouchEvent -> blink::WebTouchEvent conversion methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address jdduke's comments. Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/events/gestures/motion_event_aura.h" 8 #include "ui/events/gestures/motion_event_aura.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 } // namespace 63 } // namespace
64 64
65 MotionEventAura::MotionEventAura() { 65 MotionEventAura::MotionEventAura() {
66 set_action_index(-1); 66 set_action_index(-1);
67 } 67 }
68 68
69 MotionEventAura::~MotionEventAura() { 69 MotionEventAura::~MotionEventAura() {
70 } 70 }
71 71
72 void MotionEventAura::OnTouch(const TouchEvent& touch) { 72 bool MotionEventAura::OnTouch(const TouchEvent& touch) {
73 int index = FindPointerIndexOfId(touch.touch_id());
74 bool pointer_id_is_active = index != -1;
75
76 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
77 // Ignore touch press events if we already believe the pointer is down.
78
79 // TODO(tdresser): this should return false (or NOTREACHED());
80 // however, there is at least one case where we need to allow a
81 // touch press from a currently used touch id. See
82 // crbug.com/373125 for details.
83 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
84 // We could have an active touch stream transfered to us, resulting in touch
85 // move or touch up events without associated touch down events. Ignore
86 // them.
87 return false;
88 }
89
90 // If this is a touchmove event, and it isn't different from the last
91 // event, ignore it.
92 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) &&
93 touch.y() == GetY(index)) {
94 return false;
95 }
96
73 switch (touch.type()) { 97 switch (touch.type()) {
74 case ET_TOUCH_PRESSED: 98 case ET_TOUCH_PRESSED:
75 AddTouch(touch); 99 AddTouch(touch);
76 break; 100 break;
77 case ET_TOUCH_RELEASED: 101 case ET_TOUCH_RELEASED:
78 case ET_TOUCH_CANCELLED: 102 case ET_TOUCH_CANCELLED:
79 // Removing these touch points needs to be postponed until after the 103 // Removing these touch points needs to be postponed until after the
80 // MotionEvent has been dispatched. This cleanup occurs in 104 // MotionEvent has been dispatched. This cleanup occurs in
81 // CleanupRemovedTouchPoints. 105 // CleanupRemovedTouchPoints.
82 UpdateTouch(touch); 106 UpdateTouch(touch);
83 break; 107 break;
84 case ET_TOUCH_MOVED: 108 case ET_TOUCH_MOVED:
85 UpdateTouch(touch); 109 UpdateTouch(touch);
86 break; 110 break;
87 default: 111 default:
88 NOTREACHED(); 112 NOTREACHED();
89 break; 113 return false;
90 } 114 }
91 115
92 UpdateCachedAction(touch); 116 UpdateCachedAction(touch);
93 set_flags(touch.flags()); 117 set_flags(touch.flags());
94 set_event_time(touch.time_stamp() + base::TimeTicks()); 118 set_event_time(touch.time_stamp() + base::TimeTicks());
119 return true;
95 } 120 }
96 121
97 int MotionEventAura::GetId() const { 122 int MotionEventAura::GetId() const {
98 return GetPointerId(0); 123 return GetPointerId(0);
99 } 124 }
100 125
101 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { 126 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) {
102 if (event.type() != ET_TOUCH_RELEASED && 127 if (event.type() != ET_TOUCH_RELEASED &&
103 event.type() != ET_TOUCH_CANCELLED) { 128 event.type() != ET_TOUCH_CANCELLED) {
104 return; 129 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 185 }
161 186
162 int MotionEventAura::GetIndexFromId(int id) const { 187 int MotionEventAura::GetIndexFromId(int id) const {
163 int index = FindPointerIndexOfId(id); 188 int index = FindPointerIndexOfId(id);
164 DCHECK_GE(index, 0); 189 DCHECK_GE(index, 0);
165 DCHECK_LT(index, static_cast<int>(GetPointerCount())); 190 DCHECK_LT(index, static_cast<int>(GetPointerCount()));
166 return index; 191 return index;
167 } 192 }
168 193
169 } // namespace ui 194 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698