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

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 16295012: Made the EndDrag logic clearer by using |drag_view_| as Drag state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index f825000b4f262642be76a8c229383070835eaadd..c957fc1b0b1b4bad93ec843e5aee99e392697927 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -192,6 +192,7 @@ void AppsGridView::EnsureViewVisible(const views::View* view) {
void AppsGridView::InitiateDrag(AppListItemView* view,
Pointer pointer,
const ui::LocatedEvent& event) {
+ DCHECK(view);
if (drag_view_ || pulsing_blocks_model_.view_size())
return;
@@ -222,8 +223,11 @@ void AppsGridView::InitiateDrag(AppListItemView* view,
void AppsGridView::UpdateDrag(AppListItemView* view,
Pointer pointer,
const ui::LocatedEvent& event) {
- if (!dragging() && drag_view_ &&
- ExceededDragThreshold(event.location() - drag_start_)) {
+ // EndDrag was called before if |drag_view_| is NULL.
+ if (!drag_view_)
+ return;
+
+ if (!dragging() && ExceededDragThreshold(event.location() - drag_start_)) {
drag_pointer_ = pointer;
// Move the view to the front so that it appears on top of other views.
ReorderChildView(drag_view_, -1);
@@ -258,10 +262,14 @@ void AppsGridView::UpdateDrag(AppListItemView* view,
}
void AppsGridView::EndDrag(bool cancel) {
+ // EndDrag was called before if |drag_view_| is NULL.
+ if (!drag_view_)
+ return;
+
if (forward_events_to_drag_and_drop_host_) {
forward_events_to_drag_and_drop_host_ = false;
drag_and_drop_host_->EndDrag(cancel);
- } else if (!cancel && dragging() && drag_view_) {
+ } else if (!cancel && dragging()) {
CalculateDropTarget(last_drag_point_, true);
if (IsValidIndex(drop_target_))
MoveItemInModel(drag_view_, drop_target_);
@@ -276,10 +284,8 @@ void AppsGridView::EndDrag(bool cancel) {
drag_pointer_ = NONE;
drop_target_ = Index();
- if (drag_view_) {
- drag_view_ = NULL;
- AnimateToIdealBounds();
- }
+ drag_view_ = NULL;
+ AnimateToIdealBounds();
page_flip_timer_.Stop();
page_flip_target_ = -1;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698