Commit 8491747d authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Don't allow incremental LayoutView invalidation w/transform.

Bug: 1045421

Change-Id: Ic152bb2d1c88e34e3de012b4da9164ca1ff822ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079304
Auto-Submit: Chris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745483}
parent 3969a2c6
......@@ -250,18 +250,31 @@ BoxPaintInvalidator::ComputeViewBackgroundInvalidation() {
layout_view.BackgroundNeedsFullPaintInvalidation())
return BackgroundInvalidationType::kFull;
// LayoutView's non-fixed-attachment background is positioned in the
// document element and needs to invalidate if the size changes.
// See: https://drafts.csswg.org/css-backgrounds-3/#root-background.
if (BackgroundGeometryDependsOnLayoutOverflowRect()) {
Element* document_element = box_.GetDocument().documentElement();
if (Element* document_element = box_.GetDocument().documentElement()) {
if (document_element) {
const auto* document_background = document_element->GetLayoutObject();
if (document_background && document_background->IsBox()) {
const auto* document_background_box = ToLayoutBox(document_background);
if (ShouldFullyInvalidateBackgroundOnLayoutOverflowChange(
document_background_box->PreviousPhysicalLayoutOverflowRect(),
document_background_box->PhysicalLayoutOverflowRect())) {
if (const auto* document_element_object =
document_element->GetLayoutObject()) {
// LayoutView's non-fixed-attachment background is positioned in the
// document element and needs to invalidate if the size changes.
// See: https://drafts.csswg.org/css-backgrounds-3/#root-background.
if (BackgroundGeometryDependsOnLayoutOverflowRect()) {
if (document_element_object->IsBox()) {
const auto* document_background_box =
ToLayoutBox(document_element_object);
if (ShouldFullyInvalidateBackgroundOnLayoutOverflowChange(
document_background_box
->PreviousPhysicalLayoutOverflowRect(),
document_background_box->PhysicalLayoutOverflowRect())) {
return BackgroundInvalidationType::kFull;
}
}
}
// The document background paints with a transform but nevertheless
// extended onto an infinite canvas. In cases where it has a transform
// we cna't apply incremental invalidation, because the visual rect is
// no longer axis-aligned to the LayoutView.
if (document_element_object->StyleRef().HasTransform()) {
return BackgroundInvalidationType::kFull;
}
}
......
......@@ -440,6 +440,31 @@ TEST_P(PaintAndRasterInvalidationTest, NonCompositedLayoutViewResize) {
GetDocument().View()->SetTracksRasterInvalidations(false);
}
TEST_P(PaintAndRasterInvalidationTest, FullInvalidationWithHTMLTransform) {
GetDocument().documentElement()->setAttribute(html_names::kStyleAttr,
"transform: scale(0.5)");
const DisplayItemClient* client =
&GetDocument()
.View()
->GetLayoutView()
->GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient();
UpdateAllLifecyclePhasesForTest();
GetDocument().View()->SetTracksRasterInvalidations(true);
GetDocument().View()->Resize(WebSize(500, 500));
UpdateAllLifecyclePhasesForTest();
EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(),
UnorderedElementsAre(
RasterInvalidationInfo{client, client->DebugName(),
IntRect(0, 0, 500, 500),
PaintInvalidationReason::kBackground},
RasterInvalidationInfo{
client, client->DebugName(), IntRect(0, 0, 500, 500),
PaintInvalidationReason::kPaintProperty}));
}
TEST_P(PaintAndRasterInvalidationTest, NonCompositedLayoutViewGradientResize) {
SetBodyInnerHTML(R"HTML(
<style>
......
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