Commit a7c890f3 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Fix the issue that ScrollableShelf has no gradient zone

Layer::Clone(), which may be triggered by screen rotation, does not
copy the mask layer. As a result, gradient zone for scrollable
shelf may not show after screen rotation. This CL fixes the issue
by checking the mask layer in ScrollableShelfView::Layout() and
setting the mask layer if necessary.

Bug: 1035715
Change-Id: I0f8adb1df9991066c2e6ff46a401a561fdb15204
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986055
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728326}
parent 18c01329
......@@ -733,6 +733,13 @@ void ScrollableShelfView::Layout() {
if (right_arrow_->GetVisible())
right_arrow_->SetBoundsRect(right_arrow_bounds);
// Layer::Clone(), which may be triggered by screen rotation, does not copy
// the mask layer. So we may need to reset the mask layer.
if (!layer()->layer_mask_layer()) {
DCHECK(!gradient_layer_delegate_->layer()->layer_mask_back_link());
layer()->SetMaskLayer(gradient_layer_delegate_->layer());
}
if (gradient_layer_delegate_->layer()->bounds() != layer()->bounds())
gradient_layer_delegate_->layer()->SetBounds(layer()->bounds());
......@@ -898,6 +905,11 @@ void ScrollableShelfView::ScrollRectToVisible(const gfx::Rect& rect) {
ScrollToMainOffset(main_axis_offset_after_scroll, /*animating=*/true);
}
std::unique_ptr<ui::Layer> ScrollableShelfView::RecreateLayer() {
layer()->SetMaskLayer(nullptr);
return views::View::RecreateLayer();
}
const char* ScrollableShelfView::GetClassName() const {
return "ScrollableShelfView";
}
......
......@@ -177,6 +177,7 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void ScrollRectToVisible(const gfx::Rect& rect) override;
std::unique_ptr<ui::Layer> RecreateLayer() override;
// ShelfButtonDelegate:
void OnShelfButtonAboutToRequestFocusFromTabTraversal(ShelfButton* button,
......
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