Commit 41e0bf69 authored by Daniel Libby's avatar Daniel Libby Committed by Commit Bot

Remove non-compositing descendant DisplayItemClient invalidation

This is currently only used for scrollbar parts, which do not have
descendant layers. Instead just set needs paint on the painting layer
and invalidate the DisplayItemClient (the same LayoutObject the
ObjectPaintInvalidator is initialized with) via
SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient.

There was not any unit test coverage for
InvalidatePaintIncludingNonCompositingDescendants which uses the same
traversal algorithm, so convert tests of the deleted method to use this
one instead, and validate only the paint invalidation side-effects.

Bug: 1007989

Change-Id: Ic9849f889958300941bc9a48d97cf7f04a91c786
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247157Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#779554}
parent 21fb68f9
...@@ -407,8 +407,8 @@ void CustomScrollbar::PositionScrollbarParts() { ...@@ -407,8 +407,8 @@ void CustomScrollbar::PositionScrollbarParts() {
void CustomScrollbar::InvalidateDisplayItemClientsOfScrollbarParts() { void CustomScrollbar::InvalidateDisplayItemClientsOfScrollbarParts() {
for (auto& part : parts_) { for (auto& part : parts_) {
ObjectPaintInvalidator(*part.value) ObjectPaintInvalidator(*part.value)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
PaintInvalidationReason::kScrollControl); *part.value, PaintInvalidationReason::kScrollControl);
} }
} }
......
...@@ -134,21 +134,6 @@ static void SetPaintingLayerNeedsRepaintDuringTraverse( ...@@ -134,21 +134,6 @@ static void SetPaintingLayerNeedsRepaintDuringTraverse(
} }
} }
void ObjectPaintInvalidator::
InvalidateDisplayItemClientsIncludingNonCompositingDescendants(
PaintInvalidationReason reason) {
// This is valid because we want to invalidate the client in the display item
// list of the current backing.
DisableCompositingQueryAsserts disabler;
SlowSetPaintingLayerNeedsRepaint();
TraverseNonCompositingDescendantsInPaintOrder(
object_, [reason](const LayoutObject& object) {
SetPaintingLayerNeedsRepaintDuringTraverse(object);
object.InvalidateDisplayItemClients(reason);
});
}
void ObjectPaintInvalidator:: void ObjectPaintInvalidator::
InvalidatePaintIncludingNonCompositingDescendants() { InvalidatePaintIncludingNonCompositingDescendants() {
DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled());
......
...@@ -36,9 +36,6 @@ class CORE_EXPORT ObjectPaintInvalidator { ...@@ -36,9 +36,6 @@ class CORE_EXPORT ObjectPaintInvalidator {
InvalidateDisplayItemClient(client, reason); InvalidateDisplayItemClient(client, reason);
} }
void InvalidateDisplayItemClientsIncludingNonCompositingDescendants(
PaintInvalidationReason);
// The caller should ensure the painting layer has been SetNeedsRepaint // The caller should ensure the painting layer has been SetNeedsRepaint
// before calling this function. // before calling this function.
void InvalidateDisplayItemClient(const DisplayItemClient& client, void InvalidateDisplayItemClient(const DisplayItemClient& client,
......
...@@ -34,8 +34,7 @@ class ObjectPaintInvalidatorTest : public RenderingTest { ...@@ -34,8 +34,7 @@ class ObjectPaintInvalidatorTest : public RenderingTest {
using ::testing::ElementsAre; using ::testing::ElementsAre;
TEST_F(ObjectPaintInvalidatorTest, TEST_F(ObjectPaintInvalidatorTest, TraverseNonCompositingDescendants) {
TraverseNonCompositingDescendantsInPaintOrder) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return; return;
...@@ -65,58 +64,51 @@ TEST_F(ObjectPaintInvalidatorTest, ...@@ -65,58 +64,51 @@ TEST_F(ObjectPaintInvalidatorTest,
)HTML"); )HTML");
auto* container = GetLayoutObjectByElementId("container"); auto* container = GetLayoutObjectByElementId("container");
auto* normal_child = GetLayoutObjectByElementId("normal-child"); auto* container_layer = ToLayoutBoxModelObject(container)->Layer();
auto* stacked_child = GetLayoutObjectByElementId("stacked-child"); auto* stacked_child = GetLayoutObjectByElementId("stacked-child");
auto* stacked_child_layer = ToLayoutBoxModelObject(stacked_child)->Layer();
auto* composited_stacking_context = auto* composited_stacking_context =
GetLayoutObjectByElementId("composited-stacking-context"); GetLayoutObjectByElementId("composited-stacking-context");
auto* normal_child_of_composited_stacking_context = auto* composited_stacking_context_layer =
GetLayoutObjectByElementId("normal-child-of-composited-stacking-context"); ToLayoutBoxModelObject(composited_stacking_context)->Layer();
auto* stacked_child_of_composited_stacking_context = auto* stacked_child_of_composited_stacking_context =
GetLayoutObjectByElementId( GetLayoutObjectByElementId(
"stacked-child-of-composited-stacking-context"); "stacked-child-of-composited-stacking-context");
auto* stacked_child_of_composited_stacking_context_layer =
ToLayoutBoxModelObject(stacked_child_of_composited_stacking_context)
->Layer();
auto* composited_non_stacking_context = auto* composited_non_stacking_context =
GetLayoutObjectByElementId("composited-non-stacking-context"); GetLayoutObjectByElementId("composited-non-stacking-context");
auto* normal_child_of_composited_non_stacking_context = auto* composited_non_stacking_context_layer =
GetLayoutObjectByElementId( ToLayoutBoxModelObject(composited_non_stacking_context)->Layer();
"normal-child-of-composited-non-stacking-context");
auto* stacked_child_of_composited_non_stacking_context = auto* stacked_child_of_composited_non_stacking_context =
GetLayoutObjectByElementId( GetLayoutObjectByElementId(
"stacked-child-of-composited-non-stacking-context"); "stacked-child-of-composited-non-stacking-context");
auto* stacked_child_of_composited_non_stacking_context_layer =
ToLayoutBoxModelObject(stacked_child_of_composited_non_stacking_context)
->Layer();
auto* non_stacked_layered_child_of_composited_non_stacking_context = auto* non_stacked_layered_child_of_composited_non_stacking_context =
GetLayoutObjectByElementId( GetLayoutObjectByElementId(
"non-stacked-layered-child-of-composited-non-stacking-context"); "non-stacked-layered-child-of-composited-non-stacking-context");
auto* non_stacked_layered_child_of_composited_non_stacking_context_layer =
ValidateDisplayItemClient(container); ToLayoutBoxModelObject(
ValidateDisplayItemClient(normal_child); non_stacked_layered_child_of_composited_non_stacking_context)
ValidateDisplayItemClient(stacked_child); ->Layer();
ValidateDisplayItemClient(composited_stacking_context);
ValidateDisplayItemClient(normal_child_of_composited_stacking_context);
ValidateDisplayItemClient(stacked_child_of_composited_stacking_context);
ValidateDisplayItemClient(composited_non_stacking_context);
ValidateDisplayItemClient(normal_child_of_composited_non_stacking_context);
ValidateDisplayItemClient(stacked_child_of_composited_non_stacking_context);
ValidateDisplayItemClient(
non_stacked_layered_child_of_composited_non_stacking_context);
ObjectPaintInvalidator(*container) ObjectPaintInvalidator(*container)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .InvalidatePaintIncludingNonCompositingDescendants();
PaintInvalidationReason::kSubtree);
EXPECT_TRUE(container_layer->SelfNeedsRepaint());
EXPECT_FALSE(IsValidDisplayItemClient(container)); EXPECT_TRUE(stacked_child_layer->SelfNeedsRepaint());
EXPECT_FALSE(IsValidDisplayItemClient(normal_child)); EXPECT_FALSE(composited_stacking_context_layer->SelfNeedsRepaint());
EXPECT_FALSE(IsValidDisplayItemClient(stacked_child)); EXPECT_FALSE(
EXPECT_TRUE(IsValidDisplayItemClient(composited_stacking_context)); stacked_child_of_composited_stacking_context_layer->SelfNeedsRepaint());
EXPECT_TRUE( EXPECT_FALSE(composited_non_stacking_context_layer->SelfNeedsRepaint());
IsValidDisplayItemClient(normal_child_of_composited_stacking_context)); EXPECT_TRUE(stacked_child_of_composited_non_stacking_context_layer
EXPECT_TRUE( ->SelfNeedsRepaint());
IsValidDisplayItemClient(stacked_child_of_composited_stacking_context)); EXPECT_FALSE(
EXPECT_TRUE(IsValidDisplayItemClient(composited_non_stacking_context)); non_stacked_layered_child_of_composited_non_stacking_context_layer
EXPECT_TRUE(IsValidDisplayItemClient( ->SelfNeedsRepaint());
normal_child_of_composited_non_stacking_context));
EXPECT_FALSE(IsValidDisplayItemClient(
stacked_child_of_composited_non_stacking_context));
EXPECT_TRUE(IsValidDisplayItemClient(
non_stacked_layered_child_of_composited_non_stacking_context));
} }
TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
...@@ -146,7 +138,6 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { ...@@ -146,7 +138,6 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
ToLayoutBoxModelObject(composited_container)->Layer(); ToLayoutBoxModelObject(composited_container)->Layer();
auto* span = GetLayoutObjectByElementId("span"); auto* span = GetLayoutObjectByElementId("span");
auto* span_layer = ToLayoutBoxModelObject(span)->Layer(); auto* span_layer = ToLayoutBoxModelObject(span)->Layer();
auto* text = span->SlowFirstChild();
EXPECT_TRUE(span->IsPaintInvalidationContainer()); EXPECT_TRUE(span->IsPaintInvalidationContainer());
EXPECT_TRUE(span->IsStackingContext()); EXPECT_TRUE(span->IsStackingContext());
...@@ -158,25 +149,11 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { ...@@ -158,25 +149,11 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
EXPECT_EQ(containing_block_layer, target->PaintingLayer()); EXPECT_EQ(containing_block_layer, target->PaintingLayer());
} }
ValidateDisplayItemClient(target);
ValidateDisplayItemClient(containing_block);
ValidateDisplayItemClient(composited_container);
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
NGInlineCursor fragments;
for (fragments.MoveTo(*span); fragments;
fragments.MoveToNextForSameLayoutObject())
ValidateDisplayItemClient(fragments.Current().GetDisplayItemClient());
} else {
ValidateDisplayItemClient(span);
ValidateDisplayItemClient(text);
}
// Traversing from target should mark needsRepaint on correct layers. // Traversing from target should mark needsRepaint on correct layers.
EXPECT_FALSE(containing_block_layer->SelfNeedsRepaint()); EXPECT_FALSE(containing_block_layer->SelfNeedsRepaint());
EXPECT_FALSE(composited_container_layer->DescendantNeedsRepaint()); EXPECT_FALSE(composited_container_layer->DescendantNeedsRepaint());
ObjectPaintInvalidator(*target) ObjectPaintInvalidator(*target)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .InvalidatePaintIncludingNonCompositingDescendants();
PaintInvalidationReason::kSubtree);
if (RuntimeEnabledFeatures::LayoutNGEnabled()) { if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint());
EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint());
...@@ -188,32 +165,15 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { ...@@ -188,32 +165,15 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
EXPECT_TRUE(composited_container_layer->DescendantNeedsRepaint()); EXPECT_TRUE(composited_container_layer->DescendantNeedsRepaint());
EXPECT_FALSE(span_layer->SelfNeedsRepaint()); EXPECT_FALSE(span_layer->SelfNeedsRepaint());
} }
EXPECT_FALSE(IsValidDisplayItemClient(target));
ValidateDisplayItemClient(target);
EXPECT_TRUE(IsValidDisplayItemClient(containing_block));
EXPECT_TRUE(IsValidDisplayItemClient(composited_container));
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
NGInlineCursor fragments;
for (fragments.MoveTo(*span); fragments;
fragments.MoveToNextForSameLayoutObject()) {
EXPECT_TRUE(
IsValidDisplayItemClient(fragments.Current().GetDisplayItemClient()));
}
} else {
EXPECT_TRUE(IsValidDisplayItemClient(span));
EXPECT_TRUE(IsValidDisplayItemClient(text));
}
composited_container_layer->ClearNeedsRepaintRecursively(); composited_container_layer->ClearNeedsRepaintRecursively();
// Traversing from span should mark needsRepaint on correct layers for target. // Traversing from span should mark needsRepaint on correct layers for target.
ValidateDisplayItemClient(target);
EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint());
EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint());
EXPECT_FALSE(span_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(span_layer->SelfOrDescendantNeedsRepaint());
ObjectPaintInvalidator(*span) ObjectPaintInvalidator(*span)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .InvalidatePaintIncludingNonCompositingDescendants();
PaintInvalidationReason::kSubtree);
if (RuntimeEnabledFeatures::LayoutNGEnabled()) { if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(containing_block_layer->SelfOrDescendantNeedsRepaint());
EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint());
...@@ -225,25 +185,6 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { ...@@ -225,25 +185,6 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
} }
EXPECT_TRUE(span_layer->SelfNeedsRepaint()); EXPECT_TRUE(span_layer->SelfNeedsRepaint());
EXPECT_FALSE(IsValidDisplayItemClient(target));
ValidateDisplayItemClient(target);
EXPECT_TRUE(IsValidDisplayItemClient(containing_block));
EXPECT_TRUE(IsValidDisplayItemClient(composited_container));
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
NGInlineCursor fragments;
for (fragments.MoveTo(*span); fragments;
fragments.MoveToNextForSameLayoutObject()) {
EXPECT_FALSE(
IsValidDisplayItemClient(fragments.Current().GetDisplayItemClient()));
ValidateDisplayItemClient(fragments.Current().GetDisplayItemClient());
}
} else {
EXPECT_FALSE(IsValidDisplayItemClient(span));
ValidateDisplayItemClient(span);
EXPECT_FALSE(IsValidDisplayItemClient(text));
ValidateDisplayItemClient(text);
}
composited_container_layer->ClearNeedsRepaintRecursively(); composited_container_layer->ClearNeedsRepaintRecursively();
// Traversing from compositedContainer should not reach target. // Traversing from compositedContainer should not reach target.
...@@ -251,29 +192,10 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) { ...@@ -251,29 +192,10 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(composited_container_layer->SelfOrDescendantNeedsRepaint());
EXPECT_FALSE(span_layer->SelfOrDescendantNeedsRepaint()); EXPECT_FALSE(span_layer->SelfOrDescendantNeedsRepaint());
ObjectPaintInvalidator(*composited_container) ObjectPaintInvalidator(*composited_container)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .InvalidatePaintIncludingNonCompositingDescendants();
PaintInvalidationReason::kSubtree);
EXPECT_TRUE(containing_block_layer->SelfNeedsRepaint()); EXPECT_TRUE(containing_block_layer->SelfNeedsRepaint());
EXPECT_TRUE(composited_container_layer->DescendantNeedsRepaint()); EXPECT_TRUE(composited_container_layer->DescendantNeedsRepaint());
EXPECT_FALSE(span_layer->SelfNeedsRepaint()); EXPECT_FALSE(span_layer->SelfNeedsRepaint());
if (RuntimeEnabledFeatures::LayoutNGEnabled())
EXPECT_TRUE(IsValidDisplayItemClient(target));
else
EXPECT_FALSE(IsValidDisplayItemClient(target));
EXPECT_FALSE(IsValidDisplayItemClient(containing_block));
EXPECT_FALSE(IsValidDisplayItemClient(composited_container));
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
NGInlineCursor fragments;
for (fragments.MoveTo(*span); fragments;
fragments.MoveToNextForSameLayoutObject()) {
EXPECT_TRUE(
IsValidDisplayItemClient(fragments.Current().GetDisplayItemClient()));
}
} else {
EXPECT_TRUE(IsValidDisplayItemClient(span));
EXPECT_TRUE(IsValidDisplayItemClient(text));
}
} }
TEST_F(ObjectPaintInvalidatorTest, TraverseStackedFloatUnderCompositedInline) { TEST_F(ObjectPaintInvalidatorTest, TraverseStackedFloatUnderCompositedInline) {
...@@ -311,22 +233,8 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseStackedFloatUnderCompositedInline) { ...@@ -311,22 +233,8 @@ TEST_F(ObjectPaintInvalidatorTest, TraverseStackedFloatUnderCompositedInline) {
// Traversing from span should reach target. // Traversing from span should reach target.
EXPECT_FALSE(span_layer->SelfNeedsRepaint()); EXPECT_FALSE(span_layer->SelfNeedsRepaint());
ObjectPaintInvalidator(*span) ObjectPaintInvalidator(*span)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .InvalidatePaintIncludingNonCompositingDescendants();
PaintInvalidationReason::kSubtree);
EXPECT_TRUE(span_layer->SelfNeedsRepaint()); EXPECT_TRUE(span_layer->SelfNeedsRepaint());
EXPECT_FALSE(IsValidDisplayItemClient(target));
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
NGInlineCursor fragments;
for (fragments.MoveTo(*span); fragments;
fragments.MoveToNextForSameLayoutObject()) {
EXPECT_FALSE(
IsValidDisplayItemClient(fragments.Current().GetDisplayItemClient()));
}
} else {
EXPECT_FALSE(IsValidDisplayItemClient(span));
EXPECT_FALSE(IsValidDisplayItemClient(text));
}
} }
TEST_F(ObjectPaintInvalidatorTest, InvalidatePaintRectangle) { TEST_F(ObjectPaintInvalidatorTest, InvalidatePaintRectangle) {
......
...@@ -3024,13 +3024,13 @@ void PaintLayerScrollableArea::InvalidatePaintOfScrollControlsIfNeeded( ...@@ -3024,13 +3024,13 @@ void PaintLayerScrollableArea::InvalidatePaintOfScrollControlsIfNeeded(
SetScrollCornerAndResizerVisualRect(scroll_corner_and_resizer_visual_rect); SetScrollCornerAndResizerVisualRect(scroll_corner_and_resizer_visual_rect);
if (LayoutCustomScrollbarPart* scroll_corner = ScrollCorner()) { if (LayoutCustomScrollbarPart* scroll_corner = ScrollCorner()) {
ObjectPaintInvalidator(*scroll_corner) ObjectPaintInvalidator(*scroll_corner)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
PaintInvalidationReason::kScrollControl); *scroll_corner, PaintInvalidationReason::kScrollControl);
} }
if (LayoutCustomScrollbarPart* resizer = Resizer()) { if (LayoutCustomScrollbarPart* resizer = Resizer()) {
ObjectPaintInvalidator(*resizer) ObjectPaintInvalidator(*resizer)
.InvalidateDisplayItemClientsIncludingNonCompositingDescendants( .SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
PaintInvalidationReason::kScrollControl); *resizer, PaintInvalidationReason::kScrollControl);
} }
if (!GraphicsLayerForScrollCorner()) { if (!GraphicsLayerForScrollCorner()) {
context.painting_layer->SetNeedsRepaint(); context.painting_layer->SetNeedsRepaint();
......
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