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
3 // found in the LICENSE file.
5 #include "ui/events/gesture_detection/motion_event.h"
7 #include "base/logging.h"
11 size_t MotionEvent::GetHistorySize() const {
15 base::TimeTicks
MotionEvent::GetHistoricalEventTime(
16 size_t historical_index
) const {
18 return base::TimeTicks();
21 float MotionEvent::GetHistoricalTouchMajor(size_t pointer_index
,
22 size_t historical_index
) const {
27 float MotionEvent::GetHistoricalX(size_t pointer_index
,
28 size_t historical_index
) const {
33 float MotionEvent::GetHistoricalY(size_t pointer_index
,
34 size_t historical_index
) const {
39 int MotionEvent::FindPointerIndexOfId(int id
) const {
40 const size_t pointer_count
= GetPointerCount();
41 for (size_t i
= 0; i
< pointer_count
; ++i
) {
42 if (GetPointerId(i
) == id
)
43 return static_cast<int>(i
);
48 bool operator==(const MotionEvent
& lhs
, const MotionEvent
& rhs
) {
49 if (lhs
.GetId() != rhs
.GetId() || lhs
.GetAction() != rhs
.GetAction() ||
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())
57 for (size_t i
= 0; i
< lhs
.GetPointerCount(); ++i
) {
58 int rhsi
= rhs
.FindPointerIndexOfId(lhs
.GetPointerId(i
));
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
.GetPressure(i
) != rhs
.GetPressure(rhsi
) ||
67 lhs
.GetToolType(i
) != rhs
.GetToolType(rhsi
))
70 for (size_t h
= 0; h
< lhs
.GetHistorySize(); ++h
) {
71 if (lhs
.GetHistoricalX(i
, h
) != rhs
.GetHistoricalX(rhsi
, h
) ||
72 lhs
.GetHistoricalY(i
, h
) != rhs
.GetHistoricalY(rhsi
, h
) ||
73 lhs
.GetHistoricalTouchMajor(i
, h
) !=
74 rhs
.GetHistoricalTouchMajor(rhsi
, h
))
79 for (size_t h
= 0; h
< lhs
.GetHistorySize(); ++h
) {
80 if (lhs
.GetHistoricalEventTime(h
) != rhs
.GetHistoricalEventTime(h
))
87 bool operator!=(const MotionEvent
& lhs
, const MotionEvent
& rhs
) {