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

Side by Side Diff: ui/views/widget/root_view.cc

Issue 560053002: Do not interchange MOUSE_MOVED and MOUSE_DRAGGED events in Widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // it must be marked as handled to avoid anything happening from default 422 // it must be marked as handled to avoid anything happening from default
423 // processing if it the first click-part was handled by us. 423 // processing if it the first click-part was handled by us.
424 if (last_click_handler_ && (event.flags() & ui::EF_IS_DOUBLE_CLICK)) 424 if (last_click_handler_ && (event.flags() & ui::EF_IS_DOUBLE_CLICK))
425 hit_disabled_view = true; 425 hit_disabled_view = true;
426 426
427 last_click_handler_ = NULL; 427 last_click_handler_ = NULL;
428 return hit_disabled_view; 428 return hit_disabled_view;
429 } 429 }
430 430
431 bool RootView::OnMouseDragged(const ui::MouseEvent& event) { 431 bool RootView::OnMouseDragged(const ui::MouseEvent& event) {
432 CHECK_EQ(ui::ET_MOUSE_DRAGGED, event.type());
432 if (mouse_pressed_handler_) { 433 if (mouse_pressed_handler_) {
433 SetMouseLocationAndFlags(event); 434 SetMouseLocationAndFlags(event);
434 435
435 ui::MouseEvent mouse_event(event, static_cast<View*>(this), 436 ui::MouseEvent mouse_event(event, static_cast<View*>(this),
436 mouse_pressed_handler_); 437 mouse_pressed_handler_);
437 ui::EventDispatchDetails dispatch_details = 438 ui::EventDispatchDetails dispatch_details =
438 DispatchEvent(mouse_pressed_handler_, &mouse_event); 439 DispatchEvent(mouse_pressed_handler_, &mouse_event);
439 if (dispatch_details.dispatcher_destroyed) 440 if (dispatch_details.dispatcher_destroyed)
440 return false; 441 return false;
441 } 442 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 SetMouseHandler(NULL); 480 SetMouseHandler(NULL);
480 if (mouse_pressed_handler) 481 if (mouse_pressed_handler)
481 mouse_pressed_handler->OnMouseCaptureLost(); 482 mouse_pressed_handler->OnMouseCaptureLost();
482 else 483 else
483 gesture_handler->OnMouseCaptureLost(); 484 gesture_handler->OnMouseCaptureLost();
484 // WARNING: we may have been deleted. 485 // WARNING: we may have been deleted.
485 } 486 }
486 } 487 }
487 488
488 void RootView::OnMouseMoved(const ui::MouseEvent& event) { 489 void RootView::OnMouseMoved(const ui::MouseEvent& event) {
490 CHECK_EQ(ui::ET_MOUSE_MOVED, event.type());
489 View* v = GetEventHandlerForPoint(event.location()); 491 View* v = GetEventHandlerForPoint(event.location());
490 // Find the first enabled view, or the existing move handler, whichever comes 492 // Find the first enabled view, or the existing move handler, whichever comes
491 // first. The check for the existing handler is because if a view becomes 493 // first. The check for the existing handler is because if a view becomes
492 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED 494 // disabled while handling moves, it's wrong to suddenly send ET_MOUSE_EXITED
493 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet. 495 // and ET_MOUSE_ENTERED events, because the mouse hasn't actually exited yet.
494 while (v && !v->enabled() && (v != mouse_move_handler_)) 496 while (v && !v->enabled() && (v != mouse_move_handler_))
495 v = v->parent(); 497 v = v->parent();
496 if (v && v != this) { 498 if (v && v != this) {
497 if (v != mouse_move_handler_) { 499 if (v != mouse_move_handler_) {
498 if (mouse_move_handler_ != NULL && 500 if (mouse_move_handler_ != NULL &&
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 739
738 #ifndef NDEBUG 740 #ifndef NDEBUG
739 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 741 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
740 #endif 742 #endif
741 743
742 return details; 744 return details;
743 } 745 }
744 746
745 } // namespace internal 747 } // namespace internal
746 } // namespace views 748 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698