Commit 6d0df2ee authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Remove CompositedLayerMapping::overflow_controlls_host_layer_

The only purpose of it was to group the overflow control layers.
With it removed, we can make all GraphicsLayers collectable as
GraphicsLayerDisplayItems.

Change-Id: Ic37fa3a3902fa3bb493c2b78b15c1df5bd1f6b4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341038Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795942}
parent 93e141f1
......@@ -719,7 +719,6 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry(
snapped_offset_from_composited_ancestor);
UpdateMainGraphicsLayerGeometry(local_compositing_bounds);
UpdateOverflowControlsHostLayerGeometry(compositing_container);
UpdateSquashingLayerGeometry(
compositing_container, snapped_offset_from_composited_ancestor,
non_scrolling_squashed_layers_, layers_needing_paint_invalidation);
......@@ -790,20 +789,6 @@ void CompositedLayerMapping::ComputeGraphicsLayerParentLocation(
}
}
void CompositedLayerMapping::UpdateOverflowControlsHostLayerGeometry(
const PaintLayer* compositing_container) {
if (!overflow_controls_host_layer_)
return;
// To clip the scrollbars correctly, overflow_controls_host_layer_ should
// match our border box size.
const IntSize border_box_size =
owning_layer_.GetLayoutBox()->PixelSnappedBorderBoxSize(
PhysicalOffset(owning_layer_.SubpixelAccumulation() +
owning_layer_.GetLayoutBox()->PhysicalLocation()));
overflow_controls_host_layer_->SetSize(gfx::Size(border_box_size));
}
void CompositedLayerMapping::UpdateMaskLayerGeometry() {
if (!mask_layer_)
return;
......@@ -945,20 +930,12 @@ void CompositedLayerMapping::UpdateInternalHierarchy() {
if (scrolling_contents_layer_)
graphics_layer_->AddChild(scrolling_contents_layer_.get());
// Now constructing the subtree for the overflow controls.
if (overflow_controls_host_layer_) {
graphics_layer_->AddChild(overflow_controls_host_layer_.get());
if (layer_for_horizontal_scrollbar_) {
overflow_controls_host_layer_->AddChild(
layer_for_horizontal_scrollbar_.get());
}
if (layer_for_vertical_scrollbar_) {
overflow_controls_host_layer_->AddChild(
layer_for_vertical_scrollbar_.get());
}
if (layer_for_scroll_corner_)
overflow_controls_host_layer_->AddChild(layer_for_scroll_corner_.get());
}
if (layer_for_horizontal_scrollbar_)
graphics_layer_->AddChild(layer_for_horizontal_scrollbar_.get());
if (layer_for_vertical_scrollbar_)
graphics_layer_->AddChild(layer_for_vertical_scrollbar_.get());
if (layer_for_scroll_corner_)
graphics_layer_->AddChild(layer_for_scroll_corner_.get());
if (decoration_outline_layer_)
graphics_layer_->AddChild(decoration_outline_layer_.get());
......@@ -1136,13 +1113,6 @@ bool CompositedLayerMapping::UpdateOverflowControlsLayers(
layer_for_scroll_corner_, needs_scroll_corner_layer,
CompositingReason::kLayerForScrollCorner);
bool needs_overflow_controls_host_layer = needs_horizontal_scrollbar_layer ||
needs_vertical_scrollbar_layer ||
needs_scroll_corner_layer;
ToggleScrollbarLayerIfNeeded(
overflow_controls_host_layer_, needs_overflow_controls_host_layer,
CompositingReason::kLayerForOverflowControlsHost);
return horizontal_scrollbar_layer_changed ||
vertical_scrollbar_layer_changed || scroll_corner_layer_changed;
}
......@@ -1524,10 +1494,21 @@ bool CompositedLayerMapping::NeedsToReparentOverflowControls() const {
return owning_layer_.NeedsReorderOverlayOverflowControls();
}
GraphicsLayer* CompositedLayerMapping::DetachLayerForOverflowControls() {
if (overflow_controls_host_layer_)
overflow_controls_host_layer_->RemoveFromParent();
return overflow_controls_host_layer_.get();
wtf_size_t CompositedLayerMapping::MoveOverflowControlLayersInto(
GraphicsLayerVector& vector,
wtf_size_t position) {
wtf_size_t count = 0;
auto move_layer = [&](GraphicsLayer* layer) {
if (!layer)
return;
layer->RemoveFromParent();
vector.insert(position++, layer);
count++;
};
move_layer(layer_for_horizontal_scrollbar_.get());
move_layer(layer_for_vertical_scrollbar_.get());
move_layer(layer_for_scroll_corner_.get());
return count;
}
GraphicsLayer* CompositedLayerMapping::ParentForSublayers() const {
......@@ -1552,7 +1533,9 @@ void CompositedLayerMapping::SetSublayers(
if (layer && layer->Parent() == parent)
layers_needing_reattachment.push_back(layer);
};
add_layer_needing_reattachment(overflow_controls_host_layer_.get());
add_layer_needing_reattachment(layer_for_horizontal_scrollbar_.get());
add_layer_needing_reattachment(layer_for_vertical_scrollbar_.get());
add_layer_needing_reattachment(layer_for_scroll_corner_.get());
add_layer_needing_reattachment(decoration_outline_layer_.get());
add_layer_needing_reattachment(mask_layer_.get());
add_layer_needing_reattachment(non_scrolling_squashing_layer_.get());
......@@ -2326,8 +2309,6 @@ String CompositedLayerMapping::DebugName(
name = "Vertical Scrollbar Layer";
} else if (graphics_layer == layer_for_scroll_corner_.get()) {
name = "Scroll Corner Layer";
} else if (graphics_layer == overflow_controls_host_layer_.get()) {
name = "Overflow Controls Host Layer";
} else if (graphics_layer == scrolling_contents_layer_.get()) {
name = "Scrolling Contents Layer";
} else if (graphics_layer == decoration_outline_layer_.get()) {
......
......@@ -210,10 +210,10 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// scrolling content.
bool NeedsToReparentOverflowControls() const;
// Removes the overflow controls host layer from its parent and positions it
// so that it can be inserted as a sibling to this CLM without changing
// position.
GraphicsLayer* DetachLayerForOverflowControls();
// Move overflow control layers from its parent into the vector.
// Returns the number of layers moved.
wtf_size_t MoveOverflowControlLayersInto(GraphicsLayerVector&,
wtf_size_t position);
void SetBlendMode(BlendMode);
......@@ -312,9 +312,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
Vector<GraphicsLayerPaintInfo>& layers,
Vector<PaintLayer*>& layers_needing_paint_invalidation);
void UpdateMainGraphicsLayerGeometry(const IntRect& local_compositing_bounds);
void UpdateOverflowControlsHostLayerGeometry(
const PaintLayer* compositing_container);
void UpdateChildTransformLayerGeometry();
void UpdateMaskLayerGeometry();
void UpdateForegroundLayerGeometry();
void UpdateDecorationOutlineLayerGeometry(
......@@ -412,10 +409,9 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
//
// + graphics_layer_
// + 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]
// + layer_for_vertical_scrollbar_ [OPTIONAL]
// + layer_for_horizontal_scrollbar_ [OPTIONAL]
// + layer_for_scroll_corner_ [OPTIONAL]
// + decoration_outline_layer_ [OPTIONAL]
// + mask_layer_ [ OPTIONAL ]
// + non_scrolling_squashing_layer_ [ OPTIONAL ]
......@@ -457,12 +453,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
std::unique_ptr<GraphicsLayer> layer_for_vertical_scrollbar_;
std::unique_ptr<GraphicsLayer> layer_for_scroll_corner_;
// This layer contains the scrollbar and scroll corner layers and clips them
// to the border box bounds of our LayoutObject. It is usually added to
// graphics_layer_, but may be reparented by GraphicsLayerTreeBuilder to
// ensure that scrollbars appear above scrolling content.
std::unique_ptr<GraphicsLayer> overflow_controls_host_layer_;
// DecorationLayer which paints outline.
std::unique_ptr<GraphicsLayer> decoration_outline_layer_;
......
......@@ -1709,13 +1709,15 @@ TEST_F(CompositedLayerMappingTest, ContentsOpaque) {
EXPECT_TRUE(mapping->MainGraphicsLayer()->ContentsOpaque());
}
TEST_F(CompositedLayerMappingTest, NullOverflowControlsHostLayer) {
TEST_F(CompositedLayerMappingTest, NullOverflowControlLayers) {
SetHtmlInnerHTML("<div id='target' style='will-change: transform'></div>");
CompositedLayerMapping* mapping =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))
->Layer()
->GetCompositedLayerMapping();
EXPECT_FALSE(mapping->DetachLayerForOverflowControls());
EXPECT_FALSE(mapping->LayerForHorizontalScrollbar());
EXPECT_FALSE(mapping->LayerForVerticalScrollbar());
EXPECT_FALSE(mapping->LayerForScrollCorner());
}
TEST_F(CompositedLayerMappingTest, CompositedHiddenAnimatingLayer) {
......
......@@ -166,11 +166,9 @@ void GraphicsLayerTreeBuilder::RebuildRecursive(
return a.second < b.second;
});
for (auto& item : pending) {
if (auto* layer = item.first->GetCompositedLayerMapping()
->DetachLayerForOverflowControls()) {
this_layer_children.insert(item.second + offset, layer);
offset++;
}
offset += item.first->GetCompositedLayerMapping()
->MoveOverflowControlLayersInto(this_layer_children,
item.second + offset);
}
if (!this_layer_children.IsEmpty())
......
......@@ -113,9 +113,6 @@ constexpr CompositingReasonStringMap kCompositingReasonsStringMap[] = {
"Secondary layer, the horizontal scrollbar layer"},
{CompositingReason::kLayerForVerticalScrollbar, "layerForVerticalScrollbar",
"Secondary layer, the vertical scrollbar layer"},
{CompositingReason::kLayerForOverflowControlsHost,
"layerForOverflowControlsHost",
"Secondary layer, the overflow controls host layer"},
{CompositingReason::kLayerForScrollCorner, "layerForScrollCorner",
"Secondary layer, the scroll corner layer"},
{CompositingReason::kLayerForScrollingContents, "layerForScrollingContents",
......
......@@ -74,7 +74,6 @@ using CompositingReasons = uint64_t;
used in CompositeAfterPaint. */ \
V(LayerForHorizontalScrollbar) \
V(LayerForVerticalScrollbar) \
V(LayerForOverflowControlsHost) \
V(LayerForScrollCorner) \
V(LayerForScrollingContents) \
V(LayerForSquashingContents) \
......
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