Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "cc/output/compositor_frame_sink.h" | |
| 21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/client/capture_client.h" | 23 #include "ui/aura/client/capture_client.h" |
| 23 #include "ui/aura/client/cursor_client.h" | 24 #include "ui/aura/client/cursor_client.h" |
| 24 #include "ui/aura/client/event_client.h" | 25 #include "ui/aura/client/event_client.h" |
| 25 #include "ui/aura/client/focus_client.h" | 26 #include "ui/aura/client/focus_client.h" |
| 26 #include "ui/aura/client/screen_position_client.h" | 27 #include "ui/aura/client/screen_position_client.h" |
| 27 #include "ui/aura/client/visibility_client.h" | 28 #include "ui/aura/client/visibility_client.h" |
| 28 #include "ui/aura/client/window_stacking_client.h" | 29 #include "ui/aura/client/window_stacking_client.h" |
| 29 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
| 30 #include "ui/aura/layout_manager.h" | 31 #include "ui/aura/layout_manager.h" |
| 32 #include "ui/aura/local/compositor_frame_sink_local.h" | |
| 31 #include "ui/aura/window_delegate.h" | 33 #include "ui/aura/window_delegate.h" |
| 32 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
| 33 #include "ui/aura/window_observer.h" | 35 #include "ui/aura/window_observer.h" |
| 34 #include "ui/aura/window_port.h" | 36 #include "ui/aura/window_port.h" |
| 35 #include "ui/aura/window_port_local.h" | |
| 36 #include "ui/aura/window_tracker.h" | 37 #include "ui/aura/window_tracker.h" |
| 37 #include "ui/aura/window_tree_host.h" | 38 #include "ui/aura/window_tree_host.h" |
| 38 #include "ui/compositor/compositor.h" | 39 #include "ui/compositor/compositor.h" |
| 39 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
| 40 #include "ui/display/display.h" | 41 #include "ui/display/display.h" |
| 41 #include "ui/display/screen.h" | 42 #include "ui/display/screen.h" |
| 42 #include "ui/events/event_target_iterator.h" | 43 #include "ui/events/event_target_iterator.h" |
| 43 #include "ui/gfx/canvas.h" | 44 #include "ui/gfx/canvas.h" |
| 44 #include "ui/gfx/path.h" | 45 #include "ui/gfx/path.h" |
| 45 #include "ui/gfx/scoped_canvas.h" | 46 #include "ui/gfx/scoped_canvas.h" |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 return delegate_ ? this : nullptr; | 771 return delegate_ ? this : nullptr; |
| 771 } | 772 } |
| 772 | 773 |
| 773 void Window::RemoveChildImpl(Window* child, Window* new_parent) { | 774 void Window::RemoveChildImpl(Window* child, Window* new_parent) { |
| 774 if (layout_manager_) | 775 if (layout_manager_) |
| 775 layout_manager_->OnWillRemoveWindowFromLayout(child); | 776 layout_manager_->OnWillRemoveWindowFromLayout(child); |
| 776 for (WindowObserver& observer : observers_) | 777 for (WindowObserver& observer : observers_) |
| 777 observer.OnWillRemoveWindow(child); | 778 observer.OnWillRemoveWindow(child); |
| 778 Window* root_window = child->GetRootWindow(); | 779 Window* root_window = child->GetRootWindow(); |
| 779 Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; | 780 Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; |
| 780 if (root_window && root_window != new_root_window) | 781 if (root_window && root_window != new_root_window) |
|
sky
2017/05/08 22:36:43
Are you sure you don't care about the case when th
Peng
2017/05/09 17:26:57
In that case, this function must be called by Wind
sky
2017/05/09 19:34:06
You are indeed right. Sorry about that.
| |
| 781 child->NotifyRemovingFromRootWindow(new_root_window); | 782 child->NotifyRemovingFromRootWindow(new_root_window); |
| 782 | 783 |
| 783 if (child->OwnsLayer()) | 784 if (child->OwnsLayer()) |
| 784 layer()->Remove(child->layer()); | 785 layer()->Remove(child->layer()); |
| 785 child->parent_ = NULL; | 786 child->parent_ = NULL; |
| 786 Windows::iterator i = std::find(children_.begin(), children_.end(), child); | 787 Windows::iterator i = std::find(children_.begin(), children_.end(), child); |
| 787 DCHECK(i != children_.end()); | 788 DCHECK(i != children_.end()); |
| 788 children_.erase(i); | 789 children_.erase(i); |
| 789 child->OnParentChanged(); | 790 child->OnParentChanged(); |
| 790 if (layout_manager_) | 791 if (layout_manager_) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 observer.OnWindowStackingChanged(this); | 850 observer.OnWindowStackingChanged(this); |
| 850 } | 851 } |
| 851 | 852 |
| 852 void Window::NotifyRemovingFromRootWindow(Window* new_root) { | 853 void Window::NotifyRemovingFromRootWindow(Window* new_root) { |
| 853 for (WindowObserver& observer : observers_) | 854 for (WindowObserver& observer : observers_) |
| 854 observer.OnWindowRemovingFromRootWindow(this, new_root); | 855 observer.OnWindowRemovingFromRootWindow(this, new_root); |
| 855 for (Window::Windows::const_iterator it = children_.begin(); | 856 for (Window::Windows::const_iterator it = children_.begin(); |
| 856 it != children_.end(); ++it) { | 857 it != children_.end(); ++it) { |
| 857 (*it)->NotifyRemovingFromRootWindow(new_root); | 858 (*it)->NotifyRemovingFromRootWindow(new_root); |
| 858 } | 859 } |
| 860 port_->OnWindowRemovingFromRootWindow(); | |
|
sky
2017/05/08 22:36:43
I have a mild preferences for calling this before
Peng
2017/05/09 17:26:57
Done.
| |
| 859 } | 861 } |
| 860 | 862 |
| 861 void Window::NotifyAddedToRootWindow() { | 863 void Window::NotifyAddedToRootWindow() { |
| 864 port_->OnWindowAddedToRootWindow(); | |
| 862 for (WindowObserver& observer : observers_) | 865 for (WindowObserver& observer : observers_) |
| 863 observer.OnWindowAddedToRootWindow(this); | 866 observer.OnWindowAddedToRootWindow(this); |
| 864 for (Window::Windows::const_iterator it = children_.begin(); | 867 for (Window::Windows::const_iterator it = children_.begin(); |
| 865 it != children_.end(); ++it) { | 868 it != children_.end(); ++it) { |
| 866 (*it)->NotifyAddedToRootWindow(); | 869 (*it)->NotifyAddedToRootWindow(); |
| 867 } | 870 } |
| 868 } | 871 } |
| 869 | 872 |
| 870 void Window::NotifyWindowHierarchyChange( | 873 void Window::NotifyWindowHierarchyChange( |
| 871 const WindowObserver::HierarchyChangeParams& params) { | 874 const WindowObserver::HierarchyChangeParams& params) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 state_modified |= | 984 state_modified |= |
| 982 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); | 985 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); |
| 983 for (Window::Windows::iterator iter = children_.begin(); | 986 for (Window::Windows::iterator iter = children_.begin(); |
| 984 iter != children_.end(); | 987 iter != children_.end(); |
| 985 ++iter) { | 988 ++iter) { |
| 986 state_modified |= (*iter)->CleanupGestureState(); | 989 state_modified |= (*iter)->CleanupGestureState(); |
| 987 } | 990 } |
| 988 return state_modified; | 991 return state_modified; |
| 989 } | 992 } |
| 990 | 993 |
| 994 std::unique_ptr<cc::CompositorFrameSink> Window::CreateCompositorFrameSink() { | |
| 995 return port_->CreateCompositorFrameSink(); | |
| 996 } | |
| 997 | |
| 998 cc::SurfaceId Window::GetSurfaceId() const { | |
| 999 return port_->GetSurfaceId(); | |
| 1000 } | |
| 1001 | |
| 991 void Window::OnPaintLayer(const ui::PaintContext& context) { | 1002 void Window::OnPaintLayer(const ui::PaintContext& context) { |
| 992 Paint(context); | 1003 Paint(context); |
| 993 } | 1004 } |
| 994 | 1005 |
| 995 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 1006 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| 996 DCHECK(layer()); | 1007 DCHECK(layer()); |
| 997 for (WindowObserver& observer : observers_) | 1008 for (WindowObserver& observer : observers_) |
| 998 observer.OnDelegatedFrameDamage(this, damage_rect_in_dip); | 1009 observer.OnDelegatedFrameDamage(this, damage_rect_in_dip); |
| 999 } | 1010 } |
| 1000 | 1011 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 layer_name = "Unnamed Window"; | 1083 layer_name = "Unnamed Window"; |
| 1073 | 1084 |
| 1074 if (id_ != -1) | 1085 if (id_ != -1) |
| 1075 layer_name += " " + base::IntToString(id_); | 1086 layer_name += " " + base::IntToString(id_); |
| 1076 | 1087 |
| 1077 layer()->set_name(layer_name); | 1088 layer()->set_name(layer_name); |
| 1078 #endif | 1089 #endif |
| 1079 } | 1090 } |
| 1080 | 1091 |
| 1081 } // namespace aura | 1092 } // namespace aura |
| OLD | NEW |