Chromium Code Reviews| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "components/test_runner/mock_spell_check.h" | 19 #include "components/test_runner/mock_spell_check.h" |
| 20 #include "components/test_runner/test_interfaces.h" | 20 #include "components/test_runner/test_interfaces.h" |
| 21 #include "components/test_runner/web_frame_test_proxy.h" | |
| 21 #include "components/test_runner/web_task.h" | 22 #include "components/test_runner/web_task.h" |
| 22 #include "components/test_runner/web_test_delegate.h" | 23 #include "components/test_runner/web_test_delegate.h" |
| 23 #include "components/test_runner/web_test_proxy.h" | 24 #include "components/test_runner/web_test_proxy.h" |
| 24 #include "gin/handle.h" | 25 #include "gin/handle.h" |
| 25 #include "gin/object_template_builder.h" | 26 #include "gin/object_template_builder.h" |
| 26 #include "gin/wrappable.h" | 27 #include "gin/wrappable.h" |
| 27 #include "third_party/WebKit/public/platform/WebPointerProperties.h" | 28 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
| 28 #include "third_party/WebKit/public/platform/WebString.h" | 29 #include "third_party/WebKit/public/platform/WebString.h" |
| 29 #include "third_party/WebKit/public/platform/WebVector.h" | 30 #include "third_party/WebKit/public/platform/WebVector.h" |
| 30 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 31 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 | 1188 |
| 1188 WebMouseEvent::Button EventSender::last_button_type_ = | 1189 WebMouseEvent::Button EventSender::last_button_type_ = |
| 1189 WebMouseEvent::ButtonNone; | 1190 WebMouseEvent::ButtonNone; |
| 1190 | 1191 |
| 1191 EventSender::SavedEvent::SavedEvent() | 1192 EventSender::SavedEvent::SavedEvent() |
| 1192 : type(TYPE_UNSPECIFIED), | 1193 : type(TYPE_UNSPECIFIED), |
| 1193 button_type(WebMouseEvent::ButtonNone), | 1194 button_type(WebMouseEvent::ButtonNone), |
| 1194 milliseconds(0), | 1195 milliseconds(0), |
| 1195 modifiers(0) {} | 1196 modifiers(0) {} |
| 1196 | 1197 |
| 1197 EventSender::EventSender(WebTestProxyBase* web_test_proxy_base) | 1198 EventSender::EventSender( |
| 1198 : web_test_proxy_base_(web_test_proxy_base), | 1199 WebFrameTestProxyBase* web_frame_test_proxy_base) |
| 1200 : web_frame_test_proxy_base_(web_frame_test_proxy_base), | |
| 1199 send_wheel_gestures_(false), | 1201 send_wheel_gestures_(false), |
| 1200 replaying_saved_events_(false), | 1202 replaying_saved_events_(false), |
| 1201 weak_factory_(this) { | 1203 weak_factory_(this) { |
| 1202 Reset(); | 1204 Reset(); |
| 1203 } | 1205 } |
| 1204 | 1206 |
| 1205 EventSender::~EventSender() {} | 1207 EventSender::~EventSender() {} |
| 1206 | 1208 |
| 1207 void EventSender::Reset() { | 1209 void EventSender::Reset() { |
| 1208 DCHECK(current_drag_data_.isNull()); | 1210 DCHECK(current_drag_data_.isNull()); |
| 1209 current_drag_data_.reset(); | 1211 current_drag_data_.reset(); |
| 1210 current_drag_effect_ = blink::WebDragOperationNone; | 1212 current_drag_effect_ = blink::WebDragOperationNone; |
| 1211 current_drag_effects_allowed_ = blink::WebDragOperationNone; | 1213 current_drag_effects_allowed_ = blink::WebDragOperationNone; |
| 1212 if (view() && | 1214 if (widget() && |
| 1213 current_pointer_state_[kMousePointerId].pressed_button_ != | 1215 current_pointer_state_[kMousePointerId].pressed_button_ != |
| 1214 WebMouseEvent::ButtonNone) | 1216 WebMouseEvent::ButtonNone) |
| 1215 view()->mouseCaptureLost(); | 1217 widget()->mouseCaptureLost(); |
| 1216 current_pointer_state_.clear(); | 1218 current_pointer_state_.clear(); |
| 1217 is_drag_mode_ = true; | 1219 is_drag_mode_ = true; |
| 1218 force_layout_on_events_ = true; | 1220 force_layout_on_events_ = true; |
| 1219 | 1221 |
| 1220 #if defined(OS_WIN) | 1222 #if defined(OS_WIN) |
| 1221 wm_key_down_ = WM_KEYDOWN; | 1223 wm_key_down_ = WM_KEYDOWN; |
| 1222 wm_key_up_ = WM_KEYUP; | 1224 wm_key_up_ = WM_KEYUP; |
| 1223 wm_char_ = WM_CHAR; | 1225 wm_char_ = WM_CHAR; |
| 1224 wm_dead_char_ = WM_DEADCHAR; | 1226 wm_dead_char_ = WM_DEADCHAR; |
| 1225 wm_sys_key_down_ = WM_SYSKEYDOWN; | 1227 wm_sys_key_down_ = WM_SYSKEYDOWN; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 PointerUp(button_number, modifiers, | 1291 PointerUp(button_number, modifiers, |
| 1290 blink::WebPointerProperties::PointerType::Mouse, kMousePointerId); | 1292 blink::WebPointerProperties::PointerType::Mouse, kMousePointerId); |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 void EventSender::PointerDown( | 1295 void EventSender::PointerDown( |
| 1294 int button_number, | 1296 int button_number, |
| 1295 int modifiers, | 1297 int modifiers, |
| 1296 blink::WebPointerProperties::PointerType pointerType, | 1298 blink::WebPointerProperties::PointerType pointerType, |
| 1297 int pointerId) { | 1299 int pointerId) { |
| 1298 if (force_layout_on_events_) | 1300 if (force_layout_on_events_) |
| 1299 view()->updateAllLifecyclePhases(); | 1301 widget()->updateAllLifecyclePhases(); |
| 1300 | 1302 |
| 1301 DCHECK_NE(-1, button_number); | 1303 DCHECK_NE(-1, button_number); |
| 1302 | 1304 |
| 1303 WebMouseEvent::Button button_type = | 1305 WebMouseEvent::Button button_type = |
| 1304 GetButtonTypeFromButtonNumber(button_number); | 1306 GetButtonTypeFromButtonNumber(button_number); |
| 1305 | 1307 |
| 1306 WebMouseEvent event; | 1308 WebMouseEvent event; |
| 1307 int click_count = 0; | 1309 int click_count = 0; |
| 1308 current_pointer_state_[pointerId].pressed_button_ = button_type; | 1310 current_pointer_state_[pointerId].pressed_button_ = button_type; |
| 1309 current_pointer_state_[pointerId].current_buttons_ |= | 1311 current_pointer_state_[pointerId].current_buttons_ |= |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1327 | 1329 |
| 1328 HandleInputEventOnViewOrPopup(event); | 1330 HandleInputEventOnViewOrPopup(event); |
| 1329 } | 1331 } |
| 1330 | 1332 |
| 1331 void EventSender::PointerUp( | 1333 void EventSender::PointerUp( |
| 1332 int button_number, | 1334 int button_number, |
| 1333 int modifiers, | 1335 int modifiers, |
| 1334 blink::WebPointerProperties::PointerType pointerType, | 1336 blink::WebPointerProperties::PointerType pointerType, |
| 1335 int pointerId) { | 1337 int pointerId) { |
| 1336 if (force_layout_on_events_) | 1338 if (force_layout_on_events_) |
| 1337 view()->updateAllLifecyclePhases(); | 1339 widget()->updateAllLifecyclePhases(); |
| 1338 | 1340 |
| 1339 DCHECK_NE(-1, button_number); | 1341 DCHECK_NE(-1, button_number); |
| 1340 | 1342 |
| 1341 WebMouseEvent::Button button_type = | 1343 WebMouseEvent::Button button_type = |
| 1342 GetButtonTypeFromButtonNumber(button_number); | 1344 GetButtonTypeFromButtonNumber(button_number); |
| 1343 | 1345 |
| 1344 if (pointerType == blink::WebPointerProperties::PointerType::Mouse && | 1346 if (pointerType == blink::WebPointerProperties::PointerType::Mouse && |
| 1345 is_drag_mode_ && !replaying_saved_events_) { | 1347 is_drag_mode_ && !replaying_saved_events_) { |
| 1346 SavedEvent saved_event; | 1348 SavedEvent saved_event; |
| 1347 saved_event.type = SavedEvent::TYPE_MOUSE_UP; | 1349 saved_event.type = SavedEvent::TYPE_MOUSE_UP; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 event_down.modifiers |= WebInputEvent::IsKeyPad; | 1588 event_down.modifiers |= WebInputEvent::IsKeyPad; |
| 1587 break; | 1589 break; |
| 1588 } | 1590 } |
| 1589 | 1591 |
| 1590 WebKeyboardEvent event_up; | 1592 WebKeyboardEvent event_up; |
| 1591 event_up = event_down; | 1593 event_up = event_down; |
| 1592 event_up.type = WebInputEvent::KeyUp; | 1594 event_up.type = WebInputEvent::KeyUp; |
| 1593 // EventSender.m forces a layout here, with at least one | 1595 // EventSender.m forces a layout here, with at least one |
| 1594 // test (fast/forms/focus-control-to-page.html) relying on this. | 1596 // test (fast/forms/focus-control-to-page.html) relying on this. |
| 1595 if (force_layout_on_events_) | 1597 if (force_layout_on_events_) |
| 1596 view()->updateAllLifecyclePhases(); | 1598 widget()->updateAllLifecyclePhases(); |
| 1597 | 1599 |
| 1598 // In the browser, if a keyboard event corresponds to an editor command, | 1600 // In the browser, if a keyboard event corresponds to an editor command, |
| 1599 // the command will be dispatched to the renderer just before dispatching | 1601 // the command will be dispatched to the renderer just before dispatching |
| 1600 // the keyboard event, and then it will be executed in the | 1602 // the keyboard event, and then it will be executed in the |
| 1601 // RenderView::handleCurrentKeyboardEvent() method. | 1603 // RenderView::handleCurrentKeyboardEvent() method. |
| 1602 // We just simulate the same behavior here. | 1604 // We just simulate the same behavior here. |
| 1603 std::string edit_command; | 1605 std::string edit_command; |
| 1604 if (GetEditCommand(event_down, &edit_command)) | 1606 if (GetEditCommand(event_down, &edit_command)) |
| 1605 delegate()->SetEditCommand(edit_command, ""); | 1607 delegate()->SetEditCommand(edit_command, ""); |
| 1606 | 1608 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 } | 1640 } |
| 1639 | 1641 |
| 1640 void EventSender::EnableDOMUIEventLogging() {} | 1642 void EventSender::EnableDOMUIEventLogging() {} |
| 1641 | 1643 |
| 1642 void EventSender::FireKeyboardEventsToElement() {} | 1644 void EventSender::FireKeyboardEventsToElement() {} |
| 1643 | 1645 |
| 1644 void EventSender::ClearKillRing() {} | 1646 void EventSender::ClearKillRing() {} |
| 1645 | 1647 |
| 1646 std::vector<std::string> EventSender::ContextClick() { | 1648 std::vector<std::string> EventSender::ContextClick() { |
| 1647 if (force_layout_on_events_) { | 1649 if (force_layout_on_events_) { |
| 1648 view()->updateAllLifecyclePhases(); | 1650 widget()->updateAllLifecyclePhases(); |
| 1649 } | 1651 } |
| 1650 | 1652 |
| 1651 UpdateClickCountForButton(WebMouseEvent::ButtonRight); | 1653 UpdateClickCountForButton(WebMouseEvent::ButtonRight); |
| 1652 | 1654 |
| 1653 // Clears last context menu data because we need to know if the context menu | 1655 // Clears last context menu data because we need to know if the context menu |
| 1654 // be requested after following mouse events. | 1656 // be requested after following mouse events. |
| 1655 last_context_menu_data_.reset(); | 1657 last_context_menu_data_.reset(); |
| 1656 | 1658 |
| 1657 // Generate right mouse down and up. | 1659 // Generate right mouse down and up. |
| 1658 WebMouseEvent event; | 1660 WebMouseEvent event; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1825 void EventSender::GestureFlingCancel() { | 1827 void EventSender::GestureFlingCancel() { |
| 1826 WebGestureEvent event; | 1828 WebGestureEvent event; |
| 1827 event.type = WebInputEvent::GestureFlingCancel; | 1829 event.type = WebInputEvent::GestureFlingCancel; |
| 1828 // Generally it won't matter what device we use here, and since it might | 1830 // Generally it won't matter what device we use here, and since it might |
| 1829 // be cumbersome to expect all callers to specify a device, we'll just | 1831 // be cumbersome to expect all callers to specify a device, we'll just |
| 1830 // choose Touchpad here. | 1832 // choose Touchpad here. |
| 1831 event.sourceDevice = blink::WebGestureDeviceTouchpad; | 1833 event.sourceDevice = blink::WebGestureDeviceTouchpad; |
| 1832 event.timeStampSeconds = GetCurrentEventTimeSec(); | 1834 event.timeStampSeconds = GetCurrentEventTimeSec(); |
| 1833 | 1835 |
| 1834 if (force_layout_on_events_) | 1836 if (force_layout_on_events_) |
| 1835 view()->updateAllLifecyclePhases(); | 1837 widget()->updateAllLifecyclePhases(); |
| 1836 | 1838 |
| 1837 HandleInputEventOnViewOrPopup(event); | 1839 HandleInputEventOnViewOrPopup(event); |
| 1838 } | 1840 } |
| 1839 | 1841 |
| 1840 void EventSender::GestureFlingStart(float x, | 1842 void EventSender::GestureFlingStart(float x, |
| 1841 float y, | 1843 float y, |
| 1842 float velocity_x, | 1844 float velocity_x, |
| 1843 float velocity_y, | 1845 float velocity_y, |
| 1844 gin::Arguments* args) { | 1846 gin::Arguments* args) { |
| 1845 WebGestureEvent event; | 1847 WebGestureEvent event; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1861 event.x = x; | 1863 event.x = x; |
| 1862 event.y = y; | 1864 event.y = y; |
| 1863 event.globalX = event.x; | 1865 event.globalX = event.x; |
| 1864 event.globalY = event.y; | 1866 event.globalY = event.y; |
| 1865 | 1867 |
| 1866 event.data.flingStart.velocityX = velocity_x; | 1868 event.data.flingStart.velocityX = velocity_x; |
| 1867 event.data.flingStart.velocityY = velocity_y; | 1869 event.data.flingStart.velocityY = velocity_y; |
| 1868 event.timeStampSeconds = GetCurrentEventTimeSec(); | 1870 event.timeStampSeconds = GetCurrentEventTimeSec(); |
| 1869 | 1871 |
| 1870 if (force_layout_on_events_) | 1872 if (force_layout_on_events_) |
| 1871 view()->updateAllLifecyclePhases(); | 1873 widget()->updateAllLifecyclePhases(); |
| 1872 | 1874 |
| 1873 HandleInputEventOnViewOrPopup(event); | 1875 HandleInputEventOnViewOrPopup(event); |
| 1874 } | 1876 } |
| 1875 | 1877 |
| 1876 bool EventSender::IsFlinging() const { | 1878 bool EventSender::IsFlinging() const { |
| 1877 return view()->isFlinging(); | 1879 return view()->isFlinging(); |
| 1878 } | 1880 } |
| 1879 | 1881 |
| 1880 void EventSender::GestureScrollFirstPoint(int x, int y) { | 1882 void EventSender::GestureScrollFirstPoint(int x, int y) { |
| 1881 current_gesture_location_ = WebPoint(x, y); | 1883 current_gesture_location_ = WebPoint(x, y); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2062 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); | 2064 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); |
| 2063 if (HandleInputEventOnViewOrPopup(wheel_event) == | 2065 if (HandleInputEventOnViewOrPopup(wheel_event) == |
| 2064 WebInputEventResult::NotHandled && | 2066 WebInputEventResult::NotHandled && |
| 2065 send_gestures) { | 2067 send_gestures) { |
| 2066 SendGesturesForMouseWheelEvent(wheel_event); | 2068 SendGesturesForMouseWheelEvent(wheel_event); |
| 2067 } | 2069 } |
| 2068 } | 2070 } |
| 2069 | 2071 |
| 2070 void EventSender::MouseMoveTo(gin::Arguments* args) { | 2072 void EventSender::MouseMoveTo(gin::Arguments* args) { |
| 2071 if (force_layout_on_events_) | 2073 if (force_layout_on_events_) |
| 2072 view()->updateAllLifecyclePhases(); | 2074 widget()->updateAllLifecyclePhases(); |
| 2073 | 2075 |
| 2074 double x; | 2076 double x; |
| 2075 double y; | 2077 double y; |
| 2076 blink::WebPointerProperties::PointerType pointerType = | 2078 blink::WebPointerProperties::PointerType pointerType = |
| 2077 blink::WebPointerProperties::PointerType::Mouse; | 2079 blink::WebPointerProperties::PointerType::Mouse; |
| 2078 int pointerId = 0; | 2080 int pointerId = 0; |
| 2079 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 2081 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
| 2080 args->ThrowError(); | 2082 args->ThrowError(); |
| 2081 return; | 2083 return; |
| 2082 } | 2084 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2117 pointerId, | 2119 pointerId, |
| 2118 &event); | 2120 &event); |
| 2119 HandleInputEventOnViewOrPopup(event); | 2121 HandleInputEventOnViewOrPopup(event); |
| 2120 if (pointerType == blink::WebPointerProperties::PointerType::Mouse) | 2122 if (pointerType == blink::WebPointerProperties::PointerType::Mouse) |
| 2121 DoDragAfterMouseMove(event); | 2123 DoDragAfterMouseMove(event); |
| 2122 } | 2124 } |
| 2123 } | 2125 } |
| 2124 | 2126 |
| 2125 void EventSender::MouseLeave() { | 2127 void EventSender::MouseLeave() { |
| 2126 if (force_layout_on_events_) | 2128 if (force_layout_on_events_) |
| 2127 view()->updateAllLifecyclePhases(); | 2129 widget()->updateAllLifecyclePhases(); |
| 2128 | 2130 |
| 2129 WebMouseEvent event; | 2131 WebMouseEvent event; |
| 2130 InitMouseEvent(WebInputEvent::MouseLeave, | 2132 InitMouseEvent(WebInputEvent::MouseLeave, |
| 2131 WebMouseEvent::ButtonNone, | 2133 WebMouseEvent::ButtonNone, |
| 2132 0, | 2134 0, |
| 2133 current_pointer_state_[kMousePointerId].last_pos_, | 2135 current_pointer_state_[kMousePointerId].last_pos_, |
| 2134 GetCurrentEventTimeSec(), | 2136 GetCurrentEventTimeSec(), |
| 2135 click_count_, | 2137 click_count_, |
| 2136 0, | 2138 0, |
| 2137 blink::WebPointerProperties::PointerType::Mouse, | 2139 blink::WebPointerProperties::PointerType::Mouse, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2165 | 2167 |
| 2166 void EventSender::DoLeapForward(int milliseconds) { | 2168 void EventSender::DoLeapForward(int milliseconds) { |
| 2167 time_offset_ms_ += milliseconds; | 2169 time_offset_ms_ += milliseconds; |
| 2168 } | 2170 } |
| 2169 | 2171 |
| 2170 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, | 2172 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, |
| 2171 bool movedBeyondSlopRegion) { | 2173 bool movedBeyondSlopRegion) { |
| 2172 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), | 2174 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), |
| 2173 touch_points_.size()); | 2175 touch_points_.size()); |
| 2174 if (force_layout_on_events_) | 2176 if (force_layout_on_events_) |
| 2175 view()->updateAllLifecyclePhases(); | 2177 widget()->updateAllLifecyclePhases(); |
| 2176 | 2178 |
| 2177 WebTouchEvent touch_event; | 2179 WebTouchEvent touch_event; |
| 2178 touch_event.type = type; | 2180 touch_event.type = type; |
| 2179 touch_event.modifiers = touch_modifiers_; | 2181 touch_event.modifiers = touch_modifiers_; |
| 2180 touch_event.dispatchType = touch_cancelable_ | 2182 touch_event.dispatchType = touch_cancelable_ |
| 2181 ? WebInputEvent::Blocking | 2183 ? WebInputEvent::Blocking |
| 2182 : WebInputEvent::EventNonBlocking; | 2184 : WebInputEvent::EventNonBlocking; |
| 2183 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 2185 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
| 2184 touch_event.movedBeyondSlopRegion = movedBeyondSlopRegion; | 2186 touch_event.movedBeyondSlopRegion = movedBeyondSlopRegion; |
| 2185 touch_event.touchesLength = touch_points_.size(); | 2187 touch_event.touchesLength = touch_points_.size(); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2440 break; | 2442 break; |
| 2441 default: | 2443 default: |
| 2442 NOTREACHED(); | 2444 NOTREACHED(); |
| 2443 } | 2445 } |
| 2444 | 2446 |
| 2445 event.globalX = event.x; | 2447 event.globalX = event.x; |
| 2446 event.globalY = event.y; | 2448 event.globalY = event.y; |
| 2447 event.timeStampSeconds = GetCurrentEventTimeSec(); | 2449 event.timeStampSeconds = GetCurrentEventTimeSec(); |
| 2448 | 2450 |
| 2449 if (force_layout_on_events_) | 2451 if (force_layout_on_events_) |
| 2450 view()->updateAllLifecyclePhases(); | 2452 widget()->updateAllLifecyclePhases(); |
| 2451 | 2453 |
| 2452 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); | 2454 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); |
| 2453 | 2455 |
| 2454 // Long press might start a drag drop session. Complete it if so. | 2456 // Long press might start a drag drop session. Complete it if so. |
| 2455 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { | 2457 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { |
| 2456 WebMouseEvent mouse_event; | 2458 WebMouseEvent mouse_event; |
| 2457 InitMouseEvent(WebInputEvent::MouseDown, | 2459 InitMouseEvent(WebInputEvent::MouseDown, |
| 2458 current_pointer_state_[kMousePointerId].pressed_button_, | 2460 current_pointer_state_[kMousePointerId].pressed_button_, |
| 2459 current_pointer_state_[kMousePointerId].current_buttons_, | 2461 current_pointer_state_[kMousePointerId].current_buttons_, |
| 2460 WebPoint(x, y), GetCurrentEventTimeSec(), | 2462 WebPoint(x, y), GetCurrentEventTimeSec(), |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2485 } | 2487 } |
| 2486 | 2488 |
| 2487 void EventSender::InitMouseWheelEvent(gin::Arguments* args, | 2489 void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| 2488 MouseScrollType scroll_type, | 2490 MouseScrollType scroll_type, |
| 2489 WebMouseWheelEvent* event, | 2491 WebMouseWheelEvent* event, |
| 2490 bool* send_gestures) { | 2492 bool* send_gestures) { |
| 2491 // Force a layout here just to make sure every position has been | 2493 // Force a layout here just to make sure every position has been |
| 2492 // determined before we send events (as well as all the other methods | 2494 // determined before we send events (as well as all the other methods |
| 2493 // that send an event do). | 2495 // that send an event do). |
| 2494 if (force_layout_on_events_) | 2496 if (force_layout_on_events_) |
| 2495 view()->updateAllLifecyclePhases(); | 2497 widget()->updateAllLifecyclePhases(); |
| 2496 | 2498 |
| 2497 double horizontal; | 2499 double horizontal; |
| 2498 if (!args->GetNext(&horizontal)) { | 2500 if (!args->GetNext(&horizontal)) { |
| 2499 args->ThrowError(); | 2501 args->ThrowError(); |
| 2500 return; | 2502 return; |
| 2501 } | 2503 } |
| 2502 double vertical; | 2504 double vertical; |
| 2503 if (!args->GetNext(&vertical)) { | 2505 if (!args->GetNext(&vertical)) { |
| 2504 args->ThrowError(); | 2506 args->ThrowError(); |
| 2505 return; | 2507 return; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2709 } | 2711 } |
| 2710 } | 2712 } |
| 2711 | 2713 |
| 2712 replaying_saved_events_ = false; | 2714 replaying_saved_events_ = false; |
| 2713 } | 2715 } |
| 2714 | 2716 |
| 2715 WebInputEventResult EventSender::HandleInputEventOnViewOrPopup( | 2717 WebInputEventResult EventSender::HandleInputEventOnViewOrPopup( |
| 2716 const WebInputEvent& event) { | 2718 const WebInputEvent& event) { |
| 2717 last_event_timestamp_ = event.timeStampSeconds; | 2719 last_event_timestamp_ = event.timeStampSeconds; |
| 2718 | 2720 |
| 2719 if (WebPagePopup* popup = view()->pagePopup()) { | 2721 if (WebPagePopup* popup = widget()->pagePopup()) { |
| 2720 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2722 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2721 return popup->handleInputEvent(event); | 2723 return popup->handleInputEvent(event); |
| 2722 } | 2724 } |
| 2723 return view()->handleInputEvent(event); | 2725 return widget()->handleInputEvent(event); |
|
Łukasz Anforowicz
2016/06/02 21:05:19
Even after this change http/tests/security/referre
| |
| 2724 } | 2726 } |
| 2725 | 2727 |
| 2726 void EventSender::SendGesturesForMouseWheelEvent( | 2728 void EventSender::SendGesturesForMouseWheelEvent( |
| 2727 const WebMouseWheelEvent wheel_event) { | 2729 const WebMouseWheelEvent wheel_event) { |
| 2728 WebGestureEvent begin_event; | 2730 WebGestureEvent begin_event; |
| 2729 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollBegin, | 2731 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollBegin, |
| 2730 GetCurrentEventTimeSec(), wheel_event, | 2732 GetCurrentEventTimeSec(), wheel_event, |
| 2731 &begin_event); | 2733 &begin_event); |
| 2732 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; | 2734 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; |
| 2733 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; | 2735 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; |
| 2734 if (wheel_event.scrollByPage) { | 2736 if (wheel_event.scrollByPage) { |
| 2735 begin_event.data.scrollBegin.deltaHintUnits = blink::WebGestureEvent::Page; | 2737 begin_event.data.scrollBegin.deltaHintUnits = blink::WebGestureEvent::Page; |
| 2736 if (begin_event.data.scrollBegin.deltaXHint) { | 2738 if (begin_event.data.scrollBegin.deltaXHint) { |
| 2737 begin_event.data.scrollBegin.deltaXHint = | 2739 begin_event.data.scrollBegin.deltaXHint = |
| 2738 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; | 2740 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; |
| 2739 } | 2741 } |
| 2740 if (begin_event.data.scrollBegin.deltaYHint) { | 2742 if (begin_event.data.scrollBegin.deltaYHint) { |
| 2741 begin_event.data.scrollBegin.deltaYHint = | 2743 begin_event.data.scrollBegin.deltaYHint = |
| 2742 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; | 2744 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; |
| 2743 } | 2745 } |
| 2744 } else { | 2746 } else { |
| 2745 begin_event.data.scrollBegin.deltaHintUnits = | 2747 begin_event.data.scrollBegin.deltaHintUnits = |
| 2746 wheel_event.hasPreciseScrollingDeltas | 2748 wheel_event.hasPreciseScrollingDeltas |
| 2747 ? blink::WebGestureEvent::PrecisePixels | 2749 ? blink::WebGestureEvent::PrecisePixels |
| 2748 : blink::WebGestureEvent::Pixels; | 2750 : blink::WebGestureEvent::Pixels; |
| 2749 } | 2751 } |
| 2750 | 2752 |
| 2751 if (force_layout_on_events_) | 2753 if (force_layout_on_events_) |
| 2752 view()->updateAllLifecyclePhases(); | 2754 widget()->updateAllLifecyclePhases(); |
| 2753 | 2755 |
| 2754 HandleInputEventOnViewOrPopup(begin_event); | 2756 HandleInputEventOnViewOrPopup(begin_event); |
| 2755 | 2757 |
| 2756 WebGestureEvent update_event; | 2758 WebGestureEvent update_event; |
| 2757 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollUpdate, | 2759 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollUpdate, |
| 2758 GetCurrentEventTimeSec(), wheel_event, | 2760 GetCurrentEventTimeSec(), wheel_event, |
| 2759 &update_event); | 2761 &update_event); |
| 2760 update_event.data.scrollUpdate.deltaX = | 2762 update_event.data.scrollUpdate.deltaX = |
| 2761 begin_event.data.scrollBegin.deltaXHint; | 2763 begin_event.data.scrollBegin.deltaXHint; |
| 2762 update_event.data.scrollUpdate.deltaY = | 2764 update_event.data.scrollUpdate.deltaY = |
| 2763 begin_event.data.scrollBegin.deltaYHint; | 2765 begin_event.data.scrollBegin.deltaYHint; |
| 2764 update_event.data.scrollUpdate.deltaUnits = | 2766 update_event.data.scrollUpdate.deltaUnits = |
| 2765 begin_event.data.scrollBegin.deltaHintUnits; | 2767 begin_event.data.scrollBegin.deltaHintUnits; |
| 2766 | 2768 |
| 2767 if (force_layout_on_events_) | 2769 if (force_layout_on_events_) |
| 2768 view()->updateAllLifecyclePhases(); | 2770 widget()->updateAllLifecyclePhases(); |
| 2769 HandleInputEventOnViewOrPopup(update_event); | 2771 HandleInputEventOnViewOrPopup(update_event); |
| 2770 | 2772 |
| 2771 WebGestureEvent end_event; | 2773 WebGestureEvent end_event; |
| 2772 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollEnd, | 2774 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollEnd, |
| 2773 GetCurrentEventTimeSec(), wheel_event, | 2775 GetCurrentEventTimeSec(), wheel_event, |
| 2774 &end_event); | 2776 &end_event); |
| 2775 end_event.data.scrollEnd.deltaUnits = | 2777 end_event.data.scrollEnd.deltaUnits = |
| 2776 begin_event.data.scrollBegin.deltaHintUnits; | 2778 begin_event.data.scrollBegin.deltaHintUnits; |
| 2777 | 2779 |
| 2778 if (force_layout_on_events_) | 2780 if (force_layout_on_events_) |
| 2779 view()->updateAllLifecyclePhases(); | 2781 widget()->updateAllLifecyclePhases(); |
| 2780 HandleInputEventOnViewOrPopup(end_event); | 2782 HandleInputEventOnViewOrPopup(end_event); |
| 2781 } | 2783 } |
| 2782 | 2784 |
| 2783 TestInterfaces* EventSender::interfaces() { | 2785 TestInterfaces* EventSender::interfaces() { |
| 2784 return web_test_proxy_base_->test_interfaces(); | 2786 return web_frame_test_proxy_base_->web_test_proxy_base()->test_interfaces(); |
| 2785 } | 2787 } |
| 2786 | 2788 |
| 2787 WebTestDelegate* EventSender::delegate() { | 2789 WebTestDelegate* EventSender::delegate() { |
| 2788 return web_test_proxy_base_->delegate(); | 2790 return web_frame_test_proxy_base_->web_test_proxy_base()->delegate(); |
| 2789 } | 2791 } |
| 2790 | 2792 |
| 2791 const blink::WebView* EventSender::view() const { | 2793 const blink::WebView* EventSender::view() const { |
| 2792 return web_test_proxy_base_->web_view(); | 2794 return web_frame_test_proxy_base_->web_frame()->view(); |
| 2793 } | 2795 } |
| 2794 | 2796 |
| 2795 blink::WebView* EventSender::view() { | 2797 blink::WebView* EventSender::view() { |
| 2796 return web_test_proxy_base_->web_view(); | 2798 return web_frame_test_proxy_base_->web_frame()->view(); |
| 2799 } | |
| 2800 | |
| 2801 blink::WebWidget* EventSender::widget() { | |
| 2802 if (web_frame_test_proxy_base_->web_frame()) | |
| 2803 return web_frame_test_proxy_base_->web_frame()->localRoot()->frameWidget(); | |
| 2804 return nullptr; | |
| 2797 } | 2805 } |
| 2798 | 2806 |
| 2799 } // namespace test_runner | 2807 } // namespace test_runner |
| OLD | NEW |