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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 delegate_->GetHitTestMask(&mask); | 494 delegate_->GetHitTestMask(&mask); |
495 | 495 |
496 SkRegion clip_region; | 496 SkRegion clip_region; |
497 clip_region.setRect(local_bounds.x(), local_bounds.y(), | 497 clip_region.setRect(local_bounds.x(), local_bounds.y(), |
498 local_bounds.width(), local_bounds.height()); | 498 local_bounds.width(), local_bounds.height()); |
499 SkRegion mask_region; | 499 SkRegion mask_region; |
500 return mask_region.setPath(mask, clip_region) && | 500 return mask_region.setPath(mask, clip_region) && |
501 mask_region.contains(local_point.x(), local_point.y()); | 501 mask_region.contains(local_point.x(), local_point.y()); |
502 } | 502 } |
503 | 503 |
504 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { | 504 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point, |
505 return GetWindowForPoint(local_point, true, true); | 505 ui::EventType event_type) { |
| 506 return GetWindowForPoint(local_point, true, event_type); |
506 } | 507 } |
507 | 508 |
508 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { | 509 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { |
509 return GetWindowForPoint(local_point, false, false); | 510 return GetWindowForPoint(local_point, false, ui::ET_UNKNOWN); |
510 } | 511 } |
511 | 512 |
512 Window* Window::GetToplevelWindow() { | 513 Window* Window::GetToplevelWindow() { |
513 Window* topmost_window_with_delegate = NULL; | 514 Window* topmost_window_with_delegate = NULL; |
514 for (aura::Window* window = this; window != NULL; window = window->parent()) { | 515 for (aura::Window* window = this; window != NULL; window = window->parent()) { |
515 if (window->delegate()) | 516 if (window->delegate()) |
516 topmost_window_with_delegate = window; | 517 topmost_window_with_delegate = window; |
517 } | 518 } |
518 return topmost_window_with_delegate; | 519 return topmost_window_with_delegate; |
519 } | 520 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 if (root_window) | 694 if (root_window) |
694 root_window->OnWindowVisibilityChanged(this, visible); | 695 root_window->OnWindowVisibilityChanged(this, visible); |
695 } | 696 } |
696 | 697 |
697 void Window::SchedulePaint() { | 698 void Window::SchedulePaint() { |
698 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); | 699 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); |
699 } | 700 } |
700 | 701 |
701 Window* Window::GetWindowForPoint(const gfx::Point& local_point, | 702 Window* Window::GetWindowForPoint(const gfx::Point& local_point, |
702 bool return_tightest, | 703 bool return_tightest, |
703 bool for_event_handling) { | 704 ui::EventType event_type) { |
704 if (!IsVisible()) | 705 if (!IsVisible()) |
705 return NULL; | 706 return NULL; |
706 | 707 |
| 708 bool for_event_handling = event_type != ui::ET_UNKNOWN; |
707 if ((for_event_handling && !HitTest(local_point)) || | 709 if ((for_event_handling && !HitTest(local_point)) || |
708 (!for_event_handling && !ContainsPoint(local_point))) | 710 (!for_event_handling && !ContainsPoint(local_point))) |
709 return NULL; | 711 return NULL; |
710 | 712 |
711 // Check if I should claim this event and not pass it to my children because | 713 // Check if I should claim this event and not pass it to my children because |
712 // the location is inside my hit test override area. For details, see | 714 // the location is inside my hit test override area. For details, see |
713 // set_hit_test_bounds_override_inner(). | 715 // set_hit_test_bounds_override_inner(). |
714 if (for_event_handling && !hit_test_bounds_override_inner_.empty()) { | 716 if (for_event_handling && !hit_test_bounds_override_inner_.empty()) { |
715 gfx::Rect inset_local_bounds(gfx::Point(), bounds().size()); | 717 gfx::Rect inset_local_bounds(gfx::Point(), bounds().size()); |
716 inset_local_bounds.Inset(hit_test_bounds_override_inner_); | 718 inset_local_bounds.Inset(hit_test_bounds_override_inner_); |
(...skipping 21 matching lines...) Expand all Loading... |
738 | 740 |
739 // We don't process events for invisible windows or those that have asked | 741 // We don't process events for invisible windows or those that have asked |
740 // to ignore events. | 742 // to ignore events. |
741 if (!child->IsVisible() || (for_event_handling && child->ignore_events_)) | 743 if (!child->IsVisible() || (for_event_handling && child->ignore_events_)) |
742 continue; | 744 continue; |
743 | 745 |
744 gfx::Point point_in_child_coords(local_point); | 746 gfx::Point point_in_child_coords(local_point); |
745 ConvertPointToTarget(this, child, &point_in_child_coords); | 747 ConvertPointToTarget(this, child, &point_in_child_coords); |
746 if (for_event_handling && delegate_ && | 748 if (for_event_handling && delegate_ && |
747 !delegate_->ShouldDescendIntoChildForEventHandling( | 749 !delegate_->ShouldDescendIntoChildForEventHandling( |
748 child, local_point)) { | 750 child, local_point, event_type)) { |
749 continue; | 751 continue; |
750 } | 752 } |
751 | 753 |
752 Window* match = child->GetWindowForPoint(point_in_child_coords, | 754 Window* match = child->GetWindowForPoint(point_in_child_coords, |
753 return_tightest, | 755 return_tightest, |
754 for_event_handling); | 756 event_type); |
755 if (match) | 757 if (match) |
756 return match; | 758 return match; |
757 } | 759 } |
758 | 760 |
759 return delegate_ ? this : NULL; | 761 return delegate_ ? this : NULL; |
760 } | 762 } |
761 | 763 |
762 void Window::RemoveChildImpl(Window* child, Window* new_parent) { | 764 void Window::RemoveChildImpl(Window* child, Window* new_parent) { |
763 Windows::iterator i = std::find(children_.begin(), children_.end(), child); | 765 Windows::iterator i = std::find(children_.begin(), children_.end(), child); |
764 DCHECK(i != children_.end()); | 766 DCHECK(i != children_.end()); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 for (Windows::const_reverse_iterator it = children_.rbegin(), | 957 for (Windows::const_reverse_iterator it = children_.rbegin(), |
956 rend = children_.rend(); | 958 rend = children_.rend(); |
957 it != rend; ++it) { | 959 it != rend; ++it) { |
958 Window* child = *it; | 960 Window* child = *it; |
959 child->PrintWindowHierarchy(depth + 1); | 961 child->PrintWindowHierarchy(depth + 1); |
960 } | 962 } |
961 } | 963 } |
962 #endif | 964 #endif |
963 | 965 |
964 } // namespace aura | 966 } // namespace aura |
OLD | NEW |