| 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 "core/frame/VisualViewport.h" | 5 #include "core/frame/VisualViewport.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/BrowserControls.h" | 8 #include "core/frame/BrowserControls.h" |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 WebMouseEvent mouseUpEvent(mouseDownEvent); | 1134 WebMouseEvent mouseUpEvent(mouseDownEvent); |
| 1135 mouseUpEvent.type = WebInputEvent::MouseUp; | 1135 mouseUpEvent.type = WebInputEvent::MouseUp; |
| 1136 | 1136 |
| 1137 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1137 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
| 1138 MockWebFrameClient mockWebFrameClient; | 1138 MockWebFrameClient mockWebFrameClient; |
| 1139 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1139 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
| 1140 mouseDownEvent.x, mouseDownEvent.y))); | 1140 mouseDownEvent.x, mouseDownEvent.y))); |
| 1141 | 1141 |
| 1142 // Do a sanity check with no scale applied. | 1142 // Do a sanity check with no scale applied. |
| 1143 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1143 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
| 1144 webViewImpl()->handleInputEvent(mouseDownEvent); | 1144 webViewImpl()->handleInputEvent(mouseDownEvent, |
| 1145 webViewImpl()->handleInputEvent(mouseUpEvent); | 1145 std::vector<const WebInputEvent*>()); |
| 1146 webViewImpl()->handleInputEvent(mouseUpEvent, |
| 1147 std::vector<const WebInputEvent*>()); |
| 1146 | 1148 |
| 1147 Mock::VerifyAndClearExpectations(&mockWebFrameClient); | 1149 Mock::VerifyAndClearExpectations(&mockWebFrameClient); |
| 1148 mouseDownEvent.button = WebMouseEvent::Button::Left; | 1150 mouseDownEvent.button = WebMouseEvent::Button::Left; |
| 1149 webViewImpl()->handleInputEvent(mouseDownEvent); | 1151 webViewImpl()->handleInputEvent(mouseDownEvent, |
| 1152 std::vector<const WebInputEvent*>()); |
| 1150 | 1153 |
| 1151 // Now pinch zoom into the page and move the visual viewport. The context menu | 1154 // Now pinch zoom into the page and move the visual viewport. The context menu |
| 1152 // should still appear at the location of the event, relative to the WebView. | 1155 // should still appear at the location of the event, relative to the WebView. |
| 1153 VisualViewport& visualViewport = | 1156 VisualViewport& visualViewport = |
| 1154 frame()->page()->frameHost().visualViewport(); | 1157 frame()->page()->frameHost().visualViewport(); |
| 1155 webViewImpl()->setPageScaleFactor(2); | 1158 webViewImpl()->setPageScaleFactor(2); |
| 1156 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); | 1159 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); |
| 1157 visualViewport.setLocation(FloatPoint(60, 80)); | 1160 visualViewport.setLocation(FloatPoint(60, 80)); |
| 1158 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1161 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
| 1159 mouseDownEvent.x, mouseDownEvent.y))); | 1162 mouseDownEvent.x, mouseDownEvent.y))); |
| 1160 | 1163 |
| 1161 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1164 mouseDownEvent.button = WebMouseEvent::Button::Right; |
| 1162 webViewImpl()->handleInputEvent(mouseDownEvent); | 1165 webViewImpl()->handleInputEvent(mouseDownEvent, |
| 1163 webViewImpl()->handleInputEvent(mouseUpEvent); | 1166 std::vector<const WebInputEvent*>()); |
| 1167 webViewImpl()->handleInputEvent(mouseUpEvent, |
| 1168 std::vector<const WebInputEvent*>()); |
| 1164 | 1169 |
| 1165 // Reset the old client so destruction can occur naturally. | 1170 // Reset the old client so destruction can occur naturally. |
| 1166 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1171 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1167 } | 1172 } |
| 1168 | 1173 |
| 1169 // Test that the client is notified if page scroll events. | 1174 // Test that the client is notified if page scroll events. |
| 1170 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { | 1175 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { |
| 1171 initializeWithAndroidSettings(); | 1176 initializeWithAndroidSettings(); |
| 1172 webViewImpl()->resize(IntSize(200, 300)); | 1177 webViewImpl()->resize(IntSize(200, 300)); |
| 1173 | 1178 |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 1978 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 1974 | 1979 |
| 1975 WebGestureEvent pinchUpdate; | 1980 WebGestureEvent pinchUpdate; |
| 1976 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; | 1981 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; |
| 1977 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; | 1982 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; |
| 1978 pinchUpdate.x = 100; | 1983 pinchUpdate.x = 100; |
| 1979 pinchUpdate.y = 100; | 1984 pinchUpdate.y = 100; |
| 1980 pinchUpdate.data.pinchUpdate.scale = 2; | 1985 pinchUpdate.data.pinchUpdate.scale = 2; |
| 1981 pinchUpdate.data.pinchUpdate.zoomDisabled = false; | 1986 pinchUpdate.data.pinchUpdate.zoomDisabled = false; |
| 1982 | 1987 |
| 1983 webViewImpl()->handleInputEvent(pinchUpdate); | 1988 webViewImpl()->handleInputEvent(pinchUpdate, |
| 1989 std::vector<const WebInputEvent*>()); |
| 1984 | 1990 |
| 1985 VisualViewport& visualViewport = | 1991 VisualViewport& visualViewport = |
| 1986 webViewImpl()->page()->frameHost().visualViewport(); | 1992 webViewImpl()->page()->frameHost().visualViewport(); |
| 1987 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1993 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1988 | 1994 |
| 1989 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); | 1995 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); |
| 1990 EXPECT_SIZE_EQ(ScrollOffset(0, 0), | 1996 EXPECT_SIZE_EQ(ScrollOffset(0, 0), |
| 1991 frameView.layoutViewportScrollableArea()->scrollOffset()); | 1997 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 1992 } | 1998 } |
| 1993 | 1999 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 webViewImpl()->resize(IntSize(600, 800)); | 2080 webViewImpl()->resize(IntSize(600, 800)); |
| 2075 | 2081 |
| 2076 EXPECT_SIZE_EQ(ScrollOffset(), | 2082 EXPECT_SIZE_EQ(ScrollOffset(), |
| 2077 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2083 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 2078 EXPECT_EQ(600, scroller->scrollTop()); | 2084 EXPECT_EQ(600, scroller->scrollTop()); |
| 2079 | 2085 |
| 2080 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); | 2086 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
| 2081 } | 2087 } |
| 2082 | 2088 |
| 2083 } // namespace | 2089 } // namespace |
| OLD | NEW |