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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 int current_buttons, | 217 int current_buttons, |
218 const WebPoint& pos, | 218 const WebPoint& pos, |
219 int click_count, | 219 int click_count, |
220 WebPointerProperties::PointerType pointerType, | 220 WebPointerProperties::PointerType pointerType, |
221 int pointerId, | 221 int pointerId, |
222 float pressure, | 222 float pressure, |
223 int tiltX, | 223 int tiltX, |
224 int tiltY, | 224 int tiltY, |
225 WebMouseEvent* e) { | 225 WebMouseEvent* e) { |
226 e->button = b; | 226 e->button = b; |
227 e->x = pos.x; | 227 e->setPositionInWidget(pos.x, pos.y); |
228 e->y = pos.y; | 228 e->setPositionInScreen(pos.x, pos.y); |
229 e->globalX = pos.x; | |
230 e->globalY = pos.y; | |
231 e->pointerType = pointerType; | 229 e->pointerType = pointerType; |
232 e->id = pointerId; | 230 e->id = pointerId; |
233 e->force = pressure; | 231 e->force = pressure; |
234 e->tiltX = tiltX; | 232 e->tiltX = tiltX; |
235 e->tiltY = tiltY; | 233 e->tiltY = tiltY; |
236 e->clickCount = click_count; | 234 e->clickCount = click_count; |
237 } | 235 } |
238 | 236 |
239 void InitMouseEvent(WebMouseEvent::Button b, | 237 void InitMouseEvent(WebMouseEvent::Button b, |
240 int current_buttons, | 238 int current_buttons, |
241 const WebPoint& pos, | 239 const WebPoint& pos, |
242 int click_count, | 240 int click_count, |
243 WebMouseEvent* e) { | 241 WebMouseEvent* e) { |
244 InitMouseEventGeneric(b, current_buttons, pos, click_count, | 242 InitMouseEventGeneric(b, current_buttons, pos, click_count, |
245 WebPointerProperties::PointerType::Mouse, 0, 0.0, 0, 0, | 243 WebPointerProperties::PointerType::Mouse, 0, 0.0, 0, 0, |
246 e); | 244 e); |
247 } | 245 } |
248 | 246 |
249 void InitGestureEventFromMouseWheel(const WebMouseWheelEvent& wheel_event, | 247 void InitGestureEventFromMouseWheel(const WebMouseWheelEvent& wheel_event, |
250 WebGestureEvent* gesture_event) { | 248 WebGestureEvent* gesture_event) { |
251 gesture_event->sourceDevice = blink::WebGestureDeviceTouchpad; | 249 gesture_event->sourceDevice = blink::WebGestureDeviceTouchpad; |
252 gesture_event->x = wheel_event.x; | 250 gesture_event->x = wheel_event.positionInWidget().x; |
253 gesture_event->y = wheel_event.y; | 251 gesture_event->y = wheel_event.positionInWidget().y; |
254 gesture_event->globalX = wheel_event.globalX; | 252 gesture_event->globalX = wheel_event.positionInScreen().x; |
255 gesture_event->globalY = wheel_event.globalY; | 253 gesture_event->globalY = wheel_event.positionInScreen().y; |
256 } | 254 } |
257 | 255 |
258 int GetKeyModifier(const std::string& modifier_name) { | 256 int GetKeyModifier(const std::string& modifier_name) { |
259 const char* characters = modifier_name.c_str(); | 257 const char* characters = modifier_name.c_str(); |
260 if (!strcmp(characters, "ctrlKey") | 258 if (!strcmp(characters, "ctrlKey") |
261 #ifndef __APPLE__ | 259 #ifndef __APPLE__ |
262 || !strcmp(characters, "addSelectionKey") | 260 || !strcmp(characters, "addSelectionKey") |
263 #endif | 261 #endif |
264 ) { | 262 ) { |
265 return WebInputEvent::ControlKey; | 263 return WebInputEvent::ControlKey; |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 current_pointer_state_[kRawMousePointerId].current_buttons_, | 1352 current_pointer_state_[kRawMousePointerId].current_buttons_, |
1355 current_pointer_state_[kRawMousePointerId].last_pos_, | 1353 current_pointer_state_[kRawMousePointerId].last_pos_, |
1356 click_count_, &raw_event); | 1354 click_count_, &raw_event); |
1357 | 1355 |
1358 std::unique_ptr<WebInputEvent> widget_event = | 1356 std::unique_ptr<WebInputEvent> widget_event = |
1359 TransformScreenToWidgetCoordinates(raw_event); | 1357 TransformScreenToWidgetCoordinates(raw_event); |
1360 const WebMouseEvent* event = | 1358 const WebMouseEvent* event = |
1361 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) | 1359 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) |
1362 : &raw_event; | 1360 : &raw_event; |
1363 | 1361 |
1364 WebPoint client_point(event->x, event->y); | 1362 WebPoint client_point(event->positionInWidget().x, |
1365 WebPoint screen_point(event->globalX, event->globalY); | 1363 event->positionInWidget().y); |
| 1364 WebPoint screen_point(event->positionInScreen().x, |
| 1365 event->positionInScreen().y); |
1366 current_drag_data_ = drag_data; | 1366 current_drag_data_ = drag_data; |
1367 current_drag_effects_allowed_ = mask; | 1367 current_drag_effects_allowed_ = mask; |
1368 current_drag_effect_ = mainFrameWidget()->dragTargetDragEnter( | 1368 current_drag_effect_ = mainFrameWidget()->dragTargetDragEnter( |
1369 drag_data, client_point, screen_point, current_drag_effects_allowed_, | 1369 drag_data, client_point, screen_point, current_drag_effects_allowed_, |
1370 modifiersWithButtons( | 1370 modifiersWithButtons( |
1371 current_pointer_state_[kRawMousePointerId].modifiers_, | 1371 current_pointer_state_[kRawMousePointerId].modifiers_, |
1372 current_pointer_state_[kRawMousePointerId].current_buttons_)); | 1372 current_pointer_state_[kRawMousePointerId].current_buttons_)); |
1373 | 1373 |
1374 // Finish processing events. | 1374 // Finish processing events. |
1375 ReplaySavedEvents(); | 1375 ReplaySavedEvents(); |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 } | 2663 } |
2664 | 2664 |
2665 void EventSender::FinishDragAndDrop(const WebMouseEvent& raw_event, | 2665 void EventSender::FinishDragAndDrop(const WebMouseEvent& raw_event, |
2666 blink::WebDragOperation drag_effect) { | 2666 blink::WebDragOperation drag_effect) { |
2667 std::unique_ptr<WebInputEvent> widget_event = | 2667 std::unique_ptr<WebInputEvent> widget_event = |
2668 TransformScreenToWidgetCoordinates(raw_event); | 2668 TransformScreenToWidgetCoordinates(raw_event); |
2669 const WebMouseEvent* event = | 2669 const WebMouseEvent* event = |
2670 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) | 2670 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) |
2671 : &raw_event; | 2671 : &raw_event; |
2672 | 2672 |
2673 WebPoint client_point(event->x, event->y); | 2673 WebPoint client_point(event->positionInWidget().x, |
2674 WebPoint screen_point(event->globalX, event->globalY); | 2674 event->positionInWidget().y); |
| 2675 WebPoint screen_point(event->positionInScreen().x, |
| 2676 event->positionInScreen().y); |
2675 current_drag_effect_ = drag_effect; | 2677 current_drag_effect_ = drag_effect; |
2676 if (current_drag_effect_) { | 2678 if (current_drag_effect_) { |
2677 // Specifically pass any keyboard modifiers to the drop method. This allows | 2679 // Specifically pass any keyboard modifiers to the drop method. This allows |
2678 // tests to control the drop type (i.e. copy or move). | 2680 // tests to control the drop type (i.e. copy or move). |
2679 mainFrameWidget()->dragTargetDrop(current_drag_data_, client_point, | 2681 mainFrameWidget()->dragTargetDrop(current_drag_data_, client_point, |
2680 screen_point, event->modifiers()); | 2682 screen_point, event->modifiers()); |
2681 } else { | 2683 } else { |
2682 mainFrameWidget()->dragTargetDragLeave(blink::WebPoint(), | 2684 mainFrameWidget()->dragTargetDragLeave(blink::WebPoint(), |
2683 blink::WebPoint()); | 2685 blink::WebPoint()); |
2684 } | 2686 } |
(...skipping 10 matching lines...) Expand all Loading... |
2695 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) | 2697 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) |
2696 : &raw_event; | 2698 : &raw_event; |
2697 | 2699 |
2698 last_click_time_sec_ = event->timeStampSeconds(); | 2700 last_click_time_sec_ = event->timeStampSeconds(); |
2699 last_click_pos_ = current_pointer_state_[kRawMousePointerId].last_pos_; | 2701 last_click_pos_ = current_pointer_state_[kRawMousePointerId].last_pos_; |
2700 | 2702 |
2701 // If we're in a drag operation, complete it. | 2703 // If we're in a drag operation, complete it. |
2702 if (current_drag_data_.isNull()) | 2704 if (current_drag_data_.isNull()) |
2703 return; | 2705 return; |
2704 | 2706 |
2705 WebPoint client_point(event->x, event->y); | 2707 WebPoint client_point(event->positionInWidget().x, |
2706 WebPoint screen_point(event->globalX, event->globalY); | 2708 event->positionInWidget().y); |
| 2709 WebPoint screen_point(event->positionInScreen().x, |
| 2710 event->positionInScreen().y); |
2707 blink::WebDragOperation drag_effect = mainFrameWidget()->dragTargetDragOver( | 2711 blink::WebDragOperation drag_effect = mainFrameWidget()->dragTargetDragOver( |
2708 client_point, screen_point, current_drag_effects_allowed_, | 2712 client_point, screen_point, current_drag_effects_allowed_, |
2709 event->modifiers()); | 2713 event->modifiers()); |
2710 | 2714 |
2711 // Bail if dragover caused cancellation. | 2715 // Bail if dragover caused cancellation. |
2712 if (current_drag_data_.isNull()) | 2716 if (current_drag_data_.isNull()) |
2713 return; | 2717 return; |
2714 | 2718 |
2715 FinishDragAndDrop(raw_event, drag_effect); | 2719 FinishDragAndDrop(raw_event, drag_effect); |
2716 } | 2720 } |
2717 | 2721 |
2718 void EventSender::DoDragAfterMouseMove(const WebMouseEvent& raw_event) { | 2722 void EventSender::DoDragAfterMouseMove(const WebMouseEvent& raw_event) { |
2719 if (current_pointer_state_[kRawMousePointerId].pressed_button_ == | 2723 if (current_pointer_state_[kRawMousePointerId].pressed_button_ == |
2720 WebMouseEvent::Button::NoButton || | 2724 WebMouseEvent::Button::NoButton || |
2721 current_drag_data_.isNull()) { | 2725 current_drag_data_.isNull()) { |
2722 return; | 2726 return; |
2723 } | 2727 } |
2724 | 2728 |
2725 std::unique_ptr<WebInputEvent> widget_event = | 2729 std::unique_ptr<WebInputEvent> widget_event = |
2726 TransformScreenToWidgetCoordinates(raw_event); | 2730 TransformScreenToWidgetCoordinates(raw_event); |
2727 const WebMouseEvent* event = | 2731 const WebMouseEvent* event = |
2728 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) | 2732 widget_event.get() ? static_cast<WebMouseEvent*>(widget_event.get()) |
2729 : &raw_event; | 2733 : &raw_event; |
2730 | 2734 |
2731 WebPoint client_point(event->x, event->y); | 2735 WebPoint client_point(event->positionInWidget().x, |
2732 WebPoint screen_point(event->globalX, event->globalY); | 2736 event->positionInWidget().y); |
| 2737 WebPoint screen_point(event->positionInScreen().x, |
| 2738 event->positionInScreen().y); |
2733 current_drag_effect_ = mainFrameWidget()->dragTargetDragOver( | 2739 current_drag_effect_ = mainFrameWidget()->dragTargetDragOver( |
2734 client_point, screen_point, current_drag_effects_allowed_, | 2740 client_point, screen_point, current_drag_effects_allowed_, |
2735 event->modifiers()); | 2741 event->modifiers()); |
2736 } | 2742 } |
2737 | 2743 |
2738 void EventSender::ReplaySavedEvents() { | 2744 void EventSender::ReplaySavedEvents() { |
2739 replaying_saved_events_ = true; | 2745 replaying_saved_events_ = true; |
2740 while (!mouse_event_queue_.empty()) { | 2746 while (!mouse_event_queue_.empty()) { |
2741 SavedEvent e = mouse_event_queue_.front(); | 2747 SavedEvent e = mouse_event_queue_.front(); |
2742 mouse_event_queue_.pop_front(); | 2748 mouse_event_queue_.pop_front(); |
2743 | 2749 |
2744 switch (e.type) { | 2750 switch (e.type) { |
2745 case SavedEvent::TYPE_MOUSE_MOVE: { | 2751 case SavedEvent::TYPE_MOUSE_MOVE: { |
2746 current_pointer_state_[kRawMousePointerId].modifiers_ = e.modifiers; | 2752 current_pointer_state_[kRawMousePointerId].modifiers_ = e.modifiers; |
2747 WebMouseEvent event(WebInputEvent::MouseMove, | 2753 WebMouseEvent event(WebInputEvent::MouseMove, |
2748 ModifiersForPointer(kRawMousePointerId), | 2754 ModifiersForPointer(kRawMousePointerId), |
2749 GetCurrentEventTimeSec()); | 2755 GetCurrentEventTimeSec()); |
2750 InitMouseEvent( | 2756 InitMouseEvent( |
2751 current_pointer_state_[kRawMousePointerId].pressed_button_, | 2757 current_pointer_state_[kRawMousePointerId].pressed_button_, |
2752 current_pointer_state_[kRawMousePointerId].current_buttons_, e.pos, | 2758 current_pointer_state_[kRawMousePointerId].current_buttons_, e.pos, |
2753 click_count_, &event); | 2759 click_count_, &event); |
2754 current_pointer_state_[kRawMousePointerId].last_pos_ = | 2760 current_pointer_state_[kRawMousePointerId].last_pos_ = |
2755 WebPoint(event.x, event.y); | 2761 WebPoint(event.positionInWidget().x, event.positionInWidget().y); |
2756 HandleInputEventOnViewOrPopup(event); | 2762 HandleInputEventOnViewOrPopup(event); |
2757 DoDragAfterMouseMove(event); | 2763 DoDragAfterMouseMove(event); |
2758 break; | 2764 break; |
2759 } | 2765 } |
2760 case SavedEvent::TYPE_LEAP_FORWARD: | 2766 case SavedEvent::TYPE_LEAP_FORWARD: |
2761 DoLeapForward(e.milliseconds); | 2767 DoLeapForward(e.milliseconds); |
2762 break; | 2768 break; |
2763 case SavedEvent::TYPE_MOUSE_UP: { | 2769 case SavedEvent::TYPE_MOUSE_UP: { |
2764 current_pointer_state_[kRawMousePointerId].current_buttons_ &= | 2770 current_pointer_state_[kRawMousePointerId].current_buttons_ &= |
2765 ~GetWebMouseEventModifierForButton(e.button_type); | 2771 ~GetWebMouseEventModifierForButton(e.button_type); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2892 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); | 2898 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); |
2893 } | 2899 } |
2894 | 2900 |
2895 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( | 2901 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( |
2896 const WebInputEvent& event) { | 2902 const WebInputEvent& event) { |
2897 return delegate()->TransformScreenToWidgetCoordinates( | 2903 return delegate()->TransformScreenToWidgetCoordinates( |
2898 web_widget_test_proxy_base_, event); | 2904 web_widget_test_proxy_base_, event); |
2899 } | 2905 } |
2900 | 2906 |
2901 } // namespace test_runner | 2907 } // namespace test_runner |
OLD | NEW |