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;
} }
} }
......
...@@ -207,7 +207,7 @@ CompositedLayerMapping::~CompositedLayerMapping() { ...@@ -207,7 +207,7 @@ CompositedLayerMapping::~CompositedLayerMapping() {
UpdateOverflowControlsLayers(false, false, false); UpdateOverflowControlsLayers(false, false, false);
UpdateForegroundLayer(false); UpdateForegroundLayer(false);
UpdateMaskLayer(false); UpdateMaskLayer(false);
UpdateScrollingLayers(false); UpdateScrollingContentsLayer(false);
UpdateSquashingLayers(false); UpdateSquashingLayers(false);
} }
...@@ -301,7 +301,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -301,7 +301,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
// determined from the main thread. Or can it? // determined from the main thread. Or can it?
graphics_layer_->SetContentsOpaque(false); graphics_layer_->SetContentsOpaque(false);
} else if (BackgroundPaintsOntoScrollingContentsLayer()) { } else if (BackgroundPaintsOntoScrollingContentsLayer()) {
DCHECK(HasScrollingLayer()); DCHECK(scrolling_contents_layer_);
// Backgrounds painted onto the foreground are clipped by the padding box // Backgrounds painted onto the foreground are clipped by the padding box
// rect. // rect.
// TODO(flackr): This should actually check the entire overflow rect // TODO(flackr): This should actually check the entire overflow rect
...@@ -319,7 +319,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -319,7 +319,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
UpdateGraphicsLayerContentsOpaque(should_check_children); UpdateGraphicsLayerContentsOpaque(should_check_children);
} else { } else {
DCHECK(BackgroundPaintsOntoGraphicsLayer()); DCHECK(BackgroundPaintsOntoGraphicsLayer());
if (HasScrollingLayer()) if (scrolling_contents_layer_)
scrolling_contents_layer_->SetContentsOpaque(false); scrolling_contents_layer_->SetContentsOpaque(false);
UpdateGraphicsLayerContentsOpaque(should_check_children); UpdateGraphicsLayerContentsOpaque(should_check_children);
} }
...@@ -384,7 +384,7 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration( ...@@ -384,7 +384,7 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration(
compositor->NeedsContentsCompositingLayer(&owning_layer_))) compositor->NeedsContentsCompositingLayer(&owning_layer_)))
layer_config_changed = true; layer_config_changed = true;
if (UpdateScrollingLayers(owning_layer_.NeedsCompositedScrolling())) if (UpdateScrollingContentsLayer(owning_layer_.NeedsCompositedScrolling()))
layer_config_changed = true; layer_config_changed = true;
// If the outline needs to draw over the composited scrolling contents layer // If the outline needs to draw over the composited scrolling contents layer
...@@ -716,7 +716,7 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry( ...@@ -716,7 +716,7 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry(
// as the foreground layer. There are scenarios where the sizes could be // as the foreground layer. There are scenarios where the sizes could be
// different so the decoration layer size should be calculated separately. // different so the decoration layer size should be calculated separately.
UpdateDecorationOutlineLayerGeometry(local_compositing_bounds.Size()); UpdateDecorationOutlineLayerGeometry(local_compositing_bounds.Size());
UpdateScrollingLayerGeometry(); UpdateScrollingContentsLayerGeometry();
UpdateForegroundLayerGeometry(); UpdateForegroundLayerGeometry();
if (owning_layer_.GetScrollableArea() && if (owning_layer_.GetScrollableArea() &&
...@@ -806,8 +806,8 @@ void CompositedLayerMapping::UpdateMaskLayerGeometry() { ...@@ -806,8 +806,8 @@ void CompositedLayerMapping::UpdateMaskLayerGeometry() {
graphics_layer_->OffsetFromLayoutObject()); graphics_layer_->OffsetFromLayoutObject());
} }
void CompositedLayerMapping::UpdateScrollingLayerGeometry() { void CompositedLayerMapping::UpdateScrollingContentsLayerGeometry() {
if (!scrolling_layer_) if (!scrolling_contents_layer_)
return; return;
DCHECK(scrolling_contents_layer_); DCHECK(scrolling_contents_layer_);
...@@ -815,13 +815,10 @@ void CompositedLayerMapping::UpdateScrollingLayerGeometry() { ...@@ -815,13 +815,10 @@ void CompositedLayerMapping::UpdateScrollingLayerGeometry() {
IntRect overflow_clip_rect = PixelSnappedIntRect( IntRect overflow_clip_rect = PixelSnappedIntRect(
layout_box.OverflowClipRect(owning_layer_.SubpixelAccumulation())); layout_box.OverflowClipRect(owning_layer_.SubpixelAccumulation()));
auto old_scroll_container_size = scrolling_layer_->Size();
scrolling_layer_->SetSize(gfx::Size(overflow_clip_rect.Size()));
bool scroll_container_size_changed = bool scroll_container_size_changed =
old_scroll_container_size != scrolling_layer_->Size(); previous_scroll_container_size_ != overflow_clip_rect.Size();
if (scroll_container_size_changed)
scrolling_layer_->SetOffsetFromLayoutObject( previous_scroll_container_size_ = overflow_clip_rect.Size();
ToIntSize(overflow_clip_rect.Location()));
PaintLayerScrollableArea* scrollable_area = owning_layer_.GetScrollableArea(); PaintLayerScrollableArea* scrollable_area = owning_layer_.GetScrollableArea();
IntSize scroll_size = scrollable_area->PixelSnappedContentsSize( IntSize scroll_size = scrollable_area->PixelSnappedContentsSize(
...@@ -870,7 +867,7 @@ void CompositedLayerMapping::UpdateForegroundLayerGeometry() { ...@@ -870,7 +867,7 @@ void CompositedLayerMapping::UpdateForegroundLayerGeometry() {
IntRect compositing_bounds( IntRect compositing_bounds(
IntPoint(graphics_layer_->OffsetFromLayoutObject()), IntPoint(graphics_layer_->OffsetFromLayoutObject()),
IntSize(graphics_layer_->Size())); IntSize(graphics_layer_->Size()));
if (scrolling_layer_) { if (scrolling_contents_layer_) {
// Override compositing bounds to include full overflow if composited // Override compositing bounds to include full overflow if composited
// scrolling is used. // scrolling is used.
compositing_bounds = compositing_bounds =
...@@ -903,50 +900,36 @@ void CompositedLayerMapping::UpdateDecorationOutlineLayerGeometry( ...@@ -903,50 +900,36 @@ void CompositedLayerMapping::UpdateDecorationOutlineLayerGeometry(
} }
void CompositedLayerMapping::UpdateInternalHierarchy() { void CompositedLayerMapping::UpdateInternalHierarchy() {
// m_foregroundLayer has to be inserted in the correct order with child // foreground_layer_ has to be inserted in the correct order with child
// layers, so it's not inserted here. // layers in SetSubLayers(), so it's not inserted here.
graphics_layer_->RemoveFromParent(); graphics_layer_->RemoveFromParent();
// Layer to which children should be attached as we build the hierarchy. if (scrolling_contents_layer_)
GraphicsLayer* bottom_layer = graphics_layer_.get(); graphics_layer_->AddChild(scrolling_contents_layer_.get());
auto update_bottom_layer = [&bottom_layer](GraphicsLayer* layer) {
if (layer) {
bottom_layer->AddChild(layer);
bottom_layer = layer;
}
};
update_bottom_layer(scrolling_layer_.get());
// Now constructing the subtree for the overflow controls. // Now constructing the subtree for the overflow controls.
bottom_layer = graphics_layer_.get(); if (overflow_controls_host_layer_) {
update_bottom_layer(overflow_controls_host_layer_.get()); graphics_layer_->AddChild(overflow_controls_host_layer_.get());
if (layer_for_horizontal_scrollbar_) { if (layer_for_horizontal_scrollbar_) {
overflow_controls_host_layer_->AddChild( overflow_controls_host_layer_->AddChild(
layer_for_horizontal_scrollbar_.get()); layer_for_horizontal_scrollbar_.get());
} }
if (layer_for_vertical_scrollbar_) { if (layer_for_vertical_scrollbar_) {
overflow_controls_host_layer_->AddChild( overflow_controls_host_layer_->AddChild(
layer_for_vertical_scrollbar_.get()); layer_for_vertical_scrollbar_.get());
}
if (layer_for_scroll_corner_)
overflow_controls_host_layer_->AddChild(layer_for_scroll_corner_.get());
} }
if (layer_for_scroll_corner_)
overflow_controls_host_layer_->AddChild(layer_for_scroll_corner_.get());
// Now add the DecorationOutlineLayer as a subtree to GraphicsLayer
if (decoration_outline_layer_) if (decoration_outline_layer_)
graphics_layer_->AddChild(decoration_outline_layer_.get()); graphics_layer_->AddChild(decoration_outline_layer_.get());
if (mask_layer_) if (mask_layer_)
graphics_layer_->AddChild(mask_layer_.get()); graphics_layer_->AddChild(mask_layer_.get());
// The squashing containment layer, if it exists, becomes a no-op parent. if (squashing_layer_)
if (squashing_layer_) { graphics_layer_->AddChild(squashing_layer_.get());
if (squashing_containment_layer_) {
squashing_containment_layer_->RemoveAllChildren();
squashing_containment_layer_->AddChild(graphics_layer_.get());
squashing_containment_layer_->AddChild(squashing_layer_.get());
}
}
} }
void CompositedLayerMapping::UpdatePaintingPhases() { void CompositedLayerMapping::UpdatePaintingPhases() {
...@@ -996,9 +979,8 @@ void CompositedLayerMapping::UpdateDrawsContentAndPaintsHitTest() { ...@@ -996,9 +979,8 @@ void CompositedLayerMapping::UpdateDrawsContentAndPaintsHitTest() {
GetPluginContainer(GetLayoutObject())->WantsWheelEvents())); GetPluginContainer(GetLayoutObject())->WantsWheelEvents()));
graphics_layer_->SetPaintsHitTest(paints_hit_test || paints_scroll_hit_test); graphics_layer_->SetPaintsHitTest(paints_hit_test || paints_scroll_hit_test);
if (scrolling_layer_) { if (scrolling_contents_layer_) {
// m_scrollingLayer never has backing store. // scrolling_contents_layer_ only needs backing store if the scrolled
// m_scrollingContentsLayer only needs backing store if the scrolled
// contents need to paint. // contents need to paint.
scrolling_contents_are_empty_ = scrolling_contents_are_empty_ =
!owning_layer_.HasVisibleContent() || !owning_layer_.HasVisibleContent() ||
...@@ -1166,84 +1148,32 @@ void CompositedLayerMapping::PositionOverflowControlsLayers() { ...@@ -1166,84 +1148,32 @@ void CompositedLayerMapping::PositionOverflowControlsLayers() {
} }
} }
enum ApplyToGraphicsLayersModeFlags { enum ApplyToGraphicsLayersMode {
kApplyToLayersAffectedByPreserve3D = (1 << 0), kApplyToContentLayers,
kApplyToSquashingLayer = (1 << 1), kApplyToAllGraphicsLayers,
kApplyToScrollbarLayers = (1 << 2),
kApplyToMaskLayers = (1 << 3),
kApplyToContentLayers = (1 << 4),
kApplyToChildContainingLayers =
(1 << 5), // layers between m_graphicsLayer and children
kApplyToNonScrollingContentLayers = (1 << 6),
kApplyToScrollingContentLayers = (1 << 7),
kApplyToAllGraphicsLayers =
(kApplyToSquashingLayer | kApplyToScrollbarLayers | kApplyToMaskLayers |
kApplyToLayersAffectedByPreserve3D | kApplyToContentLayers |
kApplyToScrollingContentLayers)
}; };
typedef unsigned ApplyToGraphicsLayersMode;
template <typename Function>
// Flags to layers mapping matrix:
// bit 0 1 2 3 4 5 6 7
// ChildTransform * *
// Main * * *
// Clipping * *
// Scrolling * *
// ScrollingContents * * * *
// Foreground * * *
// Squashing *
// Mask * * *
// HorizontalScrollbar *
// VerticalScrollbar *
// ScrollCorner *
// DecorationOutline * *
template <typename Func>
static void ApplyToGraphicsLayers(const CompositedLayerMapping* mapping, static void ApplyToGraphicsLayers(const CompositedLayerMapping* mapping,
const Func& f, const Function& function,
ApplyToGraphicsLayersMode mode) { ApplyToGraphicsLayersMode mode) {
DCHECK(mode); auto null_checking_function = [&function](GraphicsLayer* layer) {
if (layer)
if (((mode & kApplyToLayersAffectedByPreserve3D) || function(layer);
(mode & kApplyToContentLayers) || };
(mode & kApplyToNonScrollingContentLayers)) &&
mapping->MainGraphicsLayer()) null_checking_function(mapping->MainGraphicsLayer());
f(mapping->MainGraphicsLayer()); null_checking_function(mapping->ScrollingContentsLayer());
if (((mode & kApplyToLayersAffectedByPreserve3D) || null_checking_function(mapping->ForegroundLayer());
(mode & kApplyToChildContainingLayers)) && null_checking_function(mapping->MaskLayer());
mapping->ScrollingLayer()) null_checking_function(mapping->DecorationOutlineLayer());
f(mapping->ScrollingLayer());
if (((mode & kApplyToLayersAffectedByPreserve3D) || if (mode == kApplyToAllGraphicsLayers) {
(mode & kApplyToContentLayers) || null_checking_function(mapping->SquashingLayer());
(mode & kApplyToChildContainingLayers) || null_checking_function(mapping->LayerForHorizontalScrollbar());
(mode & kApplyToScrollingContentLayers)) && null_checking_function(mapping->LayerForVerticalScrollbar());
mapping->ScrollingContentsLayer()) null_checking_function(mapping->LayerForScrollCorner());
f(mapping->ScrollingContentsLayer()); }
if (((mode & kApplyToLayersAffectedByPreserve3D) ||
(mode & kApplyToContentLayers) ||
(mode & kApplyToScrollingContentLayers)) &&
mapping->ForegroundLayer())
f(mapping->ForegroundLayer());
if ((mode & kApplyToSquashingLayer) && mapping->SquashingLayer())
f(mapping->SquashingLayer());
if (((mode & kApplyToMaskLayers) || (mode & kApplyToContentLayers) ||
(mode & kApplyToNonScrollingContentLayers)) &&
mapping->MaskLayer())
f(mapping->MaskLayer());
if ((mode & kApplyToScrollbarLayers) &&
mapping->LayerForHorizontalScrollbar())
f(mapping->LayerForHorizontalScrollbar());
if ((mode & kApplyToScrollbarLayers) && mapping->LayerForVerticalScrollbar())
f(mapping->LayerForVerticalScrollbar());
if ((mode & kApplyToScrollbarLayers) && mapping->LayerForScrollCorner())
f(mapping->LayerForScrollCorner());
if (((mode & kApplyToContentLayers) ||
(mode & kApplyToNonScrollingContentLayers)) &&
mapping->DecorationOutlineLayer())
f(mapping->DecorationOutlineLayer());
} }
// You receive an element id if you have an animation, or you're a scroller (and // You receive an element id if you have an animation, or you're a scroller (and
...@@ -1321,24 +1251,18 @@ bool CompositedLayerMapping::UpdateMaskLayer(bool needs_mask_layer) { ...@@ -1321,24 +1251,18 @@ bool CompositedLayerMapping::UpdateMaskLayer(bool needs_mask_layer) {
return layer_changed; return layer_changed;
} }
bool CompositedLayerMapping::UpdateScrollingLayers( bool CompositedLayerMapping::UpdateScrollingContentsLayer(
bool needs_scrolling_layers) { bool needs_scrolling_contents_layer) {
ScrollingCoordinator* scrolling_coordinator = ScrollingCoordinator* scrolling_coordinator =
owning_layer_.GetScrollingCoordinator(); owning_layer_.GetScrollingCoordinator();
auto* scrollable_area = owning_layer_.GetScrollableArea(); auto* scrollable_area = owning_layer_.GetScrollableArea();
if (scrollable_area) if (scrollable_area)
scrollable_area->SetUsesCompositedScrolling(needs_scrolling_layers); scrollable_area->SetUsesCompositedScrolling(needs_scrolling_contents_layer);
bool layer_changed = false; bool layer_changed = false;
if (needs_scrolling_layers) { if (needs_scrolling_contents_layer) {
if (!scrolling_layer_) { if (!scrolling_contents_layer_) {
// Outer layer which corresponds with the scroll view.
scrolling_layer_ =
CreateGraphicsLayer(CompositingReason::kLayerForScrollingContainer);
scrolling_layer_->SetDrawsContent(false);
scrolling_layer_->SetHitTestable(false);
// Inner layer which renders the content that scrolls. // Inner layer which renders the content that scrolls.
scrolling_contents_layer_ = scrolling_contents_layer_ =
CreateGraphicsLayer(CompositingReason::kLayerForScrollingContents); CreateGraphicsLayer(CompositingReason::kLayerForScrollingContents);
...@@ -1347,8 +1271,6 @@ bool CompositedLayerMapping::UpdateScrollingLayers( ...@@ -1347,8 +1271,6 @@ bool CompositedLayerMapping::UpdateScrollingLayers(
auto element_id = scrollable_area->GetScrollElementId(); auto element_id = scrollable_area->GetScrollElementId();
scrolling_contents_layer_->SetElementId(element_id); scrolling_contents_layer_->SetElementId(element_id);
scrolling_layer_->AddChild(scrolling_contents_layer_.get());
layer_changed = true; layer_changed = true;
if (scrolling_coordinator && scrollable_area) { if (scrolling_coordinator && scrollable_area) {
scrolling_coordinator->ScrollableAreaScrollLayerDidChange( scrolling_coordinator->ScrollableAreaScrollLayerDidChange(
...@@ -1358,8 +1280,7 @@ bool CompositedLayerMapping::UpdateScrollingLayers( ...@@ -1358,8 +1280,7 @@ bool CompositedLayerMapping::UpdateScrollingLayers(
layout_view->GetFrameView()->ScrollableAreasDidChange(); layout_view->GetFrameView()->ScrollableAreasDidChange();
} }
} }
} else if (scrolling_layer_) { } else if (scrolling_contents_layer_) {
scrolling_layer_ = nullptr;
scrolling_contents_layer_ = nullptr; scrolling_contents_layer_ = nullptr;
layer_changed = true; layer_changed = true;
if (scrolling_coordinator && scrollable_area) { if (scrolling_coordinator && scrollable_area) {
...@@ -1386,11 +1307,6 @@ bool CompositedLayerMapping::UpdateSquashingLayers( ...@@ -1386,11 +1307,6 @@ bool CompositedLayerMapping::UpdateSquashingLayers(
squashing_layer_->SetHitTestable(true); squashing_layer_->SetHitTestable(true);
layers_changed = true; layers_changed = true;
} }
if (!squashing_containment_layer_) {
squashing_containment_layer_ =
CreateGraphicsLayer(CompositingReason::kLayerForSquashingContainer);
layers_changed = true;
}
DCHECK(squashing_layer_); DCHECK(squashing_layer_);
} else { } else {
if (squashing_layer_) { if (squashing_layer_) {
...@@ -1398,13 +1314,7 @@ bool CompositedLayerMapping::UpdateSquashingLayers( ...@@ -1398,13 +1314,7 @@ bool CompositedLayerMapping::UpdateSquashingLayers(
squashing_layer_ = nullptr; squashing_layer_ = nullptr;
layers_changed = true; layers_changed = true;
} }
if (squashing_containment_layer_) {
squashing_containment_layer_->RemoveFromParent();
squashing_containment_layer_ = nullptr;
layers_changed = true;
}
DCHECK(!squashing_layer_); DCHECK(!squashing_layer_);
DCHECK(!squashing_containment_layer_);
} }
return layers_changed; return layers_changed;
...@@ -1580,13 +1490,6 @@ GraphicsLayer* CompositedLayerMapping::DetachLayerForOverflowControls() { ...@@ -1580,13 +1490,6 @@ GraphicsLayer* CompositedLayerMapping::DetachLayerForOverflowControls() {
return overflow_controls_host_layer_.get(); return overflow_controls_host_layer_.get();
} }
GraphicsLayer* CompositedLayerMapping::DetachLayerForDecorationOutline() {
if (!decoration_outline_layer_.get())
return nullptr;
decoration_outline_layer_->RemoveFromParent();
return decoration_outline_layer_.get();
}
GraphicsLayer* CompositedLayerMapping::ParentForSublayers() const { GraphicsLayer* CompositedLayerMapping::ParentForSublayers() const {
if (scrolling_contents_layer_) if (scrolling_contents_layer_)
return scrolling_contents_layer_.get(); return scrolling_contents_layer_.get();
...@@ -1609,6 +1512,7 @@ void CompositedLayerMapping::SetSublayers( ...@@ -1609,6 +1512,7 @@ void CompositedLayerMapping::SetSublayers(
add_layer_needing_reattachment(overflow_controls_host_layer_.get()); add_layer_needing_reattachment(overflow_controls_host_layer_.get());
add_layer_needing_reattachment(decoration_outline_layer_.get()); add_layer_needing_reattachment(decoration_outline_layer_.get());
add_layer_needing_reattachment(mask_layer_.get()); add_layer_needing_reattachment(mask_layer_.get());
add_layer_needing_reattachment(squashing_layer_.get());
parent->SetChildren(sublayers); parent->SetChildren(sublayers);
...@@ -1616,13 +1520,6 @@ void CompositedLayerMapping::SetSublayers( ...@@ -1616,13 +1520,6 @@ void CompositedLayerMapping::SetSublayers(
parent->AddChild(layer); parent->AddChild(layer);
} }
GraphicsLayer* CompositedLayerMapping::ChildForSuperlayers() const {
if (squashing_containment_layer_)
return squashing_containment_layer_.get();
return graphics_layer_.get();
}
GraphicsLayerUpdater::UpdateType CompositedLayerMapping::UpdateTypeForChildren( GraphicsLayerUpdater::UpdateType CompositedLayerMapping::UpdateTypeForChildren(
GraphicsLayerUpdater::UpdateType update_type) const { GraphicsLayerUpdater::UpdateType update_type) const {
if (pending_update_scope_ >= kGraphicsLayerUpdateSubtree) if (pending_update_scope_ >= kGraphicsLayerUpdateSubtree)
...@@ -1637,13 +1534,12 @@ struct SetContentsNeedsDisplayFunctor { ...@@ -1637,13 +1534,12 @@ struct SetContentsNeedsDisplayFunctor {
} }
}; };
void CompositedLayerMapping::SetSquashingContentsNeedDisplay() { void CompositedLayerMapping::SetAllLayersNeedDisplay() {
ApplyToGraphicsLayers(this, SetContentsNeedsDisplayFunctor(), ApplyToGraphicsLayers(this, SetContentsNeedsDisplayFunctor(),
kApplyToSquashingLayer); kApplyToAllGraphicsLayers);
} }
void CompositedLayerMapping::SetContentsNeedDisplay() { void CompositedLayerMapping::SetContentsNeedDisplay() {
// FIXME: need to split out paint invalidations for the background.
ApplyToGraphicsLayers(this, SetContentsNeedsDisplayFunctor(), ApplyToGraphicsLayers(this, SetContentsNeedsDisplayFunctor(),
kApplyToContentLayers); kApplyToContentLayers);
} }
...@@ -2282,8 +2178,6 @@ String CompositedLayerMapping::DebugName( ...@@ -2282,8 +2178,6 @@ String CompositedLayerMapping::DebugName(
String name; String name;
if (graphics_layer == graphics_layer_.get()) { if (graphics_layer == graphics_layer_.get()) {
name = owning_layer_.DebugName(); name = owning_layer_.DebugName();
} else if (graphics_layer == squashing_containment_layer_.get()) {
name = "Squashing Containment Layer";
} else if (graphics_layer == squashing_layer_.get()) { } else if (graphics_layer == squashing_layer_.get()) {
name = "Squashing Layer (first squashed layer: " + name = "Squashing Layer (first squashed layer: " +
(squashed_layers_.size() > 0 (squashed_layers_.size() > 0
...@@ -2302,8 +2196,6 @@ String CompositedLayerMapping::DebugName( ...@@ -2302,8 +2196,6 @@ String CompositedLayerMapping::DebugName(
name = "Scroll Corner Layer"; name = "Scroll Corner Layer";
} else if (graphics_layer == overflow_controls_host_layer_.get()) { } else if (graphics_layer == overflow_controls_host_layer_.get()) {
name = "Overflow Controls Host Layer"; name = "Overflow Controls Host Layer";
} else if (graphics_layer == scrolling_layer_.get()) {
name = "Scrolling Layer";
} else if (graphics_layer == scrolling_contents_layer_.get()) { } else if (graphics_layer == scrolling_contents_layer_.get()) {
name = "Scrolling Contents Layer"; name = "Scrolling Contents Layer";
} else if (graphics_layer == decoration_outline_layer_.get()) { } else if (graphics_layer == decoration_outline_layer_.get()) {
......
...@@ -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