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, true); |
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, false); |
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, bool continuous) { |
Mike West
2016/03/17 16:19:38
Nit: I'd prefer for this to be an enum so that it'
dtapuska
2016/03/17 18:05:51
Done.
| |
2007 WebMouseWheelEvent event; | 1943 WebMouseWheelEvent wheel_event; |
2008 InitMouseWheelEvent(args, true, &event); | 1944 bool send_gestures = false; |
2009 HandleInputEventOnViewOrPopup(event); | 1945 InitMouseWheelEvent(args, continuous, &wheel_event, &send_gestures); |
1946 if (HandleInputEventOnViewOrPopup(wheel_event) == | |
1947 WebInputEventResult::NotHandled && | |
1948 send_gestures) { | |
1949 WebGestureEvent begin_event; | |
1950 begin_event.type = WebInputEvent::GestureScrollBegin; | |
1951 begin_event.sourceDevice = blink::WebGestureDeviceTouchpad; | |
1952 begin_event.x = wheel_event.x; | |
1953 begin_event.y = wheel_event.y; | |
1954 begin_event.globalX = wheel_event.globalX; | |
1955 begin_event.globalY = wheel_event.globalY; | |
1956 begin_event.timeStampSeconds = GetCurrentEventTimeSec(); | |
1957 begin_event.data.scrollBegin.deltaXHint = wheel_event.deltaX; | |
1958 begin_event.data.scrollBegin.deltaYHint = wheel_event.deltaY; | |
1959 if (wheel_event.scrollByPage) { | |
1960 begin_event.data.scrollBegin.deltaHintUnits = | |
1961 blink::WebGestureEvent::Page; | |
1962 if (begin_event.data.scrollBegin.deltaXHint) | |
Mike West
2016/03/17 16:19:38
Nit: {} around multi-line body.
dtapuska
2016/03/17 18:05:51
Done.
| |
1963 begin_event.data.scrollBegin.deltaXHint = | |
1964 begin_event.data.scrollBegin.deltaXHint > 0 ? 1 : -1; | |
1965 if (begin_event.data.scrollBegin.deltaYHint) | |
Mike West
2016/03/17 16:19:38
Nit: {} around multi-line body.
dtapuska
2016/03/17 18:05:51
Done.
| |
1966 begin_event.data.scrollBegin.deltaYHint = | |
1967 begin_event.data.scrollBegin.deltaYHint > 0 ? 1 : -1; | |
1968 } else { | |
1969 begin_event.data.scrollBegin.deltaHintUnits = | |
1970 wheel_event.hasPreciseScrollingDeltas | |
1971 ? blink::WebGestureEvent::PrecisePixels | |
1972 : blink::WebGestureEvent::Pixels; | |
1973 } | |
1974 WebGestureEvent update_event = begin_event; | |
1975 update_event.type = WebInputEvent::GestureScrollUpdate; | |
1976 memset(&update_event.data, 0, sizeof(update_event.data)); | |
Mike West
2016/03/17 16:19:38
Could we move this to a `clear()` method on WebGes
dtapuska
2016/03/17 18:05:51
I've just cloned the fields over manually and avoi
| |
1977 update_event.data.scrollUpdate.deltaX = | |
1978 begin_event.data.scrollBegin.deltaXHint; | |
1979 update_event.data.scrollUpdate.deltaY = | |
1980 begin_event.data.scrollBegin.deltaYHint; | |
1981 update_event.data.scrollUpdate.deltaUnits = | |
1982 begin_event.data.scrollBegin.deltaHintUnits; | |
1983 | |
1984 WebGestureEvent end_event = begin_event; | |
1985 end_event.type = WebInputEvent::GestureScrollEnd; | |
1986 memset(&end_event.data, 0, sizeof(end_event.data)); | |
1987 end_event.data.scrollEnd.deltaUnits = | |
1988 begin_event.data.scrollBegin.deltaHintUnits; | |
1989 | |
1990 if (force_layout_on_events_) | |
1991 view_->updateAllLifecyclePhases(); | |
1992 | |
1993 HandleInputEventOnViewOrPopup(begin_event); | |
1994 | |
1995 if (force_layout_on_events_) | |
1996 view_->updateAllLifecyclePhases(); | |
1997 HandleInputEventOnViewOrPopup(update_event); | |
1998 | |
1999 if (force_layout_on_events_) | |
2000 view_->updateAllLifecyclePhases(); | |
2001 HandleInputEventOnViewOrPopup(end_event); | |
2002 } | |
2010 } | 2003 } |
2011 | 2004 |
2012 void EventSender::MouseMoveTo(gin::Arguments* args) { | 2005 void EventSender::MouseMoveTo(gin::Arguments* args) { |
2013 if (force_layout_on_events_) | 2006 if (force_layout_on_events_) |
2014 view_->updateAllLifecyclePhases(); | 2007 view_->updateAllLifecyclePhases(); |
2015 | 2008 |
2016 double x; | 2009 double x; |
2017 double y; | 2010 double y; |
2018 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 2011 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
2019 args->ThrowError(); | 2012 args->ThrowError(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2056 0, | 2049 0, |
2057 last_mouse_pos_, | 2050 last_mouse_pos_, |
2058 GetCurrentEventTimeSec(), | 2051 GetCurrentEventTimeSec(), |
2059 click_count_, | 2052 click_count_, |
2060 0, | 2053 0, |
2061 &event); | 2054 &event); |
2062 HandleInputEventOnViewOrPopup(event); | 2055 HandleInputEventOnViewOrPopup(event); |
2063 } | 2056 } |
2064 | 2057 |
2065 | 2058 |
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) { | 2059 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
2111 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); | 2060 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); |
2112 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); | 2061 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); |
2113 } | 2062 } |
2114 | 2063 |
2115 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, | 2064 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, |
2116 int modifiers, | 2065 int modifiers, |
2117 KeyLocationCode location) { | 2066 KeyLocationCode location) { |
2118 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); | 2067 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); |
2119 } | 2068 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2434 (button_type == last_button_type_)) { | 2383 (button_type == last_button_type_)) { |
2435 ++click_count_; | 2384 ++click_count_; |
2436 } else { | 2385 } else { |
2437 click_count_ = 1; | 2386 click_count_ = 1; |
2438 last_button_type_ = button_type; | 2387 last_button_type_ = button_type; |
2439 } | 2388 } |
2440 } | 2389 } |
2441 | 2390 |
2442 void EventSender::InitMouseWheelEvent(gin::Arguments* args, | 2391 void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
2443 bool continuous, | 2392 bool continuous, |
2444 WebMouseWheelEvent* event) { | 2393 WebMouseWheelEvent* event, |
2394 bool* send_gestures) { | |
2445 // Force a layout here just to make sure every position has been | 2395 // 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 | 2396 // determined before we send events (as well as all the other methods |
2447 // that send an event do). | 2397 // that send an event do). |
2448 if (force_layout_on_events_) | 2398 if (force_layout_on_events_) |
2449 view_->updateAllLifecyclePhases(); | 2399 view_->updateAllLifecyclePhases(); |
2450 | 2400 |
2451 double horizontal; | 2401 double horizontal; |
2452 if (!args->GetNext(&horizontal)) { | 2402 if (!args->GetNext(&horizontal)) { |
2453 args->ThrowError(); | 2403 args->ThrowError(); |
2454 return; | 2404 return; |
2455 } | 2405 } |
2456 double vertical; | 2406 double vertical; |
2457 if (!args->GetNext(&vertical)) { | 2407 if (!args->GetNext(&vertical)) { |
2458 args->ThrowError(); | 2408 args->ThrowError(); |
2459 return; | 2409 return; |
2460 } | 2410 } |
2461 | 2411 |
2462 bool paged = false; | 2412 bool paged = false; |
2463 bool has_precise_scrolling_deltas = false; | 2413 bool has_precise_scrolling_deltas = false; |
2464 int modifiers = 0; | 2414 int modifiers = 0; |
2465 bool can_scroll = true; | 2415 bool can_scroll = true; |
2466 if (!args->PeekNext().IsEmpty()) { | 2416 if (!args->PeekNext().IsEmpty()) { |
2467 args->GetNext(&paged); | 2417 args->GetNext(&paged); |
2468 if (!args->PeekNext().IsEmpty()) { | 2418 if (!args->PeekNext().IsEmpty()) { |
2469 args->GetNext(&has_precise_scrolling_deltas); | 2419 args->GetNext(&has_precise_scrolling_deltas); |
2470 if (!args->PeekNext().IsEmpty()) { | 2420 if (!args->PeekNext().IsEmpty()) { |
2471 v8::Local<v8::Value> value; | 2421 v8::Local<v8::Value> value; |
2472 args->GetNext(&value); | 2422 args->GetNext(&value); |
2473 modifiers = GetKeyModifiersFromV8(args->isolate(), value); | 2423 modifiers = GetKeyModifiersFromV8(args->isolate(), value); |
2474 if (!args->PeekNext().IsEmpty()) | 2424 if (!args->PeekNext().IsEmpty()) { |
2475 args->GetNext(&can_scroll); | 2425 args->GetNext(&can_scroll); |
2426 } | |
2476 } | 2427 } |
2477 } | 2428 } |
2478 } | 2429 } |
2430 if (can_scroll && send_wheel_gestures_) { | |
2431 can_scroll = false; | |
2432 *send_gestures = true; | |
2433 } | |
2479 | 2434 |
2480 InitMouseEvent(WebInputEvent::MouseWheel, | 2435 InitMouseEvent(WebInputEvent::MouseWheel, |
2481 pressed_button_, | 2436 pressed_button_, |
2482 current_buttons_, | 2437 current_buttons_, |
2483 last_mouse_pos_, | 2438 last_mouse_pos_, |
2484 GetCurrentEventTimeSec(), | 2439 GetCurrentEventTimeSec(), |
2485 click_count_, | 2440 click_count_, |
2486 modifiers, | 2441 modifiers, |
2487 event); | 2442 event); |
2488 event->wheelTicksX = static_cast<float>(horizontal); | 2443 event->wheelTicksX = static_cast<float>(horizontal); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2678 last_event_timestamp_ = event.timeStampSeconds; | 2633 last_event_timestamp_ = event.timeStampSeconds; |
2679 | 2634 |
2680 if (WebPagePopup* popup = view_->pagePopup()) { | 2635 if (WebPagePopup* popup = view_->pagePopup()) { |
2681 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2636 if (!WebInputEvent::isKeyboardEventType(event.type)) |
2682 return popup->handleInputEvent(event); | 2637 return popup->handleInputEvent(event); |
2683 } | 2638 } |
2684 return view_->handleInputEvent(event); | 2639 return view_->handleInputEvent(event); |
2685 } | 2640 } |
2686 | 2641 |
2687 } // namespace test_runner | 2642 } // namespace test_runner |
OLD | NEW |