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

Side by Side Diff: ui/events/gesture_detection/motion_event_generic.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 #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
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),
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_), 58 unique_event_id_(other.unique_event_id_),
60 action_index_(other.action_index_), 59 action_index_(other.action_index_),
61 button_state_(other.button_state_), 60 button_state_(other.button_state_),
62 flags_(other.flags_), 61 flags_(other.flags_),
63 pointers_(other.pointers_) { 62 pointers_(other.pointers_) {
64 const size_t history_size = other.GetHistorySize(); 63 const size_t history_size = other.GetHistorySize();
65 for (size_t h = 0; h < history_size; ++h) 64 for (size_t h = 0; h < history_size; ++h)
66 PushHistoricalEvent(other.historical_events_[h]->Clone()); 65 PushHistoricalEvent(other.historical_events_[h]->Clone());
67 } 66 }
68 67
69 MotionEventGeneric::~MotionEventGeneric() { 68 MotionEventGeneric::~MotionEventGeneric() {
70 } 69 }
71 70
72 int MotionEventGeneric::GetId() const { 71 uint64 MotionEventGeneric::GetUniqueEventId() const {
73 return id_; 72 return unique_event_id_;
74 } 73 }
75 74
76 MotionEvent::Action MotionEventGeneric::GetAction() const { 75 MotionEvent::Action MotionEventGeneric::GetAction() const {
77 return action_; 76 return action_;
78 } 77 }
79 78
80 int MotionEventGeneric::GetActionIndex() const { 79 int MotionEventGeneric::GetActionIndex() const {
81 DCHECK(action_ == ACTION_POINTER_DOWN || action_ == ACTION_POINTER_UP); 80 DCHECK(action_ == ACTION_POINTER_DOWN || action_ == ACTION_POINTER_UP);
82 DCHECK_GE(action_index_, 0); 81 DCHECK_GE(action_index_, 0);
83 DCHECK_LT(action_index_, static_cast<int>(pointers_->size())); 82 DCHECK_LT(action_index_, static_cast<int>(pointers_->size()));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 DCHECK(event); 211 DCHECK(event);
213 DCHECK_EQ(event->GetAction(), ACTION_MOVE); 212 DCHECK_EQ(event->GetAction(), ACTION_MOVE);
214 DCHECK_EQ(event->GetPointerCount(), GetPointerCount()); 213 DCHECK_EQ(event->GetPointerCount(), GetPointerCount());
215 DCHECK_EQ(event->GetAction(), GetAction()); 214 DCHECK_EQ(event->GetAction(), GetAction());
216 DCHECK_LE(event->GetEventTime().ToInternalValue(), 215 DCHECK_LE(event->GetEventTime().ToInternalValue(),
217 GetEventTime().ToInternalValue()); 216 GetEventTime().ToInternalValue());
218 historical_events_.push_back(event.release()); 217 historical_events_.push_back(event.release());
219 } 218 }
220 219
221 MotionEventGeneric::MotionEventGeneric() 220 MotionEventGeneric::MotionEventGeneric()
222 : action_(ACTION_CANCEL), id_(0), action_index_(0), button_state_(0) { 221 : action_(ACTION_CANCEL), action_index_(0), button_state_(0) {
223 } 222 }
224 223
225 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event, 224 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event,
226 bool with_history) 225 bool with_history)
227 : action_(event.GetAction()), 226 : action_(event.GetAction()),
228 event_time_(event.GetEventTime()), 227 event_time_(event.GetEventTime()),
229 id_(event.GetId()),
230 action_index_( 228 action_index_(
231 (action_ == ACTION_POINTER_UP || action_ == ACTION_POINTER_DOWN) 229 (action_ == ACTION_POINTER_UP || action_ == ACTION_POINTER_DOWN)
232 ? event.GetActionIndex() 230 ? event.GetActionIndex()
233 : 0), 231 : 0),
234 button_state_(event.GetButtonState()), 232 button_state_(event.GetButtonState()),
235 flags_(event.GetFlags()) { 233 flags_(event.GetFlags()) {
236 const size_t pointer_count = event.GetPointerCount(); 234 const size_t pointer_count = event.GetPointerCount();
237 for (size_t i = 0; i < pointer_count; ++i) 235 for (size_t i = 0; i < pointer_count; ++i)
238 PushPointer(PointerProperties(event, i)); 236 PushPointer(PointerProperties(event, i));
239 237
(...skipping 12 matching lines...) Expand all
252 event.GetHistoricalTouchMajor(i, h))); 250 event.GetHistoricalTouchMajor(i, h)));
253 } 251 }
254 PushHistoricalEvent(historical_event.Pass()); 252 PushHistoricalEvent(historical_event.Pass());
255 } 253 }
256 } 254 }
257 255
258 MotionEventGeneric& MotionEventGeneric::operator=( 256 MotionEventGeneric& MotionEventGeneric::operator=(
259 const MotionEventGeneric& other) { 257 const MotionEventGeneric& other) {
260 action_ = other.action_; 258 action_ = other.action_;
261 event_time_ = other.event_time_; 259 event_time_ = other.event_time_;
262 id_ = other.id_; 260 unique_event_id_ = other.unique_event_id_;
263 action_index_ = other.action_index_; 261 action_index_ = other.action_index_;
264 button_state_ = other.button_state_; 262 button_state_ = other.button_state_;
265 flags_ = other.flags_; 263 flags_ = other.flags_;
266 pointers_ = other.pointers_; 264 pointers_ = other.pointers_;
267 const size_t history_size = other.GetHistorySize(); 265 const size_t history_size = other.GetHistorySize();
268 for (size_t h = 0; h < history_size; ++h) 266 for (size_t h = 0; h < history_size; ++h)
269 PushHistoricalEvent(other.historical_events_[h]->Clone()); 267 PushHistoricalEvent(other.historical_events_[h]->Clone());
270 return *this; 268 return *this;
271 } 269 }
272 270
273 void MotionEventGeneric::PopPointer() { 271 void MotionEventGeneric::PopPointer() {
274 DCHECK_GT(pointers_->size(), 0U); 272 DCHECK_GT(pointers_->size(), 0U);
275 pointers_->pop_back(); 273 pointers_->pop_back();
276 } 274 }
277 275
278 } // namespace ui 276 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698