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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "content/browser/renderer_host/input/motion_event_web.h" | 8 #include "content/browser/renderer_host/input/motion_event_web.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "content/browser/renderer_host/input/web_input_event_util.h" | 13 #include "content/browser/renderer_host/input/web_input_event_util.h" |
14 #include "content/common/input/web_touch_event_traits.h" | 14 #include "content/common/input/web_touch_event_traits.h" |
15 #include "ui/events/base_event_utils.h" | |
15 | 16 |
16 using blink::WebInputEvent; | 17 using blink::WebInputEvent; |
17 using blink::WebTouchEvent; | 18 using blink::WebTouchEvent; |
18 using blink::WebTouchPoint; | 19 using blink::WebTouchPoint; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 namespace { | 22 namespace { |
22 | 23 |
23 ui::MotionEvent::Action GetActionFrom(const WebTouchEvent& event) { | 24 ui::MotionEvent::Action GetActionFrom(const WebTouchEvent& event) { |
24 DCHECK(event.touchesLength); | 25 DCHECK(event.touchesLength); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 return i; | 57 return i; |
57 } | 58 } |
58 return -1; | 59 return -1; |
59 } | 60 } |
60 | 61 |
61 } // namespace | 62 } // namespace |
62 | 63 |
63 MotionEventWeb::MotionEventWeb(const WebTouchEvent& event) | 64 MotionEventWeb::MotionEventWeb(const WebTouchEvent& event) |
64 : event_(event), | 65 : event_(event), |
65 cached_action_(GetActionFrom(event)), | 66 cached_action_(GetActionFrom(event)), |
66 cached_action_index_(GetActionIndexFrom(event)) { | 67 cached_action_index_(GetActionIndexFrom(event)), |
68 unique_event_id_(ui::GetNextTouchEventId()) { | |
67 DCHECK_GT(GetPointerCount(), 0U); | 69 DCHECK_GT(GetPointerCount(), 0U); |
68 } | 70 } |
69 | 71 |
70 MotionEventWeb::~MotionEventWeb() {} | 72 MotionEventWeb::~MotionEventWeb() {} |
71 | 73 |
72 int MotionEventWeb::GetId() const { | 74 int MotionEventWeb::GetId() const { |
73 return 0; | 75 return 0; |
74 } | 76 } |
75 | 77 |
78 uint64 MotionEventWeb::GetUniqueEventId() const { | |
79 return unique_event_id_; | |
tdresser
2015/04/09 12:33:06
Did you figure out why there were no test failures
lanwei
2015/04/16 17:09:06
The unit test does not use this type, it uses WebT
| |
80 } | |
81 | |
76 MotionEventWeb::Action MotionEventWeb::GetAction() const { | 82 MotionEventWeb::Action MotionEventWeb::GetAction() const { |
77 return cached_action_; | 83 return cached_action_; |
78 } | 84 } |
79 | 85 |
80 int MotionEventWeb::GetActionIndex() const { | 86 int MotionEventWeb::GetActionIndex() const { |
81 DCHECK(cached_action_ == ACTION_POINTER_UP || | 87 DCHECK(cached_action_ == ACTION_POINTER_UP || |
82 cached_action_ == ACTION_POINTER_DOWN) | 88 cached_action_ == ACTION_POINTER_DOWN) |
83 << "Invalid action for GetActionIndex(): " << cached_action_; | 89 << "Invalid action for GetActionIndex(): " << cached_action_; |
84 DCHECK_GE(cached_action_index_, 0); | 90 DCHECK_GE(cached_action_index_, 0); |
85 DCHECK_LT(cached_action_index_, static_cast<int>(event_.touchesLength)); | 91 DCHECK_LT(cached_action_index_, static_cast<int>(event_.touchesLength)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 169 |
164 int MotionEventWeb::GetButtonState() const { | 170 int MotionEventWeb::GetButtonState() const { |
165 return 0; | 171 return 0; |
166 } | 172 } |
167 | 173 |
168 int MotionEventWeb::GetFlags() const { | 174 int MotionEventWeb::GetFlags() const { |
169 return WebEventModifiersToEventFlags(event_.modifiers); | 175 return WebEventModifiersToEventFlags(event_.modifiers); |
170 } | 176 } |
171 | 177 |
172 } // namespace content | 178 } // namespace content |
OLD | NEW |