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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 | 1138 |
1139 // Test that the context menu's location is correct in the presence of visual | 1139 // Test that the context menu's location is correct in the presence of visual |
1140 // viewport offset. | 1140 // viewport offset. |
1141 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { | 1141 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { |
1142 initializeWithDesktopSettings(); | 1142 initializeWithDesktopSettings(); |
1143 webViewImpl()->resize(IntSize(200, 300)); | 1143 webViewImpl()->resize(IntSize(200, 300)); |
1144 | 1144 |
1145 registerMockedHttpURLLoad("200-by-300.html"); | 1145 registerMockedHttpURLLoad("200-by-300.html"); |
1146 navigateTo(m_baseURL + "200-by-300.html"); | 1146 navigateTo(m_baseURL + "200-by-300.html"); |
1147 | 1147 |
1148 WebMouseEvent mouseDownEvent; | 1148 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, |
1149 mouseDownEvent.type = WebInputEvent::MouseDown; | 1149 WebInputEvent::NoModifiers, |
| 1150 WebInputEvent::TimeStampForTesting); |
1150 mouseDownEvent.x = 10; | 1151 mouseDownEvent.x = 10; |
1151 mouseDownEvent.y = 10; | 1152 mouseDownEvent.y = 10; |
1152 mouseDownEvent.windowX = 10; | 1153 mouseDownEvent.windowX = 10; |
1153 mouseDownEvent.windowY = 10; | 1154 mouseDownEvent.windowY = 10; |
1154 mouseDownEvent.globalX = 110; | 1155 mouseDownEvent.globalX = 110; |
1155 mouseDownEvent.globalY = 210; | 1156 mouseDownEvent.globalY = 210; |
1156 mouseDownEvent.clickCount = 1; | 1157 mouseDownEvent.clickCount = 1; |
1157 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1158 mouseDownEvent.button = WebMouseEvent::Button::Right; |
1158 | 1159 |
1159 // Corresponding release event (Windows shows context menu on release). | 1160 // Corresponding release event (Windows shows context menu on release). |
1160 WebMouseEvent mouseUpEvent(mouseDownEvent); | 1161 WebMouseEvent mouseUpEvent(mouseDownEvent); |
1161 mouseUpEvent.type = WebInputEvent::MouseUp; | 1162 mouseUpEvent.setType(WebInputEvent::MouseUp); |
1162 | 1163 |
1163 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1164 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
1164 MockWebFrameClient mockWebFrameClient; | 1165 MockWebFrameClient mockWebFrameClient; |
1165 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1166 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
1166 mouseDownEvent.x, mouseDownEvent.y))); | 1167 mouseDownEvent.x, mouseDownEvent.y))); |
1167 | 1168 |
1168 // Do a sanity check with no scale applied. | 1169 // Do a sanity check with no scale applied. |
1169 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1170 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
1170 webViewImpl()->handleInputEvent(mouseDownEvent); | 1171 webViewImpl()->handleInputEvent(mouseDownEvent); |
1171 webViewImpl()->handleInputEvent(mouseUpEvent); | 1172 webViewImpl()->handleInputEvent(mouseUpEvent); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 std::string(output->innerHTML().ascii().data())); | 1997 std::string(output->innerHTML().ascii().data())); |
1997 } | 1998 } |
1998 | 1999 |
1999 TEST_P(VisualViewportTest, PinchZoomGestureScrollsVisualViewportOnly) { | 2000 TEST_P(VisualViewportTest, PinchZoomGestureScrollsVisualViewportOnly) { |
2000 initializeWithDesktopSettings(); | 2001 initializeWithDesktopSettings(); |
2001 webViewImpl()->resize(IntSize(100, 100)); | 2002 webViewImpl()->resize(IntSize(100, 100)); |
2002 | 2003 |
2003 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 2004 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
2004 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 2005 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
2005 | 2006 |
2006 WebGestureEvent pinchUpdate; | 2007 WebGestureEvent pinchUpdate(WebInputEvent::GesturePinchUpdate, |
2007 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; | 2008 WebInputEvent::NoModifiers, |
| 2009 WebInputEvent::TimeStampForTesting); |
2008 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; | 2010 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; |
2009 pinchUpdate.x = 100; | 2011 pinchUpdate.x = 100; |
2010 pinchUpdate.y = 100; | 2012 pinchUpdate.y = 100; |
2011 pinchUpdate.data.pinchUpdate.scale = 2; | 2013 pinchUpdate.data.pinchUpdate.scale = 2; |
2012 pinchUpdate.data.pinchUpdate.zoomDisabled = false; | 2014 pinchUpdate.data.pinchUpdate.zoomDisabled = false; |
2013 | 2015 |
2014 webViewImpl()->handleInputEvent(pinchUpdate); | 2016 webViewImpl()->handleInputEvent(pinchUpdate); |
2015 | 2017 |
2016 VisualViewport& visualViewport = | 2018 VisualViewport& visualViewport = |
2017 webViewImpl()->page()->frameHost().visualViewport(); | 2019 webViewImpl()->page()->frameHost().visualViewport(); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 if (rootLayerScrolling) | 2394 if (rootLayerScrolling) |
2393 EXPECT_TRUE(invalidationTracking); | 2395 EXPECT_TRUE(invalidationTracking); |
2394 else | 2396 else |
2395 EXPECT_FALSE(invalidationTracking); | 2397 EXPECT_FALSE(invalidationTracking); |
2396 | 2398 |
2397 document->view()->setTracksPaintInvalidations(false); | 2399 document->view()->setTracksPaintInvalidations(false); |
2398 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2400 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
2399 } | 2401 } |
2400 | 2402 |
2401 } // namespace | 2403 } // namespace |
OLD | NEW |