Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: ash/common/shelf/shelf_view.cc

Issue 2575613002: Remove ShelfItemDelegate::IsDraggable; check for app list button. (Closed)
Patch Set: Address comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_window_watcher_item_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/shelf_view.cc
diff --git a/ash/common/shelf/shelf_view.cc b/ash/common/shelf/shelf_view.cc
index 311b498fdf2822f4be81f5ed416f84610fca0145..f85e154d9afd5d624384a0ff9b3e426de97b7681 100644
--- a/ash/common/shelf/shelf_view.cc
+++ b/ash/common/shelf/shelf_view.cc
@@ -798,9 +798,7 @@ void ShelfView::PointerPressedOnButton(views::View* view,
if (index == -1 || view_model_->view_size() <= 1)
return; // View is being deleted, ignore request.
- ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(model_->items()[index].id);
- if (!item_delegate->IsDraggable())
+ if (view == GetAppListButton())
return; // View is not draggable, ignore request.
// Only when the repost event occurs on the same shelf item, we should ignore
@@ -1104,14 +1102,6 @@ void ShelfView::PrepareForDrag(Pointer pointer, const ui::LocatedEvent& event) {
return;
}
- // If the item is no longer draggable, bail out.
- ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(model_->items()[start_drag_index_].id);
- if (!item_delegate->IsDraggable()) {
- CancelDrag(-1);
- return;
- }
-
// Move the view to the front so that it appears on top of other views.
ReorderChildView(drag_view_, -1);
bounds_animator_->StopAnimatingView(drag_view_);
@@ -1120,18 +1110,13 @@ void ShelfView::PrepareForDrag(Pointer pointer, const ui::LocatedEvent& event) {
}
void ShelfView::ContinueDrag(const ui::LocatedEvent& event) {
+ DCHECK(dragging());
+ DCHECK(drag_view_);
// Due to a syncing operation the application might have been removed.
// Bail if it is gone.
int current_index = view_model_->GetIndexOfView(drag_view_);
DCHECK_NE(-1, current_index);
- ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(model_->items()[current_index].id);
- if (!item_delegate->IsDraggable()) {
- CancelDrag(-1);
- return;
- }
-
// If this is not a drag and drop host operation and not the app list item,
// check if the item got ripped off the shelf - if it did we are done.
if (!drag_and_drop_shelf_id_ &&
@@ -1184,14 +1169,11 @@ void ShelfView::ContinueDrag(const ui::LocatedEvent& event) {
target_index =
std::min(indices.second, std::max(target_index, indices.first));
- int first_draggable_item = 0;
- while (first_draggable_item < static_cast<int>(model_->items().size()) &&
- !model_->GetShelfItemDelegate(model_->items()[first_draggable_item].id)
- ->IsDraggable()) {
- first_draggable_item++;
- }
-
+ // The app list button is always first, and it is the only non-draggable item.
+ int first_draggable_item = model_->GetItemIndexForType(TYPE_APP_LIST) + 1;
+ DCHECK_EQ(1, first_draggable_item);
target_index = std::max(target_index, first_draggable_item);
+ DCHECK_LT(target_index, model_->item_count());
if (target_index == current_index)
return;
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_window_watcher_item_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698