Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 301103002: Update EventSender::GestureTap to return a bool (if handled). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/shell/renderer/test_runner/event_sender.h" 5 #include "content/shell/renderer/test_runner/event_sender.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/public/common/page_zoom.h" 10 #include "content/public/common/page_zoom.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void TouchEnd(); 354 void TouchEnd();
355 void LeapForward(int milliseconds); 355 void LeapForward(int milliseconds);
356 void BeginDragWithFiles(const std::vector<std::string>& files); 356 void BeginDragWithFiles(const std::vector<std::string>& files);
357 void AddTouchPoint(gin::Arguments* args); 357 void AddTouchPoint(gin::Arguments* args);
358 void MouseDragBegin(); 358 void MouseDragBegin();
359 void MouseDragEnd(); 359 void MouseDragEnd();
360 void GestureScrollBegin(gin::Arguments* args); 360 void GestureScrollBegin(gin::Arguments* args);
361 void GestureScrollEnd(gin::Arguments* args); 361 void GestureScrollEnd(gin::Arguments* args);
362 void GestureScrollUpdate(gin::Arguments* args); 362 void GestureScrollUpdate(gin::Arguments* args);
363 void GestureScrollUpdateWithoutPropagation(gin::Arguments* args); 363 void GestureScrollUpdateWithoutPropagation(gin::Arguments* args);
364 void GestureTap(gin::Arguments* args); 364 bool GestureTap(gin::Arguments* args);
365 void GestureTapDown(gin::Arguments* args); 365 void GestureTapDown(gin::Arguments* args);
366 void GestureShowPress(gin::Arguments* args); 366 void GestureShowPress(gin::Arguments* args);
367 void GestureTapCancel(gin::Arguments* args); 367 void GestureTapCancel(gin::Arguments* args);
368 void GestureLongPress(gin::Arguments* args); 368 void GestureLongPress(gin::Arguments* args);
369 void GestureLongTap(gin::Arguments* args); 369 void GestureLongTap(gin::Arguments* args);
370 void GestureTwoFingerTap(gin::Arguments* args); 370 void GestureTwoFingerTap(gin::Arguments* args);
371 void ContinuousMouseScrollBy(gin::Arguments* args); 371 void ContinuousMouseScrollBy(gin::Arguments* args);
372 void MouseMoveTo(gin::Arguments* args); 372 void MouseMoveTo(gin::Arguments* args);
373 void TrackpadScrollBegin(); 373 void TrackpadScrollBegin();
374 void TrackpadScroll(gin::Arguments* args); 374 void TrackpadScroll(gin::Arguments* args);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (sender_) 735 if (sender_)
736 sender_->GestureScrollUpdate(args); 736 sender_->GestureScrollUpdate(args);
737 } 737 }
738 738
739 void EventSenderBindings::GestureScrollUpdateWithoutPropagation( 739 void EventSenderBindings::GestureScrollUpdateWithoutPropagation(
740 gin::Arguments* args) { 740 gin::Arguments* args) {
741 if (sender_) 741 if (sender_)
742 sender_->GestureScrollUpdateWithoutPropagation(args); 742 sender_->GestureScrollUpdateWithoutPropagation(args);
743 } 743 }
744 744
745 void EventSenderBindings::GestureTap(gin::Arguments* args) { 745 bool EventSenderBindings::GestureTap(gin::Arguments* args) {
746 if (sender_) 746 if (sender_)
747 sender_->GestureTap(args); 747 return sender_->GestureTap(args);
748 return false; // TODO(donnd): true?
Rick Byers 2014/05/29 20:57:47 yeah this is goofy (should probably throw instead
donnd 2014/05/31 03:14:57 Done.
748 } 749 }
749 750
750 void EventSenderBindings::GestureTapDown(gin::Arguments* args) { 751 void EventSenderBindings::GestureTapDown(gin::Arguments* args) {
751 if (sender_) 752 if (sender_)
752 sender_->GestureTapDown(args); 753 sender_->GestureTapDown(args);
753 } 754 }
754 755
755 void EventSenderBindings::GestureShowPress(gin::Arguments* args) { 756 void EventSenderBindings::GestureShowPress(gin::Arguments* args) {
756 if (sender_) 757 if (sender_)
757 sender_->GestureShowPress(args); 758 sender_->GestureShowPress(args);
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 } 1685 }
1685 1686
1686 void EventSender::GestureScrollUpdate(gin::Arguments* args) { 1687 void EventSender::GestureScrollUpdate(gin::Arguments* args) {
1687 GestureEvent(WebInputEvent::GestureScrollUpdate, args); 1688 GestureEvent(WebInputEvent::GestureScrollUpdate, args);
1688 } 1689 }
1689 1690
1690 void EventSender::GestureScrollUpdateWithoutPropagation(gin::Arguments* args) { 1691 void EventSender::GestureScrollUpdateWithoutPropagation(gin::Arguments* args) {
1691 GestureEvent(WebInputEvent::GestureScrollUpdateWithoutPropagation, args); 1692 GestureEvent(WebInputEvent::GestureScrollUpdateWithoutPropagation, args);
1692 } 1693 }
1693 1694
1694 void EventSender::GestureTap(gin::Arguments* args) { 1695 bool EventSender::GestureTap(gin::Arguments* args) {
Rick Byers 2014/05/29 20:57:47 I'm new to gin (gin is a new lightweight javascrip
donnd 2014/05/31 03:14:57 Done.
1695 GestureEvent(WebInputEvent::GestureTap, args); 1696 return GestureEvent(WebInputEvent::GestureTap, args);
1696 } 1697 }
1697 1698
1698 void EventSender::GestureTapDown(gin::Arguments* args) { 1699 void EventSender::GestureTapDown(gin::Arguments* args) {
1699 GestureEvent(WebInputEvent::GestureTapDown, args); 1700 GestureEvent(WebInputEvent::GestureTapDown, args);
1700 } 1701 }
1701 1702
1702 void EventSender::GestureShowPress(gin::Arguments* args) { 1703 void EventSender::GestureShowPress(gin::Arguments* args) {
1703 GestureEvent(WebInputEvent::GestureShowPress, args); 1704 GestureEvent(WebInputEvent::GestureShowPress, args);
1704 } 1705 }
1705 1706
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 for (size_t i = 0; i < touch_points_.size(); ++i) { 1884 for (size_t i = 0; i < touch_points_.size(); ++i) {
1884 WebTouchPoint* touch_point = &touch_points_[i]; 1885 WebTouchPoint* touch_point = &touch_points_[i];
1885 if (touch_point->state == WebTouchPoint::StateReleased) { 1886 if (touch_point->state == WebTouchPoint::StateReleased) {
1886 touch_points_.erase(touch_points_.begin() + i); 1887 touch_points_.erase(touch_points_.begin() + i);
1887 --i; 1888 --i;
1888 } else 1889 } else
1889 touch_point->state = WebTouchPoint::StateStationary; 1890 touch_point->state = WebTouchPoint::StateStationary;
1890 } 1891 }
1891 } 1892 }
1892 1893
1893 void EventSender::GestureEvent(WebInputEvent::Type type, 1894 bool EventSender::GestureEvent(WebInputEvent::Type type,
1894 gin::Arguments* args) { 1895 gin::Arguments* args) {
1895 double x; 1896 double x;
1896 double y; 1897 double y;
1897 args->GetNext(&x); 1898 args->GetNext(&x);
1898 args->GetNext(&y); 1899 args->GetNext(&y);
1899 WebPoint point(x, y); 1900 WebPoint point(x, y);
1900 1901
1901 WebGestureEvent event; 1902 WebGestureEvent event;
1902 event.type = type; 1903 event.type = type;
1903 1904
(...skipping 17 matching lines...) Expand all
1921 case WebInputEvent::GestureScrollEnd: 1922 case WebInputEvent::GestureScrollEnd:
1922 case WebInputEvent::GestureFlingStart: 1923 case WebInputEvent::GestureFlingStart:
1923 event.x = current_gesture_location_.x; 1924 event.x = current_gesture_location_.x;
1924 event.y = current_gesture_location_.y; 1925 event.y = current_gesture_location_.y;
1925 break; 1926 break;
1926 case WebInputEvent::GestureTap: 1927 case WebInputEvent::GestureTap:
1927 if (!args->PeekNext().IsEmpty()) { 1928 if (!args->PeekNext().IsEmpty()) {
1928 float tap_count; 1929 float tap_count;
1929 if (!args->GetNext(&tap_count)) { 1930 if (!args->GetNext(&tap_count)) {
1930 args->ThrowError(); 1931 args->ThrowError();
1931 return; 1932 return false;
Rick Byers 2014/05/29 20:57:47 If the right way to set a return value to JS is ar
donnd 2014/05/31 03:14:57 Done.
1932 } 1933 }
1933 event.data.tap.tapCount = tap_count; 1934 event.data.tap.tapCount = tap_count;
1934 } else { 1935 } else {
1935 event.data.tap.tapCount = 1; 1936 event.data.tap.tapCount = 1;
1936 } 1937 }
1937 1938
1938 event.x = point.x; 1939 event.x = point.x;
1939 event.y = point.y; 1940 event.y = point.y;
1940 break; 1941 break;
1941 case WebInputEvent::GestureTapUnconfirmed: 1942 case WebInputEvent::GestureTapUnconfirmed:
1942 if (!args->PeekNext().IsEmpty()) { 1943 if (!args->PeekNext().IsEmpty()) {
1943 float tap_count; 1944 float tap_count;
1944 if (!args->GetNext(&tap_count)) { 1945 if (!args->GetNext(&tap_count)) {
1945 args->ThrowError(); 1946 args->ThrowError();
1946 return; 1947 return false;
1947 } 1948 }
1948 event.data.tap.tapCount = tap_count; 1949 event.data.tap.tapCount = tap_count;
1949 } else { 1950 } else {
1950 event.data.tap.tapCount = 1; 1951 event.data.tap.tapCount = 1;
1951 } 1952 }
1952 event.x = point.x; 1953 event.x = point.x;
1953 event.y = point.y; 1954 event.y = point.y;
1954 break; 1955 break;
1955 case WebInputEvent::GestureTapDown: 1956 case WebInputEvent::GestureTapDown:
1956 event.x = point.x; 1957 event.x = point.x;
1957 event.y = point.y; 1958 event.y = point.y;
1958 if (!args->PeekNext().IsEmpty()) { 1959 if (!args->PeekNext().IsEmpty()) {
1959 float width; 1960 float width;
1960 if (!args->GetNext(&width)) { 1961 if (!args->GetNext(&width)) {
1961 args->ThrowError(); 1962 args->ThrowError();
1962 return; 1963 return false;
1963 } 1964 }
1964 event.data.tapDown.width = width; 1965 event.data.tapDown.width = width;
1965 } 1966 }
1966 if (!args->PeekNext().IsEmpty()) { 1967 if (!args->PeekNext().IsEmpty()) {
1967 float height; 1968 float height;
1968 if (!args->GetNext(&height)) { 1969 if (!args->GetNext(&height)) {
1969 args->ThrowError(); 1970 args->ThrowError();
1970 return; 1971 return false;
1971 } 1972 }
1972 event.data.tapDown.height = height; 1973 event.data.tapDown.height = height;
1973 } 1974 }
1974 break; 1975 break;
1975 case WebInputEvent::GestureShowPress: 1976 case WebInputEvent::GestureShowPress:
1976 event.x = point.x; 1977 event.x = point.x;
1977 event.y = point.y; 1978 event.y = point.y;
1978 if (!args->PeekNext().IsEmpty()) { 1979 if (!args->PeekNext().IsEmpty()) {
1979 float width; 1980 float width;
1980 if (!args->GetNext(&width)) { 1981 if (!args->GetNext(&width)) {
1981 args->ThrowError(); 1982 args->ThrowError();
1982 return; 1983 return false;
1983 } 1984 }
1984 event.data.showPress.width = width; 1985 event.data.showPress.width = width;
1985 if (!args->PeekNext().IsEmpty()) { 1986 if (!args->PeekNext().IsEmpty()) {
1986 float height; 1987 float height;
1987 if (!args->GetNext(&height)) { 1988 if (!args->GetNext(&height)) {
1988 args->ThrowError(); 1989 args->ThrowError();
1989 return; 1990 return false;
1990 } 1991 }
1991 event.data.showPress.height = height; 1992 event.data.showPress.height = height;
1992 } 1993 }
1993 } 1994 }
1994 break; 1995 break;
1995 case WebInputEvent::GestureTapCancel: 1996 case WebInputEvent::GestureTapCancel:
1996 event.x = point.x; 1997 event.x = point.x;
1997 event.y = point.y; 1998 event.y = point.y;
1998 break; 1999 break;
1999 case WebInputEvent::GestureLongPress: 2000 case WebInputEvent::GestureLongPress:
2000 event.x = point.x; 2001 event.x = point.x;
2001 event.y = point.y; 2002 event.y = point.y;
2002 if (!args->PeekNext().IsEmpty()) { 2003 if (!args->PeekNext().IsEmpty()) {
2003 float width; 2004 float width;
2004 if (!args->GetNext(&width)) { 2005 if (!args->GetNext(&width)) {
2005 args->ThrowError(); 2006 args->ThrowError();
2006 return; 2007 return false;
2007 } 2008 }
2008 event.data.longPress.width = width; 2009 event.data.longPress.width = width;
2009 if (!args->PeekNext().IsEmpty()) { 2010 if (!args->PeekNext().IsEmpty()) {
2010 float height; 2011 float height;
2011 if (!args->GetNext(&height)) { 2012 if (!args->GetNext(&height)) {
2012 args->ThrowError(); 2013 args->ThrowError();
2013 return; 2014 return false;
2014 } 2015 }
2015 event.data.longPress.height = height; 2016 event.data.longPress.height = height;
2016 } 2017 }
2017 } 2018 }
2018 break; 2019 break;
2019 case WebInputEvent::GestureLongTap: 2020 case WebInputEvent::GestureLongTap:
2020 event.x = point.x; 2021 event.x = point.x;
2021 event.y = point.y; 2022 event.y = point.y;
2022 if (!args->PeekNext().IsEmpty()) { 2023 if (!args->PeekNext().IsEmpty()) {
2023 float width; 2024 float width;
2024 if (!args->GetNext(&width)) { 2025 if (!args->GetNext(&width)) {
2025 args->ThrowError(); 2026 args->ThrowError();
2026 return; 2027 return false;
2027 } 2028 }
2028 event.data.longPress.width = width; 2029 event.data.longPress.width = width;
2029 if (!args->PeekNext().IsEmpty()) { 2030 if (!args->PeekNext().IsEmpty()) {
2030 float height; 2031 float height;
2031 if (!args->GetNext(&height)) { 2032 if (!args->GetNext(&height)) {
2032 args->ThrowError(); 2033 args->ThrowError();
2033 return; 2034 return false;
2034 } 2035 }
2035 event.data.longPress.height = height; 2036 event.data.longPress.height = height;
2036 } 2037 }
2037 } 2038 }
2038 break; 2039 break;
2039 case WebInputEvent::GestureTwoFingerTap: 2040 case WebInputEvent::GestureTwoFingerTap:
2040 event.x = point.x; 2041 event.x = point.x;
2041 event.y = point.y; 2042 event.y = point.y;
2042 if (!args->PeekNext().IsEmpty()) { 2043 if (!args->PeekNext().IsEmpty()) {
2043 float first_finger_width; 2044 float first_finger_width;
2044 if (!args->GetNext(&first_finger_width)) { 2045 if (!args->GetNext(&first_finger_width)) {
2045 args->ThrowError(); 2046 args->ThrowError();
2046 return; 2047 return false;
2047 } 2048 }
2048 event.data.twoFingerTap.firstFingerWidth = first_finger_width; 2049 event.data.twoFingerTap.firstFingerWidth = first_finger_width;
2049 if (!args->PeekNext().IsEmpty()) { 2050 if (!args->PeekNext().IsEmpty()) {
2050 float first_finger_height; 2051 float first_finger_height;
2051 if (!args->GetNext(&first_finger_height)) { 2052 if (!args->GetNext(&first_finger_height)) {
2052 args->ThrowError(); 2053 args->ThrowError();
2053 return; 2054 return false;
2054 } 2055 }
2055 event.data.twoFingerTap.firstFingerHeight = first_finger_height; 2056 event.data.twoFingerTap.firstFingerHeight = first_finger_height;
2056 } 2057 }
2057 } 2058 }
2058 break; 2059 break;
2059 default: 2060 default:
2060 NOTREACHED(); 2061 NOTREACHED();
2061 } 2062 }
2062 2063
2063 event.globalX = event.x; 2064 event.globalX = event.x;
2064 event.globalY = event.y; 2065 event.globalY = event.y;
2065 event.timeStampSeconds = GetCurrentEventTimeSec(); 2066 event.timeStampSeconds = GetCurrentEventTimeSec();
2066 2067
2067 if (force_layout_on_events_) 2068 if (force_layout_on_events_)
2068 view_->layout(); 2069 view_->layout();
2069 2070
2070 view_->handleInputEvent(event); 2071 bool result = view_->handleInputEvent(event);
2071 2072
2072 // Long press might start a drag drop session. Complete it if so. 2073 // Long press might start a drag drop session. Complete it if so.
2073 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { 2074 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) {
2074 WebMouseEvent mouse_event; 2075 WebMouseEvent mouse_event;
2075 InitMouseEvent(WebInputEvent::MouseDown, 2076 InitMouseEvent(WebInputEvent::MouseDown,
2076 pressed_button_, 2077 pressed_button_,
2077 point, 2078 point,
2078 GetCurrentEventTimeSec(), 2079 GetCurrentEventTimeSec(),
2079 click_count_, 2080 click_count_,
2080 0, 2081 0,
2081 &mouse_event); 2082 &mouse_event);
2082 2083
2083 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); 2084 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone);
2085 result = true;
2084 } 2086 }
2087 return result;
2085 } 2088 }
2086 2089
2087 void EventSender::UpdateClickCountForButton( 2090 void EventSender::UpdateClickCountForButton(
2088 WebMouseEvent::Button button_type) { 2091 WebMouseEvent::Button button_type) {
2089 if ((GetCurrentEventTimeSec() - last_click_time_sec_ < 2092 if ((GetCurrentEventTimeSec() - last_click_time_sec_ <
2090 kMultipleClickTimeSec) && 2093 kMultipleClickTimeSec) &&
2091 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && 2094 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) &&
2092 (button_type == last_button_type_)) { 2095 (button_type == last_button_type_)) {
2093 ++click_count_; 2096 ++click_count_;
2094 } else { 2097 } else {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 } 2244 }
2242 default: 2245 default:
2243 NOTREACHED(); 2246 NOTREACHED();
2244 } 2247 }
2245 } 2248 }
2246 2249
2247 replaying_saved_events_ = false; 2250 replaying_saved_events_ = false;
2248 } 2251 }
2249 2252
2250 } // namespace content 2253 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698