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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "core/frame/PinchViewport.h" | 7 #include "core/frame/PinchViewport.h" |
8 | 8 |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 | 895 |
896 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. | 896 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. |
897 TEST_F(PinchViewportTest, TestWebViewResizeCausesViewportConstrainedLayout) | 897 TEST_F(PinchViewportTest, TestWebViewResizeCausesViewportConstrainedLayout) |
898 { | 898 { |
899 initializeWithDesktopSettings(); | 899 initializeWithDesktopSettings(); |
900 webViewImpl()->resize(IntSize(500, 300)); | 900 webViewImpl()->resize(IntSize(500, 300)); |
901 | 901 |
902 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); | 902 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); |
903 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); | 903 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); |
904 | 904 |
905 LayoutObject* navbar = frame()->document()->getElementById("navbar")->render
er(); | 905 LayoutObject* navbar = frame()->document()->getElementById("navbar")->layout
Object(); |
906 | 906 |
907 EXPECT_FALSE(navbar->needsLayout()); | 907 EXPECT_FALSE(navbar->needsLayout()); |
908 | 908 |
909 frame()->view()->resize(IntSize(500, 200)); | 909 frame()->view()->resize(IntSize(500, 200)); |
910 | 910 |
911 EXPECT_TRUE(navbar->needsLayout()); | 911 EXPECT_TRUE(navbar->needsLayout()); |
912 } | 912 } |
913 | 913 |
914 class MockWebFrameClient : public WebFrameClient { | 914 class MockWebFrameClient : public WebFrameClient { |
915 public: | 915 public: |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 initializeWithAndroidSettings(); | 1331 initializeWithAndroidSettings(); |
1332 | 1332 |
1333 webViewImpl()->resize(IntSize(500, 800)); | 1333 webViewImpl()->resize(IntSize(500, 800)); |
1334 | 1334 |
1335 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1335 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
1336 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 1336 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
1337 | 1337 |
1338 webViewImpl()->setInitialFocus(false); | 1338 webViewImpl()->setInitialFocus(false); |
1339 Element* inputElement = webViewImpl()->focusedElement(); | 1339 Element* inputElement = webViewImpl()->focusedElement(); |
1340 | 1340 |
1341 IntRect bounds = inputElement->renderer()->absoluteBoundingBoxRect(); | 1341 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); |
1342 | 1342 |
1343 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1343 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1344 IntPoint scrollDelta(250, 400); | 1344 IntPoint scrollDelta(250, 400); |
1345 pinchViewport.setScale(2); | 1345 pinchViewport.setScale(2); |
1346 pinchViewport.setLocation(scrollDelta); | 1346 pinchViewport.setLocation(scrollDelta); |
1347 | 1347 |
1348 IntRect boundsInViewport = inputElement->boundsInViewportSpace(); | 1348 IntRect boundsInViewport = inputElement->boundsInViewportSpace(); |
1349 | 1349 |
1350 EXPECT_POINT_EQ(IntPoint(bounds.location() - scrollDelta), | 1350 EXPECT_POINT_EQ(IntPoint(bounds.location() - scrollDelta), |
1351 boundsInViewport.location()); | 1351 boundsInViewport.location()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 ScrollableArea* scrollableArea = &pinchViewport; | 1459 ScrollableArea* scrollableArea = &pinchViewport; |
1460 | 1460 |
1461 webViewImpl()->setPageScaleFactor(1.0); | 1461 webViewImpl()->setPageScaleFactor(1.0); |
1462 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo
uble()); | 1462 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo
uble()); |
1463 | 1463 |
1464 webViewImpl()->setPageScaleFactor(2); | 1464 webViewImpl()->setPageScaleFactor(2); |
1465 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max
imumScrollPositionDouble()); | 1465 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max
imumScrollPositionDouble()); |
1466 } | 1466 } |
1467 | 1467 |
1468 } // namespace | 1468 } // namespace |
OLD | NEW |