Commit 25608981 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

NewMessageListView: Fix scroll position.

This CL fixes the bug that the scroll position is wrong in such cases:
1. Initially there's no notification.
2. Open SystemTray
3. Press CapsLock
4. Bottom position of notification is wrong

TEST=NewUnifiedMessageCenterTest.AddAndRemoveNotification
BUG=769219

Change-Id: I362b2497da1b89c9decca9cca8e8e2d735d1293d
Reviewed-on: https://chromium-review.googlesource.com/c/1286011
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600667}
parent ad82b628
......@@ -208,6 +208,11 @@ void NewUnifiedMessageCenterView::UpdateVisibility() {
}
void NewUnifiedMessageCenterView::ScrollToPositionFromBottom() {
// Following logic doesn't work when the view is invisible, because it uses
// the height of |scroller_|.
if (!visible())
return;
// If the last notification is taller than |scroller_|, we should align the
// top of the notification with the top of |scroller_|.
const int last_notification_offset =
......
......@@ -68,7 +68,8 @@ class NewUnifiedMessageCenterViewTest : public AshTestBase,
void OnViewPreferredSizeChanged(views::View* view) override {
if (view->GetPreferredSize() == view->size())
return;
view->SetBoundsRect(gfx::Rect(view->GetPreferredSize()));
view->SetBoundsRect(view->visible() ? gfx::Rect(view->GetPreferredSize())
: gfx::Rect());
view->Layout();
++size_changed_count_;
}
......@@ -152,6 +153,9 @@ TEST_F(NewUnifiedMessageCenterViewTest, AddAndRemoveNotification) {
auto id0 = AddNotification();
EXPECT_TRUE(message_center_view()->visible());
EXPECT_EQ(3 * kUnifiedNotificationCenterSpacing,
GetScrollerContents()->height() -
GetScroller()->GetVisibleRect().bottom());
MessageCenter::Get()->RemoveNotification(id0, true /* by_user */);
AnimateToEnd();
......
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