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

Remove dummy layers from CompositedLayerMapping

We no longer need scrolling_layer_ after BGPT launched.

For squashing_containment_layer_, we can remove it by ensuring
squashing_layer_ is always the last child of graphics_layer_.

There is still one dummy layer: overflow_controls_host_layer_ which
is needed for convenience of reparenting overflow control layers.

Change-Id: Ibdafef32d918e66a12c35d2a5726c50ea374f7a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2205518
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769984}
parent deaf77f7
......@@ -681,7 +681,6 @@ TEST_F(RootScrollerTest, AlwaysCreateCompositedScrollingLayers) {
ASSERT_TRUE(layer->HasCompositedLayerMapping());
EXPECT_TRUE(layer->GetCompositedLayerMapping()->ScrollingContentsLayer());
EXPECT_TRUE(layer->GetCompositedLayerMapping()->ScrollingLayer());
SetAndSelectRootScroller(*MainFrame()->GetDocument(), nullptr);
......
......@@ -106,7 +106,9 @@ void BoxPainter::PaintBoxDecorationBackground(
// composited in PaintArtifactCompositor::UpdateNonFastScrollableRegions.
if (layout_box_.HasLayer() &&
layout_box_.Layer()->GetCompositedLayerMapping() &&
layout_box_.Layer()->GetCompositedLayerMapping()->HasScrollingLayer()) {
layout_box_.Layer()
->GetCompositedLayerMapping()
->ScrollingContentsLayer()) {
needs_scroll_hit_test = false;
}
}
......
......@@ -113,8 +113,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
return decoration_outline_layer_.get();
}
bool HasScrollingLayer() const { return scrolling_layer_.get(); }
GraphicsLayer* ScrollingLayer() const { return scrolling_layer_.get(); }
GraphicsLayer* ScrollingContentsLayer() const {
return scrolling_contents_layer_.get();
}
......@@ -122,19 +120,14 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
GraphicsLayer* MaskLayer() const { return mask_layer_.get(); }
GraphicsLayer* ParentForSublayers() const;
GraphicsLayer* ChildForSuperlayers() const;
void SetSublayers(const GraphicsLayerVector&);
GraphicsLayer* SquashingContainmentLayer() const {
return squashing_containment_layer_.get();
}
GraphicsLayer* SquashingLayer() const { return squashing_layer_.get(); }
const IntSize& SquashingLayerOffsetFromLayoutObject() const {
return squashing_layer_offset_from_layout_object_;
}
void SetSquashingContentsNeedDisplay();
void SetContentsNeedDisplay();
void SetAllLayersNeedDisplay();
// Let all DrawsContent GraphicsLayers check raster invalidations after
// a no-change paint.
......@@ -207,9 +200,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// position.
GraphicsLayer* DetachLayerForOverflowControls();
// We may similarly need to reattach the layer for outlines and decorations.
GraphicsLayer* DetachLayerForDecorationOutline();
void SetBlendMode(BlendMode);
bool NeedsGraphicsLayerUpdate() {
......@@ -314,7 +304,7 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
void UpdateForegroundLayerGeometry();
void UpdateDecorationOutlineLayerGeometry(
const IntSize& relative_compositing_bounds_size);
void UpdateScrollingLayerGeometry();
void UpdateScrollingContentsLayerGeometry();
void CreatePrimaryGraphicsLayer();
......@@ -343,7 +333,7 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
bool RequiresHorizontalScrollbarLayer() const;
bool RequiresVerticalScrollbarLayer() const;
bool RequiresScrollCornerLayer() const;
bool UpdateScrollingLayers(bool scrolling_layers);
bool UpdateScrollingContentsLayer(bool needs_scrolling_contents_layer);
bool UpdateSquashingLayers(bool needs_squashing_layers);
void UpdateDrawsContentAndPaintsHitTest();
void UpdateCompositedBounds();
......@@ -395,29 +385,40 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// that layer does not appear earlier in the set of layers for this object.
bool InvalidateLayerIfNoPrecedingEntry(wtf_size_t);
void SetContentsNeedDisplay();
PaintLayer& owning_layer_;
// The hierarchy of layers that is maintained by the CompositedLayerMapping
// looks like this:
//
// + graphics_layer_
// + (scrolling_layer_ + scrolling_contents_layer_) [OPTIONAL]
// | + overflow_controls_host_layer_ [OPTIONAL]
// + contents layers (or contents layers under scrolling_contents_layer_)
// + overflow_controls_host_layer_ [OPTIONAL]
// | + layer_for_vertical_scrollbar_ [OPTIONAL]
// | + layer_for_horizontal_scrollbar_ [OPTIONAL]
// | + layer_for_scroll_corner_ [OPTIONAL]
// + decoration_outline_layer_ [OPTIONAL]
// + mask_layer_ [ OPTIONAL ]
// + squashing_layer_ [ OPTIONAL ]
//
// The overflow controls may need to be repositioned in the graphics layer
// tree by the RLC to ensure that they stack above scrolling content.
//
// Contents layers are directly under |graphics_layer_|, or under
// |scrolling_contents_layer_| when the layer is using composited scrolling.
// If owning_layer_ is a stacking context, contents layers include:
// - negative z-index children
// - foreground_layer_
// - normal flow and positive z-index children
// If owning_layer_ is not a stacking context, contents layers are normal
// flow children.
std::unique_ptr<GraphicsLayer> graphics_layer_;
// Only used if the layer is using composited scrolling.
std::unique_ptr<GraphicsLayer> scrolling_layer_;
// Only used if the layer is using composited scrolling.
std::unique_ptr<GraphicsLayer> scrolling_contents_layer_;
IntSize previous_scroll_container_size_;
// Only used if we have a mask.
std::unique_ptr<GraphicsLayer> mask_layer_;
......@@ -447,20 +448,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// DecorationLayer which paints outline.
std::unique_ptr<GraphicsLayer> decoration_outline_layer_;
// A squashing CLM has the following structure:
// squashing_containment_layer_
// + graphics_layer_
// + squashing_layer_
//
// Stacking children of a squashed layer receive graphics layers that are
// parented to the composited ancestor of the squashed layer (i.e. nearest
// enclosing composited layer that is not
// squashed).
// Only used if any squashed layers exist, this contains the squashed layers
// as siblings to the rest of the GraphicsLayer tree chunk.
std::unique_ptr<GraphicsLayer> squashing_containment_layer_;
// Only used if any squashed layers exist, this is the backing that squashed
// layers paint into.
std::unique_ptr<GraphicsLayer> squashing_layer_;
......
......@@ -1157,7 +1157,7 @@ TEST_F(CompositedLayerMappingTest,
// contents layer we don't have a scrolling contents layer to paint into in
// this case.
const auto* mapping = container->Layer()->GetCompositedLayerMapping();
EXPECT_FALSE(mapping->HasScrollingLayer());
EXPECT_FALSE(mapping->ScrollingContentsLayer());
EXPECT_EQ(kBackgroundPaintInGraphicsLayer,
container->GetBackgroundPaintLocation());
}
......@@ -1490,9 +1490,9 @@ TEST_F(CompositedLayerMappingTest, ScrollingLayerBackgroundColor) {
TEST_F(CompositedLayerMappingTest, ScrollLayerSizingSubpixelAccumulation) {
// This test verifies that when subpixel accumulation causes snapping it
// applies to both the scrolling and scrolling contents layers. Verify that
// the mapping doesn't have any vertical scrolling introduced as a result of
// the snapping behavior. https://crbug.com/801381.
// applies to the scrolling contents layer. Verify that the mapping doesn't
// have any vertical scrolling introduced as a result of the snapping
// behavior. https://crbug.com/801381.
GetDocument().GetFrame()->GetSettings()->SetPreferCompositingToLCDTextEnabled(
true);
......@@ -1525,10 +1525,9 @@ TEST_F(CompositedLayerMappingTest, ScrollLayerSizingSubpixelAccumulation) {
->Layer()
->GetCompositedLayerMapping();
ASSERT_TRUE(mapping);
ASSERT_TRUE(mapping->ScrollingLayer());
ASSERT_TRUE(mapping->ScrollingContentsLayer());
EXPECT_EQ(mapping->ScrollingLayer()->Size().height(),
mapping->ScrollingContentsLayer()->Size().height());
EXPECT_EQ(gfx::Size(200, 200), mapping->MainGraphicsLayer()->Size());
EXPECT_EQ(gfx::Size(1000, 200), mapping->ScrollingContentsLayer()->Size());
}
TEST_F(CompositedLayerMappingTest, SquashingScrollInterestRect) {
......
......@@ -153,7 +153,7 @@ void GraphicsLayerTreeBuilder::RebuildRecursive(
if (ShouldAppendLayer(layer)) {
child_layers.push_back(
current_composited_layer_mapping->ChildForSuperlayers());
current_composited_layer_mapping->MainGraphicsLayer());
}
}
......
......@@ -122,13 +122,13 @@ void GraphicsLayerUpdater::UpdateRecursive(
CompositedLayerMapping* mapping = layer.GetCompositedLayerMapping();
if (update_type == kForceUpdate || mapping->NeedsGraphicsLayerUpdate()) {
bool had_scrolling_layer = mapping->ScrollingLayer();
bool had_scrolling_layer = mapping->ScrollingContentsLayer();
const auto* compositing_container = context.CompositingContainer(layer);
if (mapping->UpdateGraphicsLayerConfiguration(compositing_container)) {
needs_rebuild_tree_ = true;
// Change of existence of scrolling layer affects visual rect offsets of
// descendants via LayoutObject::ScrollAdjustmentForPaintInvalidation().
if (had_scrolling_layer != !!mapping->ScrollingLayer())
if (had_scrolling_layer != !!mapping->ScrollingContentsLayer())
layers_needing_paint_invalidation.push_back(&layer);
}
mapping->UpdateGraphicsLayerGeometry(compositing_container,
......
......@@ -426,9 +426,8 @@ void PaintLayerCompositor::UpdateIfNeeded(
// Save off our current parent. We need this in subframes, because our
// parent attached us to itself via AttachFrameContentLayersToIframeLayer().
if (!IsMainFrame() && update_root->GetCompositedLayerMapping()) {
current_parent = update_root->GetCompositedLayerMapping()
->ChildForSuperlayers()
->Parent();
current_parent =
update_root->GetCompositedLayerMapping()->MainGraphicsLayer()->Parent();
}
#if DCHECK_IS_ON()
......@@ -612,10 +611,8 @@ bool PaintLayerCompositor::AttachFrameContentLayersToIframeLayer(
}
static void FullyInvalidatePaintRecursive(PaintLayer* layer) {
if (layer->GetCompositingState() == kPaintsIntoOwnBacking) {
layer->GetCompositedLayerMapping()->SetContentsNeedDisplay();
layer->GetCompositedLayerMapping()->SetSquashingContentsNeedDisplay();
}
if (layer->GetCompositingState() == kPaintsIntoOwnBacking)
layer->GetCompositedLayerMapping()->SetAllLayersNeedDisplay();
for (PaintLayer* child = layer->FirstChild(); child;
child = child->NextSibling())
......@@ -637,7 +634,7 @@ PaintLayer* PaintLayerCompositor::RootLayer() const {
GraphicsLayer* PaintLayerCompositor::RootGraphicsLayer() const {
if (CompositedLayerMapping* clm = RootLayer()->GetCompositedLayerMapping())
return clm->ChildForSuperlayers();
return clm->MainGraphicsLayer();
return nullptr;
}
......
......@@ -899,7 +899,7 @@ void NGBoxFragmentPainter::PaintBoxDecorationBackground(
// composited in PaintArtifactCompositor::UpdateNonFastScrollableRegions.
const auto* layer = PhysicalFragment().Layer();
if (layer && layer->GetCompositedLayerMapping() &&
layer->GetCompositedLayerMapping()->HasScrollingLayer()) {
layer->GetCompositedLayerMapping()->ScrollingContentsLayer()) {
needs_scroll_hit_test = false;
}
}
......
......@@ -88,7 +88,7 @@ void ViewPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info) {
layout_view_.Layer()->GetCompositedLayerMapping() &&
layout_view_.Layer()
->GetCompositedLayerMapping()
->HasScrollingLayer()) {
->ScrollingContentsLayer()) {
paints_scroll_hit_test = false;
}
}
......
......@@ -121,16 +121,8 @@ constexpr CompositingReasonStringMap kCompositingReasonsStringMap[] = {
"Secondary layer, the scroll corner layer"},
{CompositingReason::kLayerForScrollingContents, "layerForScrollingContents",
"Secondary layer, to house contents that can be scrolled"},
{CompositingReason::kLayerForScrollingContainer,
"layerForScrollingContainer",
"Secondary layer, used to position the scrolling contents while "
"scrolling"},
{CompositingReason::kLayerForSquashingContents, "layerForSquashingContents",
"Secondary layer, home for a group of squashable content"},
{CompositingReason::kLayerForSquashingContainer,
"layerForSquashingContainer",
"Secondary layer, no-op layer to place the squashing layer correctly in "
"the composited layer tree"},
{CompositingReason::kLayerForForeground, "layerForForeground",
"Secondary layer, to contain any normal flow and positive z-index "
"contents on top of a negative z-index layer"},
......
......@@ -74,9 +74,7 @@ using CompositingReasons = uint64_t;
V(LayerForOverflowControlsHost) \
V(LayerForScrollCorner) \
V(LayerForScrollingContents) \
V(LayerForScrollingContainer) \
V(LayerForSquashingContents) \
V(LayerForSquashingContainer) \
V(LayerForForeground) \
V(LayerForMask) \
/* Composited layer painted on top of all other layers as decoration. */ \
......
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