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

Unified Diff: ui/events/gestures/motion_event_aura.cc

Issue 502993004: Remove abstract Clone and Cancel methods from MotionEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nasty bug fix Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/gestures/motion_event_aura.h ('k') | ui/events/gestures/motion_event_aura_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gestures/motion_event_aura.cc
diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc
index 1b7b825e7f1fa60e47efeca5d630a247ed037604..867d47a41cb6c87ccfa2b42869e90b9a34c6d85b 100644
--- a/ui/events/gestures/motion_event_aura.cc
+++ b/ui/events/gestures/motion_event_aura.cc
@@ -173,7 +173,6 @@ MotionEvent::ToolType MotionEventAura::GetToolType(size_t pointer_index) const {
}
int MotionEventAura::GetButtonState() const {
- NOTIMPLEMENTED();
return 0;
}
@@ -185,26 +184,15 @@ base::TimeTicks MotionEventAura::GetEventTime() const {
return last_touch_time_;
}
-scoped_ptr<MotionEvent> MotionEventAura::Clone() const {
- return scoped_ptr<MotionEvent>(new MotionEventAura(pointer_count_,
- last_touch_time_,
- cached_action_,
- cached_action_index_,
- flags_,
- active_touches_));
-}
-scoped_ptr<MotionEvent> MotionEventAura::Cancel() const {
- return scoped_ptr<MotionEvent>(new MotionEventAura(
- pointer_count_, last_touch_time_, ACTION_CANCEL, -1, 0, active_touches_));
-}
-
void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) {
if (event.type() != ET_TOUCH_RELEASED &&
event.type() != ET_TOUCH_CANCELLED) {
return;
}
- int index_to_delete = static_cast<int>(GetIndexFromId(event.touch_id()));
+ DCHECK(pointer_count_);
+ int index_to_delete = GetIndexFromId(event.touch_id());
+ cached_action_index_ = 0;
pointer_count_--;
active_touches_[index_to_delete] = active_touches_[pointer_count_];
}
@@ -249,8 +237,7 @@ void MotionEventAura::UpdateCachedAction(const TouchEvent& touch) {
cached_action_ = ACTION_DOWN;
} else {
cached_action_ = ACTION_POINTER_DOWN;
- cached_action_index_ =
- static_cast<int>(GetIndexFromId(touch.touch_id()));
+ cached_action_index_ = GetIndexFromId(touch.touch_id());
}
break;
case ET_TOUCH_RELEASED:
@@ -258,9 +245,7 @@ void MotionEventAura::UpdateCachedAction(const TouchEvent& touch) {
cached_action_ = ACTION_UP;
} else {
cached_action_ = ACTION_POINTER_UP;
- cached_action_index_ =
- static_cast<int>(GetIndexFromId(touch.touch_id()));
- DCHECK_LT(cached_action_index_, static_cast<int>(pointer_count_));
+ cached_action_index_ = GetIndexFromId(touch.touch_id());
}
break;
case ET_TOUCH_CANCELLED:
@@ -275,13 +260,11 @@ void MotionEventAura::UpdateCachedAction(const TouchEvent& touch) {
}
}
-size_t MotionEventAura::GetIndexFromId(int id) const {
- for (size_t i = 0; i < pointer_count_; ++i) {
- if (active_touches_[i].touch_id == id)
- return i;
- }
- NOTREACHED();
- return 0;
+int MotionEventAura::GetIndexFromId(int id) const {
+ int index = FindPointerIndexOfId(id);
+ DCHECK_GE(index, 0);
+ DCHECK_LT(index, static_cast<int>(pointer_count_));
+ return index;
}
} // namespace ui
« no previous file with comments | « ui/events/gestures/motion_event_aura.h ('k') | ui/events/gestures/motion_event_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698