| 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 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 bool rootLayerScrolling = GetParam(); | 2392 bool rootLayerScrolling = GetParam(); |
| 2393 if (rootLayerScrolling) | 2393 if (rootLayerScrolling) |
| 2394 EXPECT_TRUE(invalidationTracking); | 2394 EXPECT_TRUE(invalidationTracking); |
| 2395 else | 2395 else |
| 2396 EXPECT_FALSE(invalidationTracking); | 2396 EXPECT_FALSE(invalidationTracking); |
| 2397 | 2397 |
| 2398 document->view()->setTracksPaintInvalidations(false); | 2398 document->view()->setTracksPaintInvalidations(false); |
| 2399 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2399 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
| 2400 } | 2400 } |
| 2401 | 2401 |
| 2402 TEST_P(VisualViewportTest, InvalidateLayoutViewWhenDocumentSmallerThanView) { |
| 2403 bool originalInertTopControls = |
| 2404 RuntimeEnabledFeatures::inertTopControlsEnabled(); |
| 2405 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 2406 |
| 2407 std::unique_ptr<FrameTestHelpers::TestWebViewClient> |
| 2408 fakeCompositingWebViewClient = |
| 2409 WTF::makeUnique<FrameTestHelpers::TestWebViewClient>(); |
| 2410 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2411 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 2412 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, |
| 2413 &configureAndroidCompositing); |
| 2414 |
| 2415 int pageWidth = 320; |
| 2416 int pageHeight = 590; |
| 2417 float browserControlsHeight = 50.0f; |
| 2418 int largestHeight = pageHeight + browserControlsHeight; |
| 2419 |
| 2420 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), |
| 2421 browserControlsHeight, true); |
| 2422 |
| 2423 FrameTestHelpers::loadFrame(webViewImpl->mainFrame(), "about:blank"); |
| 2424 webViewImpl->updateAllLifecyclePhases(); |
| 2425 |
| 2426 Document* document = |
| 2427 toLocalFrame(webViewImpl->page()->mainFrame())->document(); |
| 2428 |
| 2429 // Do a resize to check for invalidations. |
| 2430 document->view()->setTracksPaintInvalidations(true); |
| 2431 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, largestHeight), |
| 2432 browserControlsHeight, false); |
| 2433 |
| 2434 // The layout size should not have changed. |
| 2435 ASSERT_EQ(pageWidth, document->view()->layoutSize().width()); |
| 2436 ASSERT_EQ(pageHeight, document->view()->layoutSize().height()); |
| 2437 |
| 2438 // The entire viewport should have been invalidated. |
| 2439 { |
| 2440 const RasterInvalidationTracking* invalidationTracking = |
| 2441 document->layoutView() |
| 2442 ->layer() |
| 2443 ->graphicsLayerBacking() |
| 2444 ->getRasterInvalidationTracking(); |
| 2445 ASSERT_TRUE(invalidationTracking); |
| 2446 const auto* rasterInvalidations = |
| 2447 &invalidationTracking->trackedRasterInvalidations; |
| 2448 ASSERT_EQ(1u, rasterInvalidations->size()); |
| 2449 EXPECT_EQ(IntRect(0, 0, pageWidth, largestHeight), |
| 2450 (*rasterInvalidations)[0].rect); |
| 2451 } |
| 2452 |
| 2453 document->view()->setTracksPaintInvalidations(false); |
| 2454 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
| 2455 } |
| 2456 |
| 2402 } // namespace | 2457 } // namespace |
| OLD | NEW |