Commit 04355b9e authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Fix notification list scrolling after toggling check box.

The relayout after toggling a checkbox resets the scroll poition, causing a
jarring scroll to start of the list. The fix is to retain the original scroll
position during the layout.

BUG=1000599

Change-Id: I9102c924ac9526ed604124d99677506bca76469f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815537Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698635}
parent a3e54982
...@@ -419,6 +419,7 @@ NotifierSettingsView::NotifierSettingsView() ...@@ -419,6 +419,7 @@ NotifierSettingsView::NotifierSettingsView()
quiet_mode_toggle_(nullptr), quiet_mode_toggle_(nullptr),
header_view_(nullptr), header_view_(nullptr),
top_label_(nullptr), top_label_(nullptr),
scroll_bar_(nullptr),
scroller_(nullptr), scroller_(nullptr),
no_notifiers_view_(nullptr) { no_notifiers_view_(nullptr) {
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
...@@ -486,10 +487,11 @@ NotifierSettingsView::NotifierSettingsView() ...@@ -486,10 +487,11 @@ NotifierSettingsView::NotifierSettingsView()
header_view_ = AddChildView(std::move(header_view)); header_view_ = AddChildView(std::move(header_view));
scroll_bar_ = new views::OverlayScrollBar(/*horizontal=*/false);
auto scroller = std::make_unique<views::ScrollView>(); auto scroller = std::make_unique<views::ScrollView>();
scroller->SetBackgroundColor(SK_ColorTRANSPARENT); scroller->SetBackgroundColor(SK_ColorTRANSPARENT);
scroller->SetVerticalScrollBar(new views::OverlayScrollBar(false)); scroller->SetVerticalScrollBar(scroll_bar_);
scroller->SetHorizontalScrollBar(new views::OverlayScrollBar(true));
scroller->SetDrawOverflowIndicator(false); scroller->SetDrawOverflowIndicator(false);
scroller_ = AddChildView(std::move(scroller)); scroller_ = AddChildView(std::move(scroller));
...@@ -577,6 +579,7 @@ void NotifierSettingsView::OnNotifierIconUpdated(const NotifierId& notifier_id, ...@@ -577,6 +579,7 @@ void NotifierSettingsView::OnNotifierIconUpdated(const NotifierId& notifier_id,
} }
void NotifierSettingsView::Layout() { void NotifierSettingsView::Layout() {
int original_scroll_position = scroller_->GetVisibleRect().y();
int header_height = header_view_->GetHeightForWidth(width()); int header_height = header_view_->GetHeightForWidth(width());
header_view_->SetBounds(0, 0, width(), header_height); header_view_->SetBounds(0, 0, width(), header_height);
...@@ -591,6 +594,9 @@ void NotifierSettingsView::Layout() { ...@@ -591,6 +594,9 @@ void NotifierSettingsView::Layout() {
scroller_->SetBounds(0, header_height, width(), height() - header_height); scroller_->SetBounds(0, header_height, width(), height() - header_height);
no_notifiers_view_->SetBounds(0, header_height, width(), no_notifiers_view_->SetBounds(0, header_height, width(),
height() - header_height); height() - header_height);
// The scroll position may have changed after the layout.
scroller_->ScrollToPosition(scroll_bar_, original_scroll_position);
} }
gfx::Size NotifierSettingsView::GetMinimumSize() const { gfx::Size NotifierSettingsView::GetMinimumSize() const {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace views { namespace views {
class Label; class Label;
class ScrollBar;
class ToggleButton; class ToggleButton;
} // namespace views } // namespace views
...@@ -99,6 +100,7 @@ class ASH_EXPORT NotifierSettingsView : public views::View, ...@@ -99,6 +100,7 @@ class ASH_EXPORT NotifierSettingsView : public views::View,
views::ToggleButton* quiet_mode_toggle_; views::ToggleButton* quiet_mode_toggle_;
views::View* header_view_; views::View* header_view_;
views::Label* top_label_; views::Label* top_label_;
views::ScrollBar* scroll_bar_;
views::ScrollView* scroller_; views::ScrollView* scroller_;
views::View* no_notifiers_view_; views::View* no_notifiers_view_;
std::set<NotifierButton*> buttons_; std::set<NotifierButton*> buttons_;
......
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