diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-27 02:07:47 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-27 02:07:47 +0000 |
commit | cb2233a0acbb93b28d176ef6c9d2a53da8331fc8 (patch) | |
tree | 21a086e6b080d761cfc6b67f04a82e48ee77a104 /ui/app_list | |
parent | cf08865fd9c6f7236a48530c880c2318db815fa8 (diff) | |
download | chromium_src-cb2233a0acbb93b28d176ef6c9d2a53da8331fc8.zip chromium_src-cb2233a0acbb93b28d176ef6c9d2a53da8331fc8.tar.gz chromium_src-cb2233a0acbb93b28d176ef6c9d2a53da8331fc8.tar.bz2 |
app_list: Fix AnimationBetweenRows DCHECK.
Removed the DCHECK and updated the animation direction logic to be more general.
BUG=158110
TEST=Manual. App list should run without DCHECK or crash with in progress app sync.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11308015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r-- | ui/app_list/apps_grid_view.cc | 20 | ||||
-rw-r--r-- | ui/app_list/apps_grid_view.h | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/ui/app_list/apps_grid_view.cc b/ui/app_list/apps_grid_view.cc index 574938c..f9e21c9 100644 --- a/ui/app_list/apps_grid_view.cc +++ b/ui/app_list/apps_grid_view.cc @@ -187,6 +187,7 @@ void AppsGridView::UpdateDrag(views::View* view, last_drag_point_ = event.location(); views::View::ConvertPointToTarget(drag_view_, this, &last_drag_point_); + const Index last_drop_target = drop_target_; CalculateDropTarget(last_drag_point_); MaybeStartPageFlipTimer(last_drag_point_); @@ -195,7 +196,8 @@ void AppsGridView::UpdateDrag(views::View* view, &page_switcher_point); page_switcher_view_->UpdateUIForDragPoint(page_switcher_point); - AnimateToIdealBounds(); + if (last_drop_target != drop_target_) + AnimateToIdealBounds(); drag_view_->SetPosition(last_drag_point_.Subtract(drag_offset_)); } } @@ -496,13 +498,15 @@ void AppsGridView::AnimationBetweenRows(views::View* view, const gfx::Rect& current, bool animate_target, const gfx::Rect& target) { - const int y_diff = target.y() - current.y(); - // It should be either wrap to next/prev row or next/prev page. - DCHECK(abs(y_diff) == kPreferredTileHeight || - abs(y_diff) == (rows_per_page_ - 1) * kPreferredTileHeight); + // Determine page of |current| and |target|. -1 means in the left invisible + // page, 0 is the center visible page and 1 means in the right invisible page. + const int current_page = current.x() < 0 ? -1 : + current.x() >= width() ? 1 : 0; + const int target_page = target.x() < 0 ? -1 : + target.x() >= width() ? 1 : 0; - const int dir = y_diff == kPreferredTileHeight || - y_diff == (1 - rows_per_page_) * kPreferredTileHeight ? 1 : -1; + const int dir = current_page < target_page || + (current_page == target_page && current.y() < target.y()) ? 1 : -1; #if !defined(OS_WIN) scoped_ptr<ui::Layer> layer; @@ -648,7 +652,6 @@ void AppsGridView::ListItemsAdded(size_t start, size_t count) { } UpdatePaging(); - Layout(); SchedulePaint(); } @@ -663,7 +666,6 @@ void AppsGridView::ListItemsRemoved(size_t start, size_t count) { } UpdatePaging(); - Layout(); SchedulePaint(); } diff --git a/ui/app_list/apps_grid_view.h b/ui/app_list/apps_grid_view.h index 852ac92..13d1bcb 100644 --- a/ui/app_list/apps_grid_view.h +++ b/ui/app_list/apps_grid_view.h @@ -97,6 +97,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View, bool operator==(const Index& other) const { return page == other.page && slot == other.slot; } + bool operator!=(const Index& other) const { + return page != other.page || slot != other.slot; + } int page; // Which page an item view is on. int slot; // Which slot in the page an item view is in. |