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/gestures/motion_event_aura.h" | 5 #include "ui/events/gestures/motion_event_aura.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
tdresser
2014/08/16 00:31:47
This is a layering violation. I'm still not sure w
| |
8 #include "ui/events/gestures/gesture_configuration.h" | 9 #include "ui/events/gestures/gesture_configuration.h" |
9 | 10 |
10 namespace ui { | 11 namespace ui { |
11 | 12 |
12 MotionEventAura::MotionEventAura() | 13 MotionEventAura::MotionEventAura() |
13 : pointer_count_(0), cached_action_index_(-1) { | 14 : pointer_count_(0), cached_action_index_(-1) { |
14 } | 15 } |
15 | 16 |
16 MotionEventAura::MotionEventAura( | 17 MotionEventAura::MotionEventAura(size_t pointer_count, |
17 size_t pointer_count, | 18 const base::TimeTicks& last_touch_time, |
18 const base::TimeTicks& last_touch_time, | 19 Action cached_action, |
19 Action cached_action, | 20 int cached_action_index, |
20 int cached_action_index, | 21 const PointData (&active_touches)[10/*TODO*/]) |
21 const PointData (&active_touches)[GestureSequence::kMaxGesturePoints]) | |
22 : pointer_count_(pointer_count), | 22 : pointer_count_(pointer_count), |
23 last_touch_time_(last_touch_time), | 23 last_touch_time_(last_touch_time), |
24 cached_action_(cached_action), | 24 cached_action_(cached_action), |
25 cached_action_index_(cached_action_index) { | 25 cached_action_index_(cached_action_index) { |
26 DCHECK(pointer_count_); | 26 DCHECK(pointer_count_); |
27 for (size_t i = 0; i < pointer_count; ++i) | 27 for (size_t i = 0; i < pointer_count; ++i) |
28 active_touches_[i] = active_touches[i]; | 28 active_touches_[i] = active_touches[i]; |
29 } | 29 } |
30 | 30 |
31 MotionEventAura::~MotionEventAura() {} | 31 MotionEventAura::~MotionEventAura() {} |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 source_device_id(0), | 173 source_device_id(0), |
174 major_radius(0) { | 174 major_radius(0) { |
175 } | 175 } |
176 | 176 |
177 int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { | 177 int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { |
178 DCHECK_LE(pointer_index, pointer_count_); | 178 DCHECK_LE(pointer_index, pointer_count_); |
179 return active_touches_[pointer_index].source_device_id; | 179 return active_touches_[pointer_index].source_device_id; |
180 } | 180 } |
181 | 181 |
182 void MotionEventAura::AddTouch(const TouchEvent& touch) { | 182 void MotionEventAura::AddTouch(const TouchEvent& touch) { |
183 if (pointer_count_ == static_cast<size_t>(GestureSequence::kMaxGesturePoints)) | 183 if (pointer_count_ == blink::WebTouchEvent::touchesLengthCap) |
184 return; | 184 return; |
185 | 185 |
186 active_touches_[pointer_count_] = GetPointDataFromTouchEvent(touch); | 186 active_touches_[pointer_count_] = GetPointDataFromTouchEvent(touch); |
187 pointer_count_++; | 187 pointer_count_++; |
188 } | 188 } |
189 | 189 |
190 | 190 |
191 void MotionEventAura::UpdateTouch(const TouchEvent& touch) { | 191 void MotionEventAura::UpdateTouch(const TouchEvent& touch) { |
192 active_touches_[GetIndexFromId(touch.touch_id())] = | 192 active_touches_[GetIndexFromId(touch.touch_id())] = |
193 GetPointDataFromTouchEvent(touch); | 193 GetPointDataFromTouchEvent(touch); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 size_t MotionEventAura::GetIndexFromId(int id) const { | 230 size_t MotionEventAura::GetIndexFromId(int id) const { |
231 for (size_t i = 0; i < pointer_count_; ++i) { | 231 for (size_t i = 0; i < pointer_count_; ++i) { |
232 if (active_touches_[i].touch_id == id) | 232 if (active_touches_[i].touch_id == id) |
233 return i; | 233 return i; |
234 } | 234 } |
235 NOTREACHED(); | 235 NOTREACHED(); |
236 return 0; | 236 return 0; |
237 } | 237 } |
238 | 238 |
239 } // namespace ui | 239 } // namespace ui |
OLD | NEW |