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

[root layer scrolls] Invalidate scrolling contents on size changes

This patch factors ViewPaintInvalidator into BoxPaintInvalidator
which reuses BoxPaintInvalidator's logic for invalidating the
scrolling contents layer. This fixes one root layer scrolling test.

Bug: 781419

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_root_layer_scrolls;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I62a84be195920a63e2db1207d4e329450eebeabf
Reviewed-on: https://chromium-review.googlesource.com/759738
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515969}
parent 6a4bf41e
...@@ -96,7 +96,6 @@ crbug.com/417782 paint/invalidation/resize-iframe-text.html [ Failure ] ...@@ -96,7 +96,6 @@ crbug.com/417782 paint/invalidation/resize-iframe-text.html [ Failure ]
crbug.com/417782 paint/invalidation/svg/absolute-sized-document-no-scrollbars.svg [ Failure ] crbug.com/417782 paint/invalidation/svg/absolute-sized-document-no-scrollbars.svg [ Failure ]
crbug.com/417782 paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ] crbug.com/417782 paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ]
crbug.com/417782 paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ] crbug.com/417782 paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ]
crbug.com/417782 paint/invalidation/viewport-gradient-background-html-resize.html [ Crash ]
crbug.com/417782 paint/invalidation/window-resize-background-image-fixed-centered-composited.html [ Failure ] crbug.com/417782 paint/invalidation/window-resize-background-image-fixed-centered-composited.html [ Failure ]
crbug.com/417782 paint/invalidation/window-resize-background-image-fixed-centered.html [ Failure ] crbug.com/417782 paint/invalidation/window-resize-background-image-fixed-centered.html [ Failure ]
crbug.com/417782 paint/invalidation/window-resize-background-image-generated.html [ Failure ] crbug.com/417782 paint/invalidation/window-resize-background-image-generated.html [ Failure ]
......
{
"layers": [
{
"name": "LayoutView #document",
"bounds": [800, 600],
"backgroundColor": "#FFFFFF"
},
{
"name": "Scrolling Layer",
"bounds": [800, 600],
"drawsContent": false
},
{
"name": "Scrolling Contents Layer",
"bounds": [800, 600],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF",
"paintInvalidations": [
{
"object": "LayoutView #document",
"rect": [0, 0, 800, 600],
"reason": "background on scrolling contents layer"
},
{
"object": "LayoutBlockFlow BODY",
"rect": [0, 0, 800, 200],
"reason": "geometry"
}
]
}
],
"objectPaintInvalidations": [
{
"object": "Scrolling Contents Layer",
"reason": "background on scrolling contents layer"
},
{
"object": "LayoutBlockFlow BODY",
"reason": "geometry"
}
]
}
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "core/page/ChromeClient.h" #include "core/page/ChromeClient.h"
#include "core/page/Page.h" #include "core/page/Page.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "core/paint/ViewPaintInvalidator.h"
#include "core/paint/ViewPainter.h" #include "core/paint/ViewPainter.h"
#include "core/paint/compositing/PaintLayerCompositor.h" #include "core/paint/compositing/PaintLayerCompositor.h"
#include "core/svg/SVGDocumentExtensions.h" #include "core/svg/SVGDocumentExtensions.h"
...@@ -450,11 +449,6 @@ void LayoutView::ComputeSelfHitTestRects(Vector<LayoutRect>& rects, ...@@ -450,11 +449,6 @@ void LayoutView::ComputeSelfHitTestRects(Vector<LayoutRect>& rects,
LayoutSize(GetFrameView()->ContentsSize()))); LayoutSize(GetFrameView()->ContentsSize())));
} }
PaintInvalidationReason LayoutView::InvalidatePaint(
const PaintInvalidatorContext& context) const {
return ViewPaintInvalidator(*this, context).InvalidatePaint();
}
void LayoutView::Paint(const PaintInfo& paint_info, void LayoutView::Paint(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) const { const LayoutPoint& paint_offset) const {
ViewPainter(*this).Paint(paint_info, paint_offset); ViewPainter(*this).Paint(paint_info, paint_offset);
......
...@@ -140,9 +140,6 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow { ...@@ -140,9 +140,6 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow {
void InvalidatePaintForViewAndCompositedLayers(); void InvalidatePaintForViewAndCompositedLayers();
PaintInvalidationReason InvalidatePaint(
const PaintInvalidatorContext&) const override;
void Paint(const PaintInfo&, const LayoutPoint&) const override; void Paint(const PaintInfo&, const LayoutPoint&) const override;
void PaintBoxDecorationBackground(const PaintInfo&, void PaintBoxDecorationBackground(const PaintInfo&,
const LayoutPoint&) const override; const LayoutPoint&) const override;
......
...@@ -218,8 +218,6 @@ blink_core_sources("paint") { ...@@ -218,8 +218,6 @@ blink_core_sources("paint") {
"TransformRecorder.h", "TransformRecorder.h",
"VideoPainter.cpp", "VideoPainter.cpp",
"VideoPainter.h", "VideoPainter.h",
"ViewPaintInvalidator.cpp",
"ViewPaintInvalidator.h",
"ViewPainter.cpp", "ViewPainter.cpp",
"ViewPainter.h", "ViewPainter.h",
"compositing/CompositedLayerMapping.cpp", "compositing/CompositedLayerMapping.cpp",
......
...@@ -159,7 +159,8 @@ PaintInvalidationReason BoxPaintInvalidator::ComputePaintInvalidationReason() { ...@@ -159,7 +159,8 @@ PaintInvalidationReason BoxPaintInvalidator::ComputePaintInvalidationReason() {
return PaintInvalidationReason::kIncremental; return PaintInvalidationReason::kIncremental;
} }
bool BoxPaintInvalidator::BackgroundGeometryDependsOnLayoutOverflowRect() { bool BoxPaintInvalidator::BackgroundGeometryDependsOnLayoutOverflowRect()
const {
return !box_.IsDocumentElement() && !box_.BackgroundStolenForBeingBody() && return !box_.IsDocumentElement() && !box_.BackgroundStolenForBeingBody() &&
box_.StyleRef() box_.StyleRef()
.BackgroundLayers() .BackgroundLayers()
...@@ -200,11 +201,49 @@ bool BoxPaintInvalidator::ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( ...@@ -200,11 +201,49 @@ bool BoxPaintInvalidator::ShouldFullyInvalidateBackgroundOnLayoutOverflowChange(
return false; return false;
} }
bool BoxPaintInvalidator::ViewBackgroundShouldFullyInvalidate() const {
DCHECK(box_.IsLayoutView());
// Fixed attachment background is handled in LayoutView::layout().
// TODO(wangxianzhu): Combine code for fixed-attachment background when we
// enable rootLayerScrolling permanently.
if (box_.StyleRef().HasEntirelyFixedBackground())
return false;
// 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 (document_element) {
const auto* document_background = document_element->GetLayoutObject();
if (document_background && document_background->IsBox()) {
// TODO(pdr): Change this to use layout overflow instead of size because
// the background size actually depends on the layout overflow.
LayoutSize old_size = ToLayoutBox(document_background)->PreviousSize();
LayoutSize new_size = ToLayoutBox(document_background)->Size();
const auto& layers = box_.StyleRef().BackgroundLayers();
if (old_size.Width() != new_size.Width() &&
LayoutBox::MustInvalidateFillLayersPaintOnWidthChange(layers)) {
return true;
}
if (old_size.Height() != new_size.Height() &&
LayoutBox::MustInvalidateFillLayersPaintOnHeightChange(layers)) {
return true;
}
}
}
}
return false;
}
BoxPaintInvalidator::BackgroundInvalidationType BoxPaintInvalidator::BackgroundInvalidationType
BoxPaintInvalidator::ComputeBackgroundInvalidation() { BoxPaintInvalidator::ComputeBackgroundInvalidation() {
if (box_.BackgroundChangedSinceLastPaintInvalidation()) if (box_.BackgroundChangedSinceLastPaintInvalidation())
return BackgroundInvalidationType::kFull; return BackgroundInvalidationType::kFull;
if (box_.IsLayoutView() && ViewBackgroundShouldFullyInvalidate())
return BackgroundInvalidationType::kFull;
bool layout_overflow_change_causes_invalidation = bool layout_overflow_change_causes_invalidation =
(BackgroundGeometryDependsOnLayoutOverflowRect() || (BackgroundGeometryDependsOnLayoutOverflowRect() ||
BackgroundPaintsOntoScrollingContentsLayer()); BackgroundPaintsOntoScrollingContentsLayer());
......
...@@ -30,11 +30,12 @@ class CORE_EXPORT BoxPaintInvalidator { ...@@ -30,11 +30,12 @@ class CORE_EXPORT BoxPaintInvalidator {
private: private:
friend class BoxPaintInvalidatorTest; friend class BoxPaintInvalidatorTest;
bool BackgroundGeometryDependsOnLayoutOverflowRect(); bool BackgroundGeometryDependsOnLayoutOverflowRect() const;
bool BackgroundPaintsOntoScrollingContentsLayer(); bool BackgroundPaintsOntoScrollingContentsLayer();
bool ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( bool ShouldFullyInvalidateBackgroundOnLayoutOverflowChange(
const LayoutRect& old_layout_overflow, const LayoutRect& old_layout_overflow,
const LayoutRect& new_layout_overflow); const LayoutRect& new_layout_overflow);
bool ViewBackgroundShouldFullyInvalidate() const;
enum BackgroundInvalidationType { kNone = 0, kIncremental, kFull }; enum BackgroundInvalidationType { kNone = 0, kIncremental, kFull };
BackgroundInvalidationType ComputeBackgroundInvalidation(); BackgroundInvalidationType ComputeBackgroundInvalidation();
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/paint/ViewPaintInvalidator.h"
#include "core/layout/LayoutView.h"
#include "core/paint/BoxPaintInvalidator.h"
#include "platform/geometry/LayoutSize.h"
namespace blink {
PaintInvalidationReason ViewPaintInvalidator::InvalidatePaint() {
InvalidateBackgroundIfNeeded();
return BoxPaintInvalidator(view_, context_).InvalidatePaint();
}
void ViewPaintInvalidator::InvalidateBackgroundIfNeeded() {
// Fixed attachment background is handled in LayoutView::layout().
// TODO(wangxianzhu): Combine code for fixed-attachment background when we
// enable rootLayerScrolling permanently.
if (view_.StyleRef().HasEntirelyFixedBackground())
return;
// LayoutView's non-fixed-attachment background is positioned in the
// document element.
// See https://drafts.csswg.org/css-backgrounds-3/#root-background.
Element* document_element = view_.GetDocument().documentElement();
if (!document_element)
return;
const LayoutObject* background_object = document_element->GetLayoutObject();
if (!background_object || !background_object->IsBox())
return;
const LayoutBox& background_box = ToLayoutBox(*background_object);
LayoutSize old_size = background_box.PreviousSize();
LayoutSize new_size = background_box.Size();
const auto& background_layers = view_.StyleRef().BackgroundLayers();
if ((old_size.Width() != new_size.Width() &&
LayoutBox::MustInvalidateFillLayersPaintOnWidthChange(
background_layers)) ||
(old_size.Height() != new_size.Height() &&
LayoutBox::MustInvalidateFillLayersPaintOnHeightChange(
background_layers))) {
view_.GetMutableForPainting().SetShouldDoFullPaintInvalidation(
PaintInvalidationReason::kBackground);
}
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ViewPaintInvalidator_h
#define ViewPaintInvalidator_h
#include "platform/graphics/PaintInvalidationReason.h"
#include "platform/wtf/Allocator.h"
namespace blink {
class LayoutView;
struct PaintInvalidatorContext;
class ViewPaintInvalidator {
STACK_ALLOCATED();
public:
ViewPaintInvalidator(const LayoutView& view,
const PaintInvalidatorContext& context)
: view_(view), context_(context) {}
PaintInvalidationReason InvalidatePaint();
private:
void InvalidateBackgroundIfNeeded();
const LayoutView& view_;
const PaintInvalidatorContext& context_;
};
} // namespace blink
#endif
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