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

Side by Side Diff: content/browser/renderer_host/input/motion_event_android.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 "content/browser/renderer_host/input/motion_event_android.h" 5 #include "content/browser/renderer_host/input/motion_event_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/float_util.h" 10 #include "base/float_util.h"
11 #include "jni/MotionEvent_jni.h" 11 #include "jni/MotionEvent_jni.h"
12 #include "ui/events/base_event_utils.h"
12 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
13 14
14 using base::android::AttachCurrentThread; 15 using base::android::AttachCurrentThread;
15 using namespace JNI_MotionEvent; 16 using namespace JNI_MotionEvent;
16 17
17 namespace content { 18 namespace content {
18 namespace { 19 namespace {
19 20
20 MotionEventAndroid::Action FromAndroidAction(int android_action) { 21 MotionEventAndroid::Action FromAndroidAction(int android_action) {
21 switch (android_action) { 22 switch (android_action) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const Pointer& pointer1) 158 const Pointer& pointer1)
158 : pix_to_dip_(pix_to_dip), 159 : pix_to_dip_(pix_to_dip),
159 cached_time_(FromAndroidTime(time_ms)), 160 cached_time_(FromAndroidTime(time_ms)),
160 cached_action_(FromAndroidAction(android_action)), 161 cached_action_(FromAndroidAction(android_action)),
161 cached_pointer_count_(pointer_count), 162 cached_pointer_count_(pointer_count),
162 cached_history_size_(ToValidHistorySize(history_size, cached_action_)), 163 cached_history_size_(ToValidHistorySize(history_size, cached_action_)),
163 cached_action_index_(action_index), 164 cached_action_index_(action_index),
164 cached_button_state_(FromAndroidButtonState(android_button_state)), 165 cached_button_state_(FromAndroidButtonState(android_button_state)),
165 cached_flags_(FromAndroidMetaState(meta_state)), 166 cached_flags_(FromAndroidMetaState(meta_state)),
166 cached_raw_position_offset_(ToDips(raw_offset_x_pixels), 167 cached_raw_position_offset_(ToDips(raw_offset_x_pixels),
167 ToDips(raw_offset_y_pixels)) { 168 ToDips(raw_offset_y_pixels)),
169 unique_event_id_(ui::GetNextTouchEventId()) {
168 DCHECK_GT(pointer_count, 0); 170 DCHECK_GT(pointer_count, 0);
169 171
170 event_.Reset(env, event); 172 event_.Reset(env, event);
171 if (cached_pointer_count_ > MAX_POINTERS_TO_CACHE || cached_history_size_ > 0) 173 if (cached_pointer_count_ > MAX_POINTERS_TO_CACHE || cached_history_size_ > 0)
172 DCHECK(event_.obj()); 174 DCHECK(event_.obj());
173 175
174 cached_pointers_[0] = FromAndroidPointer(pointer0); 176 cached_pointers_[0] = FromAndroidPointer(pointer0);
175 cached_pointers_[1] = FromAndroidPointer(pointer1); 177 cached_pointers_[1] = FromAndroidPointer(pointer1);
176 } 178 }
177 179
178 MotionEventAndroid::~MotionEventAndroid() { 180 MotionEventAndroid::~MotionEventAndroid() {
179 } 181 }
180 182
181 int MotionEventAndroid::GetId() const { 183 int MotionEventAndroid::GetId() const {
182 return 0; 184 return 0;
183 } 185 }
184 186
187 uint64 MotionEventAndroid::GetUniqueEventId() const {
188 return unique_event_id_;
189 }
190
185 MotionEventAndroid::Action MotionEventAndroid::GetAction() const { 191 MotionEventAndroid::Action MotionEventAndroid::GetAction() const {
186 return cached_action_; 192 return cached_action_;
187 } 193 }
188 194
189 int MotionEventAndroid::GetActionIndex() const { 195 int MotionEventAndroid::GetActionIndex() const {
190 DCHECK(cached_action_ == ACTION_POINTER_UP || 196 DCHECK(cached_action_ == ACTION_POINTER_UP ||
191 cached_action_ == ACTION_POINTER_DOWN) 197 cached_action_ == ACTION_POINTER_DOWN)
192 << "Invalid action for GetActionIndex(): " << cached_action_; 198 << "Invalid action for GetActionIndex(): " << cached_action_;
193 DCHECK_GE(cached_action_index_, 0); 199 DCHECK_GE(cached_action_index_, 0);
194 DCHECK_LT(cached_action_index_, static_cast<int>(cached_pointer_count_)); 200 DCHECK_LT(cached_action_index_, static_cast<int>(cached_pointer_count_));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 result.tool_type = FromAndroidToolType(pointer.tool_type); 338 result.tool_type = FromAndroidToolType(pointer.tool_type);
333 return result; 339 return result;
334 } 340 }
335 341
336 // static 342 // static
337 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) { 343 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) {
338 return JNI_MotionEvent::RegisterNativesImpl(env); 344 return JNI_MotionEvent::RegisterNativesImpl(env);
339 } 345 }
340 346
341 } // namespace content 347 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698