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 #include "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 | 1916 |
1917 if (device_string == kSourceDeviceStringTouchpad) { | 1917 if (device_string == kSourceDeviceStringTouchpad) { |
1918 event.sourceDevice = blink::WebGestureDeviceTouchpad; | 1918 event.sourceDevice = blink::WebGestureDeviceTouchpad; |
1919 } else if (device_string == kSourceDeviceStringTouchscreen) { | 1919 } else if (device_string == kSourceDeviceStringTouchscreen) { |
1920 event.sourceDevice = blink::WebGestureDeviceTouchscreen; | 1920 event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
1921 } else { | 1921 } else { |
1922 args->ThrowError(); | 1922 args->ThrowError(); |
1923 return; | 1923 return; |
1924 } | 1924 } |
1925 | 1925 |
| 1926 float max_start_velocity = std::max(fabs(velocity_x), fabs(velocity_y)); |
| 1927 if (!max_start_velocity) { |
| 1928 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1929 isolate->ThrowException(v8::Exception::TypeError( |
| 1930 gin::StringToV8(isolate, "Invalid max start velocity."))); |
| 1931 return; |
| 1932 } |
| 1933 |
1926 event.x = x; | 1934 event.x = x; |
1927 event.y = y; | 1935 event.y = y; |
1928 event.globalX = event.x; | 1936 event.globalX = event.x; |
1929 event.globalY = event.y; | 1937 event.globalY = event.y; |
1930 | 1938 |
1931 event.data.flingStart.velocityX = velocity_x; | 1939 event.data.flingStart.velocityX = velocity_x; |
1932 event.data.flingStart.velocityY = velocity_y; | 1940 event.data.flingStart.velocityY = velocity_y; |
1933 event.timeStampSeconds = GetCurrentEventTimeSec(); | 1941 event.timeStampSeconds = GetCurrentEventTimeSec(); |
1934 | 1942 |
1935 if (force_layout_on_events_) | 1943 if (force_layout_on_events_) |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 } | 2864 } |
2857 | 2865 |
2858 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( | 2866 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( |
2859 const WebInputEvent& event) { | 2867 const WebInputEvent& event) { |
2860 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event | 2868 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event |
2861 // does not have to be converted. | 2869 // does not have to be converted. |
2862 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | 2870 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); |
2863 } | 2871 } |
2864 | 2872 |
2865 } // namespace test_runner | 2873 } // namespace test_runner |
OLD | NEW |