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/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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 expectedLocation, | 298 expectedLocation, |
| 299 frameView.getScrollableArea()->visibleContentRect().location()); | 299 frameView.getScrollableArea()->visibleContentRect().location()); |
| 300 | 300 |
| 301 webViewImpl()->resize(IntSize(800, 600)); | 301 webViewImpl()->resize(IntSize(800, 600)); |
| 302 | 302 |
| 303 EXPECT_POINT_EQ( | 303 EXPECT_POINT_EQ( |
| 304 expectedLocation, | 304 expectedLocation, |
| 305 frameView.getScrollableArea()->visibleContentRect().location()); | 305 frameView.getScrollableArea()->visibleContentRect().location()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // Test the main frame scrollbars take visual viewport into account. | |
| 309 TEST_P(VisualViewportTest, VerifyScrollbarBehavior) { | |
| 310 // TODO(ymalik): With root layer scrolling enabled, the scroller returned | |
| 311 // by FrameView is PaintLayerScrollableArea. PLSA doesn't know about the | |
| 312 // visual viewport and thus, scrollbars aren't added when we zoom in. | |
| 313 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | |
|
bokan
2016/11/03 19:59:59
Run the test but change the expectations below bas
ymalik
2016/11/04 18:54:18
Good tip. Done.
| |
| 314 return; | |
| 315 | |
| 316 initializeWithDesktopSettings(); | |
| 317 | |
| 318 registerMockedHttpURLLoad("200-by-800-viewport.html"); | |
| 319 navigateTo(m_baseURL + "200-by-800-viewport.html"); | |
| 320 | |
| 321 webViewImpl()->resize(IntSize(300, 200)); | |
| 322 | |
| 323 ScrollableArea* scroller = frame()->view()->getScrollableArea(); | |
| 324 | |
| 325 // Initially, there is no horizontal scrollbar since the content fits. | |
| 326 EXPECT_FALSE(scroller->horizontalScrollbar()); | |
| 327 EXPECT_TRUE(scroller->verticalScrollbar()); | |
| 328 | |
| 329 // Scroll layout viewport. | |
| 330 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200)); | |
| 331 EXPECT_SIZE_EQ(ScrollOffset(0, 200), scroller->scrollOffset()); | |
| 332 | |
| 333 webViewImpl()->setPageScaleFactor(2.0); | |
| 334 | |
| 335 // Pinch-zooming should add horizontal scrollbar. | |
| 336 EXPECT_TRUE(scroller->horizontalScrollbar()); | |
| 337 EXPECT_TRUE(scroller->verticalScrollbar()); | |
| 338 | |
| 339 // Scroll visual viewport. | |
| 340 VisualViewport& visualViewport = | |
| 341 frame()->page()->frameHost().visualViewport(); | |
| 342 visualViewport.setLocation(FloatPoint(100, 100)); | |
| 343 EXPECT_FLOAT_SIZE_EQ(FloatSize(100, 100), visualViewport.scrollOffset()); | |
| 344 | |
| 345 // Scrollbar offset should take visual viewport into account. | |
| 346 EXPECT_FLOAT_EQ(100, scroller->horizontalScrollbar()->currentPos()); | |
| 347 EXPECT_FLOAT_EQ(300, scroller->verticalScrollbar()->currentPos()); | |
| 348 } | |
| 349 | |
| 308 // Test that the VisualViewport works as expected in case of a scaled | 350 // Test that the VisualViewport works as expected in case of a scaled |
| 309 // and scrolled viewport - scroll down. | 351 // and scrolled viewport - scroll down. |
| 310 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { | 352 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { |
| 311 /* | 353 /* |
| 312 200 200 | 354 200 200 |
| 313 | | | | | 355 | | | | |
| 314 | | | | | 356 | | | | |
| 315 | | 800 | | 800 | 357 | | 800 | | 800 |
| 316 |-------------------| | | | 358 |-------------------| | | |
| 317 | | | | | 359 | | | | |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2111 webViewImpl()->resize(IntSize(600, 800)); | 2153 webViewImpl()->resize(IntSize(600, 800)); |
| 2112 | 2154 |
| 2113 EXPECT_SIZE_EQ(ScrollOffset(), | 2155 EXPECT_SIZE_EQ(ScrollOffset(), |
| 2114 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2156 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 2115 EXPECT_EQ(600, scroller->scrollTop()); | 2157 EXPECT_EQ(600, scroller->scrollTop()); |
| 2116 | 2158 |
| 2117 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); | 2159 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
| 2118 } | 2160 } |
| 2119 | 2161 |
| 2120 } // namespace | 2162 } // namespace |
| OLD | NEW |