| 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/command_line.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "components/test_runner/mock_spell_check.h" | 17 #include "components/test_runner/mock_spell_check.h" |
| 17 #include "components/test_runner/test_interfaces.h" | 18 #include "components/test_runner/test_interfaces.h" |
| 18 #include "components/test_runner/web_test_delegate.h" | 19 #include "components/test_runner/web_test_delegate.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 e->modifiers = modifiersWithButtons(modifiers, current_buttons); | 109 e->modifiers = modifiersWithButtons(modifiers, current_buttons); |
| 109 e->x = pos.x; | 110 e->x = pos.x; |
| 110 e->y = pos.y; | 111 e->y = pos.y; |
| 111 e->globalX = pos.x; | 112 e->globalX = pos.x; |
| 112 e->globalY = pos.y; | 113 e->globalY = pos.y; |
| 113 e->pointerType = blink::WebPointerProperties::PointerType::Mouse; | 114 e->pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| 114 e->timeStampSeconds = time_stamp; | 115 e->timeStampSeconds = time_stamp; |
| 115 e->clickCount = click_count; | 116 e->clickCount = click_count; |
| 116 } | 117 } |
| 117 | 118 |
| 119 void InitGestureEventFromMouseWheel(WebInputEvent::Type type, |
| 120 double time_stamp, |
| 121 const WebMouseWheelEvent& wheel_event, |
| 122 WebGestureEvent* gesture_event) { |
| 123 gesture_event->type = type; |
| 124 gesture_event->sourceDevice = blink::WebGestureDeviceTouchpad; |
| 125 gesture_event->x = wheel_event.x; |
| 126 gesture_event->y = wheel_event.y; |
| 127 gesture_event->globalX = wheel_event.globalX; |
| 128 gesture_event->globalY = wheel_event.globalY; |
| 129 gesture_event->timeStampSeconds = time_stamp; |
| 130 } |
| 131 |
| 118 int GetKeyModifier(const std::string& modifier_name) { | 132 int GetKeyModifier(const std::string& modifier_name) { |
| 119 const char* characters = modifier_name.c_str(); | 133 const char* characters = modifier_name.c_str(); |
| 120 if (!strcmp(characters, "ctrlKey") | 134 if (!strcmp(characters, "ctrlKey") |
| 121 #ifndef __APPLE__ | 135 #ifndef __APPLE__ |
| 122 || !strcmp(characters, "addSelectionKey") | 136 || !strcmp(characters, "addSelectionKey") |
| 123 #endif | 137 #endif |
| 124 ) { | 138 ) { |
| 125 return WebInputEvent::ControlKey; | 139 return WebInputEvent::ControlKey; |
| 126 } else if (!strcmp(characters, "shiftKey") || | 140 } else if (!strcmp(characters, "shiftKey") || |
| 127 !strcmp(characters, "rangeSelectionKey")) { | 141 !strcmp(characters, "rangeSelectionKey")) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 void GestureScrollFirstPoint(int x, int y); | 507 void GestureScrollFirstPoint(int x, int y); |
| 494 void TouchStart(); | 508 void TouchStart(); |
| 495 void TouchMove(); | 509 void TouchMove(); |
| 496 void TouchMoveCausingScrollIfUncanceled(); | 510 void TouchMoveCausingScrollIfUncanceled(); |
| 497 void TouchCancel(); | 511 void TouchCancel(); |
| 498 void TouchEnd(); | 512 void TouchEnd(); |
| 499 void LeapForward(int milliseconds); | 513 void LeapForward(int milliseconds); |
| 500 double LastEventTimestamp(); | 514 double LastEventTimestamp(); |
| 501 void BeginDragWithFiles(const std::vector<std::string>& files); | 515 void BeginDragWithFiles(const std::vector<std::string>& files); |
| 502 void AddTouchPoint(double x, double y, gin::Arguments* args); | 516 void AddTouchPoint(double x, double y, gin::Arguments* args); |
| 503 void MouseDragBegin(); | |
| 504 void MouseDragEnd(); | |
| 505 void GestureScrollBegin(gin::Arguments* args); | 517 void GestureScrollBegin(gin::Arguments* args); |
| 506 void GestureScrollEnd(gin::Arguments* args); | 518 void GestureScrollEnd(gin::Arguments* args); |
| 507 void GestureScrollUpdate(gin::Arguments* args); | 519 void GestureScrollUpdate(gin::Arguments* args); |
| 508 void GesturePinchBegin(gin::Arguments* args); | 520 void GesturePinchBegin(gin::Arguments* args); |
| 509 void GesturePinchEnd(gin::Arguments* args); | 521 void GesturePinchEnd(gin::Arguments* args); |
| 510 void GesturePinchUpdate(gin::Arguments* args); | 522 void GesturePinchUpdate(gin::Arguments* args); |
| 511 void GestureTap(gin::Arguments* args); | 523 void GestureTap(gin::Arguments* args); |
| 512 void GestureTapDown(gin::Arguments* args); | 524 void GestureTapDown(gin::Arguments* args); |
| 513 void GestureShowPress(gin::Arguments* args); | 525 void GestureShowPress(gin::Arguments* args); |
| 514 void GestureTapCancel(gin::Arguments* args); | 526 void GestureTapCancel(gin::Arguments* args); |
| 515 void GestureLongPress(gin::Arguments* args); | 527 void GestureLongPress(gin::Arguments* args); |
| 516 void GestureLongTap(gin::Arguments* args); | 528 void GestureLongTap(gin::Arguments* args); |
| 517 void GestureTwoFingerTap(gin::Arguments* args); | 529 void GestureTwoFingerTap(gin::Arguments* args); |
| 518 void ContinuousMouseScrollBy(gin::Arguments* args); | 530 void ContinuousMouseScrollBy(gin::Arguments* args); |
| 519 void MouseMoveTo(gin::Arguments* args); | 531 void MouseMoveTo(gin::Arguments* args); |
| 520 void MouseLeave(); | 532 void MouseLeave(); |
| 521 void TrackpadScrollBegin(); | |
| 522 void TrackpadScroll(gin::Arguments* args); | |
| 523 void TrackpadScrollEnd(); | |
| 524 void MouseScrollBy(gin::Arguments* args); | 533 void MouseScrollBy(gin::Arguments* args); |
| 525 void ScheduleAsynchronousClick(gin::Arguments* args); | 534 void ScheduleAsynchronousClick(gin::Arguments* args); |
| 526 void ScheduleAsynchronousKeyDown(gin::Arguments* args); | 535 void ScheduleAsynchronousKeyDown(gin::Arguments* args); |
| 527 void MouseDown(gin::Arguments* args); | 536 void MouseDown(gin::Arguments* args); |
| 528 void MouseUp(gin::Arguments* args); | 537 void MouseUp(gin::Arguments* args); |
| 529 void SetMouseButtonState(gin::Arguments* args); | 538 void SetMouseButtonState(gin::Arguments* args); |
| 530 void KeyDown(gin::Arguments* args); | 539 void KeyDown(gin::Arguments* args); |
| 531 | 540 |
| 532 // Binding properties: | 541 // Binding properties: |
| 533 bool ForceLayoutOnEvents() const; | 542 bool ForceLayoutOnEvents() const; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 632 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 624 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 633 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| 625 .SetMethod("touchMoveCausingScrollIfUncanceled", | 634 .SetMethod("touchMoveCausingScrollIfUncanceled", |
| 626 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) | 635 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) |
| 627 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) | 636 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) |
| 628 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) | 637 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) |
| 629 .SetMethod("leapForward", &EventSenderBindings::LeapForward) | 638 .SetMethod("leapForward", &EventSenderBindings::LeapForward) |
| 630 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) | 639 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) |
| 631 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) | 640 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) |
| 632 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) | 641 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) |
| 633 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) | |
| 634 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) | |
| 635 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) | 642 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) |
| 636 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) | 643 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) |
| 637 .SetMethod("gestureScrollUpdate", | 644 .SetMethod("gestureScrollUpdate", |
| 638 &EventSenderBindings::GestureScrollUpdate) | 645 &EventSenderBindings::GestureScrollUpdate) |
| 639 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) | 646 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) |
| 640 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) | 647 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) |
| 641 .SetMethod("gesturePinchUpdate", &EventSenderBindings::GesturePinchUpdate) | 648 .SetMethod("gesturePinchUpdate", &EventSenderBindings::GesturePinchUpdate) |
| 642 .SetMethod("gestureTap", &EventSenderBindings::GestureTap) | 649 .SetMethod("gestureTap", &EventSenderBindings::GestureTap) |
| 643 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown) | 650 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown) |
| 644 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress) | 651 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress) |
| 645 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel) | 652 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel) |
| 646 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress) | 653 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress) |
| 647 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap) | 654 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap) |
| 648 .SetMethod("gestureTwoFingerTap", | 655 .SetMethod("gestureTwoFingerTap", |
| 649 &EventSenderBindings::GestureTwoFingerTap) | 656 &EventSenderBindings::GestureTwoFingerTap) |
| 650 .SetMethod("continuousMouseScrollBy", | 657 .SetMethod("continuousMouseScrollBy", |
| 651 &EventSenderBindings::ContinuousMouseScrollBy) | 658 &EventSenderBindings::ContinuousMouseScrollBy) |
| 652 .SetMethod("keyDown", &EventSenderBindings::KeyDown) | 659 .SetMethod("keyDown", &EventSenderBindings::KeyDown) |
| 653 .SetMethod("mouseDown", &EventSenderBindings::MouseDown) | 660 .SetMethod("mouseDown", &EventSenderBindings::MouseDown) |
| 654 .SetMethod("mouseMoveTo", &EventSenderBindings::MouseMoveTo) | 661 .SetMethod("mouseMoveTo", &EventSenderBindings::MouseMoveTo) |
| 655 .SetMethod("mouseLeave", &EventSenderBindings::MouseLeave) | 662 .SetMethod("mouseLeave", &EventSenderBindings::MouseLeave) |
| 656 .SetMethod("trackpadScrollBegin", | |
| 657 &EventSenderBindings::TrackpadScrollBegin) | |
| 658 .SetMethod("trackpadScroll", &EventSenderBindings::TrackpadScroll) | |
| 659 .SetMethod("trackpadScrollEnd", &EventSenderBindings::TrackpadScrollEnd) | |
| 660 .SetMethod("mouseScrollBy", &EventSenderBindings::MouseScrollBy) | 663 .SetMethod("mouseScrollBy", &EventSenderBindings::MouseScrollBy) |
| 661 .SetMethod("mouseUp", &EventSenderBindings::MouseUp) | 664 .SetMethod("mouseUp", &EventSenderBindings::MouseUp) |
| 662 .SetMethod("setMouseButtonState", | 665 .SetMethod("setMouseButtonState", |
| 663 &EventSenderBindings::SetMouseButtonState) | 666 &EventSenderBindings::SetMouseButtonState) |
| 664 .SetMethod("scheduleAsynchronousClick", | 667 .SetMethod("scheduleAsynchronousClick", |
| 665 &EventSenderBindings::ScheduleAsynchronousClick) | 668 &EventSenderBindings::ScheduleAsynchronousClick) |
| 666 .SetMethod("scheduleAsynchronousKeyDown", | 669 .SetMethod("scheduleAsynchronousKeyDown", |
| 667 &EventSenderBindings::ScheduleAsynchronousKeyDown) | 670 &EventSenderBindings::ScheduleAsynchronousKeyDown) |
| 668 .SetProperty("forceLayoutOnEvents", | 671 .SetProperty("forceLayoutOnEvents", |
| 669 &EventSenderBindings::ForceLayoutOnEvents, | 672 &EventSenderBindings::ForceLayoutOnEvents, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 sender_->BeginDragWithFiles(files); | 847 sender_->BeginDragWithFiles(files); |
| 845 } | 848 } |
| 846 | 849 |
| 847 void EventSenderBindings::AddTouchPoint(double x, | 850 void EventSenderBindings::AddTouchPoint(double x, |
| 848 double y, | 851 double y, |
| 849 gin::Arguments* args) { | 852 gin::Arguments* args) { |
| 850 if (sender_) | 853 if (sender_) |
| 851 sender_->AddTouchPoint(static_cast<float>(x), static_cast<float>(y), args); | 854 sender_->AddTouchPoint(static_cast<float>(x), static_cast<float>(y), args); |
| 852 } | 855 } |
| 853 | 856 |
| 854 void EventSenderBindings::MouseDragBegin() { | |
| 855 if (sender_) | |
| 856 sender_->MouseDragBegin(); | |
| 857 } | |
| 858 | |
| 859 void EventSenderBindings::MouseDragEnd() { | |
| 860 if (sender_) | |
| 861 sender_->MouseDragEnd(); | |
| 862 } | |
| 863 | |
| 864 void EventSenderBindings::GestureScrollBegin(gin::Arguments* args) { | 857 void EventSenderBindings::GestureScrollBegin(gin::Arguments* args) { |
| 865 if (sender_) | 858 if (sender_) |
| 866 sender_->GestureScrollBegin(args); | 859 sender_->GestureScrollBegin(args); |
| 867 } | 860 } |
| 868 | 861 |
| 869 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) { | 862 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) { |
| 870 if (sender_) | 863 if (sender_) |
| 871 sender_->GestureScrollEnd(args); | 864 sender_->GestureScrollEnd(args); |
| 872 } | 865 } |
| 873 | 866 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 sender_->GestureLongTap(args); | 914 sender_->GestureLongTap(args); |
| 922 } | 915 } |
| 923 | 916 |
| 924 void EventSenderBindings::GestureTwoFingerTap(gin::Arguments* args) { | 917 void EventSenderBindings::GestureTwoFingerTap(gin::Arguments* args) { |
| 925 if (sender_) | 918 if (sender_) |
| 926 sender_->GestureTwoFingerTap(args); | 919 sender_->GestureTwoFingerTap(args); |
| 927 } | 920 } |
| 928 | 921 |
| 929 void EventSenderBindings::ContinuousMouseScrollBy(gin::Arguments* args) { | 922 void EventSenderBindings::ContinuousMouseScrollBy(gin::Arguments* args) { |
| 930 if (sender_) | 923 if (sender_) |
| 931 sender_->ContinuousMouseScrollBy(args); | 924 sender_->MouseScrollBy(args, EventSender::MouseScrollType::PIXEL); |
| 932 } | 925 } |
| 933 | 926 |
| 934 void EventSenderBindings::MouseMoveTo(gin::Arguments* args) { | 927 void EventSenderBindings::MouseMoveTo(gin::Arguments* args) { |
| 935 if (sender_) | 928 if (sender_) |
| 936 sender_->MouseMoveTo(args); | 929 sender_->MouseMoveTo(args); |
| 937 } | 930 } |
| 938 | 931 |
| 939 void EventSenderBindings::MouseLeave() { | 932 void EventSenderBindings::MouseLeave() { |
| 940 if (sender_) | 933 if (sender_) |
| 941 sender_->MouseLeave(); | 934 sender_->MouseLeave(); |
| 942 } | 935 } |
| 943 | 936 |
| 944 void EventSenderBindings::TrackpadScrollBegin() { | |
| 945 if (sender_) | |
| 946 sender_->TrackpadScrollBegin(); | |
| 947 } | |
| 948 | |
| 949 void EventSenderBindings::TrackpadScroll(gin::Arguments* args) { | |
| 950 if (sender_) | |
| 951 sender_->TrackpadScroll(args); | |
| 952 } | |
| 953 | |
| 954 void EventSenderBindings::TrackpadScrollEnd() { | |
| 955 if (sender_) | |
| 956 sender_->TrackpadScrollEnd(); | |
| 957 } | |
| 958 | |
| 959 void EventSenderBindings::MouseScrollBy(gin::Arguments* args) { | 937 void EventSenderBindings::MouseScrollBy(gin::Arguments* args) { |
| 960 if (sender_) | 938 if (sender_) |
| 961 sender_->MouseScrollBy(args); | 939 sender_->MouseScrollBy(args, EventSender::MouseScrollType::TICK); |
| 962 } | 940 } |
| 963 | 941 |
| 964 void EventSenderBindings::ScheduleAsynchronousClick(gin::Arguments* args) { | 942 void EventSenderBindings::ScheduleAsynchronousClick(gin::Arguments* args) { |
| 965 if (!sender_) | 943 if (!sender_) |
| 966 return; | 944 return; |
| 967 | 945 |
| 968 int button_number = 0; | 946 int button_number = 0; |
| 969 int modifiers = 0; | 947 int modifiers = 0; |
| 970 if (!args->PeekNext().IsEmpty()) { | 948 if (!args->PeekNext().IsEmpty()) { |
| 971 args->GetNext(&button_number); | 949 args->GetNext(&button_number); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 wm_char_(0), | 1173 wm_char_(0), |
| 1196 wm_dead_char_(0), | 1174 wm_dead_char_(0), |
| 1197 wm_sys_key_down_(0), | 1175 wm_sys_key_down_(0), |
| 1198 wm_sys_key_up_(0), | 1176 wm_sys_key_up_(0), |
| 1199 wm_sys_char_(0), | 1177 wm_sys_char_(0), |
| 1200 wm_sys_dead_char_(0), | 1178 wm_sys_dead_char_(0), |
| 1201 #endif | 1179 #endif |
| 1202 interfaces_(interfaces), | 1180 interfaces_(interfaces), |
| 1203 delegate_(NULL), | 1181 delegate_(NULL), |
| 1204 view_(NULL), | 1182 view_(NULL), |
| 1183 send_wheel_gestures_(false), |
| 1205 force_layout_on_events_(false), | 1184 force_layout_on_events_(false), |
| 1206 is_drag_mode_(true), | 1185 is_drag_mode_(true), |
| 1207 touch_modifiers_(0), | 1186 touch_modifiers_(0), |
| 1208 touch_cancelable_(true), | 1187 touch_cancelable_(true), |
| 1209 replaying_saved_events_(false), | 1188 replaying_saved_events_(false), |
| 1210 current_drag_effects_allowed_(blink::WebDragOperationNone), | 1189 current_drag_effects_allowed_(blink::WebDragOperationNone), |
| 1211 last_click_time_sec_(0), | 1190 last_click_time_sec_(0), |
| 1212 current_drag_effect_(blink::WebDragOperationNone), | 1191 current_drag_effect_(blink::WebDragOperationNone), |
| 1213 time_offset_ms_(0), | 1192 time_offset_ms_(0), |
| 1214 click_count_(0), | 1193 click_count_(0), |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 InitPointerProperties(args, &touch_point, &touch_point.radiusX, | 1893 InitPointerProperties(args, &touch_point, &touch_point.radiusX, |
| 1915 &touch_point.radiusY); | 1894 &touch_point.radiusY); |
| 1916 | 1895 |
| 1917 // Set the touch point pressure to zero if it was not set by the caller | 1896 // Set the touch point pressure to zero if it was not set by the caller |
| 1918 if (std::isnan(touch_point.force)) | 1897 if (std::isnan(touch_point.force)) |
| 1919 touch_point.force = 0.0; | 1898 touch_point.force = 0.0; |
| 1920 | 1899 |
| 1921 touch_points_.push_back(touch_point); | 1900 touch_points_.push_back(touch_point); |
| 1922 } | 1901 } |
| 1923 | 1902 |
| 1924 void EventSender::MouseDragBegin() { | |
| 1925 WebMouseWheelEvent event; | |
| 1926 InitMouseEvent(WebInputEvent::MouseWheel, | |
| 1927 WebMouseEvent::ButtonNone, | |
| 1928 0, | |
| 1929 last_mouse_pos_, | |
| 1930 GetCurrentEventTimeSec(), | |
| 1931 click_count_, | |
| 1932 0, | |
| 1933 &event); | |
| 1934 event.phase = WebMouseWheelEvent::PhaseBegan; | |
| 1935 event.hasPreciseScrollingDeltas = true; | |
| 1936 HandleInputEventOnViewOrPopup(event); | |
| 1937 } | |
| 1938 | |
| 1939 void EventSender::MouseDragEnd() { | |
| 1940 WebMouseWheelEvent event; | |
| 1941 InitMouseEvent(WebInputEvent::MouseWheel, | |
| 1942 WebMouseEvent::ButtonNone, | |
| 1943 0, | |
| 1944 last_mouse_pos_, | |
| 1945 GetCurrentEventTimeSec(), | |
| 1946 click_count_, | |
| 1947 0, | |
| 1948 &event); | |
| 1949 event.phase = WebMouseWheelEvent::PhaseEnded; | |
| 1950 event.hasPreciseScrollingDeltas = true; | |
| 1951 HandleInputEventOnViewOrPopup(event); | |
| 1952 } | |
| 1953 | |
| 1954 void EventSender::GestureScrollBegin(gin::Arguments* args) { | 1903 void EventSender::GestureScrollBegin(gin::Arguments* args) { |
| 1955 GestureEvent(WebInputEvent::GestureScrollBegin, args); | 1904 GestureEvent(WebInputEvent::GestureScrollBegin, args); |
| 1956 } | 1905 } |
| 1957 | 1906 |
| 1958 void EventSender::GestureScrollEnd(gin::Arguments* args) { | 1907 void EventSender::GestureScrollEnd(gin::Arguments* args) { |
| 1959 GestureEvent(WebInputEvent::GestureScrollEnd, args); | 1908 GestureEvent(WebInputEvent::GestureScrollEnd, args); |
| 1960 } | 1909 } |
| 1961 | 1910 |
| 1962 void EventSender::GestureScrollUpdate(gin::Arguments* args) { | 1911 void EventSender::GestureScrollUpdate(gin::Arguments* args) { |
| 1963 GestureEvent(WebInputEvent::GestureScrollUpdate, args); | 1912 GestureEvent(WebInputEvent::GestureScrollUpdate, args); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 } | 1945 } |
| 1997 | 1946 |
| 1998 void EventSender::GestureLongTap(gin::Arguments* args) { | 1947 void EventSender::GestureLongTap(gin::Arguments* args) { |
| 1999 GestureEvent(WebInputEvent::GestureLongTap, args); | 1948 GestureEvent(WebInputEvent::GestureLongTap, args); |
| 2000 } | 1949 } |
| 2001 | 1950 |
| 2002 void EventSender::GestureTwoFingerTap(gin::Arguments* args) { | 1951 void EventSender::GestureTwoFingerTap(gin::Arguments* args) { |
| 2003 GestureEvent(WebInputEvent::GestureTwoFingerTap, args); | 1952 GestureEvent(WebInputEvent::GestureTwoFingerTap, args); |
| 2004 } | 1953 } |
| 2005 | 1954 |
| 2006 void EventSender::ContinuousMouseScrollBy(gin::Arguments* args) { | 1955 void EventSender::MouseScrollBy(gin::Arguments* args, |
| 2007 WebMouseWheelEvent event; | 1956 MouseScrollType scroll_type) { |
| 2008 InitMouseWheelEvent(args, true, &event); | 1957 WebMouseWheelEvent wheel_event; |
| 2009 HandleInputEventOnViewOrPopup(event); | 1958 // TODO(dtapuska): Gestures really should be sent by the MouseWheelEventQueue |
| 1959 // class in the browser. But since the event doesn't propogate up into |
| 1960 // the browser generate the events here. See crbug.com/596095. |
| 1961 bool send_gestures = false; |
| 1962 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); |
| 1963 if (HandleInputEventOnViewOrPopup(wheel_event) == |
| 1964 WebInputEventResult::NotHandled && |
| 1965 send_gestures) { |
| 1966 SendGesturesForMouseWheelEvent(wheel_event); |
| 1967 } |
| 2010 } | 1968 } |
| 2011 | 1969 |
| 2012 void EventSender::MouseMoveTo(gin::Arguments* args) { | 1970 void EventSender::MouseMoveTo(gin::Arguments* args) { |
| 2013 if (force_layout_on_events_) | 1971 if (force_layout_on_events_) |
| 2014 view_->updateAllLifecyclePhases(); | 1972 view_->updateAllLifecyclePhases(); |
| 2015 | 1973 |
| 2016 double x; | 1974 double x; |
| 2017 double y; | 1975 double y; |
| 2018 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 1976 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
| 2019 args->ThrowError(); | 1977 args->ThrowError(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2056 0, | 2014 0, |
| 2057 last_mouse_pos_, | 2015 last_mouse_pos_, |
| 2058 GetCurrentEventTimeSec(), | 2016 GetCurrentEventTimeSec(), |
| 2059 click_count_, | 2017 click_count_, |
| 2060 0, | 2018 0, |
| 2061 &event); | 2019 &event); |
| 2062 HandleInputEventOnViewOrPopup(event); | 2020 HandleInputEventOnViewOrPopup(event); |
| 2063 } | 2021 } |
| 2064 | 2022 |
| 2065 | 2023 |
| 2066 void EventSender::TrackpadScrollBegin() { | |
| 2067 WebMouseWheelEvent event; | |
| 2068 InitMouseEvent(WebInputEvent::MouseWheel, | |
| 2069 WebMouseEvent::ButtonNone, | |
| 2070 0, | |
| 2071 last_mouse_pos_, | |
| 2072 GetCurrentEventTimeSec(), | |
| 2073 click_count_, | |
| 2074 0, | |
| 2075 &event); | |
| 2076 event.phase = blink::WebMouseWheelEvent::PhaseBegan; | |
| 2077 event.hasPreciseScrollingDeltas = true; | |
| 2078 HandleInputEventOnViewOrPopup(event); | |
| 2079 } | |
| 2080 | |
| 2081 void EventSender::TrackpadScroll(gin::Arguments* args) { | |
| 2082 WebMouseWheelEvent event; | |
| 2083 InitMouseWheelEvent(args, true, &event); | |
| 2084 event.phase = blink::WebMouseWheelEvent::PhaseChanged; | |
| 2085 event.hasPreciseScrollingDeltas = true; | |
| 2086 HandleInputEventOnViewOrPopup(event); | |
| 2087 } | |
| 2088 | |
| 2089 void EventSender::TrackpadScrollEnd() { | |
| 2090 WebMouseWheelEvent event; | |
| 2091 InitMouseEvent(WebInputEvent::MouseWheel, | |
| 2092 WebMouseEvent::ButtonNone, | |
| 2093 0, | |
| 2094 last_mouse_pos_, | |
| 2095 GetCurrentEventTimeSec(), | |
| 2096 click_count_, | |
| 2097 0, | |
| 2098 &event); | |
| 2099 event.phase = WebMouseWheelEvent::PhaseEnded; | |
| 2100 event.hasPreciseScrollingDeltas = true; | |
| 2101 HandleInputEventOnViewOrPopup(event); | |
| 2102 } | |
| 2103 | |
| 2104 void EventSender::MouseScrollBy(gin::Arguments* args) { | |
| 2105 WebMouseWheelEvent event; | |
| 2106 InitMouseWheelEvent(args, false, &event); | |
| 2107 HandleInputEventOnViewOrPopup(event); | |
| 2108 } | |
| 2109 | |
| 2110 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { | 2024 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
| 2111 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); | 2025 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); |
| 2112 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); | 2026 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); |
| 2113 } | 2027 } |
| 2114 | 2028 |
| 2115 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, | 2029 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, |
| 2116 int modifiers, | 2030 int modifiers, |
| 2117 KeyLocationCode location) { | 2031 KeyLocationCode location) { |
| 2118 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); | 2032 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); |
| 2119 } | 2033 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2433 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && | 2347 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && |
| 2434 (button_type == last_button_type_)) { | 2348 (button_type == last_button_type_)) { |
| 2435 ++click_count_; | 2349 ++click_count_; |
| 2436 } else { | 2350 } else { |
| 2437 click_count_ = 1; | 2351 click_count_ = 1; |
| 2438 last_button_type_ = button_type; | 2352 last_button_type_ = button_type; |
| 2439 } | 2353 } |
| 2440 } | 2354 } |
| 2441 | 2355 |
| 2442 void EventSender::InitMouseWheelEvent(gin::Arguments* args, | 2356 void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| 2443 bool continuous, | 2357 MouseScrollType scroll_type, |
| 2444 WebMouseWheelEvent* event) { | 2358 WebMouseWheelEvent* event, |
| 2359 bool* send_gestures) { |
| 2445 // Force a layout here just to make sure every position has been | 2360 // Force a layout here just to make sure every position has been |
| 2446 // determined before we send events (as well as all the other methods | 2361 // determined before we send events (as well as all the other methods |
| 2447 // that send an event do). | 2362 // that send an event do). |
| 2448 if (force_layout_on_events_) | 2363 if (force_layout_on_events_) |
| 2449 view_->updateAllLifecyclePhases(); | 2364 view_->updateAllLifecyclePhases(); |
| 2450 | 2365 |
| 2451 double horizontal; | 2366 double horizontal; |
| 2452 if (!args->GetNext(&horizontal)) { | 2367 if (!args->GetNext(&horizontal)) { |
| 2453 args->ThrowError(); | 2368 args->ThrowError(); |
| 2454 return; | 2369 return; |
| 2455 } | 2370 } |
| 2456 double vertical; | 2371 double vertical; |
| 2457 if (!args->GetNext(&vertical)) { | 2372 if (!args->GetNext(&vertical)) { |
| 2458 args->ThrowError(); | 2373 args->ThrowError(); |
| 2459 return; | 2374 return; |
| 2460 } | 2375 } |
| 2461 | 2376 |
| 2462 bool paged = false; | 2377 bool paged = false; |
| 2463 bool has_precise_scrolling_deltas = false; | 2378 bool has_precise_scrolling_deltas = false; |
| 2464 int modifiers = 0; | 2379 int modifiers = 0; |
| 2465 bool can_scroll = true; | 2380 bool can_scroll = true; |
| 2466 if (!args->PeekNext().IsEmpty()) { | 2381 if (!args->PeekNext().IsEmpty()) { |
| 2467 args->GetNext(&paged); | 2382 args->GetNext(&paged); |
| 2468 if (!args->PeekNext().IsEmpty()) { | 2383 if (!args->PeekNext().IsEmpty()) { |
| 2469 args->GetNext(&has_precise_scrolling_deltas); | 2384 args->GetNext(&has_precise_scrolling_deltas); |
| 2470 if (!args->PeekNext().IsEmpty()) { | 2385 if (!args->PeekNext().IsEmpty()) { |
| 2471 v8::Local<v8::Value> value; | 2386 v8::Local<v8::Value> value; |
| 2472 args->GetNext(&value); | 2387 args->GetNext(&value); |
| 2473 modifiers = GetKeyModifiersFromV8(args->isolate(), value); | 2388 modifiers = GetKeyModifiersFromV8(args->isolate(), value); |
| 2474 if (!args->PeekNext().IsEmpty()) | 2389 if (!args->PeekNext().IsEmpty()) { |
| 2475 args->GetNext(&can_scroll); | 2390 args->GetNext(&can_scroll); |
| 2391 } |
| 2476 } | 2392 } |
| 2477 } | 2393 } |
| 2478 } | 2394 } |
| 2395 if (can_scroll && send_wheel_gestures_) { |
| 2396 can_scroll = false; |
| 2397 *send_gestures = true; |
| 2398 } |
| 2479 | 2399 |
| 2480 InitMouseEvent(WebInputEvent::MouseWheel, | 2400 InitMouseEvent(WebInputEvent::MouseWheel, |
| 2481 pressed_button_, | 2401 pressed_button_, |
| 2482 current_buttons_, | 2402 current_buttons_, |
| 2483 last_mouse_pos_, | 2403 last_mouse_pos_, |
| 2484 GetCurrentEventTimeSec(), | 2404 GetCurrentEventTimeSec(), |
| 2485 click_count_, | 2405 click_count_, |
| 2486 modifiers, | 2406 modifiers, |
| 2487 event); | 2407 event); |
| 2488 event->wheelTicksX = static_cast<float>(horizontal); | 2408 event->wheelTicksX = static_cast<float>(horizontal); |
| 2489 event->wheelTicksY = static_cast<float>(vertical); | 2409 event->wheelTicksY = static_cast<float>(vertical); |
| 2490 event->deltaX = event->wheelTicksX; | 2410 event->deltaX = event->wheelTicksX; |
| 2491 event->deltaY = event->wheelTicksY; | 2411 event->deltaY = event->wheelTicksY; |
| 2492 event->scrollByPage = paged; | 2412 event->scrollByPage = paged; |
| 2493 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; | 2413 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; |
| 2494 event->canScroll = can_scroll; | 2414 event->canScroll = can_scroll; |
| 2495 if (continuous) { | 2415 if (scroll_type == MouseScrollType::PIXEL) { |
| 2496 event->wheelTicksX /= kScrollbarPixelsPerTick; | 2416 event->wheelTicksX /= kScrollbarPixelsPerTick; |
| 2497 event->wheelTicksY /= kScrollbarPixelsPerTick; | 2417 event->wheelTicksY /= kScrollbarPixelsPerTick; |
| 2498 } else { | 2418 } else { |
| 2499 event->deltaX *= kScrollbarPixelsPerTick; | 2419 event->deltaX *= kScrollbarPixelsPerTick; |
| 2500 event->deltaY *= kScrollbarPixelsPerTick; | 2420 event->deltaY *= kScrollbarPixelsPerTick; |
| 2501 } | 2421 } |
| 2502 } | 2422 } |
| 2503 | 2423 |
| 2504 // Radius fields radius_x and radius_y should eventually be moved to | 2424 // Radius fields radius_x and radius_y should eventually be moved to |
| 2505 // WebPointerProperties. | 2425 // WebPointerProperties. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2677 const WebInputEvent& event) { | 2597 const WebInputEvent& event) { |
| 2678 last_event_timestamp_ = event.timeStampSeconds; | 2598 last_event_timestamp_ = event.timeStampSeconds; |
| 2679 | 2599 |
| 2680 if (WebPagePopup* popup = view_->pagePopup()) { | 2600 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2681 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2601 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2682 return popup->handleInputEvent(event); | 2602 return popup->handleInputEvent(event); |
| 2683 } | 2603 } |
| 2684 return view_->handleInputEvent(event); | 2604 return view_->handleInputEvent(event); |
| 2685 } | 2605 } |
| 2686 | 2606 |
| 2607 void EventSender::SendGesturesForMouseWheelEvent( |
| 2608 const WebMouseWheelEvent wheel_event) { |
| 2609 WebGestureEvent begin_event; |
| 2610 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollBegin, |
| 2611 GetCurrentEventTimeSec(), wheel_event, |
| 2612 &begin_event); |
| 2613 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; |
| 2614 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; |
| 2615 if (wheel_event.scrollByPage) { |
| 2616 begin_event.data.scrollBegin.deltaHintUnits = blink::WebGestureEvent::Page; |
| 2617 if (begin_event.data.scrollBegin.deltaXHint) { |
| 2618 begin_event.data.scrollBegin.deltaXHint = |
| 2619 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; |
| 2620 } |
| 2621 if (begin_event.data.scrollBegin.deltaYHint) { |
| 2622 begin_event.data.scrollBegin.deltaYHint = |
| 2623 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; |
| 2624 } |
| 2625 } else { |
| 2626 begin_event.data.scrollBegin.deltaHintUnits = |
| 2627 wheel_event.hasPreciseScrollingDeltas |
| 2628 ? blink::WebGestureEvent::PrecisePixels |
| 2629 : blink::WebGestureEvent::Pixels; |
| 2630 } |
| 2631 |
| 2632 if (force_layout_on_events_) |
| 2633 view_->updateAllLifecyclePhases(); |
| 2634 |
| 2635 HandleInputEventOnViewOrPopup(begin_event); |
| 2636 |
| 2637 WebGestureEvent update_event; |
| 2638 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollUpdate, |
| 2639 GetCurrentEventTimeSec(), wheel_event, |
| 2640 &update_event); |
| 2641 update_event.data.scrollUpdate.deltaX = |
| 2642 begin_event.data.scrollBegin.deltaXHint; |
| 2643 update_event.data.scrollUpdate.deltaY = |
| 2644 begin_event.data.scrollBegin.deltaYHint; |
| 2645 update_event.data.scrollUpdate.deltaUnits = |
| 2646 begin_event.data.scrollBegin.deltaHintUnits; |
| 2647 |
| 2648 if (force_layout_on_events_) |
| 2649 view_->updateAllLifecyclePhases(); |
| 2650 HandleInputEventOnViewOrPopup(update_event); |
| 2651 |
| 2652 WebGestureEvent end_event; |
| 2653 InitGestureEventFromMouseWheel(WebInputEvent::GestureScrollEnd, |
| 2654 GetCurrentEventTimeSec(), wheel_event, |
| 2655 &end_event); |
| 2656 end_event.data.scrollEnd.deltaUnits = |
| 2657 begin_event.data.scrollBegin.deltaHintUnits; |
| 2658 |
| 2659 if (force_layout_on_events_) |
| 2660 view_->updateAllLifecyclePhases(); |
| 2661 HandleInputEventOnViewOrPopup(end_event); |
| 2662 } |
| 2663 |
| 2687 } // namespace test_runner | 2664 } // namespace test_runner |
| OLD | NEW |