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