Commit da1aa26f authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Ensure graphics layers are invalidated on resize

This patch ensures graphics layers are marked for incremental
invalidation when their size changes. This fixes a regression
from https://crrev.com/564140 where the scrolling contents layer
would not be invalidated when hiding browser controls.

Bug: 851881
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I88885fc389c8a32a19e7aac8a0ff74689ead55a0
Reviewed-on: https://chromium-review.googlesource.com/1103439
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568075}
parent 57b28df5
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h" #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h" #include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h" #include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
...@@ -64,6 +66,7 @@ class BrowserControlsTest : public testing::Test { ...@@ -64,6 +66,7 @@ class BrowserControlsTest : public testing::Test {
RegisterMockedHttpURLLoad("percent-height.html"); RegisterMockedHttpURLLoad("percent-height.html");
RegisterMockedHttpURLLoad("vh-height.html"); RegisterMockedHttpURLLoad("vh-height.html");
RegisterMockedHttpURLLoad("vh-height-width-800.html"); RegisterMockedHttpURLLoad("vh-height-width-800.html");
RegisterMockedHttpURLLoad("95-vh.html");
RegisterMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); RegisterMockedHttpURLLoad("vh-height-width-800-extra-wide.html");
} }
...@@ -1154,5 +1157,37 @@ TEST_F(BrowserControlsTest, MAYBE(GrowingHeightKeepsTopControlsHidden)) { ...@@ -1154,5 +1157,37 @@ TEST_F(BrowserControlsTest, MAYBE(GrowingHeightKeepsTopControlsHidden)) {
EXPECT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); EXPECT_EQ(0.f, web_view->GetBrowserControls().ContentOffset());
} }
TEST_F(BrowserControlsTest,
MAYBE(HidingBrowserControlsInvalidatesGraphicsLayer)) {
// Initialize with the browser controls showing.
WebViewImpl* web_view = Initialize("95-vh.html");
web_view->ResizeWithBrowserControls(WebSize(412, 604), 56.f, 0, true);
web_view->GetBrowserControls().SetShownRatio(1);
web_view->UpdateAllLifecyclePhases();
GetFrame()->GetDocument()->View()->SetTracksPaintInvalidations(true);
// Hide the browser controls.
VerticalScroll(-100.f);
web_view->ResizeWithBrowserControls(WebSize(412, 660), 56.f, 0, false);
web_view->UpdateAllLifecyclePhases();
// Ensure there is a raster invalidation of the bottom of the layer.
const auto& raster_invalidations = GetFrame()
->View()
->Layer()
->GetCompositedLayerMapping()
->ScrollingContentsLayer()
->GetRasterInvalidationTracking()
->Invalidations();
EXPECT_EQ(1u, raster_invalidations.size());
EXPECT_EQ(IntRect(0, 643, 412, 17), raster_invalidations[0].rect);
EXPECT_EQ(PaintInvalidationReason::kIncremental,
raster_invalidations[0].reason);
GetFrame()->GetDocument()->View()->SetTracksPaintInvalidations(false);
}
#undef MAYBE #undef MAYBE
} // namespace blink } // namespace blink
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<div style="background: linear-gradient(#e66465, #9198e5); height: 95vh; width: 10px;"></div>
...@@ -992,6 +992,8 @@ void GraphicsLayer::SetSize(const IntSize& size) { ...@@ -992,6 +992,8 @@ void GraphicsLayer::SetSize(const IntSize& size) {
size_ = clamped_size; size_ = clamped_size;
SetDisplayItemsUncached(PaintInvalidationReason::kIncremental);
layer_->SetBounds(static_cast<gfx::Size>(size_)); layer_->SetBounds(static_cast<gfx::Size>(size_));
// Note that we don't resize m_contentsLayer. It's up the caller to do that. // Note that we don't resize m_contentsLayer. It's up the caller to do that.
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment