| 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 "content/shell/test_runner/event_sender.h" | 5 #include "content/shell/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 const int kRawMousePointerId = -1; | 76 const int kRawMousePointerId = -1; |
| 77 const char* const kPointerTypeStringUnknown = ""; | 77 const char* const kPointerTypeStringUnknown = ""; |
| 78 const char* const kPointerTypeStringMouse = "mouse"; | 78 const char* const kPointerTypeStringMouse = "mouse"; |
| 79 const char* const kPointerTypeStringTouch = "touch"; | 79 const char* const kPointerTypeStringTouch = "touch"; |
| 80 const char* const kPointerTypeStringPen = "pen"; | 80 const char* const kPointerTypeStringPen = "pen"; |
| 81 const char* const kPointerTypeStringEraser = "eraser"; | 81 const char* const kPointerTypeStringEraser = "eraser"; |
| 82 | 82 |
| 83 // Assigns |pointerType| from the provided |args|. Returns false if there was | 83 // Assigns |pointerType| from the provided |args|. Returns false if there was |
| 84 // any error. | 84 // any error. |
| 85 bool getPointerType(gin::Arguments* args, | 85 bool GetPointerType(gin::Arguments* args, |
| 86 bool isOnlyMouseAndPenAllowed, | 86 bool isOnlyMouseAndPenAllowed, |
| 87 WebPointerProperties::PointerType& pointerType) { | 87 WebPointerProperties::PointerType& pointerType) { |
| 88 if (args->PeekNext().IsEmpty()) | 88 if (args->PeekNext().IsEmpty()) |
| 89 return true; | 89 return true; |
| 90 std::string pointer_type_string; | 90 std::string pointer_type_string; |
| 91 if (!args->GetNext(&pointer_type_string)) { | 91 if (!args->GetNext(&pointer_type_string)) { |
| 92 args->ThrowError(); | 92 args->ThrowError(); |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 if (isOnlyMouseAndPenAllowed && | 95 if (isOnlyMouseAndPenAllowed && |
| (...skipping 29 matching lines...) Expand all Loading... |
| 125 float& pressure, | 125 float& pressure, |
| 126 int& tiltX, | 126 int& tiltX, |
| 127 int& tiltY) { | 127 int& tiltY) { |
| 128 pointerType = WebPointerProperties::PointerType::kMouse; | 128 pointerType = WebPointerProperties::PointerType::kMouse; |
| 129 rawPointerId = kRawMousePointerId; | 129 rawPointerId = kRawMousePointerId; |
| 130 pressure = std::numeric_limits<float>::quiet_NaN(); | 130 pressure = std::numeric_limits<float>::quiet_NaN(); |
| 131 tiltX = 0; | 131 tiltX = 0; |
| 132 tiltY = 0; | 132 tiltY = 0; |
| 133 | 133 |
| 134 // Only allow pen or mouse through this API. | 134 // Only allow pen or mouse through this API. |
| 135 if (!getPointerType(args, false, pointerType)) | 135 if (!GetPointerType(args, false, pointerType)) |
| 136 return false; | 136 return false; |
| 137 if (!args->PeekNext().IsEmpty()) { | 137 if (!args->PeekNext().IsEmpty()) { |
| 138 if (!args->GetNext(&rawPointerId)) { | 138 if (!args->GetNext(&rawPointerId)) { |
| 139 args->ThrowError(); | 139 args->ThrowError(); |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Parse optional params | 143 // Parse optional params |
| 144 if (!args->PeekNext().IsEmpty()) { | 144 if (!args->PeekNext().IsEmpty()) { |
| 145 if (!args->GetNext(&pressure)) { | 145 if (!args->GetNext(&pressure)) { |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1016 |
| 1017 void EventSenderBindings::MouseLeave(gin::Arguments* args) { | 1017 void EventSenderBindings::MouseLeave(gin::Arguments* args) { |
| 1018 if (!sender_) | 1018 if (!sender_) |
| 1019 return; | 1019 return; |
| 1020 | 1020 |
| 1021 WebPointerProperties::PointerType pointerType = | 1021 WebPointerProperties::PointerType pointerType = |
| 1022 WebPointerProperties::PointerType::kMouse; | 1022 WebPointerProperties::PointerType::kMouse; |
| 1023 int pointerId = kRawMousePointerId; | 1023 int pointerId = kRawMousePointerId; |
| 1024 | 1024 |
| 1025 // Only allow pen or mouse through this API. | 1025 // Only allow pen or mouse through this API. |
| 1026 if (!getPointerType(args, false, pointerType)) | 1026 if (!GetPointerType(args, false, pointerType)) |
| 1027 return; | 1027 return; |
| 1028 if (!args->PeekNext().IsEmpty()) { | 1028 if (!args->PeekNext().IsEmpty()) { |
| 1029 if (!args->GetNext(&pointerId)) { | 1029 if (!args->GetNext(&pointerId)) { |
| 1030 args->ThrowError(); | 1030 args->ThrowError(); |
| 1031 return; | 1031 return; |
| 1032 } | 1032 } |
| 1033 } | 1033 } |
| 1034 sender_->MouseLeave(pointerType, pointerId); | 1034 sender_->MouseLeave(pointerType, pointerId); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2518 } | 2518 } |
| 2519 event.data.two_finger_tap.first_finger_height = first_finger_height; | 2519 event.data.two_finger_tap.first_finger_height = first_finger_height; |
| 2520 } | 2520 } |
| 2521 } | 2521 } |
| 2522 break; | 2522 break; |
| 2523 default: | 2523 default: |
| 2524 NOTREACHED(); | 2524 NOTREACHED(); |
| 2525 } | 2525 } |
| 2526 | 2526 |
| 2527 event.unique_touch_event_id = GetUniqueTouchEventId(args); | 2527 event.unique_touch_event_id = GetUniqueTouchEventId(args); |
| 2528 if (!GetPointerType(args, false, event.primary_pointer_type)) |
| 2529 return; |
| 2528 | 2530 |
| 2529 event.global_x = event.x; | 2531 event.global_x = event.x; |
| 2530 event.global_y = event.y; | 2532 event.global_y = event.y; |
| 2531 | 2533 |
| 2532 if (force_layout_on_events_) | 2534 if (force_layout_on_events_) |
| 2533 widget()->UpdateAllLifecyclePhases(); | 2535 widget()->UpdateAllLifecyclePhases(); |
| 2534 | 2536 |
| 2535 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); | 2537 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); |
| 2536 | 2538 |
| 2537 // Long press might start a drag drop session. Complete it if so. | 2539 // Long press might start a drag drop session. Complete it if so. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2667 if (!args->PeekNext().IsEmpty()) { | 2669 if (!args->PeekNext().IsEmpty()) { |
| 2668 int tiltX, tiltY; | 2670 int tiltX, tiltY; |
| 2669 if (!args->GetNext(&tiltX) || !args->GetNext(&tiltY)) { | 2671 if (!args->GetNext(&tiltX) || !args->GetNext(&tiltY)) { |
| 2670 args->ThrowError(); | 2672 args->ThrowError(); |
| 2671 return; | 2673 return; |
| 2672 } | 2674 } |
| 2673 e->tilt_x = tiltX; | 2675 e->tilt_x = tiltX; |
| 2674 e->tilt_y = tiltY; | 2676 e->tilt_y = tiltY; |
| 2675 } | 2677 } |
| 2676 | 2678 |
| 2677 if (!getPointerType(args, false, e->pointer_type)) | 2679 if (!GetPointerType(args, false, e->pointer_type)) |
| 2678 return; | 2680 return; |
| 2679 } | 2681 } |
| 2680 | 2682 |
| 2681 void EventSender::FinishDragAndDrop(const WebMouseEvent& raw_event, | 2683 void EventSender::FinishDragAndDrop(const WebMouseEvent& raw_event, |
| 2682 blink::WebDragOperation drag_effect) { | 2684 blink::WebDragOperation drag_effect) { |
| 2683 std::unique_ptr<WebInputEvent> widget_event = | 2685 std::unique_ptr<WebInputEvent> widget_event = |
| 2684 TransformScreenToWidgetCoordinates(raw_event); | 2686 TransformScreenToWidgetCoordinates(raw_event); |
| 2685 const WebMouseEvent* event = | 2687 const WebMouseEvent* event = |
| 2686 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) | 2688 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) |
| 2687 : &raw_event; | 2689 : &raw_event; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 return view()->MainFrame()->ToWebLocalFrame()->FrameWidget(); | 2918 return view()->MainFrame()->ToWebLocalFrame()->FrameWidget(); |
| 2917 } | 2919 } |
| 2918 | 2920 |
| 2919 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( | 2921 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( |
| 2920 const WebInputEvent& event) { | 2922 const WebInputEvent& event) { |
| 2921 return delegate()->TransformScreenToWidgetCoordinates( | 2923 return delegate()->TransformScreenToWidgetCoordinates( |
| 2922 web_widget_test_proxy_base_, event); | 2924 web_widget_test_proxy_base_, event); |
| 2923 } | 2925 } |
| 2924 | 2926 |
| 2925 } // namespace test_runner | 2927 } // namespace test_runner |
| OLD | NEW |