| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/events/blink/blink_event_util.h" | 8 #include "ui/events/blink/blink_event_util.h" | 
| 9 | 9 | 
| 10 #include <stddef.h> | 10 #include <stddef.h> | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138     return WebPointerProperties::Button::kNoButton; | 138     return WebPointerProperties::Button::kNoButton; | 
| 139 } | 139 } | 
| 140 | 140 | 
| 141 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, | 141 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, | 
| 142                                   size_t pointer_index) { | 142                                   size_t pointer_index) { | 
| 143   WebTouchPoint touch; | 143   WebTouchPoint touch; | 
| 144 | 144 | 
| 145   SetWebPointerPropertiesFromMotionEventData( | 145   SetWebPointerPropertiesFromMotionEventData( | 
| 146       touch, event.GetPointerId(pointer_index), | 146       touch, event.GetPointerId(pointer_index), | 
| 147       event.GetPressure(pointer_index), event.GetOrientation(pointer_index), | 147       event.GetPressure(pointer_index), event.GetOrientation(pointer_index), | 
| 148       event.GetTilt(pointer_index), 0 /* no button changed */, | 148       event.GetTiltX(pointer_index), event.GetTiltY(pointer_index), | 
| 149       event.GetToolType(pointer_index)); | 149       0 /* no button changed */, event.GetToolType(pointer_index)); | 
| 150 | 150 | 
| 151   touch.state = ToWebTouchPointState(event, pointer_index); | 151   touch.state = ToWebTouchPointState(event, pointer_index); | 
| 152   touch.position.x = event.GetX(pointer_index); | 152   touch.position.x = event.GetX(pointer_index); | 
| 153   touch.position.y = event.GetY(pointer_index); | 153   touch.position.y = event.GetY(pointer_index); | 
| 154   touch.screen_position.x = event.GetRawX(pointer_index); | 154   touch.screen_position.x = event.GetRawX(pointer_index); | 
| 155   touch.screen_position.y = event.GetRawY(pointer_index); | 155   touch.screen_position.y = event.GetRawY(pointer_index); | 
| 156 | 156 | 
| 157   // A note on touch ellipse specifications: | 157   // A note on touch ellipse specifications: | 
| 158   // | 158   // | 
| 159   // Android MotionEvent provides the major and minor axes of the touch ellipse, | 159   // Android MotionEvent provides the major and minor axes of the touch ellipse, | 
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 890   } | 890   } | 
| 891   NOTREACHED() << "Invalid MotionEvent::Action = " << action; | 891   NOTREACHED() << "Invalid MotionEvent::Action = " << action; | 
| 892   return WebInputEvent::kUndefined; | 892   return WebInputEvent::kUndefined; | 
| 893 } | 893 } | 
| 894 | 894 | 
| 895 void SetWebPointerPropertiesFromMotionEventData( | 895 void SetWebPointerPropertiesFromMotionEventData( | 
| 896     WebPointerProperties& webPointerProperties, | 896     WebPointerProperties& webPointerProperties, | 
| 897     int pointer_id, | 897     int pointer_id, | 
| 898     float pressure, | 898     float pressure, | 
| 899     float orientation_rad, | 899     float orientation_rad, | 
| 900     float tilt_rad, | 900     float tilt_x, | 
|  | 901     float tilt_y, | 
| 901     int android_buttons_changed, | 902     int android_buttons_changed, | 
| 902     int tool_type) { | 903     int tool_type) { | 
| 903 |  | 
| 904   webPointerProperties.id = pointer_id; | 904   webPointerProperties.id = pointer_id; | 
| 905   webPointerProperties.force = pressure; | 905   webPointerProperties.force = pressure; | 
| 906 | 906 | 
| 907   if (tool_type == MotionEvent::TOOL_TYPE_STYLUS) { | 907   if (tool_type == MotionEvent::TOOL_TYPE_STYLUS) { | 
| 908     // A stylus points to a direction specified by orientation and tilts to | 908     // A stylus points to a direction specified by orientation and tilts to | 
| 909     // the opposite direction. Coordinate system is left-handed. | 909     // the opposite direction. Coordinate system is left-handed. | 
| 910     float r = sin(tilt_rad); | 910     webPointerProperties.tilt_x = tilt_x; | 
| 911     float z = cos(tilt_rad); | 911     webPointerProperties.tilt_y = tilt_y; | 
| 912     webPointerProperties.tilt_x = |  | 
| 913         lround(atan2(sin(-orientation_rad) * r, z) * 180.f / M_PI); |  | 
| 914     webPointerProperties.tilt_y = |  | 
| 915         lround(atan2(cos(-orientation_rad) * r, z) * 180.f / M_PI); |  | 
| 916   } else { | 912   } else { | 
| 917     webPointerProperties.tilt_x = webPointerProperties.tilt_y = 0; | 913     webPointerProperties.tilt_x = webPointerProperties.tilt_y = 0; | 
| 918   } | 914   } | 
| 919 | 915 | 
| 920   webPointerProperties.button = ToWebPointerButton(android_buttons_changed); | 916   webPointerProperties.button = ToWebPointerButton(android_buttons_changed); | 
| 921   webPointerProperties.pointer_type = ToWebPointerType(tool_type); | 917   webPointerProperties.pointer_type = ToWebPointerType(tool_type); | 
| 922 } | 918 } | 
| 923 | 919 | 
| 924 int WebEventModifiersToEventFlags(int modifiers) { | 920 int WebEventModifiersToEventFlags(int modifiers) { | 
| 925   int flags = 0; | 921   int flags = 0; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 988   switch (type) { | 984   switch (type) { | 
| 989     case blink::WebGestureEvent::kGestureScrollUpdate: | 985     case blink::WebGestureEvent::kGestureScrollUpdate: | 
| 990     case blink::WebGestureEvent::kGesturePinchUpdate: | 986     case blink::WebGestureEvent::kGesturePinchUpdate: | 
| 991       return true; | 987       return true; | 
| 992     default: | 988     default: | 
| 993       return false; | 989       return false; | 
| 994   } | 990   } | 
| 995 } | 991 } | 
| 996 | 992 | 
| 997 }  // namespace ui | 993 }  // namespace ui | 
| OLD | NEW | 
|---|