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 "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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 if (touch_point->state == WebTouchPoint::StateReleased) { | 1915 if (touch_point->state == WebTouchPoint::StateReleased) { |
1916 touch_points_.erase(touch_points_.begin() + i); | 1916 touch_points_.erase(touch_points_.begin() + i); |
1917 --i; | 1917 --i; |
1918 } else | 1918 } else |
1919 touch_point->state = WebTouchPoint::StateStationary; | 1919 touch_point->state = WebTouchPoint::StateStationary; |
1920 } | 1920 } |
1921 } | 1921 } |
1922 | 1922 |
1923 void EventSender::GestureEvent(WebInputEvent::Type type, | 1923 void EventSender::GestureEvent(WebInputEvent::Type type, |
1924 gin::Arguments* args) { | 1924 gin::Arguments* args) { |
1925 double x; | 1925 double x = 0; |
1926 double y; | 1926 double y = 0; |
1927 args->GetNext(&x); | 1927 DCHECK(args->GetNext(&x)); |
Rick Byers
2014/09/23 14:27:14
I think we should check to see if there are args a
earthdok
2014/09/23 14:33:08
DCHECKs aren't evaluated in Release builds, so thi
| |
1928 args->GetNext(&y); | 1928 DCHECK(args->GetNext(&y)); |
1929 WebPoint point(x, y); | |
1930 | 1929 |
1931 WebGestureEvent event; | 1930 WebGestureEvent event; |
1932 event.type = type; | 1931 event.type = type; |
1933 | 1932 |
1934 switch (type) { | 1933 switch (type) { |
1935 case WebInputEvent::GestureScrollUpdate: | 1934 case WebInputEvent::GestureScrollUpdate: |
1936 case WebInputEvent::GestureScrollUpdateWithoutPropagation: | 1935 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
1937 event.data.scrollUpdate.deltaX = static_cast<float>(x); | 1936 event.data.scrollUpdate.deltaX = static_cast<float>(x); |
1938 event.data.scrollUpdate.deltaY = static_cast<float>(y); | 1937 event.data.scrollUpdate.deltaY = static_cast<float>(y); |
1939 event.x = current_gesture_location_.x; | 1938 event.x = current_gesture_location_.x; |
1940 event.y = current_gesture_location_.y; | 1939 event.y = current_gesture_location_.y; |
1941 current_gesture_location_.x = | 1940 current_gesture_location_.x = |
1942 current_gesture_location_.x + event.data.scrollUpdate.deltaX; | 1941 current_gesture_location_.x + event.data.scrollUpdate.deltaX; |
1943 current_gesture_location_.y = | 1942 current_gesture_location_.y = |
1944 current_gesture_location_.y + event.data.scrollUpdate.deltaY; | 1943 current_gesture_location_.y + event.data.scrollUpdate.deltaY; |
1945 break; | 1944 break; |
1946 case WebInputEvent::GestureScrollBegin: | 1945 case WebInputEvent::GestureScrollBegin: |
1947 current_gesture_location_ = WebPoint(point.x, point.y); | 1946 current_gesture_location_ = WebPoint(x, y); |
1948 event.x = current_gesture_location_.x; | 1947 event.x = current_gesture_location_.x; |
1949 event.y = current_gesture_location_.y; | 1948 event.y = current_gesture_location_.y; |
1950 break; | 1949 break; |
1951 case WebInputEvent::GestureScrollEnd: | 1950 case WebInputEvent::GestureScrollEnd: |
1952 case WebInputEvent::GestureFlingStart: | 1951 case WebInputEvent::GestureFlingStart: |
1953 event.x = current_gesture_location_.x; | 1952 event.x = current_gesture_location_.x; |
1954 event.y = current_gesture_location_.y; | 1953 event.y = current_gesture_location_.y; |
1955 break; | 1954 break; |
1956 case WebInputEvent::GestureTap: | 1955 case WebInputEvent::GestureTap: |
1957 { | 1956 { |
(...skipping 14 matching lines...) Expand all Loading... | |
1972 } | 1971 } |
1973 if (!args->PeekNext().IsEmpty()) { | 1972 if (!args->PeekNext().IsEmpty()) { |
1974 if (!args->GetNext(&height)) { | 1973 if (!args->GetNext(&height)) { |
1975 args->ThrowError(); | 1974 args->ThrowError(); |
1976 return; | 1975 return; |
1977 } | 1976 } |
1978 } | 1977 } |
1979 event.data.tap.tapCount = tap_count; | 1978 event.data.tap.tapCount = tap_count; |
1980 event.data.tap.width = width; | 1979 event.data.tap.width = width; |
1981 event.data.tap.height = height; | 1980 event.data.tap.height = height; |
1982 event.x = point.x; | 1981 event.x = x; |
1983 event.y = point.y; | 1982 event.y = y; |
1984 break; | 1983 break; |
1985 } | 1984 } |
1986 case WebInputEvent::GestureTapUnconfirmed: | 1985 case WebInputEvent::GestureTapUnconfirmed: |
1987 if (!args->PeekNext().IsEmpty()) { | 1986 if (!args->PeekNext().IsEmpty()) { |
1988 float tap_count; | 1987 float tap_count; |
1989 if (!args->GetNext(&tap_count)) { | 1988 if (!args->GetNext(&tap_count)) { |
1990 args->ThrowError(); | 1989 args->ThrowError(); |
1991 return; | 1990 return; |
1992 } | 1991 } |
1993 event.data.tap.tapCount = tap_count; | 1992 event.data.tap.tapCount = tap_count; |
1994 } else { | 1993 } else { |
1995 event.data.tap.tapCount = 1; | 1994 event.data.tap.tapCount = 1; |
1996 } | 1995 } |
1997 event.x = point.x; | 1996 event.x = x; |
1998 event.y = point.y; | 1997 event.y = y; |
1999 break; | 1998 break; |
2000 case WebInputEvent::GestureTapDown: | 1999 case WebInputEvent::GestureTapDown: |
2001 { | 2000 { |
2002 float width = 30; | 2001 float width = 30; |
2003 float height = 30; | 2002 float height = 30; |
2004 if (!args->PeekNext().IsEmpty()) { | 2003 if (!args->PeekNext().IsEmpty()) { |
2005 if (!args->GetNext(&width)) { | 2004 if (!args->GetNext(&width)) { |
2006 args->ThrowError(); | 2005 args->ThrowError(); |
2007 return; | 2006 return; |
2008 } | 2007 } |
2009 } | 2008 } |
2010 if (!args->PeekNext().IsEmpty()) { | 2009 if (!args->PeekNext().IsEmpty()) { |
2011 if (!args->GetNext(&height)) { | 2010 if (!args->GetNext(&height)) { |
2012 args->ThrowError(); | 2011 args->ThrowError(); |
2013 return; | 2012 return; |
2014 } | 2013 } |
2015 } | 2014 } |
2016 event.x = point.x; | 2015 event.x = x; |
2017 event.y = point.y; | 2016 event.y = y; |
2018 event.data.tapDown.width = width; | 2017 event.data.tapDown.width = width; |
2019 event.data.tapDown.height = height; | 2018 event.data.tapDown.height = height; |
2020 break; | 2019 break; |
2021 } | 2020 } |
2022 case WebInputEvent::GestureShowPress: | 2021 case WebInputEvent::GestureShowPress: |
2023 { | 2022 { |
2024 float width = 30; | 2023 float width = 30; |
2025 float height = 30; | 2024 float height = 30; |
2026 if (!args->PeekNext().IsEmpty()) { | 2025 if (!args->PeekNext().IsEmpty()) { |
2027 if (!args->GetNext(&width)) { | 2026 if (!args->GetNext(&width)) { |
2028 args->ThrowError(); | 2027 args->ThrowError(); |
2029 return; | 2028 return; |
2030 } | 2029 } |
2031 if (!args->PeekNext().IsEmpty()) { | 2030 if (!args->PeekNext().IsEmpty()) { |
2032 if (!args->GetNext(&height)) { | 2031 if (!args->GetNext(&height)) { |
2033 args->ThrowError(); | 2032 args->ThrowError(); |
2034 return; | 2033 return; |
2035 } | 2034 } |
2036 } | 2035 } |
2037 } | 2036 } |
2038 event.x = point.x; | 2037 event.x = x; |
2039 event.y = point.y; | 2038 event.y = y; |
2040 event.data.showPress.width = width; | 2039 event.data.showPress.width = width; |
2041 event.data.showPress.height = height; | 2040 event.data.showPress.height = height; |
2042 break; | 2041 break; |
2043 } | 2042 } |
2044 case WebInputEvent::GestureTapCancel: | 2043 case WebInputEvent::GestureTapCancel: |
2045 event.x = point.x; | 2044 event.x = x; |
2046 event.y = point.y; | 2045 event.y = y; |
2047 break; | 2046 break; |
2048 case WebInputEvent::GestureLongPress: | 2047 case WebInputEvent::GestureLongPress: |
2049 event.x = point.x; | 2048 event.x = x; |
2050 event.y = point.y; | 2049 event.y = y; |
2051 if (!args->PeekNext().IsEmpty()) { | 2050 if (!args->PeekNext().IsEmpty()) { |
2052 float width; | 2051 float width; |
2053 if (!args->GetNext(&width)) { | 2052 if (!args->GetNext(&width)) { |
2054 args->ThrowError(); | 2053 args->ThrowError(); |
2055 return; | 2054 return; |
2056 } | 2055 } |
2057 event.data.longPress.width = width; | 2056 event.data.longPress.width = width; |
2058 if (!args->PeekNext().IsEmpty()) { | 2057 if (!args->PeekNext().IsEmpty()) { |
2059 float height; | 2058 float height; |
2060 if (!args->GetNext(&height)) { | 2059 if (!args->GetNext(&height)) { |
2061 args->ThrowError(); | 2060 args->ThrowError(); |
2062 return; | 2061 return; |
2063 } | 2062 } |
2064 event.data.longPress.height = height; | 2063 event.data.longPress.height = height; |
2065 } | 2064 } |
2066 } | 2065 } |
2067 break; | 2066 break; |
2068 case WebInputEvent::GestureLongTap: | 2067 case WebInputEvent::GestureLongTap: |
2069 event.x = point.x; | 2068 event.x = x; |
2070 event.y = point.y; | 2069 event.y = y; |
2071 if (!args->PeekNext().IsEmpty()) { | 2070 if (!args->PeekNext().IsEmpty()) { |
2072 float width; | 2071 float width; |
2073 if (!args->GetNext(&width)) { | 2072 if (!args->GetNext(&width)) { |
2074 args->ThrowError(); | 2073 args->ThrowError(); |
2075 return; | 2074 return; |
2076 } | 2075 } |
2077 event.data.longPress.width = width; | 2076 event.data.longPress.width = width; |
2078 if (!args->PeekNext().IsEmpty()) { | 2077 if (!args->PeekNext().IsEmpty()) { |
2079 float height; | 2078 float height; |
2080 if (!args->GetNext(&height)) { | 2079 if (!args->GetNext(&height)) { |
2081 args->ThrowError(); | 2080 args->ThrowError(); |
2082 return; | 2081 return; |
2083 } | 2082 } |
2084 event.data.longPress.height = height; | 2083 event.data.longPress.height = height; |
2085 } | 2084 } |
2086 } | 2085 } |
2087 break; | 2086 break; |
2088 case WebInputEvent::GestureTwoFingerTap: | 2087 case WebInputEvent::GestureTwoFingerTap: |
2089 event.x = point.x; | 2088 event.x = x; |
2090 event.y = point.y; | 2089 event.y = y; |
2091 if (!args->PeekNext().IsEmpty()) { | 2090 if (!args->PeekNext().IsEmpty()) { |
2092 float first_finger_width; | 2091 float first_finger_width; |
2093 if (!args->GetNext(&first_finger_width)) { | 2092 if (!args->GetNext(&first_finger_width)) { |
2094 args->ThrowError(); | 2093 args->ThrowError(); |
2095 return; | 2094 return; |
2096 } | 2095 } |
2097 event.data.twoFingerTap.firstFingerWidth = first_finger_width; | 2096 event.data.twoFingerTap.firstFingerWidth = first_finger_width; |
2098 if (!args->PeekNext().IsEmpty()) { | 2097 if (!args->PeekNext().IsEmpty()) { |
2099 float first_finger_height; | 2098 float first_finger_height; |
2100 if (!args->GetNext(&first_finger_height)) { | 2099 if (!args->GetNext(&first_finger_height)) { |
(...skipping 15 matching lines...) Expand all Loading... | |
2116 if (force_layout_on_events_) | 2115 if (force_layout_on_events_) |
2117 view_->layout(); | 2116 view_->layout(); |
2118 | 2117 |
2119 bool result = view_->handleInputEvent(event); | 2118 bool result = view_->handleInputEvent(event); |
2120 | 2119 |
2121 // Long press might start a drag drop session. Complete it if so. | 2120 // Long press might start a drag drop session. Complete it if so. |
2122 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { | 2121 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { |
2123 WebMouseEvent mouse_event; | 2122 WebMouseEvent mouse_event; |
2124 InitMouseEvent(WebInputEvent::MouseDown, | 2123 InitMouseEvent(WebInputEvent::MouseDown, |
2125 pressed_button_, | 2124 pressed_button_, |
2126 point, | 2125 WebPoint(x, y), |
2127 GetCurrentEventTimeSec(), | 2126 GetCurrentEventTimeSec(), |
2128 click_count_, | 2127 click_count_, |
2129 0, | 2128 0, |
2130 &mouse_event); | 2129 &mouse_event); |
2131 | 2130 |
2132 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); | 2131 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); |
2133 } | 2132 } |
2134 args->Return(result); | 2133 args->Return(result); |
2135 } | 2134 } |
2136 | 2135 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2291 } | 2290 } |
2292 default: | 2291 default: |
2293 NOTREACHED(); | 2292 NOTREACHED(); |
2294 } | 2293 } |
2295 } | 2294 } |
2296 | 2295 |
2297 replaying_saved_events_ = false; | 2296 replaying_saved_events_ = false; |
2298 } | 2297 } |
2299 | 2298 |
2300 } // namespace content | 2299 } // namespace content |
OLD | NEW |