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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 expectedLocation, | 300 expectedLocation, |
| 301 frameView.getScrollableArea()->visibleContentRect().location()); | 301 frameView.getScrollableArea()->visibleContentRect().location()); |
| 302 | 302 |
| 303 webViewImpl()->resize(IntSize(800, 600)); | 303 webViewImpl()->resize(IntSize(800, 600)); |
| 304 | 304 |
| 305 EXPECT_POINT_EQ( | 305 EXPECT_POINT_EQ( |
| 306 expectedLocation, | 306 expectedLocation, |
| 307 frameView.getScrollableArea()->visibleContentRect().location()); | 307 frameView.getScrollableArea()->visibleContentRect().location()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 // Test the main frame scrollbars take visual viewport into account. | |
| 311 TEST_P(VisualViewportTest, VerifyScrollbarBehavior) { | |
| 312 // TODO(ymalik): With root layer scrolling enabled, the scroller returned | |
|
skobes
2016/11/09 23:18:25
If the test doesn't work with RLS, it shouldn't be
bokan
2016/11/10 15:16:57
I asked for this. The test should eventually work
ymalik
2016/11/10 17:58:04
I agree with this. It will increase the chances th
| |
| 313 // by FrameView is PaintLayerScrollableArea. PLSA doesn't know about the | |
| 314 // visual viewport and thus, scrollbars aren't added when we zoom in. | |
| 315 bool rootLayerScrolls = RuntimeEnabledFeatures::rootLayerScrollingEnabled(); | |
| 316 | |
| 317 initializeWithDesktopSettings(); | |
| 318 | |
| 319 registerMockedHttpURLLoad("200-by-800-viewport.html"); | |
| 320 navigateTo(m_baseURL + "200-by-800-viewport.html"); | |
| 321 | |
| 322 webViewImpl()->resize(IntSize(300, 200)); | |
| 323 | |
| 324 ScrollableArea* scroller = frame()->view()->getScrollableArea(); | |
| 325 | |
| 326 // Initially, there is no horizontal scrollbar since the content fits. | |
| 327 EXPECT_FALSE(scroller->horizontalScrollbar()); | |
| 328 EXPECT_TRUE(scroller->verticalScrollbar()); | |
| 329 | |
| 330 // Scroll layout viewport. | |
| 331 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200)); | |
| 332 EXPECT_SIZE_EQ(ScrollOffset(0, 200), scroller->scrollOffset()); | |
| 333 | |
| 334 webViewImpl()->setPageScaleFactor(2.0); | |
| 335 | |
| 336 // Pinch-zooming should add horizontal scrollbar. | |
| 337 if (!rootLayerScrolls) | |
| 338 EXPECT_TRUE(scroller->horizontalScrollbar()); | |
| 339 else | |
| 340 EXPECT_FALSE(scroller->horizontalScrollbar()); | |
| 341 EXPECT_TRUE(scroller->verticalScrollbar()); | |
| 342 | |
| 343 // Scroll visual viewport. | |
| 344 VisualViewport& visualViewport = | |
| 345 frame()->page()->frameHost().visualViewport(); | |
| 346 visualViewport.setLocation(FloatPoint(100, 100)); | |
| 347 EXPECT_FLOAT_SIZE_EQ(FloatSize(100, 100), visualViewport.scrollOffset()); | |
| 348 | |
| 349 // Scrollbar offset should take visual viewport into account. | |
| 350 if (!rootLayerScrolls) { | |
| 351 EXPECT_FLOAT_EQ(100, scroller->horizontalScrollbar()->currentPos()); | |
| 352 EXPECT_FLOAT_EQ(300, scroller->verticalScrollbar()->currentPos()); | |
| 353 } else { | |
| 354 EXPECT_FLOAT_EQ(200, scroller->verticalScrollbar()->currentPos()); | |
| 355 } | |
| 356 } | |
| 357 | |
| 310 // Test that the VisualViewport works as expected in case of a scaled | 358 // Test that the VisualViewport works as expected in case of a scaled |
| 311 // and scrolled viewport - scroll down. | 359 // and scrolled viewport - scroll down. |
| 312 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { | 360 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { |
| 313 /* | 361 /* |
| 314 200 200 | 362 200 200 |
| 315 | | | | | 363 | | | | |
| 316 | | | | | 364 | | | | |
| 317 | | 800 | | 800 | 365 | | 800 | | 800 |
| 318 |-------------------| | | | 366 |-------------------| | | |
| 319 | | | | | 367 | | | | |
| (...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2397 if (rootLayerScrolling) | 2445 if (rootLayerScrolling) |
| 2398 EXPECT_TRUE(invalidationTracking); | 2446 EXPECT_TRUE(invalidationTracking); |
| 2399 else | 2447 else |
| 2400 EXPECT_FALSE(invalidationTracking); | 2448 EXPECT_FALSE(invalidationTracking); |
| 2401 | 2449 |
| 2402 document->view()->setTracksPaintInvalidations(false); | 2450 document->view()->setTracksPaintInvalidations(false); |
| 2403 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2451 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
| 2404 } | 2452 } |
| 2405 | 2453 |
| 2406 } // namespace | 2454 } // namespace |
| OLD | NEW |