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/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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 void GestureScrollFirstPoint(int x, int y); | 494 void GestureScrollFirstPoint(int x, int y); |
| 494 void TouchStart(); | 495 void TouchStart(); |
| 495 void TouchMove(); | 496 void TouchMove(); |
| 496 void TouchMoveCausingScrollIfUncanceled(); | 497 void TouchMoveCausingScrollIfUncanceled(); |
| 497 void TouchCancel(); | 498 void TouchCancel(); |
| 498 void TouchEnd(); | 499 void TouchEnd(); |
| 499 void LeapForward(int milliseconds); | 500 void LeapForward(int milliseconds); |
| 500 double LastEventTimestamp(); | 501 double LastEventTimestamp(); |
| 501 void BeginDragWithFiles(const std::vector<std::string>& files); | 502 void BeginDragWithFiles(const std::vector<std::string>& files); |
| 502 void AddTouchPoint(double x, double y, gin::Arguments* args); | 503 void AddTouchPoint(double x, double y, gin::Arguments* args); |
| 503 void MouseDragBegin(); | |
| 504 void MouseDragEnd(); | |
| 505 void GestureScrollBegin(gin::Arguments* args); | 504 void GestureScrollBegin(gin::Arguments* args); |
| 506 void GestureScrollEnd(gin::Arguments* args); | 505 void GestureScrollEnd(gin::Arguments* args); |
| 507 void GestureScrollUpdate(gin::Arguments* args); | 506 void GestureScrollUpdate(gin::Arguments* args); |
| 508 void GesturePinchBegin(gin::Arguments* args); | 507 void GesturePinchBegin(gin::Arguments* args); |
| 509 void GesturePinchEnd(gin::Arguments* args); | 508 void GesturePinchEnd(gin::Arguments* args); |
| 510 void GesturePinchUpdate(gin::Arguments* args); | 509 void GesturePinchUpdate(gin::Arguments* args); |
| 511 void GestureTap(gin::Arguments* args); | 510 void GestureTap(gin::Arguments* args); |
| 512 void GestureTapDown(gin::Arguments* args); | 511 void GestureTapDown(gin::Arguments* args); |
| 513 void GestureShowPress(gin::Arguments* args); | 512 void GestureShowPress(gin::Arguments* args); |
| 514 void GestureTapCancel(gin::Arguments* args); | 513 void GestureTapCancel(gin::Arguments* args); |
| 515 void GestureLongPress(gin::Arguments* args); | 514 void GestureLongPress(gin::Arguments* args); |
| 516 void GestureLongTap(gin::Arguments* args); | 515 void GestureLongTap(gin::Arguments* args); |
| 517 void GestureTwoFingerTap(gin::Arguments* args); | 516 void GestureTwoFingerTap(gin::Arguments* args); |
| 518 void ContinuousMouseScrollBy(gin::Arguments* args); | 517 void ContinuousMouseScrollBy(gin::Arguments* args); |
| 519 void MouseMoveTo(gin::Arguments* args); | 518 void MouseMoveTo(gin::Arguments* args); |
| 520 void MouseLeave(); | 519 void MouseLeave(); |
| 521 void TrackpadScrollBegin(); | |
| 522 void TrackpadScroll(gin::Arguments* args); | |
| 523 void TrackpadScrollEnd(); | |
| 524 void MouseScrollBy(gin::Arguments* args); | 520 void MouseScrollBy(gin::Arguments* args); |
| 525 void ScheduleAsynchronousClick(gin::Arguments* args); | 521 void ScheduleAsynchronousClick(gin::Arguments* args); |
| 526 void ScheduleAsynchronousKeyDown(gin::Arguments* args); | 522 void ScheduleAsynchronousKeyDown(gin::Arguments* args); |
| 527 void MouseDown(gin::Arguments* args); | 523 void MouseDown(gin::Arguments* args); |
| 528 void MouseUp(gin::Arguments* args); | 524 void MouseUp(gin::Arguments* args); |
| 529 void SetMouseButtonState(gin::Arguments* args); | 525 void SetMouseButtonState(gin::Arguments* args); |
| 530 void KeyDown(gin::Arguments* args); | 526 void KeyDown(gin::Arguments* args); |
| 531 | 527 |
| 532 // Binding properties: | 528 // Binding properties: |
| 533 bool ForceLayoutOnEvents() const; | 529 bool ForceLayoutOnEvents() const; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 619 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 624 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 620 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| 625 .SetMethod("touchMoveCausingScrollIfUncanceled", | 621 .SetMethod("touchMoveCausingScrollIfUncanceled", |
| 626 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) | 622 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) |
| 627 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) | 623 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) |
| 628 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) | 624 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) |
| 629 .SetMethod("leapForward", &EventSenderBindings::LeapForward) | 625 .SetMethod("leapForward", &EventSenderBindings::LeapForward) |
| 630 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) | 626 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) |
| 631 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) | 627 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) |
| 632 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) | 628 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) |
| 633 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) | |
| 634 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) | |
| 635 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) | 629 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) |
| 636 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) | 630 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) |
| 637 .SetMethod("gestureScrollUpdate", | 631 .SetMethod("gestureScrollUpdate", |
| 638 &EventSenderBindings::GestureScrollUpdate) | 632 &EventSenderBindings::GestureScrollUpdate) |
| 639 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) | 633 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) |
| 640 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) | 634 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) |
| 641 .SetMethod("gesturePinchUpdate", &EventSenderBindings::GesturePinchUpdate) | 635 .SetMethod("gesturePinchUpdate", &EventSenderBindings::GesturePinchUpdate) |
| 642 .SetMethod("gestureTap", &EventSenderBindings::GestureTap) | 636 .SetMethod("gestureTap", &EventSenderBindings::GestureTap) |
| 643 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown) | 637 .SetMethod("gestureTapDown", &EventSenderBindings::GestureTapDown) |
| 644 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress) | 638 .SetMethod("gestureShowPress", &EventSenderBindings::GestureShowPress) |
| 645 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel) | 639 .SetMethod("gestureTapCancel", &EventSenderBindings::GestureTapCancel) |
| 646 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress) | 640 .SetMethod("gestureLongPress", &EventSenderBindings::GestureLongPress) |
| 647 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap) | 641 .SetMethod("gestureLongTap", &EventSenderBindings::GestureLongTap) |
| 648 .SetMethod("gestureTwoFingerTap", | 642 .SetMethod("gestureTwoFingerTap", |
| 649 &EventSenderBindings::GestureTwoFingerTap) | 643 &EventSenderBindings::GestureTwoFingerTap) |
| 650 .SetMethod("continuousMouseScrollBy", | 644 .SetMethod("continuousMouseScrollBy", |
| 651 &EventSenderBindings::ContinuousMouseScrollBy) | 645 &EventSenderBindings::ContinuousMouseScrollBy) |
| 652 .SetMethod("keyDown", &EventSenderBindings::KeyDown) | 646 .SetMethod("keyDown", &EventSenderBindings::KeyDown) |
| 653 .SetMethod("mouseDown", &EventSenderBindings::MouseDown) | 647 .SetMethod("mouseDown", &EventSenderBindings::MouseDown) |
| 654 .SetMethod("mouseMoveTo", &EventSenderBindings::MouseMoveTo) | 648 .SetMethod("mouseMoveTo", &EventSenderBindings::MouseMoveTo) |
| 655 .SetMethod("mouseLeave", &EventSenderBindings::MouseLeave) | 649 .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) | 650 .SetMethod("mouseScrollBy", &EventSenderBindings::MouseScrollBy) |
| 661 .SetMethod("mouseUp", &EventSenderBindings::MouseUp) | 651 .SetMethod("mouseUp", &EventSenderBindings::MouseUp) |
| 662 .SetMethod("setMouseButtonState", | 652 .SetMethod("setMouseButtonState", |
| 663 &EventSenderBindings::SetMouseButtonState) | 653 &EventSenderBindings::SetMouseButtonState) |
| 664 .SetMethod("scheduleAsynchronousClick", | 654 .SetMethod("scheduleAsynchronousClick", |
| 665 &EventSenderBindings::ScheduleAsynchronousClick) | 655 &EventSenderBindings::ScheduleAsynchronousClick) |
| 666 .SetMethod("scheduleAsynchronousKeyDown", | 656 .SetMethod("scheduleAsynchronousKeyDown", |
| 667 &EventSenderBindings::ScheduleAsynchronousKeyDown) | 657 &EventSenderBindings::ScheduleAsynchronousKeyDown) |
| 668 .SetProperty("forceLayoutOnEvents", | 658 .SetProperty("forceLayoutOnEvents", |
| 669 &EventSenderBindings::ForceLayoutOnEvents, | 659 &EventSenderBindings::ForceLayoutOnEvents, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 sender_->BeginDragWithFiles(files); | 834 sender_->BeginDragWithFiles(files); |
| 845 } | 835 } |
| 846 | 836 |
| 847 void EventSenderBindings::AddTouchPoint(double x, | 837 void EventSenderBindings::AddTouchPoint(double x, |
| 848 double y, | 838 double y, |
| 849 gin::Arguments* args) { | 839 gin::Arguments* args) { |
| 850 if (sender_) | 840 if (sender_) |
| 851 sender_->AddTouchPoint(static_cast<float>(x), static_cast<float>(y), args); | 841 sender_->AddTouchPoint(static_cast<float>(x), static_cast<float>(y), args); |
| 852 } | 842 } |
| 853 | 843 |
| 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) { | 844 void EventSenderBindings::GestureScrollBegin(gin::Arguments* args) { |
| 865 if (sender_) | 845 if (sender_) |
| 866 sender_->GestureScrollBegin(args); | 846 sender_->GestureScrollBegin(args); |
| 867 } | 847 } |
| 868 | 848 |
| 869 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) { | 849 void EventSenderBindings::GestureScrollEnd(gin::Arguments* args) { |
| 870 if (sender_) | 850 if (sender_) |
| 871 sender_->GestureScrollEnd(args); | 851 sender_->GestureScrollEnd(args); |
| 872 } | 852 } |
| 873 | 853 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 sender_->GestureLongTap(args); | 901 sender_->GestureLongTap(args); |
| 922 } | 902 } |
| 923 | 903 |
| 924 void EventSenderBindings::GestureTwoFingerTap(gin::Arguments* args) { | 904 void EventSenderBindings::GestureTwoFingerTap(gin::Arguments* args) { |
| 925 if (sender_) | 905 if (sender_) |
| 926 sender_->GestureTwoFingerTap(args); | 906 sender_->GestureTwoFingerTap(args); |
| 927 } | 907 } |
| 928 | 908 |
| 929 void EventSenderBindings::ContinuousMouseScrollBy(gin::Arguments* args) { | 909 void EventSenderBindings::ContinuousMouseScrollBy(gin::Arguments* args) { |
| 930 if (sender_) | 910 if (sender_) |
| 931 sender_->ContinuousMouseScrollBy(args); | 911 sender_->MouseScrollBy(args, EventSender::MouseScrollType::PIXEL); |
| 932 } | 912 } |
| 933 | 913 |
| 934 void EventSenderBindings::MouseMoveTo(gin::Arguments* args) { | 914 void EventSenderBindings::MouseMoveTo(gin::Arguments* args) { |
| 935 if (sender_) | 915 if (sender_) |
| 936 sender_->MouseMoveTo(args); | 916 sender_->MouseMoveTo(args); |
| 937 } | 917 } |
| 938 | 918 |
| 939 void EventSenderBindings::MouseLeave() { | 919 void EventSenderBindings::MouseLeave() { |
| 940 if (sender_) | 920 if (sender_) |
| 941 sender_->MouseLeave(); | 921 sender_->MouseLeave(); |
| 942 } | 922 } |
| 943 | 923 |
| 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) { | 924 void EventSenderBindings::MouseScrollBy(gin::Arguments* args) { |
| 960 if (sender_) | 925 if (sender_) |
| 961 sender_->MouseScrollBy(args); | 926 sender_->MouseScrollBy(args, EventSender::MouseScrollType::TICK); |
| 962 } | 927 } |
| 963 | 928 |
| 964 void EventSenderBindings::ScheduleAsynchronousClick(gin::Arguments* args) { | 929 void EventSenderBindings::ScheduleAsynchronousClick(gin::Arguments* args) { |
| 965 if (!sender_) | 930 if (!sender_) |
| 966 return; | 931 return; |
| 967 | 932 |
| 968 int button_number = 0; | 933 int button_number = 0; |
| 969 int modifiers = 0; | 934 int modifiers = 0; |
| 970 if (!args->PeekNext().IsEmpty()) { | 935 if (!args->PeekNext().IsEmpty()) { |
| 971 args->GetNext(&button_number); | 936 args->GetNext(&button_number); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1195 wm_char_(0), | 1160 wm_char_(0), |
| 1196 wm_dead_char_(0), | 1161 wm_dead_char_(0), |
| 1197 wm_sys_key_down_(0), | 1162 wm_sys_key_down_(0), |
| 1198 wm_sys_key_up_(0), | 1163 wm_sys_key_up_(0), |
| 1199 wm_sys_char_(0), | 1164 wm_sys_char_(0), |
| 1200 wm_sys_dead_char_(0), | 1165 wm_sys_dead_char_(0), |
| 1201 #endif | 1166 #endif |
| 1202 interfaces_(interfaces), | 1167 interfaces_(interfaces), |
| 1203 delegate_(NULL), | 1168 delegate_(NULL), |
| 1204 view_(NULL), | 1169 view_(NULL), |
| 1170 send_wheel_gestures_(false), | |
| 1205 force_layout_on_events_(false), | 1171 force_layout_on_events_(false), |
| 1206 is_drag_mode_(true), | 1172 is_drag_mode_(true), |
| 1207 touch_modifiers_(0), | 1173 touch_modifiers_(0), |
| 1208 touch_cancelable_(true), | 1174 touch_cancelable_(true), |
| 1209 replaying_saved_events_(false), | 1175 replaying_saved_events_(false), |
| 1210 current_drag_effects_allowed_(blink::WebDragOperationNone), | 1176 current_drag_effects_allowed_(blink::WebDragOperationNone), |
| 1211 last_click_time_sec_(0), | 1177 last_click_time_sec_(0), |
| 1212 current_drag_effect_(blink::WebDragOperationNone), | 1178 current_drag_effect_(blink::WebDragOperationNone), |
| 1213 time_offset_ms_(0), | 1179 time_offset_ms_(0), |
| 1214 click_count_(0), | 1180 click_count_(0), |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1914 InitPointerProperties(args, &touch_point, &touch_point.radiusX, | 1880 InitPointerProperties(args, &touch_point, &touch_point.radiusX, |
| 1915 &touch_point.radiusY); | 1881 &touch_point.radiusY); |
| 1916 | 1882 |
| 1917 // Set the touch point pressure to zero if it was not set by the caller | 1883 // Set the touch point pressure to zero if it was not set by the caller |
| 1918 if (std::isnan(touch_point.force)) | 1884 if (std::isnan(touch_point.force)) |
| 1919 touch_point.force = 0.0; | 1885 touch_point.force = 0.0; |
| 1920 | 1886 |
| 1921 touch_points_.push_back(touch_point); | 1887 touch_points_.push_back(touch_point); |
| 1922 } | 1888 } |
| 1923 | 1889 |
| 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) { | 1890 void EventSender::GestureScrollBegin(gin::Arguments* args) { |
| 1955 GestureEvent(WebInputEvent::GestureScrollBegin, args); | 1891 GestureEvent(WebInputEvent::GestureScrollBegin, args); |
| 1956 } | 1892 } |
| 1957 | 1893 |
| 1958 void EventSender::GestureScrollEnd(gin::Arguments* args) { | 1894 void EventSender::GestureScrollEnd(gin::Arguments* args) { |
| 1959 GestureEvent(WebInputEvent::GestureScrollEnd, args); | 1895 GestureEvent(WebInputEvent::GestureScrollEnd, args); |
| 1960 } | 1896 } |
| 1961 | 1897 |
| 1962 void EventSender::GestureScrollUpdate(gin::Arguments* args) { | 1898 void EventSender::GestureScrollUpdate(gin::Arguments* args) { |
| 1963 GestureEvent(WebInputEvent::GestureScrollUpdate, args); | 1899 GestureEvent(WebInputEvent::GestureScrollUpdate, args); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1996 } | 1932 } |
| 1997 | 1933 |
| 1998 void EventSender::GestureLongTap(gin::Arguments* args) { | 1934 void EventSender::GestureLongTap(gin::Arguments* args) { |
| 1999 GestureEvent(WebInputEvent::GestureLongTap, args); | 1935 GestureEvent(WebInputEvent::GestureLongTap, args); |
| 2000 } | 1936 } |
| 2001 | 1937 |
| 2002 void EventSender::GestureTwoFingerTap(gin::Arguments* args) { | 1938 void EventSender::GestureTwoFingerTap(gin::Arguments* args) { |
| 2003 GestureEvent(WebInputEvent::GestureTwoFingerTap, args); | 1939 GestureEvent(WebInputEvent::GestureTwoFingerTap, args); |
| 2004 } | 1940 } |
| 2005 | 1941 |
| 2006 void EventSender::ContinuousMouseScrollBy(gin::Arguments* args) { | 1942 void EventSender::MouseScrollBy(gin::Arguments* args, |
| 2007 WebMouseWheelEvent event; | 1943 MouseScrollType scroll_type) { |
| 2008 InitMouseWheelEvent(args, true, &event); | 1944 WebMouseWheelEvent wheel_event; |
| 2009 HandleInputEventOnViewOrPopup(event); | 1945 bool send_gestures = false; |
| 1946 InitMouseWheelEvent(args, scroll_type, &wheel_event, &send_gestures); | |
| 1947 if (HandleInputEventOnViewOrPopup(wheel_event) == | |
| 1948 WebInputEventResult::NotHandled && | |
| 1949 send_gestures) { | |
| 1950 WebGestureEvent begin_event; | |
| 1951 begin_event.type = WebInputEvent::GestureScrollBegin; | |
| 1952 begin_event.sourceDevice = blink::WebGestureDeviceTouchpad; | |
|
Rick Byers
2016/03/18 15:36:25
Generally our approach in eventSender is to genera
dtapuska
2016/03/18 17:04:43
Done.
| |
| 1953 begin_event.x = wheel_event.x; | |
| 1954 begin_event.y = wheel_event.y; | |
| 1955 begin_event.globalX = wheel_event.globalX; | |
| 1956 begin_event.globalY = wheel_event.globalY; | |
| 1957 begin_event.timeStampSeconds = GetCurrentEventTimeSec(); | |
| 1958 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; | |
| 1959 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; | |
| 1960 if (wheel_event.scrollByPage) { | |
| 1961 begin_event.data.scrollBegin.deltaHintUnits = | |
| 1962 blink::WebGestureEvent::Page; | |
| 1963 if (begin_event.data.scrollBegin.deltaXHint) { | |
| 1964 begin_event.data.scrollBegin.deltaXHint = | |
| 1965 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; | |
| 1966 } | |
| 1967 if (begin_event.data.scrollBegin.deltaYHint) { | |
| 1968 begin_event.data.scrollBegin.deltaYHint = | |
| 1969 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; | |
| 1970 } | |
| 1971 } else { | |
| 1972 begin_event.data.scrollBegin.deltaHintUnits = | |
| 1973 wheel_event.hasPreciseScrollingDeltas | |
| 1974 ? blink::WebGestureEvent::PrecisePixels | |
| 1975 : blink::WebGestureEvent::Pixels; | |
| 1976 } | |
| 1977 | |
| 1978 if (force_layout_on_events_) | |
| 1979 view_->updateAllLifecyclePhases(); | |
| 1980 | |
| 1981 HandleInputEventOnViewOrPopup(begin_event); | |
| 1982 | |
| 1983 WebGestureEvent update_event; | |
| 1984 update_event.type = WebInputEvent::GestureScrollUpdate; | |
| 1985 update_event.sourceDevice = blink::WebGestureDeviceTouchpad; | |
| 1986 update_event.x = wheel_event.x; | |
| 1987 update_event.y = wheel_event.y; | |
| 1988 update_event.globalX = wheel_event.globalX; | |
| 1989 update_event.globalY = wheel_event.globalY; | |
| 1990 update_event.timeStampSeconds = GetCurrentEventTimeSec(); | |
| 1991 update_event.data.scrollUpdate.deltaX = | |
| 1992 begin_event.data.scrollBegin.deltaXHint; | |
| 1993 update_event.data.scrollUpdate.deltaY = | |
| 1994 begin_event.data.scrollBegin.deltaYHint; | |
| 1995 update_event.data.scrollUpdate.deltaUnits = | |
| 1996 begin_event.data.scrollBegin.deltaHintUnits; | |
| 1997 | |
| 1998 if (force_layout_on_events_) | |
| 1999 view_->updateAllLifecyclePhases(); | |
| 2000 HandleInputEventOnViewOrPopup(update_event); | |
| 2001 | |
| 2002 WebGestureEvent end_event; | |
| 2003 end_event.type = WebInputEvent::GestureScrollEnd; | |
| 2004 end_event.sourceDevice = blink::WebGestureDeviceTouchpad; | |
| 2005 end_event.x = wheel_event.x; | |
| 2006 end_event.y = wheel_event.y; | |
| 2007 end_event.globalX = wheel_event.globalX; | |
| 2008 end_event.globalY = wheel_event.globalY; | |
| 2009 end_event.timeStampSeconds = GetCurrentEventTimeSec(); | |
| 2010 end_event.data.scrollEnd.deltaUnits = | |
| 2011 begin_event.data.scrollBegin.deltaHintUnits; | |
| 2012 | |
| 2013 if (force_layout_on_events_) | |
| 2014 view_->updateAllLifecyclePhases(); | |
| 2015 HandleInputEventOnViewOrPopup(end_event); | |
| 2016 } | |
| 2010 } | 2017 } |
| 2011 | 2018 |
| 2012 void EventSender::MouseMoveTo(gin::Arguments* args) { | 2019 void EventSender::MouseMoveTo(gin::Arguments* args) { |
| 2013 if (force_layout_on_events_) | 2020 if (force_layout_on_events_) |
| 2014 view_->updateAllLifecyclePhases(); | 2021 view_->updateAllLifecyclePhases(); |
| 2015 | 2022 |
| 2016 double x; | 2023 double x; |
| 2017 double y; | 2024 double y; |
| 2018 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 2025 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
| 2019 args->ThrowError(); | 2026 args->ThrowError(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2056 0, | 2063 0, |
| 2057 last_mouse_pos_, | 2064 last_mouse_pos_, |
| 2058 GetCurrentEventTimeSec(), | 2065 GetCurrentEventTimeSec(), |
| 2059 click_count_, | 2066 click_count_, |
| 2060 0, | 2067 0, |
| 2061 &event); | 2068 &event); |
| 2062 HandleInputEventOnViewOrPopup(event); | 2069 HandleInputEventOnViewOrPopup(event); |
| 2063 } | 2070 } |
| 2064 | 2071 |
| 2065 | 2072 |
| 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) { | 2073 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
| 2111 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); | 2074 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); |
| 2112 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); | 2075 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); |
| 2113 } | 2076 } |
| 2114 | 2077 |
| 2115 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, | 2078 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, |
| 2116 int modifiers, | 2079 int modifiers, |
| 2117 KeyLocationCode location) { | 2080 KeyLocationCode location) { |
| 2118 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); | 2081 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); |
| 2119 } | 2082 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2433 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && | 2396 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && |
| 2434 (button_type == last_button_type_)) { | 2397 (button_type == last_button_type_)) { |
| 2435 ++click_count_; | 2398 ++click_count_; |
| 2436 } else { | 2399 } else { |
| 2437 click_count_ = 1; | 2400 click_count_ = 1; |
| 2438 last_button_type_ = button_type; | 2401 last_button_type_ = button_type; |
| 2439 } | 2402 } |
| 2440 } | 2403 } |
| 2441 | 2404 |
| 2442 void EventSender::InitMouseWheelEvent(gin::Arguments* args, | 2405 void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| 2443 bool continuous, | 2406 MouseScrollType scroll_type, |
| 2444 WebMouseWheelEvent* event) { | 2407 WebMouseWheelEvent* event, |
| 2408 bool* send_gestures) { | |
| 2445 // Force a layout here just to make sure every position has been | 2409 // 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 | 2410 // determined before we send events (as well as all the other methods |
| 2447 // that send an event do). | 2411 // that send an event do). |
| 2448 if (force_layout_on_events_) | 2412 if (force_layout_on_events_) |
| 2449 view_->updateAllLifecyclePhases(); | 2413 view_->updateAllLifecyclePhases(); |
| 2450 | 2414 |
| 2451 double horizontal; | 2415 double horizontal; |
| 2452 if (!args->GetNext(&horizontal)) { | 2416 if (!args->GetNext(&horizontal)) { |
| 2453 args->ThrowError(); | 2417 args->ThrowError(); |
| 2454 return; | 2418 return; |
| 2455 } | 2419 } |
| 2456 double vertical; | 2420 double vertical; |
| 2457 if (!args->GetNext(&vertical)) { | 2421 if (!args->GetNext(&vertical)) { |
| 2458 args->ThrowError(); | 2422 args->ThrowError(); |
| 2459 return; | 2423 return; |
| 2460 } | 2424 } |
| 2461 | 2425 |
| 2462 bool paged = false; | 2426 bool paged = false; |
| 2463 bool has_precise_scrolling_deltas = false; | 2427 bool has_precise_scrolling_deltas = false; |
| 2464 int modifiers = 0; | 2428 int modifiers = 0; |
| 2465 bool can_scroll = true; | 2429 bool can_scroll = true; |
| 2466 if (!args->PeekNext().IsEmpty()) { | 2430 if (!args->PeekNext().IsEmpty()) { |
| 2467 args->GetNext(&paged); | 2431 args->GetNext(&paged); |
| 2468 if (!args->PeekNext().IsEmpty()) { | 2432 if (!args->PeekNext().IsEmpty()) { |
| 2469 args->GetNext(&has_precise_scrolling_deltas); | 2433 args->GetNext(&has_precise_scrolling_deltas); |
| 2470 if (!args->PeekNext().IsEmpty()) { | 2434 if (!args->PeekNext().IsEmpty()) { |
| 2471 v8::Local<v8::Value> value; | 2435 v8::Local<v8::Value> value; |
| 2472 args->GetNext(&value); | 2436 args->GetNext(&value); |
| 2473 modifiers = GetKeyModifiersFromV8(args->isolate(), value); | 2437 modifiers = GetKeyModifiersFromV8(args->isolate(), value); |
| 2474 if (!args->PeekNext().IsEmpty()) | 2438 if (!args->PeekNext().IsEmpty()) { |
| 2475 args->GetNext(&can_scroll); | 2439 args->GetNext(&can_scroll); |
| 2440 } | |
| 2476 } | 2441 } |
| 2477 } | 2442 } |
| 2478 } | 2443 } |
| 2444 if (can_scroll && send_wheel_gestures_) { | |
| 2445 can_scroll = false; | |
| 2446 *send_gestures = true; | |
| 2447 } | |
| 2479 | 2448 |
| 2480 InitMouseEvent(WebInputEvent::MouseWheel, | 2449 InitMouseEvent(WebInputEvent::MouseWheel, |
| 2481 pressed_button_, | 2450 pressed_button_, |
| 2482 current_buttons_, | 2451 current_buttons_, |
| 2483 last_mouse_pos_, | 2452 last_mouse_pos_, |
| 2484 GetCurrentEventTimeSec(), | 2453 GetCurrentEventTimeSec(), |
| 2485 click_count_, | 2454 click_count_, |
| 2486 modifiers, | 2455 modifiers, |
| 2487 event); | 2456 event); |
| 2488 event->wheelTicksX = static_cast<float>(horizontal); | 2457 event->wheelTicksX = static_cast<float>(horizontal); |
| 2489 event->wheelTicksY = static_cast<float>(vertical); | 2458 event->wheelTicksY = static_cast<float>(vertical); |
| 2490 event->deltaX = event->wheelTicksX; | 2459 event->deltaX = event->wheelTicksX; |
| 2491 event->deltaY = event->wheelTicksY; | 2460 event->deltaY = event->wheelTicksY; |
| 2492 event->scrollByPage = paged; | 2461 event->scrollByPage = paged; |
| 2493 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; | 2462 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; |
| 2494 event->canScroll = can_scroll; | 2463 event->canScroll = can_scroll; |
| 2495 if (continuous) { | 2464 if (scroll_type == MouseScrollType::PIXEL) { |
| 2496 event->wheelTicksX /= kScrollbarPixelsPerTick; | 2465 event->wheelTicksX /= kScrollbarPixelsPerTick; |
| 2497 event->wheelTicksY /= kScrollbarPixelsPerTick; | 2466 event->wheelTicksY /= kScrollbarPixelsPerTick; |
| 2498 } else { | 2467 } else { |
| 2499 event->deltaX *= kScrollbarPixelsPerTick; | 2468 event->deltaX *= kScrollbarPixelsPerTick; |
| 2500 event->deltaY *= kScrollbarPixelsPerTick; | 2469 event->deltaY *= kScrollbarPixelsPerTick; |
| 2501 } | 2470 } |
| 2502 } | 2471 } |
| 2503 | 2472 |
| 2504 // Radius fields radius_x and radius_y should eventually be moved to | 2473 // Radius fields radius_x and radius_y should eventually be moved to |
| 2505 // WebPointerProperties. | 2474 // WebPointerProperties. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2678 last_event_timestamp_ = event.timeStampSeconds; | 2647 last_event_timestamp_ = event.timeStampSeconds; |
| 2679 | 2648 |
| 2680 if (WebPagePopup* popup = view_->pagePopup()) { | 2649 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2681 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2650 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2682 return popup->handleInputEvent(event); | 2651 return popup->handleInputEvent(event); |
| 2683 } | 2652 } |
| 2684 return view_->handleInputEvent(event); | 2653 return view_->handleInputEvent(event); |
| 2685 } | 2654 } |
| 2686 | 2655 |
| 2687 } // namespace test_runner | 2656 } // namespace test_runner |
| OLD | NEW |