Chromium Code Reviews| 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/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 IntRect expectedBounds = bounds; | 1537 IntRect expectedBounds = bounds; |
| 1538 expectedBounds.scale(2.f); | 1538 expectedBounds.scale(2.f); |
| 1539 IntPoint expectedScrollDelta = scrollDelta; | 1539 IntPoint expectedScrollDelta = scrollDelta; |
| 1540 expectedScrollDelta.scale(2.f, 2.f); | 1540 expectedScrollDelta.scale(2.f, 2.f); |
| 1541 | 1541 |
| 1542 EXPECT_POINT_EQ(IntPoint(expectedBounds.location() - expectedScrollDelta), | 1542 EXPECT_POINT_EQ(IntPoint(expectedBounds.location() - expectedScrollDelta), |
| 1543 boundsInViewport.location()); | 1543 boundsInViewport.location()); |
| 1544 EXPECT_SIZE_EQ(expectedBounds.size(), boundsInViewport.size()); | 1544 EXPECT_SIZE_EQ(expectedBounds.size(), boundsInViewport.size()); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 TEST_P(ParameterizedVisualViewportTest, ElementVisibleBoundsInViewport) | |
| 1548 { | |
| 1549 initializeWithAndroidSettings(); | |
| 1550 webViewImpl()->resize(IntSize(640, 1080)); | |
| 1551 registerMockedHttpURLLoad("viewport-select.html"); | |
| 1552 navigateTo(m_baseURL + "viewport-select.html"); | |
| 1553 | |
| 1554 webViewImpl()->setInitialFocus(false); | |
| 1555 Element* element = webViewImpl()->focusedElement(); | |
| 1556 EXPECT_FALSE(element->visibleBoundsInViewport().isEmpty()); | |
|
bokan
2016/08/08 15:22:59
Please add the converse of this check above before
tkent
2016/08/09 03:17:12
Done. I improved the test scenario to make its pu
| |
| 1557 } | |
| 1558 | |
| 1547 // Test that the various window.scroll and document.body.scroll properties and | 1559 // Test that the various window.scroll and document.body.scroll properties and |
| 1548 // methods work unchanged from the pre-virtual viewport mode. | 1560 // methods work unchanged from the pre-virtual viewport mode. |
| 1549 TEST_P(ParameterizedVisualViewportTest, bodyAndWindowScrollPropertiesAccountForV iewport) | 1561 TEST_P(ParameterizedVisualViewportTest, bodyAndWindowScrollPropertiesAccountForV iewport) |
| 1550 { | 1562 { |
| 1551 initializeWithAndroidSettings(); | 1563 initializeWithAndroidSettings(); |
| 1552 | 1564 |
| 1553 webViewImpl()->resize(IntSize(200, 300)); | 1565 webViewImpl()->resize(IntSize(200, 300)); |
| 1554 | 1566 |
| 1555 // Load page with no main frame scrolling. | 1567 // Load page with no main frame scrolling. |
| 1556 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 1568 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1851 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1840 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(700, 500), ProgrammaticScroll); | 1852 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(700, 500), ProgrammaticScroll); |
| 1841 | 1853 |
| 1842 webViewImpl()->resize(IntSize(400, 300)); | 1854 webViewImpl()->resize(IntSize(400, 300)); |
| 1843 EXPECT_POINT_EQ(DoublePoint(300, 200), frameView.layoutViewportScrollableAre a()->scrollPositionDouble()); | 1855 EXPECT_POINT_EQ(DoublePoint(300, 200), frameView.layoutViewportScrollableAre a()->scrollPositionDouble()); |
| 1844 | 1856 |
| 1845 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled) ; | 1857 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled) ; |
| 1846 } | 1858 } |
| 1847 | 1859 |
| 1848 } // namespace | 1860 } // namespace |
| OLD | NEW |