Chromium Code Reviews| 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()) { | |
|
jdduke (slow)
2015/04/17 20:30:01
Shouldn't this ID come from event.uniqueTouchEvent
lanwei
2015/04/20 19:58:59
This WebTouchEvent does not have a valid unique_ev
tdresser
2015/04/20 20:12:09
Shouldn't it have a valid unique_event_id?
tdresser
2015/04/20 20:26:20
Lan pointed out that this isn't the case with synt
| |
| 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 uint64 MotionEventWeb::GetUniqueEventId() const { |
| 73 return 0; | 75 return unique_event_id_; |
| 74 } | 76 } |
| 75 | 77 |
| 76 MotionEventWeb::Action MotionEventWeb::GetAction() const { | 78 MotionEventWeb::Action MotionEventWeb::GetAction() const { |
| 77 return cached_action_; | 79 return cached_action_; |
| 78 } | 80 } |
| 79 | 81 |
| 80 int MotionEventWeb::GetActionIndex() const { | 82 int MotionEventWeb::GetActionIndex() const { |
| 81 DCHECK(cached_action_ == ACTION_POINTER_UP || | 83 DCHECK(cached_action_ == ACTION_POINTER_UP || |
| 82 cached_action_ == ACTION_POINTER_DOWN) | 84 cached_action_ == ACTION_POINTER_DOWN) |
| 83 << "Invalid action for GetActionIndex(): " << cached_action_; | 85 << "Invalid action for GetActionIndex(): " << cached_action_; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 | 165 |
| 164 int MotionEventWeb::GetButtonState() const { | 166 int MotionEventWeb::GetButtonState() const { |
| 165 return 0; | 167 return 0; |
| 166 } | 168 } |
| 167 | 169 |
| 168 int MotionEventWeb::GetFlags() const { | 170 int MotionEventWeb::GetFlags() const { |
| 169 return WebEventModifiersToEventFlags(event_.modifiers); | 171 return WebEventModifiersToEventFlags(event_.modifiers); |
| 170 } | 172 } |
| 171 | 173 |
| 172 } // namespace content | 174 } // namespace content |
| OLD | NEW |