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( ...@@ -719,7 +719,6 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry(
snapped_offset_from_composited_ancestor); snapped_offset_from_composited_ancestor);
UpdateMainGraphicsLayerGeometry(local_compositing_bounds); UpdateMainGraphicsLayerGeometry(local_compositing_bounds);
UpdateOverflowControlsHostLayerGeometry(compositing_container);
UpdateSquashingLayerGeometry( UpdateSquashingLayerGeometry(
compositing_container, snapped_offset_from_composited_ancestor, compositing_container, snapped_offset_from_composited_ancestor,
non_scrolling_squashed_layers_, layers_needing_paint_invalidation); non_scrolling_squashed_layers_, layers_needing_paint_invalidation);
...@@ -790,20 +789,6 @@ void CompositedLayerMapping::ComputeGraphicsLayerParentLocation( ...@@ -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() { void CompositedLayerMapping::UpdateMaskLayerGeometry() {
if (!mask_layer_) if (!mask_layer_)
return; return;
...@@ -945,20 +930,12 @@ void CompositedLayerMapping::UpdateInternalHierarchy() { ...@@ -945,20 +930,12 @@ void CompositedLayerMapping::UpdateInternalHierarchy() {
if (scrolling_contents_layer_) if (scrolling_contents_layer_)
graphics_layer_->AddChild(scrolling_contents_layer_.get()); graphics_layer_->AddChild(scrolling_contents_layer_.get());
// Now constructing the subtree for the overflow controls. if (layer_for_horizontal_scrollbar_)
if (overflow_controls_host_layer_) { graphics_layer_->AddChild(layer_for_horizontal_scrollbar_.get());
graphics_layer_->AddChild(overflow_controls_host_layer_.get()); if (layer_for_vertical_scrollbar_)
if (layer_for_horizontal_scrollbar_) { graphics_layer_->AddChild(layer_for_vertical_scrollbar_.get());
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_) if (layer_for_scroll_corner_)
overflow_controls_host_layer_->AddChild(layer_for_scroll_corner_.get()); graphics_layer_->AddChild(layer_for_scroll_corner_.get());
}
if (decoration_outline_layer_) if (decoration_outline_layer_)
graphics_layer_->AddChild(decoration_outline_layer_.get()); graphics_layer_->AddChild(decoration_outline_layer_.get());
...@@ -1136,13 +1113,6 @@ bool CompositedLayerMapping::UpdateOverflowControlsLayers( ...@@ -1136,13 +1113,6 @@ bool CompositedLayerMapping::UpdateOverflowControlsLayers(
layer_for_scroll_corner_, needs_scroll_corner_layer, layer_for_scroll_corner_, needs_scroll_corner_layer,
CompositingReason::kLayerForScrollCorner); 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 || return horizontal_scrollbar_layer_changed ||
vertical_scrollbar_layer_changed || scroll_corner_layer_changed; vertical_scrollbar_layer_changed || scroll_corner_layer_changed;
} }
...@@ -1524,10 +1494,21 @@ bool CompositedLayerMapping::NeedsToReparentOverflowControls() const { ...@@ -1524,10 +1494,21 @@ bool CompositedLayerMapping::NeedsToReparentOverflowControls() const {
return owning_layer_.NeedsReorderOverlayOverflowControls(); return owning_layer_.NeedsReorderOverlayOverflowControls();
} }
GraphicsLayer* CompositedLayerMapping::DetachLayerForOverflowControls() { wtf_size_t CompositedLayerMapping::MoveOverflowControlLayersInto(
if (overflow_controls_host_layer_) GraphicsLayerVector& vector,
overflow_controls_host_layer_->RemoveFromParent(); wtf_size_t position) {
return overflow_controls_host_layer_.get(); 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 { GraphicsLayer* CompositedLayerMapping::ParentForSublayers() const {
...@@ -1552,7 +1533,9 @@ void CompositedLayerMapping::SetSublayers( ...@@ -1552,7 +1533,9 @@ void CompositedLayerMapping::SetSublayers(
if (layer && layer->Parent() == parent) if (layer && layer->Parent() == parent)
layers_needing_reattachment.push_back(layer); 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(decoration_outline_layer_.get());
add_layer_needing_reattachment(mask_layer_.get()); add_layer_needing_reattachment(mask_layer_.get());
add_layer_needing_reattachment(non_scrolling_squashing_layer_.get()); add_layer_needing_reattachment(non_scrolling_squashing_layer_.get());
...@@ -2326,8 +2309,6 @@ String CompositedLayerMapping::DebugName( ...@@ -2326,8 +2309,6 @@ String CompositedLayerMapping::DebugName(
name = "Vertical Scrollbar Layer"; name = "Vertical Scrollbar Layer";
} else if (graphics_layer == layer_for_scroll_corner_.get()) { } else if (graphics_layer == layer_for_scroll_corner_.get()) {
name = "Scroll Corner Layer"; 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()) { } 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()) {
......
...@@ -210,10 +210,10 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient { ...@@ -210,10 +210,10 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// scrolling content. // scrolling content.
bool NeedsToReparentOverflowControls() const; bool NeedsToReparentOverflowControls() const;
// Removes the overflow controls host layer from its parent and positions it // Move overflow control layers from its parent into the vector.
// so that it can be inserted as a sibling to this CLM without changing // Returns the number of layers moved.
// position. wtf_size_t MoveOverflowControlLayersInto(GraphicsLayerVector&,
GraphicsLayer* DetachLayerForOverflowControls(); wtf_size_t position);
void SetBlendMode(BlendMode); void SetBlendMode(BlendMode);
...@@ -312,9 +312,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient { ...@@ -312,9 +312,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
Vector<GraphicsLayerPaintInfo>& layers, Vector<GraphicsLayerPaintInfo>& layers,
Vector<PaintLayer*>& layers_needing_paint_invalidation); Vector<PaintLayer*>& layers_needing_paint_invalidation);
void UpdateMainGraphicsLayerGeometry(const IntRect& local_compositing_bounds); void UpdateMainGraphicsLayerGeometry(const IntRect& local_compositing_bounds);
void UpdateOverflowControlsHostLayerGeometry(
const PaintLayer* compositing_container);
void UpdateChildTransformLayerGeometry();
void UpdateMaskLayerGeometry(); void UpdateMaskLayerGeometry();
void UpdateForegroundLayerGeometry(); void UpdateForegroundLayerGeometry();
void UpdateDecorationOutlineLayerGeometry( void UpdateDecorationOutlineLayerGeometry(
...@@ -412,10 +409,9 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient { ...@@ -412,10 +409,9 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// //
// + graphics_layer_ // + graphics_layer_
// + contents layers (or contents layers under scrolling_contents_layer_) // + contents layers (or contents layers under scrolling_contents_layer_)
// + 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 ]
// + non_scrolling_squashing_layer_ [ OPTIONAL ] // + non_scrolling_squashing_layer_ [ OPTIONAL ]
...@@ -457,12 +453,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient { ...@@ -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_vertical_scrollbar_;
std::unique_ptr<GraphicsLayer> layer_for_scroll_corner_; 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. // DecorationLayer which paints outline.
std::unique_ptr<GraphicsLayer> decoration_outline_layer_; std::unique_ptr<GraphicsLayer> decoration_outline_layer_;
......
...@@ -1709,13 +1709,15 @@ TEST_F(CompositedLayerMappingTest, ContentsOpaque) { ...@@ -1709,13 +1709,15 @@ TEST_F(CompositedLayerMappingTest, ContentsOpaque) {
EXPECT_TRUE(mapping->MainGraphicsLayer()->ContentsOpaque()); EXPECT_TRUE(mapping->MainGraphicsLayer()->ContentsOpaque());
} }
TEST_F(CompositedLayerMappingTest, NullOverflowControlsHostLayer) { TEST_F(CompositedLayerMappingTest, NullOverflowControlLayers) {
SetHtmlInnerHTML("<div id='target' style='will-change: transform'></div>"); SetHtmlInnerHTML("<div id='target' style='will-change: transform'></div>");
CompositedLayerMapping* mapping = CompositedLayerMapping* mapping =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target")) ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))
->Layer() ->Layer()
->GetCompositedLayerMapping(); ->GetCompositedLayerMapping();
EXPECT_FALSE(mapping->DetachLayerForOverflowControls()); EXPECT_FALSE(mapping->LayerForHorizontalScrollbar());
EXPECT_FALSE(mapping->LayerForVerticalScrollbar());
EXPECT_FALSE(mapping->LayerForScrollCorner());
} }
TEST_F(CompositedLayerMappingTest, CompositedHiddenAnimatingLayer) { TEST_F(CompositedLayerMappingTest, CompositedHiddenAnimatingLayer) {
......
...@@ -166,11 +166,9 @@ void GraphicsLayerTreeBuilder::RebuildRecursive( ...@@ -166,11 +166,9 @@ void GraphicsLayerTreeBuilder::RebuildRecursive(
return a.second < b.second; return a.second < b.second;
}); });
for (auto& item : pending) { for (auto& item : pending) {
if (auto* layer = item.first->GetCompositedLayerMapping() offset += item.first->GetCompositedLayerMapping()
->DetachLayerForOverflowControls()) { ->MoveOverflowControlLayersInto(this_layer_children,
this_layer_children.insert(item.second + offset, layer); item.second + offset);
offset++;
}
} }
if (!this_layer_children.IsEmpty()) if (!this_layer_children.IsEmpty())
......
...@@ -113,9 +113,6 @@ constexpr CompositingReasonStringMap kCompositingReasonsStringMap[] = { ...@@ -113,9 +113,6 @@ constexpr CompositingReasonStringMap kCompositingReasonsStringMap[] = {
"Secondary layer, the horizontal scrollbar layer"}, "Secondary layer, the horizontal scrollbar layer"},
{CompositingReason::kLayerForVerticalScrollbar, "layerForVerticalScrollbar", {CompositingReason::kLayerForVerticalScrollbar, "layerForVerticalScrollbar",
"Secondary layer, the vertical scrollbar layer"}, "Secondary layer, the vertical scrollbar layer"},
{CompositingReason::kLayerForOverflowControlsHost,
"layerForOverflowControlsHost",
"Secondary layer, the overflow controls host layer"},
{CompositingReason::kLayerForScrollCorner, "layerForScrollCorner", {CompositingReason::kLayerForScrollCorner, "layerForScrollCorner",
"Secondary layer, the scroll corner layer"}, "Secondary layer, the scroll corner layer"},
{CompositingReason::kLayerForScrollingContents, "layerForScrollingContents", {CompositingReason::kLayerForScrollingContents, "layerForScrollingContents",
......
...@@ -74,7 +74,6 @@ using CompositingReasons = uint64_t; ...@@ -74,7 +74,6 @@ using CompositingReasons = uint64_t;
used in CompositeAfterPaint. */ \ used in CompositeAfterPaint. */ \
V(LayerForHorizontalScrollbar) \ V(LayerForHorizontalScrollbar) \
V(LayerForVerticalScrollbar) \ V(LayerForVerticalScrollbar) \
V(LayerForOverflowControlsHost) \
V(LayerForScrollCorner) \ V(LayerForScrollCorner) \
V(LayerForScrollingContents) \ V(LayerForScrollingContents) \
V(LayerForSquashingContents) \ 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