OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_benchmarking_extension.h" | 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; | 967 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; |
968 | 968 |
969 if (!GetArg(args, &position_x) || | 969 if (!GetArg(args, &position_x) || |
970 !GetArg(args, &position_y) || | 970 !GetArg(args, &position_y) || |
971 !GetOptionalArg(args, &callback) || | 971 !GetOptionalArg(args, &callback) || |
972 !GetOptionalArg(args, &duration_ms) || | 972 !GetOptionalArg(args, &duration_ms) || |
973 !GetOptionalArg(args, &gesture_source_type)) { | 973 !GetOptionalArg(args, &gesture_source_type)) { |
974 return false; | 974 return false; |
975 } | 975 } |
976 | 976 |
| 977 // Convert coordinates from CSS pixels to density independent pixels (DIPs). |
| 978 float page_scale_factor = context.web_view()->PageScaleFactor(); |
| 979 gfx::Rect rect = context.render_view_impl()->GetWidget()->ViewRect(); |
| 980 rect -= rect.OffsetFromOrigin(); |
| 981 if (!rect.Contains(position_x * page_scale_factor, |
| 982 position_y * page_scale_factor)) { |
| 983 args->ThrowError(); |
| 984 return false; |
| 985 } |
| 986 |
977 std::unique_ptr<SyntheticTapGestureParams> gesture_params( | 987 std::unique_ptr<SyntheticTapGestureParams> gesture_params( |
978 new SyntheticTapGestureParams); | 988 new SyntheticTapGestureParams); |
979 | 989 |
980 // Convert coordinates from CSS pixels to density independent pixels (DIPs). | |
981 float page_scale_factor = context.web_view()->PageScaleFactor(); | |
982 | |
983 gesture_params->position.SetPoint(position_x * page_scale_factor, | 990 gesture_params->position.SetPoint(position_x * page_scale_factor, |
984 position_y * page_scale_factor); | 991 position_y * page_scale_factor); |
985 gesture_params->duration_ms = duration_ms; | 992 gesture_params->duration_ms = duration_ms; |
986 | 993 |
987 if (gesture_source_type < 0 || | 994 if (gesture_source_type < 0 || |
988 gesture_source_type > SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX) { | 995 gesture_source_type > SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX) { |
989 return false; | 996 return false; |
990 } | 997 } |
991 gesture_params->gesture_source_type = | 998 gesture_params->gesture_source_type = |
992 static_cast<SyntheticGestureParams::GestureSourceType>( | 999 static_cast<SyntheticGestureParams::GestureSourceType>( |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 &gpu_driver_bug_workarounds))) { | 1137 &gpu_driver_bug_workarounds))) { |
1131 return; | 1138 return; |
1132 } | 1139 } |
1133 | 1140 |
1134 v8::Local<v8::Value> result; | 1141 v8::Local<v8::Value> result; |
1135 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1142 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
1136 args->Return(result); | 1143 args->Return(result); |
1137 } | 1144 } |
1138 | 1145 |
1139 } // namespace content | 1146 } // namespace content |
OLD | NEW |