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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 return &drag_info_; | 640 return &drag_info_; |
641 } | 641 } |
642 | 642 |
643 //////////////////////////////////////////////////////////////////////////////// | 643 //////////////////////////////////////////////////////////////////////////////// |
644 // RootView, private: | 644 // RootView, private: |
645 | 645 |
646 // Input ----------------------------------------------------------------------- | 646 // Input ----------------------------------------------------------------------- |
647 | 647 |
648 void RootView::DispatchGestureEvent(ui::GestureEvent* event) { | 648 void RootView::DispatchGestureEvent(ui::GestureEvent* event) { |
649 bool gesture_handler_set_before_dispatch = !!gesture_handler_; | 649 bool gesture_handler_set_before_dispatch = !!gesture_handler_; |
650 View* target = | 650 scoped_ptr<ui::Event> event_copy = ui::Event::Clone(*event); |
651 static_cast<View*>(targeter()->FindTargetForEvent(this, event)); | 651 View* target = static_cast<View*>( |
| 652 targeter()->FindTargetForEvent(this, event_copy.get())); |
652 while (target && target != this) { | 653 while (target && target != this) { |
653 // Create and dispatch a copy of |event|. | 654 // Create and dispatch a copy of |event|. |
654 ui::GestureEvent event_copy(*event, static_cast<View*>(this), target); | |
655 ui::EventDispatchDetails dispatch_details = | 655 ui::EventDispatchDetails dispatch_details = |
656 DispatchEvent(target, &event_copy); | 656 DispatchEvent(target, event_copy.get()); |
657 if (dispatch_details.dispatcher_destroyed) | 657 if (dispatch_details.dispatcher_destroyed) |
658 return; | 658 return; |
659 | 659 |
660 if (event_copy.stopped_propagation()) | 660 if (event_copy->stopped_propagation()) |
661 event->StopPropagation(); | 661 event->StopPropagation(); |
662 else if (event_copy.handled()) | 662 else if (event_copy->handled()) |
663 event->SetHandled(); | 663 event->SetHandled(); |
664 | 664 |
665 // If the event was handled by the previous dispatch or if the target | 665 // If the event was handled by the previous dispatch or if the target |
666 // was destroyed, do not allow any further processing of |event|. | 666 // was destroyed, do not allow any further processing of |event|. |
667 if (event->handled() || dispatch_details.target_destroyed) | 667 if (event->handled() || dispatch_details.target_destroyed) |
668 return; | 668 return; |
669 | 669 |
670 // The event was not handled by |target|, so continue processing by | 670 // The event was not handled by |target|, so continue processing by |
671 // re-targeting the event. | 671 // re-targeting the event. |
672 target = static_cast<View*>(targeter()->FindNextBestTarget(target, event)); | 672 target = static_cast<View*>( |
| 673 targeter()->FindNextBestTarget(target, event_copy.get())); |
673 } | 674 } |
674 | 675 |
675 // |event| was not handled, so if |gesture_handler_| was not set by the | 676 // |event| was not handled, so if |gesture_handler_| was not set by the |
676 // dispatch of a previous gesture event, then no default gesture handler | 677 // dispatch of a previous gesture event, then no default gesture handler |
677 // should be set prior to the next gesture event being received. | 678 // should be set prior to the next gesture event being received. |
678 // TODO(tdanderson): Move this into a new virtual function | 679 // TODO(tdanderson): Move this into a new virtual function |
679 // EventProcessor::OnEventProcessingFinished(), to be called | 680 // EventProcessor::OnEventProcessingFinished(), to be called |
680 // at the end of EventProcessor::OnEventFromSource(). | 681 // at the end of EventProcessor::OnEventFromSource(). |
681 if (!gesture_handler_set_before_dispatch) | 682 if (!gesture_handler_set_before_dispatch) |
682 gesture_handler_ = NULL; | 683 gesture_handler_ = NULL; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 765 |
765 #ifndef NDEBUG | 766 #ifndef NDEBUG |
766 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 767 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
767 #endif | 768 #endif |
768 | 769 |
769 return details; | 770 return details; |
770 } | 771 } |
771 | 772 |
772 } // namespace internal | 773 } // namespace internal |
773 } // namespace views | 774 } // namespace views |
OLD | NEW |