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

Side by Side Diff: ui/events/gesture_detection/motion_event.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, 1 month 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.h" 5 #include "ui/events/gesture_detection/motion_event.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/gesture_detection/motion_event_generic.h"
8 9
9 namespace ui { 10 namespace ui {
10 11
11 size_t MotionEvent::GetHistorySize() const { 12 size_t MotionEvent::GetHistorySize() const {
12 return 0; 13 return 0;
13 } 14 }
14 15
15 base::TimeTicks MotionEvent::GetHistoricalEventTime( 16 base::TimeTicks MotionEvent::GetHistoricalEventTime(
16 size_t historical_index) const { 17 size_t historical_index) const {
17 NOTIMPLEMENTED(); 18 NOTIMPLEMENTED();
(...skipping 20 matching lines...) Expand all
38 39
39 int MotionEvent::FindPointerIndexOfId(int id) const { 40 int MotionEvent::FindPointerIndexOfId(int id) const {
40 const size_t pointer_count = GetPointerCount(); 41 const size_t pointer_count = GetPointerCount();
41 for (size_t i = 0; i < pointer_count; ++i) { 42 for (size_t i = 0; i < pointer_count; ++i) {
42 if (GetPointerId(i) == id) 43 if (GetPointerId(i) == id)
43 return static_cast<int>(i); 44 return static_cast<int>(i);
44 } 45 }
45 return -1; 46 return -1;
46 } 47 }
47 48
48 bool operator==(const MotionEvent& lhs, const MotionEvent& rhs) { 49 scoped_ptr<MotionEvent> MotionEvent::Clone() const {
49 if (lhs.GetId() != rhs.GetId() || lhs.GetAction() != rhs.GetAction() || 50 return MotionEventGeneric::CloneEvent(*this);
50 lhs.GetActionIndex() != rhs.GetActionIndex() ||
51 lhs.GetPointerCount() != rhs.GetPointerCount() ||
52 lhs.GetButtonState() != rhs.GetButtonState() ||
53 lhs.GetEventTime() != rhs.GetEventTime() ||
54 lhs.GetHistorySize() != rhs.GetHistorySize())
55 return false;
56
57 for (size_t i = 0; i < lhs.GetPointerCount(); ++i) {
58 int rhsi = rhs.FindPointerIndexOfId(lhs.GetPointerId(i));
59 if (rhsi == -1)
60 return false;
61
62 if (lhs.GetX(i) != rhs.GetX(rhsi) || lhs.GetY(i) != rhs.GetY(rhsi) ||
63 lhs.GetRawX(i) != rhs.GetRawX(rhsi) ||
64 lhs.GetRawY(i) != rhs.GetRawY(rhsi) ||
65 lhs.GetTouchMajor(i) != rhs.GetTouchMajor(rhsi) ||
66 lhs.GetTouchMinor(i) != rhs.GetTouchMinor(rhsi) ||
67 lhs.GetOrientation(i) != rhs.GetOrientation(rhsi) ||
68 lhs.GetPressure(i) != rhs.GetPressure(rhsi) ||
69 lhs.GetToolType(i) != rhs.GetToolType(rhsi))
70 return false;
71
72 for (size_t h = 0; h < lhs.GetHistorySize(); ++h) {
73 if (lhs.GetHistoricalX(i, h) != rhs.GetHistoricalX(rhsi, h) ||
74 lhs.GetHistoricalY(i, h) != rhs.GetHistoricalY(rhsi, h) ||
75 lhs.GetHistoricalTouchMajor(i, h) !=
76 rhs.GetHistoricalTouchMajor(rhsi, h))
77 return false;
78 }
79 }
80
81 for (size_t h = 0; h < lhs.GetHistorySize(); ++h) {
82 if (lhs.GetHistoricalEventTime(h) != rhs.GetHistoricalEventTime(h))
83 return false;
84 }
85
86 return true;
87 } 51 }
88 52
89 bool operator!=(const MotionEvent& lhs, const MotionEvent& rhs) { 53 scoped_ptr<MotionEvent> MotionEvent::Cancel() const {
90 return !(lhs == rhs); 54 return MotionEventGeneric::CancelEvent(*this);
91 } 55 }
92 56
93 } // namespace ui 57 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/motion_event.h ('k') | ui/events/gesture_detection/motion_event_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698