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" |
11 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
12 #include "core/html/HTMLBodyElement.h" | 12 #include "core/html/HTMLBodyElement.h" |
13 #include "core/html/HTMLElement.h" | 13 #include "core/html/HTMLElement.h" |
14 #include "core/input/EventHandler.h" | 14 #include "core/input/EventHandler.h" |
15 #include "core/layout/LayoutObject.h" | 15 #include "core/layout/LayoutObject.h" |
16 #include "core/layout/api/LayoutViewItem.h" | 16 #include "core/layout/api/LayoutViewItem.h" |
17 #include "core/layout/compositing/PaintLayerCompositor.h" | 17 #include "core/layout/compositing/PaintLayerCompositor.h" |
18 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
19 #include "core/paint/PaintLayer.h" | 19 #include "core/paint/PaintLayer.h" |
20 #include "platform/PlatformGestureEvent.h" | 20 #include "platform/PlatformGestureEvent.h" |
21 #include "platform/geometry/DoublePoint.h" | 21 #include "platform/geometry/DoublePoint.h" |
22 #include "platform/geometry/DoubleRect.h" | 22 #include "platform/geometry/DoubleRect.h" |
23 #include "platform/graphics/CompositorElementId.h" | 23 #include "platform/graphics/CompositorElementId.h" |
24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
25 #include "platform/testing/URLTestHelpers.h" | 25 #include "platform/testing/URLTestHelpers.h" |
| 26 #include "public/platform/CoalescedWebInputEvent.h" |
26 #include "public/platform/Platform.h" | 27 #include "public/platform/Platform.h" |
27 #include "public/platform/WebCachePolicy.h" | 28 #include "public/platform/WebCachePolicy.h" |
28 #include "public/platform/WebInputEvent.h" | 29 #include "public/platform/WebInputEvent.h" |
29 #include "public/platform/WebLayerTreeView.h" | 30 #include "public/platform/WebLayerTreeView.h" |
30 #include "public/platform/WebURLLoaderMockFactory.h" | 31 #include "public/platform/WebURLLoaderMockFactory.h" |
31 #include "public/web/WebCache.h" | 32 #include "public/web/WebCache.h" |
32 #include "public/web/WebContextMenuData.h" | 33 #include "public/web/WebContextMenuData.h" |
33 #include "public/web/WebDocument.h" | 34 #include "public/web/WebDocument.h" |
34 #include "public/web/WebFrameClient.h" | 35 #include "public/web/WebFrameClient.h" |
35 #include "public/web/WebScriptSource.h" | 36 #include "public/web/WebScriptSource.h" |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 WebMouseEvent mouseUpEvent(mouseDownEvent); | 1174 WebMouseEvent mouseUpEvent(mouseDownEvent); |
1174 mouseUpEvent.type = WebInputEvent::MouseUp; | 1175 mouseUpEvent.type = WebInputEvent::MouseUp; |
1175 | 1176 |
1176 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1177 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
1177 MockWebFrameClient mockWebFrameClient; | 1178 MockWebFrameClient mockWebFrameClient; |
1178 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1179 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
1179 mouseDownEvent.x, mouseDownEvent.y))); | 1180 mouseDownEvent.x, mouseDownEvent.y))); |
1180 | 1181 |
1181 // Do a sanity check with no scale applied. | 1182 // Do a sanity check with no scale applied. |
1182 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1183 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
1183 webViewImpl()->handleInputEvent(mouseDownEvent); | 1184 webViewImpl()->handleInputEvent(CoalescedWebInputEvent(mouseDownEvent)); |
1184 webViewImpl()->handleInputEvent(mouseUpEvent); | 1185 webViewImpl()->handleInputEvent(CoalescedWebInputEvent(mouseUpEvent)); |
1185 | 1186 |
1186 Mock::VerifyAndClearExpectations(&mockWebFrameClient); | 1187 Mock::VerifyAndClearExpectations(&mockWebFrameClient); |
1187 mouseDownEvent.button = WebMouseEvent::Button::Left; | 1188 mouseDownEvent.button = WebMouseEvent::Button::Left; |
1188 webViewImpl()->handleInputEvent(mouseDownEvent); | 1189 webViewImpl()->handleInputEvent(CoalescedWebInputEvent(mouseDownEvent)); |
1189 | 1190 |
1190 // Now pinch zoom into the page and move the visual viewport. The context menu | 1191 // Now pinch zoom into the page and move the visual viewport. The context menu |
1191 // should still appear at the location of the event, relative to the WebView. | 1192 // should still appear at the location of the event, relative to the WebView. |
1192 VisualViewport& visualViewport = | 1193 VisualViewport& visualViewport = |
1193 frame()->page()->frameHost().visualViewport(); | 1194 frame()->page()->frameHost().visualViewport(); |
1194 webViewImpl()->setPageScaleFactor(2); | 1195 webViewImpl()->setPageScaleFactor(2); |
1195 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); | 1196 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); |
1196 visualViewport.setLocation(FloatPoint(60, 80)); | 1197 visualViewport.setLocation(FloatPoint(60, 80)); |
1197 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1198 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
1198 mouseDownEvent.x, mouseDownEvent.y))); | 1199 mouseDownEvent.x, mouseDownEvent.y))); |
1199 | 1200 |
1200 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1201 mouseDownEvent.button = WebMouseEvent::Button::Right; |
1201 webViewImpl()->handleInputEvent(mouseDownEvent); | 1202 webViewImpl()->handleInputEvent(mouseDownEvent, |
1202 webViewImpl()->handleInputEvent(mouseUpEvent); | 1203 std::vector<const WebInputEvent*>()); |
| 1204 webViewImpl()->handleInputEvent(mouseUpEvent, |
| 1205 std::vector<const WebInputEvent*>()); |
1203 | 1206 |
1204 // Reset the old client so destruction can occur naturally. | 1207 // Reset the old client so destruction can occur naturally. |
1205 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1208 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
1206 } | 1209 } |
1207 | 1210 |
1208 // Test that the client is notified if page scroll events. | 1211 // Test that the client is notified if page scroll events. |
1209 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { | 1212 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { |
1210 initializeWithAndroidSettings(); | 1213 initializeWithAndroidSettings(); |
1211 webViewImpl()->resize(IntSize(200, 300)); | 1214 webViewImpl()->resize(IntSize(200, 300)); |
1212 | 1215 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 2015 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
2013 | 2016 |
2014 WebGestureEvent pinchUpdate; | 2017 WebGestureEvent pinchUpdate; |
2015 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; | 2018 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; |
2016 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; | 2019 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; |
2017 pinchUpdate.x = 100; | 2020 pinchUpdate.x = 100; |
2018 pinchUpdate.y = 100; | 2021 pinchUpdate.y = 100; |
2019 pinchUpdate.data.pinchUpdate.scale = 2; | 2022 pinchUpdate.data.pinchUpdate.scale = 2; |
2020 pinchUpdate.data.pinchUpdate.zoomDisabled = false; | 2023 pinchUpdate.data.pinchUpdate.zoomDisabled = false; |
2021 | 2024 |
2022 webViewImpl()->handleInputEvent(pinchUpdate); | 2025 webViewImpl()->handleInputEvent(pinchUpdate, |
| 2026 std::vector<const WebInputEvent*>()); |
2023 | 2027 |
2024 VisualViewport& visualViewport = | 2028 VisualViewport& visualViewport = |
2025 webViewImpl()->page()->frameHost().visualViewport(); | 2029 webViewImpl()->page()->frameHost().visualViewport(); |
2026 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 2030 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
2027 | 2031 |
2028 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); | 2032 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); |
2029 EXPECT_SIZE_EQ(ScrollOffset(0, 0), | 2033 EXPECT_SIZE_EQ(ScrollOffset(0, 0), |
2030 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2034 frameView.layoutViewportScrollableArea()->scrollOffset()); |
2031 } | 2035 } |
2032 | 2036 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 if (rootLayerScrolling) | 2401 if (rootLayerScrolling) |
2398 EXPECT_TRUE(invalidationTracking); | 2402 EXPECT_TRUE(invalidationTracking); |
2399 else | 2403 else |
2400 EXPECT_FALSE(invalidationTracking); | 2404 EXPECT_FALSE(invalidationTracking); |
2401 | 2405 |
2402 document->view()->setTracksPaintInvalidations(false); | 2406 document->view()->setTracksPaintInvalidations(false); |
2403 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2407 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
2404 } | 2408 } |
2405 | 2409 |
2406 } // namespace | 2410 } // namespace |
OLD | NEW |