| 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return_tightest, | 772 return_tightest, |
| 773 for_event_handling); | 773 for_event_handling); |
| 774 if (match) | 774 if (match) |
| 775 return match; | 775 return match; |
| 776 } | 776 } |
| 777 | 777 |
| 778 return delegate_ ? this : NULL; | 778 return delegate_ ? this : NULL; |
| 779 } | 779 } |
| 780 | 780 |
| 781 void Window::RemoveChildImpl(Window* child, Window* new_parent) { | 781 void Window::RemoveChildImpl(Window* child, Window* new_parent) { |
| 782 Windows::iterator i = std::find(children_.begin(), children_.end(), child); | |
| 783 DCHECK(i != children_.end()); | |
| 784 if (layout_manager_.get()) | 782 if (layout_manager_.get()) |
| 785 layout_manager_->OnWillRemoveWindowFromLayout(child); | 783 layout_manager_->OnWillRemoveWindowFromLayout(child); |
| 786 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); | 784 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); |
| 787 RootWindow* root_window = child->GetRootWindow(); | 785 RootWindow* root_window = child->GetRootWindow(); |
| 788 RootWindow* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; | 786 RootWindow* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; |
| 789 if (root_window && root_window != new_root_window) { | 787 if (root_window && root_window != new_root_window) { |
| 790 root_window->OnWindowRemovedFromRootWindow(child, new_root_window); | 788 root_window->OnWindowRemovedFromRootWindow(child, new_root_window); |
| 791 child->NotifyRemovingFromRootWindow(); | 789 child->NotifyRemovingFromRootWindow(); |
| 792 } | 790 } |
| 793 child->parent_ = NULL; | 791 child->parent_ = NULL; |
| 794 // We should only remove the child's layer if the child still owns that layer. | 792 // We should only remove the child's layer if the child still owns that layer. |
| 795 // Someone else may have acquired ownership of it via AcquireLayer() and may | 793 // Someone else may have acquired ownership of it via AcquireLayer() and may |
| 796 // expect the hierarchy to go unchanged as the Window is destroyed. | 794 // expect the hierarchy to go unchanged as the Window is destroyed. |
| 797 if (child->layer_owner_.get()) | 795 if (child->layer_owner_.get()) |
| 798 layer_->Remove(child->layer_); | 796 layer_->Remove(child->layer_); |
| 797 Windows::iterator i = std::find(children_.begin(), children_.end(), child); |
| 798 DCHECK(i != children_.end()); |
| 799 children_.erase(i); | 799 children_.erase(i); |
| 800 child->OnParentChanged(); | 800 child->OnParentChanged(); |
| 801 if (layout_manager_.get()) | 801 if (layout_manager_.get()) |
| 802 layout_manager_->OnWindowRemovedFromLayout(child); | 802 layout_manager_->OnWindowRemovedFromLayout(child); |
| 803 } | 803 } |
| 804 | 804 |
| 805 void Window::OnParentChanged() { | 805 void Window::OnParentChanged() { |
| 806 FOR_EACH_OBSERVER( | 806 FOR_EACH_OBSERVER( |
| 807 WindowObserver, observers_, OnWindowParentChanged(this, parent_)); | 807 WindowObserver, observers_, OnWindowParentChanged(this, parent_)); |
| 808 } | 808 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 bool contains_mouse = false; | 962 bool contains_mouse = false; |
| 963 if (IsVisible()) { | 963 if (IsVisible()) { |
| 964 RootWindow* root_window = GetRootWindow(); | 964 RootWindow* root_window = GetRootWindow(); |
| 965 contains_mouse = root_window && | 965 contains_mouse = root_window && |
| 966 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 966 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); |
| 967 } | 967 } |
| 968 return contains_mouse; | 968 return contains_mouse; |
| 969 } | 969 } |
| 970 | 970 |
| 971 } // namespace aura | 971 } // namespace aura |
| OLD | NEW |