Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / gesture_detection / motion_event.cc
blobd3646cc4f9bd0a00698bd75b0382792af376184a
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"
9 namespace ui {
11 size_t MotionEvent::GetHistorySize() const {
12 return 0;
15 base::TimeTicks MotionEvent::GetHistoricalEventTime(
16 size_t historical_index) const {
17 NOTIMPLEMENTED();
18 return base::TimeTicks();
21 float MotionEvent::GetHistoricalTouchMajor(size_t pointer_index,
22 size_t historical_index) const {
23 NOTIMPLEMENTED();
24 return 0.f;
27 float MotionEvent::GetHistoricalX(size_t pointer_index,
28 size_t historical_index) const {
29 NOTIMPLEMENTED();
30 return 0.f;
33 float MotionEvent::GetHistoricalY(size_t pointer_index,
34 size_t historical_index) const {
35 NOTIMPLEMENTED();
36 return 0.f;
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);
45 return -1;
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())
55 return false;
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;
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))
68 return false;
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))
75 return false;
79 for (size_t h = 0; h < lhs.GetHistorySize(); ++h) {
80 if (lhs.GetHistoricalEventTime(h) != rhs.GetHistoricalEventTime(h))
81 return false;
84 return true;
87 bool operator!=(const MotionEvent& lhs, const MotionEvent& rhs) {
88 return !(lhs == rhs);
91 } // namespace ui