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

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: Fix tests. Created 6 years 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 return false;
79 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
80 // We could have an active touch stream transfered to us, resulting in touch
81 // move or touch up events without associated touch down events. Ignore
82 // them.
83 return false;
84 }
85
86 // If this is a touchmove event, and it isn't different from the last
87 // event, ignore it.
88 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) &&
89 touch.y() == GetY(index)) {
90 return false;
91 }
92
73 switch (touch.type()) { 93 switch (touch.type()) {
74 case ET_TOUCH_PRESSED: 94 case ET_TOUCH_PRESSED:
75 AddTouch(touch); 95 AddTouch(touch);
76 break; 96 break;
77 case ET_TOUCH_RELEASED: 97 case ET_TOUCH_RELEASED:
78 case ET_TOUCH_CANCELLED: 98 case ET_TOUCH_CANCELLED:
79 // Removing these touch points needs to be postponed until after the 99 // Removing these touch points needs to be postponed until after the
80 // MotionEvent has been dispatched. This cleanup occurs in 100 // MotionEvent has been dispatched. This cleanup occurs in
81 // CleanupRemovedTouchPoints. 101 // CleanupRemovedTouchPoints.
82 UpdateTouch(touch); 102 UpdateTouch(touch);
83 break; 103 break;
84 case ET_TOUCH_MOVED: 104 case ET_TOUCH_MOVED:
85 UpdateTouch(touch); 105 UpdateTouch(touch);
86 break; 106 break;
87 default: 107 default:
88 NOTREACHED(); 108 NOTREACHED();
89 break; 109 return false;
90 } 110 }
91 111
92 UpdateCachedAction(touch); 112 UpdateCachedAction(touch);
93 set_flags(touch.flags()); 113 set_flags(touch.flags());
94 set_event_time(touch.time_stamp() + base::TimeTicks()); 114 set_event_time(touch.time_stamp() + base::TimeTicks());
115 return true;
95 } 116 }
96 117
97 int MotionEventAura::GetId() const { 118 int MotionEventAura::GetId() const {
98 return GetPointerId(0); 119 return GetPointerId(0);
99 } 120 }
100 121
101 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { 122 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) {
102 if (event.type() != ET_TOUCH_RELEASED && 123 if (event.type() != ET_TOUCH_RELEASED &&
103 event.type() != ET_TOUCH_CANCELLED) { 124 event.type() != ET_TOUCH_CANCELLED) {
104 return; 125 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 181 }
161 182
162 int MotionEventAura::GetIndexFromId(int id) const { 183 int MotionEventAura::GetIndexFromId(int id) const {
163 int index = FindPointerIndexOfId(id); 184 int index = FindPointerIndexOfId(id);
164 DCHECK_GE(index, 0); 185 DCHECK_GE(index, 0);
165 DCHECK_LT(index, static_cast<int>(GetPointerCount())); 186 DCHECK_LT(index, static_cast<int>(GetPointerCount()));
166 return index; 187 return index;
167 } 188 }
168 189
169 } // namespace ui 190 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698