| OLD | NEW |
| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 if (mouse_move_handler_ != NULL && | 486 if (mouse_move_handler_ != NULL && |
| 487 (!mouse_move_handler_->notify_enter_exit_on_child() || | 487 (!mouse_move_handler_->notify_enter_exit_on_child() || |
| 488 !mouse_move_handler_->Contains(v))) { | 488 !mouse_move_handler_->Contains(v))) { |
| 489 MouseEnterExitEvent exit(event, ui::ET_MOUSE_EXITED); | 489 MouseEnterExitEvent exit(event, ui::ET_MOUSE_EXITED); |
| 490 exit.ConvertLocationToTarget(static_cast<View*>(this), | 490 exit.ConvertLocationToTarget(static_cast<View*>(this), |
| 491 mouse_move_handler_); | 491 mouse_move_handler_); |
| 492 ui::EventDispatchDetails dispatch_details = | 492 ui::EventDispatchDetails dispatch_details = |
| 493 DispatchEvent(mouse_move_handler_, &exit); | 493 DispatchEvent(mouse_move_handler_, &exit); |
| 494 if (dispatch_details.dispatcher_destroyed) | 494 if (dispatch_details.dispatcher_destroyed) |
| 495 return; | 495 return; |
| 496 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, | 496 // The mouse_move_handler_ could have been destroyed in the context of |
| 497 mouse_move_handler_, v); | 497 // the mouse exit event. |
| 498 if (!dispatch_details.target_destroyed) { |
| 499 CHECK(mouse_move_handler_); |
| 500 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, |
| 501 mouse_move_handler_, v); |
| 502 } |
| 498 } | 503 } |
| 499 View* old_handler = mouse_move_handler_; | 504 View* old_handler = mouse_move_handler_; |
| 500 mouse_move_handler_ = v; | 505 mouse_move_handler_ = v; |
| 501 if (!mouse_move_handler_->notify_enter_exit_on_child() || | 506 if (!mouse_move_handler_->notify_enter_exit_on_child() || |
| 502 !mouse_move_handler_->Contains(old_handler)) { | 507 !mouse_move_handler_->Contains(old_handler)) { |
| 503 MouseEnterExitEvent entered(event, ui::ET_MOUSE_ENTERED); | 508 MouseEnterExitEvent entered(event, ui::ET_MOUSE_ENTERED); |
| 504 entered.ConvertLocationToTarget(static_cast<View*>(this), | 509 entered.ConvertLocationToTarget(static_cast<View*>(this), |
| 505 mouse_move_handler_); | 510 mouse_move_handler_); |
| 506 ui::EventDispatchDetails dispatch_details = | 511 ui::EventDispatchDetails dispatch_details = |
| 507 DispatchEvent(mouse_move_handler_, &entered); | 512 DispatchEvent(mouse_move_handler_, &entered); |
| 508 if (dispatch_details.dispatcher_destroyed) | 513 if (dispatch_details.dispatcher_destroyed) |
| 509 return; | 514 return; |
| 510 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_ENTERED, | 515 // The mouse_move_handler_ could have been destroyed in the context of |
| 511 mouse_move_handler_, old_handler); | 516 // the mouse exit event. |
| 517 if (!dispatch_details.target_destroyed) { |
| 518 CHECK(mouse_move_handler_); |
| 519 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_ENTERED, |
| 520 mouse_move_handler_, old_handler); |
| 521 } |
| 512 } | 522 } |
| 513 } | 523 } |
| 514 ui::MouseEvent moved_event(event, static_cast<View*>(this), | 524 ui::MouseEvent moved_event(event, static_cast<View*>(this), |
| 515 mouse_move_handler_); | 525 mouse_move_handler_); |
| 516 mouse_move_handler_->OnMouseMoved(moved_event); | 526 mouse_move_handler_->OnMouseMoved(moved_event); |
| 517 // TODO(tdanderson): It may be possible to avoid setting the cursor twice | 527 // TODO(tdanderson): It may be possible to avoid setting the cursor twice |
| 518 // (once here and once from CompoundEventFilter) on a | 528 // (once here and once from CompoundEventFilter) on a |
| 519 // mousemove. See crbug.com/351469. | 529 // mousemove. See crbug.com/351469. |
| 520 if (!(moved_event.flags() & ui::EF_IS_NON_CLIENT)) | 530 if (!(moved_event.flags() & ui::EF_IS_NON_CLIENT)) |
| 521 widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event)); | 531 widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event)); |
| 522 } else if (mouse_move_handler_ != NULL) { | 532 } else if (mouse_move_handler_ != NULL) { |
| 523 MouseEnterExitEvent exited(event, ui::ET_MOUSE_EXITED); | 533 MouseEnterExitEvent exited(event, ui::ET_MOUSE_EXITED); |
| 524 ui::EventDispatchDetails dispatch_details = | 534 ui::EventDispatchDetails dispatch_details = |
| 525 DispatchEvent(mouse_move_handler_, &exited); | 535 DispatchEvent(mouse_move_handler_, &exited); |
| 526 if (dispatch_details.dispatcher_destroyed) | 536 if (dispatch_details.dispatcher_destroyed) |
| 527 return; | 537 return; |
| 528 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, | 538 // The mouse_move_handler_ could have been destroyed in the context of the |
| 529 mouse_move_handler_, v); | 539 // mouse exit event. |
| 540 if (!dispatch_details.target_destroyed) { |
| 541 CHECK(mouse_move_handler_); |
| 542 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, |
| 543 mouse_move_handler_, v); |
| 544 } |
| 530 // On Aura the non-client area extends slightly outside the root view for | 545 // On Aura the non-client area extends slightly outside the root view for |
| 531 // some windows. Let the non-client cursor handling code set the cursor | 546 // some windows. Let the non-client cursor handling code set the cursor |
| 532 // as we do above. | 547 // as we do above. |
| 533 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) | 548 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) |
| 534 widget_->SetCursor(gfx::kNullCursor); | 549 widget_->SetCursor(gfx::kNullCursor); |
| 535 mouse_move_handler_ = NULL; | 550 mouse_move_handler_ = NULL; |
| 536 } | 551 } |
| 537 } | 552 } |
| 538 | 553 |
| 539 void RootView::OnMouseExited(const ui::MouseEvent& event) { | 554 void RootView::OnMouseExited(const ui::MouseEvent& event) { |
| 540 if (mouse_move_handler_ != NULL) { | 555 if (mouse_move_handler_ != NULL) { |
| 541 MouseEnterExitEvent exited(event, ui::ET_MOUSE_EXITED); | 556 MouseEnterExitEvent exited(event, ui::ET_MOUSE_EXITED); |
| 542 ui::EventDispatchDetails dispatch_details = | 557 ui::EventDispatchDetails dispatch_details = |
| 543 DispatchEvent(mouse_move_handler_, &exited); | 558 DispatchEvent(mouse_move_handler_, &exited); |
| 544 if (dispatch_details.dispatcher_destroyed) | 559 if (dispatch_details.dispatcher_destroyed) |
| 545 return; | 560 return; |
| 546 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, | 561 // The mouse_move_handler_ could have been destroyed in the context of the |
| 547 mouse_move_handler_, NULL); | 562 // mouse exit event. |
| 563 if (!dispatch_details.target_destroyed) { |
| 564 CHECK(mouse_move_handler_); |
| 565 NotifyEnterExitOfDescendant(event, ui::ET_MOUSE_EXITED, |
| 566 mouse_move_handler_, NULL); |
| 567 } |
| 548 mouse_move_handler_ = NULL; | 568 mouse_move_handler_ = NULL; |
| 549 } | 569 } |
| 550 } | 570 } |
| 551 | 571 |
| 552 bool RootView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 572 bool RootView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
| 553 for (View* v = GetEventHandlerForPoint(event.location()); | 573 for (View* v = GetEventHandlerForPoint(event.location()); |
| 554 v && v != this && !event.handled(); v = v->parent()) { | 574 v && v != this && !event.handled(); v = v->parent()) { |
| 555 ui::EventDispatchDetails dispatch_details = | 575 ui::EventDispatchDetails dispatch_details = |
| 556 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event)); | 576 DispatchEvent(v, const_cast<ui::MouseWheelEvent*>(&event)); |
| 557 if (dispatch_details.dispatcher_destroyed || | 577 if (dispatch_details.dispatcher_destroyed || |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 745 |
| 726 #ifndef NDEBUG | 746 #ifndef NDEBUG |
| 727 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 747 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
| 728 #endif | 748 #endif |
| 729 | 749 |
| 730 return details; | 750 return details; |
| 731 } | 751 } |
| 732 | 752 |
| 733 } // namespace internal | 753 } // namespace internal |
| 734 } // namespace views | 754 } // namespace views |
| OLD | NEW |