Commit 5fdd948e authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Cleanup PaintLayerScrollableArea about paint invalidation

Some code was left when we separated paint invalidation and raster
invalidation. Some perhaps were caused by cleaning up for raster
invalidation and root-layer-scrolling at the same time.

Change-Id: I8d26291941f17f555c1e09ba0483d41c4c4bfe47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826994Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702146}
parent d28414d2
......@@ -89,7 +89,6 @@
#include "third_party/blink/renderer/core/page/scrolling/top_document_root_scroller_controller.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h"
#include "third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h"
#include "third_party/blink/renderer/core/paint/paint_invalidator.h"
#include "third_party/blink/renderer/core/paint/paint_layer_fragment.h"
#include "third_party/blink/renderer/core/scroll/scroll_alignment.h"
......@@ -2626,41 +2625,20 @@ void PaintLayerScrollableArea::WillRemoveScrollbar(
ScrollableArea::WillRemoveScrollbar(scrollbar, orientation);
}
static IntRect ScrollControlVisualRect(const IntRect& scroll_control_rect,
const LayoutBox& box,
const PaintInvalidatorContext& context,
const IntRect& previous_visual_rect) {
IntRect visual_rect(scroll_control_rect);
#if DCHECK_IS_ON()
FindVisualRectNeedingUpdateScope finder(box, context, previous_visual_rect,
visual_rect);
#endif
if (!context.NeedsVisualRectUpdate(box))
return previous_visual_rect;
// No need to apply any paint offset. Scroll controls paint in a different
// transform space than their contained box (the scrollbarPaintOffset
// transform node).
return visual_rect;
}
// Returns true if the scroll control is invalidated.
static bool InvalidatePaintOfScrollControlIfNeeded(
static bool ScrollControlNeedsPaintInvalidation(
const IntRect& new_visual_rect,
const IntRect& previous_visual_rect,
bool needs_paint_invalidation,
LayoutBox& box,
const LayoutBoxModelObject& paint_invalidation_container) {
bool should_invalidate_new_rect = needs_paint_invalidation;
if (new_visual_rect != previous_visual_rect) {
should_invalidate_new_rect = true;
} else if (previous_visual_rect.IsEmpty()) {
bool needs_paint_invalidation) {
if (new_visual_rect != previous_visual_rect)
return true;
if (previous_visual_rect.IsEmpty()) {
DCHECK(new_visual_rect.IsEmpty());
// Do not issue an empty invalidation.
should_invalidate_new_rect = false;
return false;
}
return should_invalidate_new_rect;
return needs_paint_invalidation;
}
static IntRect InvalidatePaintOfScrollbarIfNeeded(
......@@ -2675,22 +2653,14 @@ static IntRect InvalidatePaintOfScrollbarIfNeeded(
bool is_overlay = scrollbar && scrollbar->IsOverlayScrollbar();
IntRect new_visual_rect;
// Calculate visual rect of the scrollbar, except overlay composited
// scrollbars because we invalidate the graphics layer only.
if (scrollbar && !(graphics_layer && is_overlay)) {
new_visual_rect = ScrollControlVisualRect(scrollbar->FrameRect(), box,
context, previous_visual_rect);
}
if (scrollbar)
new_visual_rect = scrollbar->FrameRect();
if (needs_paint_invalidation && graphics_layer) {
// If the scrollbar needs paint invalidation but didn't change location/size
// or the scrollbar is an overlay scrollbar (visual rect is empty),
// invalidating the graphics layer is enough (which has been done in
// ScrollableArea::setScrollbarNeedsPaintInvalidation()).
// Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate
// the old and new location of the scrollbar on the box's paint invalidation
// container to ensure newly expanded/shrunk areas of the box to be
// invalidated.
needs_paint_invalidation = false;
DCHECK(!graphics_layer->PaintsContentOrHitTest() ||
graphics_layer->GetPaintController().GetPaintArtifact().IsEmpty());
......@@ -2698,12 +2668,10 @@ static IntRect InvalidatePaintOfScrollbarIfNeeded(
// Invalidate the box's display item client if the box's padding box size is
// affected by change of the non-overlay scrollbar width. We detect change of
// visual rect size instead of change of scrollbar width change, which may
// have some false-positives (e.g. the scrollbar changed length but not width)
// but won't invalidate more than expected because in the false-positive case
// the box must have changed size and have been invalidated.
const LayoutBoxModelObject& paint_invalidation_container =
*context.paint_invalidation_container;
// visual rect size instead of change of scrollbar width, which may have some
// false-positives (e.g. the scrollbar changed length but not width) but won't
// invalidate more than expected because in the false-positive case the box
// must have changed size and have been invalidated.
IntSize new_scrollbar_used_space_in_box;
if (!is_overlay)
new_scrollbar_used_space_in_box = new_visual_rect.Size();
......@@ -2723,13 +2691,11 @@ static IntRect InvalidatePaintOfScrollbarIfNeeded(
box_geometry_has_been_invalidated = true;
}
bool invalidated = InvalidatePaintOfScrollControlIfNeeded(
new_visual_rect, previous_visual_rect, needs_paint_invalidation, box,
paint_invalidation_container);
previously_was_overlay = is_overlay;
if (!invalidated || !scrollbar || graphics_layer)
if (!scrollbar || graphics_layer ||
!ScrollControlNeedsPaintInvalidation(
new_visual_rect, previous_visual_rect, needs_paint_invalidation))
return new_visual_rect;
context.painting_layer->SetNeedsRepaint();
......@@ -2760,16 +2726,11 @@ void PaintLayerScrollableArea::InvalidatePaintOfScrollControlsIfNeeded(
VerticalScrollbarNeedsPaintInvalidation(), box,
box_geometry_has_been_invalidated, context));
IntRect scroll_corner_and_resizer_visual_rect =
ScrollControlVisualRect(ScrollCornerAndResizerRect(), box, context,
scroll_corner_and_resizer_visual_rect_);
const LayoutBoxModelObject& paint_invalidation_container =
*context.paint_invalidation_container;
if (InvalidatePaintOfScrollControlIfNeeded(
IntRect scroll_corner_and_resizer_visual_rect = ScrollCornerAndResizerRect();
if (ScrollControlNeedsPaintInvalidation(
scroll_corner_and_resizer_visual_rect,
scroll_corner_and_resizer_visual_rect_,
ScrollCornerNeedsPaintInvalidation(), box,
paint_invalidation_container)) {
ScrollCornerNeedsPaintInvalidation())) {
SetScrollCornerAndResizerVisualRect(scroll_corner_and_resizer_visual_rect);
if (LayoutScrollbarPart* scroll_corner = ScrollCorner()) {
ObjectPaintInvalidator(*scroll_corner)
......
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