Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ui/events/gesture_detection/motion_event_generic.h" | 5 #include "ui/events/gesture_detection/motion_event_generic.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace ui { | 9 namespace ui { |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 touch_minor(event.GetTouchMinor(pointer_index)), | 39 touch_minor(event.GetTouchMinor(pointer_index)), |
| 40 orientation(event.GetOrientation(pointer_index)), | 40 orientation(event.GetOrientation(pointer_index)), |
| 41 source_device_id(0) { | 41 source_device_id(0) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 MotionEventGeneric::MotionEventGeneric(Action action, | 44 MotionEventGeneric::MotionEventGeneric(Action action, |
| 45 base::TimeTicks event_time, | 45 base::TimeTicks event_time, |
| 46 const PointerProperties& pointer) | 46 const PointerProperties& pointer) |
| 47 : action_(action), | 47 : action_(action), |
| 48 event_time_(event_time), | 48 event_time_(event_time), |
| 49 id_(0), | |
| 50 action_index_(0), | 49 action_index_(0), |
|
jdduke (slow)
2015/04/17 20:30:01
unique_event_id_ needs to be initialized in all of
lanwei
2015/04/20 19:58:59
The MotionEventGeneric's unique_event_id is from T
jdduke (slow)
2015/04/21 14:56:50
I don't fully understand this comment, what do you
lanwei
2015/04/21 21:32:45
Sorry, I was wrong, I thought we do not pass Motio
| |
| 51 button_state_(0), | 50 button_state_(0), |
| 52 flags_(0) { | 51 flags_(0) { |
| 53 PushPointer(pointer); | 52 PushPointer(pointer); |
| 54 } | 53 } |
| 55 | 54 |
| 56 MotionEventGeneric::MotionEventGeneric(const MotionEventGeneric& other) | 55 MotionEventGeneric::MotionEventGeneric(const MotionEventGeneric& other) |
| 57 : action_(other.action_), | 56 : action_(other.action_), |
| 58 event_time_(other.event_time_), | 57 event_time_(other.event_time_), |
| 59 id_(other.id_), | |
| 60 action_index_(other.action_index_), | 58 action_index_(other.action_index_), |
| 61 button_state_(other.button_state_), | 59 button_state_(other.button_state_), |
| 62 flags_(other.flags_), | 60 flags_(other.flags_), |
| 63 pointers_(other.pointers_) { | 61 pointers_(other.pointers_) { |
| 64 const size_t history_size = other.GetHistorySize(); | 62 const size_t history_size = other.GetHistorySize(); |
| 65 for (size_t h = 0; h < history_size; ++h) | 63 for (size_t h = 0; h < history_size; ++h) |
| 66 PushHistoricalEvent(other.historical_events_[h]->Clone()); | 64 PushHistoricalEvent(other.historical_events_[h]->Clone()); |
| 67 } | 65 } |
| 68 | 66 |
| 69 MotionEventGeneric::~MotionEventGeneric() { | 67 MotionEventGeneric::~MotionEventGeneric() { |
| 70 } | 68 } |
| 71 | 69 |
| 72 int MotionEventGeneric::GetId() const { | 70 uint64 MotionEventGeneric::GetUniqueEventId() const { |
| 73 return id_; | 71 return unique_event_id_; |
| 74 } | 72 } |
| 75 | 73 |
| 76 MotionEvent::Action MotionEventGeneric::GetAction() const { | 74 MotionEvent::Action MotionEventGeneric::GetAction() const { |
| 77 return action_; | 75 return action_; |
| 78 } | 76 } |
| 79 | 77 |
| 80 int MotionEventGeneric::GetActionIndex() const { | 78 int MotionEventGeneric::GetActionIndex() const { |
| 81 DCHECK(action_ == ACTION_POINTER_DOWN || action_ == ACTION_POINTER_UP); | 79 DCHECK(action_ == ACTION_POINTER_DOWN || action_ == ACTION_POINTER_UP); |
| 82 DCHECK_GE(action_index_, 0); | 80 DCHECK_GE(action_index_, 0); |
| 83 DCHECK_LT(action_index_, static_cast<int>(pointers_->size())); | 81 DCHECK_LT(action_index_, static_cast<int>(pointers_->size())); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 DCHECK(event); | 210 DCHECK(event); |
| 213 DCHECK_EQ(event->GetAction(), ACTION_MOVE); | 211 DCHECK_EQ(event->GetAction(), ACTION_MOVE); |
| 214 DCHECK_EQ(event->GetPointerCount(), GetPointerCount()); | 212 DCHECK_EQ(event->GetPointerCount(), GetPointerCount()); |
| 215 DCHECK_EQ(event->GetAction(), GetAction()); | 213 DCHECK_EQ(event->GetAction(), GetAction()); |
| 216 DCHECK_LE(event->GetEventTime().ToInternalValue(), | 214 DCHECK_LE(event->GetEventTime().ToInternalValue(), |
| 217 GetEventTime().ToInternalValue()); | 215 GetEventTime().ToInternalValue()); |
| 218 historical_events_.push_back(event.release()); | 216 historical_events_.push_back(event.release()); |
| 219 } | 217 } |
| 220 | 218 |
| 221 MotionEventGeneric::MotionEventGeneric() | 219 MotionEventGeneric::MotionEventGeneric() |
| 222 : action_(ACTION_CANCEL), id_(0), action_index_(0), button_state_(0) { | 220 : action_(ACTION_CANCEL), action_index_(0), button_state_(0) { |
| 223 } | 221 } |
| 224 | 222 |
| 225 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event, | 223 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event, |
| 226 bool with_history) | 224 bool with_history) |
| 227 : action_(event.GetAction()), | 225 : action_(event.GetAction()), |
| 228 event_time_(event.GetEventTime()), | 226 event_time_(event.GetEventTime()), |
| 229 id_(event.GetId()), | |
| 230 action_index_( | 227 action_index_( |
| 231 (action_ == ACTION_POINTER_UP || action_ == ACTION_POINTER_DOWN) | 228 (action_ == ACTION_POINTER_UP || action_ == ACTION_POINTER_DOWN) |
| 232 ? event.GetActionIndex() | 229 ? event.GetActionIndex() |
| 233 : 0), | 230 : 0), |
| 234 button_state_(event.GetButtonState()), | 231 button_state_(event.GetButtonState()), |
| 235 flags_(event.GetFlags()) { | 232 flags_(event.GetFlags()) { |
| 236 const size_t pointer_count = event.GetPointerCount(); | 233 const size_t pointer_count = event.GetPointerCount(); |
| 237 for (size_t i = 0; i < pointer_count; ++i) | 234 for (size_t i = 0; i < pointer_count; ++i) |
| 238 PushPointer(PointerProperties(event, i)); | 235 PushPointer(PointerProperties(event, i)); |
| 239 | 236 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 252 event.GetHistoricalTouchMajor(i, h))); | 249 event.GetHistoricalTouchMajor(i, h))); |
| 253 } | 250 } |
| 254 PushHistoricalEvent(historical_event.Pass()); | 251 PushHistoricalEvent(historical_event.Pass()); |
| 255 } | 252 } |
| 256 } | 253 } |
| 257 | 254 |
| 258 MotionEventGeneric& MotionEventGeneric::operator=( | 255 MotionEventGeneric& MotionEventGeneric::operator=( |
| 259 const MotionEventGeneric& other) { | 256 const MotionEventGeneric& other) { |
| 260 action_ = other.action_; | 257 action_ = other.action_; |
| 261 event_time_ = other.event_time_; | 258 event_time_ = other.event_time_; |
| 262 id_ = other.id_; | |
| 263 action_index_ = other.action_index_; | 259 action_index_ = other.action_index_; |
|
jdduke (slow)
2015/04/17 20:30:01
Don't we need to copy the unique_event_id_?
lanwei
2015/04/20 19:58:59
Done.
| |
| 264 button_state_ = other.button_state_; | 260 button_state_ = other.button_state_; |
| 265 flags_ = other.flags_; | 261 flags_ = other.flags_; |
| 266 pointers_ = other.pointers_; | 262 pointers_ = other.pointers_; |
| 267 const size_t history_size = other.GetHistorySize(); | 263 const size_t history_size = other.GetHistorySize(); |
| 268 for (size_t h = 0; h < history_size; ++h) | 264 for (size_t h = 0; h < history_size; ++h) |
| 269 PushHistoricalEvent(other.historical_events_[h]->Clone()); | 265 PushHistoricalEvent(other.historical_events_[h]->Clone()); |
| 270 return *this; | 266 return *this; |
| 271 } | 267 } |
| 272 | 268 |
| 273 void MotionEventGeneric::PopPointer() { | 269 void MotionEventGeneric::PopPointer() { |
| 274 DCHECK_GT(pointers_->size(), 0U); | 270 DCHECK_GT(pointers_->size(), 0U); |
| 275 pointers_->pop_back(); | 271 pointers_->pop_back(); |
| 276 } | 272 } |
| 277 | 273 |
| 278 } // namespace ui | 274 } // namespace ui |
| OLD | NEW |