| 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 | 15 |
| 16 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
| 17 using blink::WebPointerProperties; |
| 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); |
| 25 switch (event.type) { | 26 switch (event.type) { |
| 26 case WebInputEvent::TouchStart: | 27 case WebInputEvent::TouchStart: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 151 } |
| 151 | 152 |
| 152 base::TimeTicks MotionEventWeb::GetEventTime() const { | 153 base::TimeTicks MotionEventWeb::GetEventTime() const { |
| 153 return base::TimeTicks() + | 154 return base::TimeTicks() + |
| 154 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * | 155 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * |
| 155 base::Time::kMicrosecondsPerSecond); | 156 base::Time::kMicrosecondsPerSecond); |
| 156 } | 157 } |
| 157 | 158 |
| 158 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( | 159 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( |
| 159 size_t pointer_index) const { | 160 size_t pointer_index) const { |
| 160 // TODO(jdduke): Plumb tool type from the platform event, crbug.com/404128. | |
| 161 DCHECK_LT(pointer_index, GetPointerCount()); | 161 DCHECK_LT(pointer_index, GetPointerCount()); |
| 162 return TOOL_TYPE_UNKNOWN; | 162 |
| 163 const WebPointerProperties& pointer = event_.touches[pointer_index]; |
| 164 |
| 165 switch (pointer.pointerType) { |
| 166 case WebPointerProperties::PointerTypeUnknown: |
| 167 return TOOL_TYPE_UNKNOWN; |
| 168 case WebPointerProperties::PointerTypeMouse: |
| 169 return TOOL_TYPE_MOUSE; |
| 170 case WebPointerProperties::PointerTypePen: |
| 171 return TOOL_TYPE_STYLUS; |
| 172 case WebPointerProperties::PointerTypeTouch: |
| 173 return TOOL_TYPE_FINGER; |
| 174 default: |
| 175 NOTREACHED() << "Unhandled pointer type " << pointer.pointerType; |
| 176 return TOOL_TYPE_UNKNOWN; |
| 177 } |
| 163 } | 178 } |
| 164 | 179 |
| 165 int MotionEventWeb::GetButtonState() const { | 180 int MotionEventWeb::GetButtonState() const { |
| 166 return 0; | 181 return 0; |
| 167 } | 182 } |
| 168 | 183 |
| 169 int MotionEventWeb::GetFlags() const { | 184 int MotionEventWeb::GetFlags() const { |
| 170 return WebEventModifiersToEventFlags(event_.modifiers); | 185 return WebEventModifiersToEventFlags(event_.modifiers); |
| 171 } | 186 } |
| 172 | 187 |
| 173 } // namespace content | 188 } // namespace content |
| OLD | NEW |