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 <memory> | |
10 | |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 20 #include "build/build_config.h" |
19 #include "components/test_runner/mock_spell_check.h" | 21 #include "components/test_runner/mock_spell_check.h" |
20 #include "components/test_runner/test_interfaces.h" | 22 #include "components/test_runner/test_interfaces.h" |
21 #include "components/test_runner/web_test_delegate.h" | 23 #include "components/test_runner/web_test_delegate.h" |
22 #include "components/test_runner/web_view_test_proxy.h" | 24 #include "components/test_runner/web_view_test_proxy.h" |
25 #include "components/test_runner/web_widget_test_proxy.h" | |
23 #include "gin/handle.h" | 26 #include "gin/handle.h" |
24 #include "gin/object_template_builder.h" | 27 #include "gin/object_template_builder.h" |
25 #include "gin/wrappable.h" | 28 #include "gin/wrappable.h" |
26 #include "third_party/WebKit/public/platform/WebPointerProperties.h" | 29 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
27 #include "third_party/WebKit/public/platform/WebString.h" | 30 #include "third_party/WebKit/public/platform/WebString.h" |
28 #include "third_party/WebKit/public/platform/WebVector.h" | 31 #include "third_party/WebKit/public/platform/WebVector.h" |
29 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 32 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
30 #include "third_party/WebKit/public/web/WebKit.h" | 33 #include "third_party/WebKit/public/web/WebKit.h" |
31 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 34 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
32 #include "third_party/WebKit/public/web/WebPagePopup.h" | 35 #include "third_party/WebKit/public/web/WebPagePopup.h" |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 | 1276 |
1274 WebMouseEvent::Button EventSender::last_button_type_ = | 1277 WebMouseEvent::Button EventSender::last_button_type_ = |
1275 WebMouseEvent::Button::NoButton; | 1278 WebMouseEvent::Button::NoButton; |
1276 | 1279 |
1277 EventSender::SavedEvent::SavedEvent() | 1280 EventSender::SavedEvent::SavedEvent() |
1278 : type(TYPE_UNSPECIFIED), | 1281 : type(TYPE_UNSPECIFIED), |
1279 button_type(WebMouseEvent::Button::NoButton), | 1282 button_type(WebMouseEvent::Button::NoButton), |
1280 milliseconds(0), | 1283 milliseconds(0), |
1281 modifiers(0) {} | 1284 modifiers(0) {} |
1282 | 1285 |
1283 EventSender::EventSender(WebViewTestProxyBase* web_view_test_proxy_base) | 1286 EventSender::EventSender(WebWidgetTestProxyBase* web_widget_test_proxy_base) |
1284 : web_view_test_proxy_base_(web_view_test_proxy_base), | 1287 : web_widget_test_proxy_base_(web_widget_test_proxy_base), |
1285 replaying_saved_events_(false), | 1288 replaying_saved_events_(false), |
1286 weak_factory_(this) { | 1289 weak_factory_(this) { |
1287 Reset(); | 1290 Reset(); |
1288 } | 1291 } |
1289 | 1292 |
1290 EventSender::~EventSender() {} | 1293 EventSender::~EventSender() {} |
1291 | 1294 |
1292 void EventSender::Reset() { | 1295 void EventSender::Reset() { |
1293 DCHECK(current_drag_data_.isNull()); | 1296 DCHECK(current_drag_data_.isNull()); |
1294 current_drag_data_.reset(); | 1297 current_drag_data_.reset(); |
1295 current_drag_effect_ = blink::WebDragOperationNone; | 1298 current_drag_effect_ = blink::WebDragOperationNone; |
1296 current_drag_effects_allowed_ = blink::WebDragOperationNone; | 1299 current_drag_effects_allowed_ = blink::WebDragOperationNone; |
1297 if (view() && | 1300 if (widget() && |
1298 current_pointer_state_[kRawMousePointerId].pressed_button_ != | 1301 current_pointer_state_[kRawMousePointerId].pressed_button_ != |
1299 WebMouseEvent::Button::NoButton) | 1302 WebMouseEvent::Button::NoButton) |
1300 view()->mouseCaptureLost(); | 1303 widget()->mouseCaptureLost(); |
1301 current_pointer_state_.clear(); | 1304 current_pointer_state_.clear(); |
1302 is_drag_mode_ = true; | 1305 is_drag_mode_ = true; |
1303 force_layout_on_events_ = true; | 1306 force_layout_on_events_ = true; |
1304 | 1307 |
1305 #if defined(OS_WIN) | 1308 #if defined(OS_WIN) |
1306 wm_key_down_ = WM_KEYDOWN; | 1309 wm_key_down_ = WM_KEYDOWN; |
1307 wm_key_up_ = WM_KEYUP; | 1310 wm_key_up_ = WM_KEYUP; |
1308 wm_char_ = WM_CHAR; | 1311 wm_char_ = WM_CHAR; |
1309 wm_dead_char_ = WM_DEADCHAR; | 1312 wm_dead_char_ = WM_DEADCHAR; |
1310 wm_sys_key_down_ = WM_SYSKEYDOWN; | 1313 wm_sys_key_down_ = WM_SYSKEYDOWN; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1342 WebDragOperationsMask mask) { | 1345 WebDragOperationsMask mask) { |
1343 WebMouseEvent unscaled_event; | 1346 WebMouseEvent unscaled_event; |
1344 InitMouseEvent(WebInputEvent::MouseDown, | 1347 InitMouseEvent(WebInputEvent::MouseDown, |
1345 current_pointer_state_[kRawMousePointerId].pressed_button_, | 1348 current_pointer_state_[kRawMousePointerId].pressed_button_, |
1346 current_pointer_state_[kRawMousePointerId].current_buttons_, | 1349 current_pointer_state_[kRawMousePointerId].current_buttons_, |
1347 current_pointer_state_[kRawMousePointerId].last_pos_, | 1350 current_pointer_state_[kRawMousePointerId].last_pos_, |
1348 GetCurrentEventTimeSec(), click_count_, | 1351 GetCurrentEventTimeSec(), click_count_, |
1349 current_pointer_state_[kRawMousePointerId].modifiers_, | 1352 current_pointer_state_[kRawMousePointerId].modifiers_, |
1350 &unscaled_event); | 1353 &unscaled_event); |
1351 | 1354 |
1352 std::unique_ptr<WebInputEvent> scaled_event = ScaleEvent(unscaled_event); | 1355 std::unique_ptr<WebInputEvent> scaled_event = |
lfg
2016/09/29 22:12:52
This is doing more than scaling, rename it?
Łukasz Anforowicz
2016/09/29 23:42:35
Done (in patchset 8):
- s/unscaled_event/raw_event
| |
1353 const WebMouseEvent* event = | 1356 TransformScreenToWidgetCoordinates(unscaled_event); |
1354 scaled_event.get() ? static_cast<WebMouseEvent*>(scaled_event.get()) | 1357 const WebMouseEvent* event = static_cast<WebMouseEvent*>(scaled_event.get()); |
1355 : &unscaled_event; | |
1356 | 1358 |
1357 WebPoint client_point(event->x, event->y); | 1359 WebPoint client_point(event->x, event->y); |
1358 WebPoint screen_point(event->globalX, event->globalY); | 1360 WebPoint screen_point(event->globalX, event->globalY); |
1359 current_drag_data_ = drag_data; | 1361 current_drag_data_ = drag_data; |
1360 current_drag_effects_allowed_ = mask; | 1362 current_drag_effects_allowed_ = mask; |
1361 current_drag_effect_ = view()->dragTargetDragEnter( | 1363 current_drag_effect_ = view()->dragTargetDragEnter( |
1362 drag_data, client_point, screen_point, current_drag_effects_allowed_, | 1364 drag_data, client_point, screen_point, current_drag_effects_allowed_, |
1363 modifiersWithButtons( | 1365 modifiersWithButtons( |
1364 current_pointer_state_[kRawMousePointerId].modifiers_, | 1366 current_pointer_state_[kRawMousePointerId].modifiers_, |
1365 current_pointer_state_[kRawMousePointerId].current_buttons_)); | 1367 current_pointer_state_[kRawMousePointerId].current_buttons_)); |
(...skipping 14 matching lines...) Expand all Loading... | |
1380 } | 1382 } |
1381 | 1383 |
1382 void EventSender::PointerDown(int button_number, | 1384 void EventSender::PointerDown(int button_number, |
1383 int modifiers, | 1385 int modifiers, |
1384 WebPointerProperties::PointerType pointerType, | 1386 WebPointerProperties::PointerType pointerType, |
1385 int pointerId, | 1387 int pointerId, |
1386 float pressure, | 1388 float pressure, |
1387 int tiltX, | 1389 int tiltX, |
1388 int tiltY) { | 1390 int tiltY) { |
1389 if (force_layout_on_events_) | 1391 if (force_layout_on_events_) |
1390 view()->updateAllLifecyclePhases(); | 1392 widget()->updateAllLifecyclePhases(); |
1391 | 1393 |
1392 DCHECK_NE(-1, button_number); | 1394 DCHECK_NE(-1, button_number); |
1393 | 1395 |
1394 WebMouseEvent::Button button_type = | 1396 WebMouseEvent::Button button_type = |
1395 GetButtonTypeFromButtonNumber(button_number); | 1397 GetButtonTypeFromButtonNumber(button_number); |
1396 | 1398 |
1397 WebMouseEvent event; | 1399 WebMouseEvent event; |
1398 int click_count = 0; | 1400 int click_count = 0; |
1399 current_pointer_state_[pointerId].pressed_button_ = button_type; | 1401 current_pointer_state_[pointerId].pressed_button_ = button_type; |
1400 current_pointer_state_[pointerId].current_buttons_ |= | 1402 current_pointer_state_[pointerId].current_buttons_ |= |
(...skipping 16 matching lines...) Expand all Loading... | |
1417 } | 1419 } |
1418 | 1420 |
1419 void EventSender::PointerUp(int button_number, | 1421 void EventSender::PointerUp(int button_number, |
1420 int modifiers, | 1422 int modifiers, |
1421 WebPointerProperties::PointerType pointerType, | 1423 WebPointerProperties::PointerType pointerType, |
1422 int pointerId, | 1424 int pointerId, |
1423 float pressure, | 1425 float pressure, |
1424 int tiltX, | 1426 int tiltX, |
1425 int tiltY) { | 1427 int tiltY) { |
1426 if (force_layout_on_events_) | 1428 if (force_layout_on_events_) |
1427 view()->updateAllLifecyclePhases(); | 1429 widget()->updateAllLifecyclePhases(); |
1428 | 1430 |
1429 DCHECK_NE(-1, button_number); | 1431 DCHECK_NE(-1, button_number); |
1430 | 1432 |
1431 WebMouseEvent::Button button_type = | 1433 WebMouseEvent::Button button_type = |
1432 GetButtonTypeFromButtonNumber(button_number); | 1434 GetButtonTypeFromButtonNumber(button_number); |
1433 | 1435 |
1434 if (pointerType == WebPointerProperties::PointerType::Mouse && | 1436 if (pointerType == WebPointerProperties::PointerType::Mouse && |
1435 is_drag_mode_ && !replaying_saved_events_) { | 1437 is_drag_mode_ && !replaying_saved_events_) { |
1436 SavedEvent saved_event; | 1438 SavedEvent saved_event; |
1437 saved_event.type = SavedEvent::TYPE_MOUSE_UP; | 1439 saved_event.type = SavedEvent::TYPE_MOUSE_UP; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1686 event_down.modifiers |= WebInputEvent::IsKeyPad; | 1688 event_down.modifiers |= WebInputEvent::IsKeyPad; |
1687 break; | 1689 break; |
1688 } | 1690 } |
1689 | 1691 |
1690 WebKeyboardEvent event_up; | 1692 WebKeyboardEvent event_up; |
1691 event_up = event_down; | 1693 event_up = event_down; |
1692 event_up.type = WebInputEvent::KeyUp; | 1694 event_up.type = WebInputEvent::KeyUp; |
1693 // EventSender.m forces a layout here, with at least one | 1695 // EventSender.m forces a layout here, with at least one |
1694 // test (fast/forms/focus-control-to-page.html) relying on this. | 1696 // test (fast/forms/focus-control-to-page.html) relying on this. |
1695 if (force_layout_on_events_) | 1697 if (force_layout_on_events_) |
1696 view()->updateAllLifecyclePhases(); | 1698 widget()->updateAllLifecyclePhases(); |
1697 | 1699 |
1698 // In the browser, if a keyboard event corresponds to an editor command, | 1700 // In the browser, if a keyboard event corresponds to an editor command, |
1699 // the command will be dispatched to the renderer just before dispatching | 1701 // the command will be dispatched to the renderer just before dispatching |
1700 // the keyboard event, and then it will be executed in the | 1702 // the keyboard event, and then it will be executed in the |
1701 // RenderView::handleCurrentKeyboardEvent() method. | 1703 // RenderView::handleCurrentKeyboardEvent() method. |
1702 // We just simulate the same behavior here. | 1704 // We just simulate the same behavior here. |
1703 std::string edit_command; | 1705 std::string edit_command; |
1704 if (GetEditCommand(event_down, &edit_command)) | 1706 if (GetEditCommand(event_down, &edit_command)) |
1705 delegate()->SetEditCommand(edit_command, ""); | 1707 delegate()->SetEditCommand(edit_command, ""); |
1706 | 1708 |
(...skipping 20 matching lines...) Expand all Loading... | |
1727 HandleInputEventOnViewOrPopup(event_up); | 1729 HandleInputEventOnViewOrPopup(event_up); |
1728 } | 1730 } |
1729 | 1731 |
1730 void EventSender::EnableDOMUIEventLogging() {} | 1732 void EventSender::EnableDOMUIEventLogging() {} |
1731 | 1733 |
1732 void EventSender::FireKeyboardEventsToElement() {} | 1734 void EventSender::FireKeyboardEventsToElement() {} |
1733 | 1735 |
1734 void EventSender::ClearKillRing() {} | 1736 void EventSender::ClearKillRing() {} |
1735 | 1737 |
1736 std::vector<std::string> EventSender::ContextClick() { | 1738 std::vector<std::string> EventSender::ContextClick() { |
1737 if (force_layout_on_events_) { | 1739 if (force_layout_on_events_) |
1738 view()->updateAllLifecyclePhases(); | 1740 widget()->updateAllLifecyclePhases(); |
1739 } | |
1740 | 1741 |
1741 UpdateClickCountForButton(WebMouseEvent::Button::Right); | 1742 UpdateClickCountForButton(WebMouseEvent::Button::Right); |
1742 | 1743 |
1743 // Clears last context menu data because we need to know if the context menu | 1744 // Clears last context menu data because we need to know if the context menu |
1744 // be requested after following mouse events. | 1745 // be requested after following mouse events. |
1745 last_context_menu_data_.reset(); | 1746 last_context_menu_data_.reset(); |
1746 | 1747 |
1747 // Generate right mouse down and up. | 1748 // Generate right mouse down and up. |
1748 WebMouseEvent event; | 1749 WebMouseEvent event; |
1749 // This is a hack to work around only allowing a single pressed button since | 1750 // This is a hack to work around only allowing a single pressed button since |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1903 void EventSender::GestureFlingCancel() { | 1904 void EventSender::GestureFlingCancel() { |
1904 WebGestureEvent event; | 1905 WebGestureEvent event; |
1905 event.type = WebInputEvent::GestureFlingCancel; | 1906 event.type = WebInputEvent::GestureFlingCancel; |
1906 // Generally it won't matter what device we use here, and since it might | 1907 // Generally it won't matter what device we use here, and since it might |
1907 // be cumbersome to expect all callers to specify a device, we'll just | 1908 // be cumbersome to expect all callers to specify a device, we'll just |
1908 // choose Touchpad here. | 1909 // choose Touchpad here. |
1909 event.sourceDevice = blink::WebGestureDeviceTouchpad; | 1910 event.sourceDevice = blink::WebGestureDeviceTouchpad; |
1910 event.timeStampSeconds = GetCurrentEventTimeSec(); | 1911 event.timeStampSeconds = GetCurrentEventTimeSec(); |
1911 | 1912 |
1912 if (force_layout_on_events_) | 1913 if (force_layout_on_events_) |
1913 view()->updateAllLifecyclePhases(); | 1914 widget()->updateAllLifecyclePhases(); |
1914 | 1915 |
1915 HandleInputEventOnViewOrPopup(event); | 1916 HandleInputEventOnViewOrPopup(event); |
1916 } | 1917 } |
1917 | 1918 |
1918 void EventSender::GestureFlingStart(float x, | 1919 void EventSender::GestureFlingStart(float x, |
1919 float y, | 1920 float y, |
1920 float velocity_x, | 1921 float velocity_x, |
1921 float velocity_y, | 1922 float velocity_y, |
1922 gin::Arguments* args) { | 1923 gin::Arguments* args) { |
1923 WebGestureEvent event; | 1924 WebGestureEvent event; |
(...skipping 23 matching lines...) Expand all Loading... | |
1947 event.x = x; | 1948 event.x = x; |
1948 event.y = y; | 1949 event.y = y; |
1949 event.globalX = event.x; | 1950 event.globalX = event.x; |
1950 event.globalY = event.y; | 1951 event.globalY = event.y; |
1951 | 1952 |
1952 event.data.flingStart.velocityX = velocity_x; | 1953 event.data.flingStart.velocityX = velocity_x; |
1953 event.data.flingStart.velocityY = velocity_y; | 1954 event.data.flingStart.velocityY = velocity_y; |
1954 event.timeStampSeconds = GetCurrentEventTimeSec(); | 1955 event.timeStampSeconds = GetCurrentEventTimeSec(); |
1955 | 1956 |
1956 if (force_layout_on_events_) | 1957 if (force_layout_on_events_) |
1957 view()->updateAllLifecyclePhases(); | 1958 widget()->updateAllLifecyclePhases(); |
1958 | 1959 |
1959 HandleInputEventOnViewOrPopup(event); | 1960 HandleInputEventOnViewOrPopup(event); |
1960 } | 1961 } |
1961 | 1962 |
1962 bool EventSender::IsFlinging() const { | 1963 bool EventSender::IsFlinging() const { |
1963 return view()->isFlinging(); | 1964 return view()->isFlinging(); |
1964 } | 1965 } |
1965 | 1966 |
1966 void EventSender::GestureScrollFirstPoint(int x, int y) { | 1967 void EventSender::GestureScrollFirstPoint(int x, int y) { |
1967 current_gesture_location_ = WebPoint(x, y); | 1968 current_gesture_location_ = WebPoint(x, y); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2134 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); | 2135 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); |
2135 if (HandleInputEventOnViewOrPopup(wheel_event) == | 2136 if (HandleInputEventOnViewOrPopup(wheel_event) == |
2136 WebInputEventResult::NotHandled && | 2137 WebInputEventResult::NotHandled && |
2137 send_gestures) { | 2138 send_gestures) { |
2138 SendGesturesForMouseWheelEvent(wheel_event); | 2139 SendGesturesForMouseWheelEvent(wheel_event); |
2139 } | 2140 } |
2140 } | 2141 } |
2141 | 2142 |
2142 void EventSender::MouseMoveTo(gin::Arguments* args) { | 2143 void EventSender::MouseMoveTo(gin::Arguments* args) { |
2143 if (force_layout_on_events_) | 2144 if (force_layout_on_events_) |
2144 view()->updateAllLifecyclePhases(); | 2145 widget()->updateAllLifecyclePhases(); |
2145 | 2146 |
2146 double x; | 2147 double x; |
2147 double y; | 2148 double y; |
2148 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 2149 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
2149 args->ThrowError(); | 2150 args->ThrowError(); |
2150 return; | 2151 return; |
2151 } | 2152 } |
2152 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y)); | 2153 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y)); |
2153 | 2154 |
2154 int modifiers = 0; | 2155 int modifiers = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2189 GetCurrentEventTimeSec(), click_count, modifiers, pointerType, | 2190 GetCurrentEventTimeSec(), click_count, modifiers, pointerType, |
2190 pointerId, pressure, tiltX, tiltY, &event); | 2191 pointerId, pressure, tiltX, tiltY, &event); |
2191 HandleInputEventOnViewOrPopup(event); | 2192 HandleInputEventOnViewOrPopup(event); |
2192 if (pointerType == WebPointerProperties::PointerType::Mouse) | 2193 if (pointerType == WebPointerProperties::PointerType::Mouse) |
2193 DoDragAfterMouseMove(event); | 2194 DoDragAfterMouseMove(event); |
2194 } | 2195 } |
2195 } | 2196 } |
2196 | 2197 |
2197 void EventSender::MouseLeave() { | 2198 void EventSender::MouseLeave() { |
2198 if (force_layout_on_events_) | 2199 if (force_layout_on_events_) |
2199 view()->updateAllLifecyclePhases(); | 2200 widget()->updateAllLifecyclePhases(); |
2200 | 2201 |
2201 WebMouseEvent event; | 2202 WebMouseEvent event; |
2202 InitMouseEvent(WebInputEvent::MouseLeave, WebMouseEvent::Button::NoButton, 0, | 2203 InitMouseEvent(WebInputEvent::MouseLeave, WebMouseEvent::Button::NoButton, 0, |
2203 current_pointer_state_[kRawMousePointerId].last_pos_, | 2204 current_pointer_state_[kRawMousePointerId].last_pos_, |
2204 GetCurrentEventTimeSec(), click_count_, 0, &event); | 2205 GetCurrentEventTimeSec(), click_count_, 0, &event); |
2205 HandleInputEventOnViewOrPopup(event); | 2206 HandleInputEventOnViewOrPopup(event); |
2206 } | 2207 } |
2207 | 2208 |
2208 | 2209 |
2209 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { | 2210 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2258 | 2259 |
2259 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, | 2260 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, |
2260 gin::Arguments* args) { | 2261 gin::Arguments* args) { |
2261 bool moved_beyond_slop_region; | 2262 bool moved_beyond_slop_region; |
2262 uint32_t unique_touch_event_id; | 2263 uint32_t unique_touch_event_id; |
2263 GetOptionalTouchArgs(args, moved_beyond_slop_region, unique_touch_event_id); | 2264 GetOptionalTouchArgs(args, moved_beyond_slop_region, unique_touch_event_id); |
2264 | 2265 |
2265 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), | 2266 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), |
2266 touch_points_.size()); | 2267 touch_points_.size()); |
2267 if (force_layout_on_events_) | 2268 if (force_layout_on_events_) |
2268 view()->updateAllLifecyclePhases(); | 2269 widget()->updateAllLifecyclePhases(); |
2269 | 2270 |
2270 WebTouchEvent touch_event; | 2271 WebTouchEvent touch_event; |
2271 touch_event.type = type; | 2272 touch_event.type = type; |
2272 touch_event.modifiers = touch_modifiers_; | 2273 touch_event.modifiers = touch_modifiers_; |
2273 touch_event.dispatchType = touch_cancelable_ | 2274 touch_event.dispatchType = touch_cancelable_ |
2274 ? WebInputEvent::Blocking | 2275 ? WebInputEvent::Blocking |
2275 : WebInputEvent::EventNonBlocking; | 2276 : WebInputEvent::EventNonBlocking; |
2276 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 2277 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
2277 touch_event.movedBeyondSlopRegion = moved_beyond_slop_region; | 2278 touch_event.movedBeyondSlopRegion = moved_beyond_slop_region; |
2278 touch_event.uniqueTouchEventId = unique_touch_event_id; | 2279 touch_event.uniqueTouchEventId = unique_touch_event_id; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2517 NOTREACHED(); | 2518 NOTREACHED(); |
2518 } | 2519 } |
2519 | 2520 |
2520 event.uniqueTouchEventId = GetUniqueTouchEventId(args); | 2521 event.uniqueTouchEventId = GetUniqueTouchEventId(args); |
2521 | 2522 |
2522 event.globalX = event.x; | 2523 event.globalX = event.x; |
2523 event.globalY = event.y; | 2524 event.globalY = event.y; |
2524 event.timeStampSeconds = GetCurrentEventTimeSec(); | 2525 event.timeStampSeconds = GetCurrentEventTimeSec(); |
2525 | 2526 |
2526 if (force_layout_on_events_) | 2527 if (force_layout_on_events_) |
2527 view()->updateAllLifecyclePhases(); | 2528 widget()->updateAllLifecyclePhases(); |
2528 | 2529 |
2529 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); | 2530 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); |
2530 | 2531 |
2531 // Long press might start a drag drop session. Complete it if so. | 2532 // Long press might start a drag drop session. Complete it if so. |
2532 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { | 2533 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { |
2533 WebMouseEvent mouse_event; | 2534 WebMouseEvent mouse_event; |
2534 InitMouseEvent(WebInputEvent::MouseDown, | 2535 InitMouseEvent(WebInputEvent::MouseDown, |
2535 current_pointer_state_[kRawMousePointerId].pressed_button_, | 2536 current_pointer_state_[kRawMousePointerId].pressed_button_, |
2536 current_pointer_state_[kRawMousePointerId].current_buttons_, | 2537 current_pointer_state_[kRawMousePointerId].current_buttons_, |
2537 WebPoint(x, y), GetCurrentEventTimeSec(), click_count_, | 2538 WebPoint(x, y), GetCurrentEventTimeSec(), click_count_, |
(...skipping 21 matching lines...) Expand all Loading... | |
2559 } | 2560 } |
2560 | 2561 |
2561 void EventSender::InitMouseWheelEvent(gin::Arguments* args, | 2562 void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
2562 MouseScrollType scroll_type, | 2563 MouseScrollType scroll_type, |
2563 WebMouseWheelEvent* event, | 2564 WebMouseWheelEvent* event, |
2564 bool* send_gestures) { | 2565 bool* send_gestures) { |
2565 // Force a layout here just to make sure every position has been | 2566 // Force a layout here just to make sure every position has been |
2566 // determined before we send events (as well as all the other methods | 2567 // determined before we send events (as well as all the other methods |
2567 // that send an event do). | 2568 // that send an event do). |
2568 if (force_layout_on_events_) | 2569 if (force_layout_on_events_) |
2569 view()->updateAllLifecyclePhases(); | 2570 widget()->updateAllLifecyclePhases(); |
2570 | 2571 |
2571 double horizontal; | 2572 double horizontal; |
2572 if (!args->GetNext(&horizontal)) { | 2573 if (!args->GetNext(&horizontal)) { |
2573 args->ThrowError(); | 2574 args->ThrowError(); |
2574 return; | 2575 return; |
2575 } | 2576 } |
2576 double vertical; | 2577 double vertical; |
2577 if (!args->GetNext(&vertical)) { | 2578 if (!args->GetNext(&vertical)) { |
2578 args->ThrowError(); | 2579 args->ThrowError(); |
2579 return; | 2580 return; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2668 e->tiltX = tiltX; | 2669 e->tiltX = tiltX; |
2669 e->tiltY = tiltY; | 2670 e->tiltY = tiltY; |
2670 } | 2671 } |
2671 | 2672 |
2672 if (!getPointerType(args, false, e->pointerType)) | 2673 if (!getPointerType(args, false, e->pointerType)) |
2673 return; | 2674 return; |
2674 } | 2675 } |
2675 | 2676 |
2676 void EventSender::FinishDragAndDrop(const WebMouseEvent& unscaled_event, | 2677 void EventSender::FinishDragAndDrop(const WebMouseEvent& unscaled_event, |
2677 blink::WebDragOperation drag_effect) { | 2678 blink::WebDragOperation drag_effect) { |
2678 std::unique_ptr<WebInputEvent> scaled_event = ScaleEvent(unscaled_event); | 2679 std::unique_ptr<WebInputEvent> scaled_event = |
2680 TransformScreenToWidgetCoordinates(unscaled_event); | |
2679 const WebMouseEvent* event = | 2681 const WebMouseEvent* event = |
2680 scaled_event.get() ? static_cast<const WebMouseEvent*>(scaled_event.get()) | 2682 static_cast<const WebMouseEvent*>(scaled_event.get()); |
2681 : &unscaled_event; | |
2682 | 2683 |
2683 WebPoint client_point(event->x, event->y); | 2684 WebPoint client_point(event->x, event->y); |
2684 WebPoint screen_point(event->globalX, event->globalY); | 2685 WebPoint screen_point(event->globalX, event->globalY); |
2685 current_drag_effect_ = drag_effect; | 2686 current_drag_effect_ = drag_effect; |
2686 if (current_drag_effect_) { | 2687 if (current_drag_effect_) { |
2687 // Specifically pass any keyboard modifiers to the drop method. This allows | 2688 // Specifically pass any keyboard modifiers to the drop method. This allows |
2688 // tests to control the drop type (i.e. copy or move). | 2689 // tests to control the drop type (i.e. copy or move). |
2689 view()->dragTargetDrop(current_drag_data_, client_point, screen_point, | 2690 view()->dragTargetDrop(current_drag_data_, client_point, screen_point, |
2690 event->modifiers); | 2691 event->modifiers); |
2691 } else { | 2692 } else { |
2692 view()->dragTargetDragLeave(); | 2693 view()->dragTargetDragLeave(); |
2693 } | 2694 } |
2694 current_drag_data_.reset(); | 2695 current_drag_data_.reset(); |
2695 view()->dragSourceEndedAt(client_point, screen_point, current_drag_effect_); | 2696 view()->dragSourceEndedAt(client_point, screen_point, current_drag_effect_); |
2696 view()->dragSourceSystemDragEnded(); | 2697 view()->dragSourceSystemDragEnded(); |
2697 } | 2698 } |
2698 | 2699 |
2699 void EventSender::DoDragAfterMouseUp(const WebMouseEvent& unscaled_event) { | 2700 void EventSender::DoDragAfterMouseUp(const WebMouseEvent& unscaled_event) { |
2700 std::unique_ptr<WebInputEvent> scaled_event = ScaleEvent(unscaled_event); | 2701 std::unique_ptr<WebInputEvent> scaled_event = |
2701 const WebMouseEvent* event = | 2702 TransformScreenToWidgetCoordinates(unscaled_event); |
2702 scaled_event.get() ? static_cast<WebMouseEvent*>(scaled_event.get()) | 2703 const WebMouseEvent* event = static_cast<WebMouseEvent*>(scaled_event.get()); |
2703 : &unscaled_event; | |
2704 | 2704 |
2705 last_click_time_sec_ = event->timeStampSeconds; | 2705 last_click_time_sec_ = event->timeStampSeconds; |
2706 last_click_pos_ = current_pointer_state_[kRawMousePointerId].last_pos_; | 2706 last_click_pos_ = current_pointer_state_[kRawMousePointerId].last_pos_; |
2707 | 2707 |
2708 // If we're in a drag operation, complete it. | 2708 // If we're in a drag operation, complete it. |
2709 if (current_drag_data_.isNull()) | 2709 if (current_drag_data_.isNull()) |
2710 return; | 2710 return; |
2711 | 2711 |
2712 WebPoint client_point(event->x, event->y); | 2712 WebPoint client_point(event->x, event->y); |
2713 WebPoint screen_point(event->globalX, event->globalY); | 2713 WebPoint screen_point(event->globalX, event->globalY); |
2714 blink::WebDragOperation drag_effect = view()->dragTargetDragOver( | 2714 blink::WebDragOperation drag_effect = view()->dragTargetDragOver( |
2715 client_point, screen_point, current_drag_effects_allowed_, | 2715 client_point, screen_point, current_drag_effects_allowed_, |
2716 event->modifiers); | 2716 event->modifiers); |
2717 | 2717 |
2718 // Bail if dragover caused cancellation. | 2718 // Bail if dragover caused cancellation. |
2719 if (current_drag_data_.isNull()) | 2719 if (current_drag_data_.isNull()) |
2720 return; | 2720 return; |
2721 | 2721 |
2722 FinishDragAndDrop(unscaled_event, drag_effect); | 2722 FinishDragAndDrop(unscaled_event, drag_effect); |
2723 } | 2723 } |
2724 | 2724 |
2725 void EventSender::DoDragAfterMouseMove(const WebMouseEvent& unscaled_event) { | 2725 void EventSender::DoDragAfterMouseMove(const WebMouseEvent& unscaled_event) { |
2726 if (current_pointer_state_[kRawMousePointerId].pressed_button_ == | 2726 if (current_pointer_state_[kRawMousePointerId].pressed_button_ == |
2727 WebMouseEvent::Button::NoButton || | 2727 WebMouseEvent::Button::NoButton || |
2728 current_drag_data_.isNull()) { | 2728 current_drag_data_.isNull()) { |
2729 return; | 2729 return; |
2730 } | 2730 } |
2731 | 2731 |
2732 std::unique_ptr<WebInputEvent> scaled_event = ScaleEvent(unscaled_event); | 2732 std::unique_ptr<WebInputEvent> scaled_event = |
2733 const WebMouseEvent* event = | 2733 TransformScreenToWidgetCoordinates(unscaled_event); |
2734 scaled_event.get() ? static_cast<WebMouseEvent*>(scaled_event.get()) | 2734 const WebMouseEvent* event = static_cast<WebMouseEvent*>(scaled_event.get()); |
2735 : &unscaled_event; | |
2736 | 2735 |
2737 WebPoint client_point(event->x, event->y); | 2736 WebPoint client_point(event->x, event->y); |
2738 WebPoint screen_point(event->globalX, event->globalY); | 2737 WebPoint screen_point(event->globalX, event->globalY); |
2739 current_drag_effect_ = view()->dragTargetDragOver( | 2738 current_drag_effect_ = view()->dragTargetDragOver( |
2740 client_point, screen_point, current_drag_effects_allowed_, | 2739 client_point, screen_point, current_drag_effects_allowed_, |
2741 event->modifiers); | 2740 event->modifiers); |
2742 } | 2741 } |
2743 | 2742 |
2744 void EventSender::ReplaySavedEvents() { | 2743 void EventSender::ReplaySavedEvents() { |
2745 replaying_saved_events_ = true; | 2744 replaying_saved_events_ = true; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2782 } | 2781 } |
2783 default: | 2782 default: |
2784 NOTREACHED(); | 2783 NOTREACHED(); |
2785 } | 2784 } |
2786 } | 2785 } |
2787 | 2786 |
2788 replaying_saved_events_ = false; | 2787 replaying_saved_events_ = false; |
2789 } | 2788 } |
2790 | 2789 |
2791 WebInputEventResult EventSender::HandleInputEventOnViewOrPopup( | 2790 WebInputEventResult EventSender::HandleInputEventOnViewOrPopup( |
2792 const WebInputEvent& unscaled_event) { | 2791 const WebInputEvent& event) { |
2793 std::unique_ptr<WebInputEvent> scaled_event = ScaleEvent(unscaled_event); | 2792 last_event_timestamp_ = event.timeStampSeconds; |
2794 const WebInputEvent* event = | |
2795 scaled_event.get() ? scaled_event.get() : &unscaled_event; | |
2796 | 2793 |
2797 last_event_timestamp_ = event->timeStampSeconds; | 2794 if (WebPagePopup* popup = widget()->pagePopup()) { |
2795 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the | |
2796 // event does not have to be converted. | |
2797 std::unique_ptr<WebInputEvent> scaled_event = | |
2798 ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | |
2799 const WebInputEvent* popup_friendly_event = | |
2800 scaled_event.get() ? scaled_event.get() : &event; | |
2801 if (!WebInputEvent::isKeyboardEventType(popup_friendly_event->type)) | |
2802 return popup->handleInputEvent(*popup_friendly_event); | |
2803 } | |
2798 | 2804 |
2799 if (WebPagePopup* popup = view()->pagePopup()) { | 2805 std::unique_ptr<WebInputEvent> widget_friendly_event = |
2800 if (!WebInputEvent::isKeyboardEventType(event->type)) | 2806 TransformScreenToWidgetCoordinates(event); |
2801 return popup->handleInputEvent(*event); | 2807 return widget()->handleInputEvent(*widget_friendly_event); |
2802 } | |
2803 return view()->handleInputEvent(*event); | |
2804 } | 2808 } |
2805 | 2809 |
2806 void EventSender::SendGesturesForMouseWheelEvent( | 2810 void EventSender::SendGesturesForMouseWheelEvent( |
2807 const WebMouseWheelEvent wheel_event) { | 2811 const WebMouseWheelEvent wheel_event) { |
2808 WebGestureEvent begin_event; | 2812 WebGestureEvent begin_event; |
2809 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollBegin, | 2813 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollBegin, |
2810 GetCurrentEventTimeSec(), wheel_event, | 2814 GetCurrentEventTimeSec(), wheel_event, |
2811 &begin_event); | 2815 &begin_event); |
2812 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; | 2816 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; |
2813 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; | 2817 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; |
2814 if (wheel_event.scrollByPage) { | 2818 if (wheel_event.scrollByPage) { |
2815 begin_event.data.scrollBegin.deltaHintUnits = blink::WebGestureEvent::Page; | 2819 begin_event.data.scrollBegin.deltaHintUnits = blink::WebGestureEvent::Page; |
2816 if (begin_event.data.scrollBegin.deltaXHint) { | 2820 if (begin_event.data.scrollBegin.deltaXHint) { |
2817 begin_event.data.scrollBegin.deltaXHint = | 2821 begin_event.data.scrollBegin.deltaXHint = |
2818 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; | 2822 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; |
2819 } | 2823 } |
2820 if (begin_event.data.scrollBegin.deltaYHint) { | 2824 if (begin_event.data.scrollBegin.deltaYHint) { |
2821 begin_event.data.scrollBegin.deltaYHint = | 2825 begin_event.data.scrollBegin.deltaYHint = |
2822 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; | 2826 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; |
2823 } | 2827 } |
2824 } else { | 2828 } else { |
2825 begin_event.data.scrollBegin.deltaHintUnits = | 2829 begin_event.data.scrollBegin.deltaHintUnits = |
2826 wheel_event.hasPreciseScrollingDeltas | 2830 wheel_event.hasPreciseScrollingDeltas |
2827 ? blink::WebGestureEvent::PrecisePixels | 2831 ? blink::WebGestureEvent::PrecisePixels |
2828 : blink::WebGestureEvent::Pixels; | 2832 : blink::WebGestureEvent::Pixels; |
2829 } | 2833 } |
2830 | 2834 |
2831 if (force_layout_on_events_) | 2835 if (force_layout_on_events_) |
2832 view()->updateAllLifecyclePhases(); | 2836 widget()->updateAllLifecyclePhases(); |
2833 | 2837 |
2834 HandleInputEventOnViewOrPopup(begin_event); | 2838 HandleInputEventOnViewOrPopup(begin_event); |
2835 | 2839 |
2836 WebGestureEvent update_event; | 2840 WebGestureEvent update_event; |
2837 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollUpdate, | 2841 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollUpdate, |
2838 GetCurrentEventTimeSec(), wheel_event, | 2842 GetCurrentEventTimeSec(), wheel_event, |
2839 &update_event); | 2843 &update_event); |
2840 update_event.data.scrollUpdate.deltaX = | 2844 update_event.data.scrollUpdate.deltaX = |
2841 begin_event.data.scrollBegin.deltaXHint; | 2845 begin_event.data.scrollBegin.deltaXHint; |
2842 update_event.data.scrollUpdate.deltaY = | 2846 update_event.data.scrollUpdate.deltaY = |
2843 begin_event.data.scrollBegin.deltaYHint; | 2847 begin_event.data.scrollBegin.deltaYHint; |
2844 update_event.data.scrollUpdate.deltaUnits = | 2848 update_event.data.scrollUpdate.deltaUnits = |
2845 begin_event.data.scrollBegin.deltaHintUnits; | 2849 begin_event.data.scrollBegin.deltaHintUnits; |
2846 | 2850 |
2847 if (force_layout_on_events_) | 2851 if (force_layout_on_events_) |
2848 view()->updateAllLifecyclePhases(); | 2852 widget()->updateAllLifecyclePhases(); |
2849 HandleInputEventOnViewOrPopup(update_event); | 2853 HandleInputEventOnViewOrPopup(update_event); |
2850 | 2854 |
2851 WebGestureEvent end_event; | 2855 WebGestureEvent end_event; |
2852 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollEnd, | 2856 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollEnd, |
2853 GetCurrentEventTimeSec(), wheel_event, | 2857 GetCurrentEventTimeSec(), wheel_event, |
2854 &end_event); | 2858 &end_event); |
2855 end_event.data.scrollEnd.deltaUnits = | 2859 end_event.data.scrollEnd.deltaUnits = |
2856 begin_event.data.scrollBegin.deltaHintUnits; | 2860 begin_event.data.scrollBegin.deltaHintUnits; |
2857 | 2861 |
2858 if (force_layout_on_events_) | 2862 if (force_layout_on_events_) |
2859 view()->updateAllLifecyclePhases(); | 2863 widget()->updateAllLifecyclePhases(); |
2860 HandleInputEventOnViewOrPopup(end_event); | 2864 HandleInputEventOnViewOrPopup(end_event); |
2861 } | 2865 } |
2862 | 2866 |
2863 TestInterfaces* EventSender::interfaces() { | 2867 TestInterfaces* EventSender::interfaces() { |
2864 return web_view_test_proxy_base_->test_interfaces(); | 2868 return web_widget_test_proxy_base_->web_view_test_proxy_base() |
2869 ->test_interfaces(); | |
2865 } | 2870 } |
2866 | 2871 |
2867 WebTestDelegate* EventSender::delegate() { | 2872 WebTestDelegate* EventSender::delegate() { |
2868 return web_view_test_proxy_base_->delegate(); | 2873 return web_widget_test_proxy_base_->web_view_test_proxy_base()->delegate(); |
2869 } | 2874 } |
2870 | 2875 |
2871 const blink::WebView* EventSender::view() const { | 2876 const blink::WebView* EventSender::view() const { |
2872 return web_view_test_proxy_base_->web_view(); | 2877 return web_widget_test_proxy_base_->web_view_test_proxy_base()->web_view(); |
2873 } | 2878 } |
2874 | 2879 |
2875 blink::WebView* EventSender::view() { | 2880 blink::WebView* EventSender::view() { |
2876 return web_view_test_proxy_base_->web_view(); | 2881 return web_widget_test_proxy_base_->web_view_test_proxy_base()->web_view(); |
2877 } | 2882 } |
2878 | 2883 |
2879 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( | 2884 blink::WebWidget* EventSender::widget() { |
2885 return web_widget_test_proxy_base_->web_widget(); | |
2886 } | |
2887 | |
2888 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( | |
2880 const WebInputEvent& event) { | 2889 const WebInputEvent& event) { |
2881 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event | 2890 return delegate()->TransformScreenToWidgetCoordinates( |
2882 // does not have to be converted. | 2891 web_widget_test_proxy_base_, event); |
2883 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | |
2884 } | 2892 } |
2885 | 2893 |
2886 } // namespace test_runner | 2894 } // namespace test_runner |
OLD | NEW |