Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: ash/aura/wm_window_aura.cc

Issue 2613793002: Removes/promotes functions from WmWindowMus to WmWindowAura (Closed)
Patch Set: move WmWindowAuraTestApi to ash/test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/aura/wm_window_aura.h ('k') | ash/common/wm_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/aura/wm_window_aura.h" 5 #include "ash/aura/wm_window_aura.h"
6 6
7 #include "ash/aura/aura_layout_manager_adapter.h" 7 #include "ash/aura/aura_layout_manager_adapter.h"
8 #include "ash/aura/wm_root_window_controller_aura.h" 8 #include "ash/aura/wm_root_window_controller_aura.h"
9 #include "ash/aura/wm_shell_aura.h" 9 #include "ash/aura/wm_shell_aura.h"
10 #include "ash/common/ash_constants.h" 10 #include "ash/common/ash_constants.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void SetBounds(aura::Window* window, const gfx::Rect& bounds) { 79 void SetBounds(aura::Window* window, const gfx::Rect& bounds) {
80 SetChildBoundsDirect(window, bounds); 80 SetChildBoundsDirect(window, bounds);
81 } 81 }
82 82
83 private: 83 private:
84 DISALLOW_COPY_AND_ASSIGN(BoundsSetter); 84 DISALLOW_COPY_AND_ASSIGN(BoundsSetter);
85 }; 85 };
86 86
87 } // namespace 87 } // namespace
88 88
89 // static
90 bool WmWindowAura::default_use_empty_minimum_size_for_testing_ = false;
91
89 WmWindowAura::~WmWindowAura() { 92 WmWindowAura::~WmWindowAura() {
90 if (added_transient_observer_) 93 if (added_transient_observer_)
91 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); 94 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this);
92 95
93 window_->RemoveObserver(this); 96 window_->RemoveObserver(this);
94 } 97 }
95 98
96 // static 99 // static
97 const WmWindow* WmWindowAura::Get(const aura::Window* window) { 100 const WmWindow* WmWindowAura::Get(const aura::Window* window) {
98 if (!window) 101 if (!window)
(...skipping 25 matching lines...) Expand all
124 result[i] = WmWindowAura::GetAuraWindow(windows[i]); 127 result[i] = WmWindowAura::GetAuraWindow(windows[i]);
125 return result; 128 return result;
126 } 129 }
127 130
128 // static 131 // static
129 const aura::Window* WmWindowAura::GetAuraWindow(const WmWindow* wm_window) { 132 const aura::Window* WmWindowAura::GetAuraWindow(const WmWindow* wm_window) {
130 return wm_window ? static_cast<const WmWindowAura*>(wm_window)->aura_window() 133 return wm_window ? static_cast<const WmWindowAura*>(wm_window)->aura_window()
131 : nullptr; 134 : nullptr;
132 } 135 }
133 136
137 bool WmWindowAura::ShouldUseExtendedHitRegion() const {
138 const WmWindow* parent = Get(window_->parent());
139 return parent &&
140 static_cast<const WmWindowAura*>(parent)
141 ->children_use_extended_hit_region_;
142 }
143
134 void WmWindowAura::Destroy() { 144 void WmWindowAura::Destroy() {
135 delete window_; 145 delete window_;
136 // WARNING: this has been deleted. 146 // WARNING: this has been deleted.
137 } 147 }
138 148
139 const WmWindow* WmWindowAura::GetRootWindow() const { 149 const WmWindow* WmWindowAura::GetRootWindow() const {
140 return Get(window_->GetRootWindow()); 150 return Get(window_->GetRootWindow());
141 } 151 }
142 152
143 WmRootWindowController* WmWindowAura::GetRootWindowController() { 153 WmRootWindowController* WmWindowAura::GetRootWindowController() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 188 }
179 189
180 int WmWindowAura::GetAppType() const { 190 int WmWindowAura::GetAppType() const {
181 return window_->GetProperty(aura::client::kAppType); 191 return window_->GetProperty(aura::client::kAppType);
182 } 192 }
183 193
184 void WmWindowAura::SetAppType(int app_type) const { 194 void WmWindowAura::SetAppType(int app_type) const {
185 window_->SetProperty(aura::client::kAppType, app_type); 195 window_->SetProperty(aura::client::kAppType, app_type);
186 } 196 }
187 197
188 bool WmWindowAura::IsBubble() {
189 views::Widget* widget = views::Widget::GetWidgetForNativeView(window_);
190 return widget->widget_delegate()->AsBubbleDialogDelegate() != nullptr;
191 }
192
193 ui::Layer* WmWindowAura::GetLayer() { 198 ui::Layer* WmWindowAura::GetLayer() {
194 return window_->layer(); 199 return window_->layer();
195 } 200 }
196 201
197 bool WmWindowAura::GetLayerTargetVisibility() { 202 bool WmWindowAura::GetLayerTargetVisibility() {
198 return GetLayer()->GetTargetVisibility(); 203 return GetLayer()->GetTargetVisibility();
199 } 204 }
200 205
201 bool WmWindowAura::GetLayerVisible() { 206 bool WmWindowAura::GetLayerVisible() {
202 return GetLayer()->visible(); 207 return GetLayer()->visible();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 242
238 gfx::Rect WmWindowAura::ConvertRectToScreen(const gfx::Rect& rect) const { 243 gfx::Rect WmWindowAura::ConvertRectToScreen(const gfx::Rect& rect) const {
239 return ScreenUtil::ConvertRectToScreen(window_, rect); 244 return ScreenUtil::ConvertRectToScreen(window_, rect);
240 } 245 }
241 246
242 gfx::Rect WmWindowAura::ConvertRectFromScreen(const gfx::Rect& rect) const { 247 gfx::Rect WmWindowAura::ConvertRectFromScreen(const gfx::Rect& rect) const {
243 return ScreenUtil::ConvertRectFromScreen(window_, rect); 248 return ScreenUtil::ConvertRectFromScreen(window_, rect);
244 } 249 }
245 250
246 gfx::Size WmWindowAura::GetMinimumSize() const { 251 gfx::Size WmWindowAura::GetMinimumSize() const {
247 return window_->delegate() ? window_->delegate()->GetMinimumSize() 252 return window_->delegate() && !use_empty_minimum_size_for_testing_
248 : gfx::Size(); 253 ? window_->delegate()->GetMinimumSize()
254 : gfx::Size();
249 } 255 }
250 256
251 gfx::Size WmWindowAura::GetMaximumSize() const { 257 gfx::Size WmWindowAura::GetMaximumSize() const {
252 return window_->delegate() ? window_->delegate()->GetMaximumSize() 258 return window_->delegate() ? window_->delegate()->GetMaximumSize()
253 : gfx::Size(); 259 : gfx::Size();
254 } 260 }
255 261
256 bool WmWindowAura::GetTargetVisibility() const { 262 bool WmWindowAura::GetTargetVisibility() const {
257 return window_->TargetVisibility(); 263 return window_->TargetVisibility();
258 } 264 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 693
688 void WmWindowAura::Hide() { 694 void WmWindowAura::Hide() {
689 window_->Hide(); 695 window_->Hide();
690 } 696 }
691 697
692 void WmWindowAura::Show() { 698 void WmWindowAura::Show() {
693 window_->Show(); 699 window_->Show();
694 } 700 }
695 701
696 views::Widget* WmWindowAura::GetInternalWidget() { 702 views::Widget* WmWindowAura::GetInternalWidget() {
697 return views::Widget::GetWidgetForNativeView(window_); 703 return window_->GetProperty(kWidgetCreationTypeKey) ==
704 WidgetCreationType::INTERNAL
705 ? views::Widget::GetWidgetForNativeView(window_)
706 : nullptr;
698 } 707 }
699 708
700 void WmWindowAura::CloseWidget() { 709 void WmWindowAura::CloseWidget() {
701 DCHECK(GetInternalWidget()); 710 DCHECK(GetInternalWidget());
702 GetInternalWidget()->Close(); 711 GetInternalWidget()->Close();
703 } 712 }
704 713
705 void WmWindowAura::SetFocused() { 714 void WmWindowAura::SetFocused() {
706 aura::client::GetFocusClient(window_)->FocusWindow(window_); 715 aura::client::GetFocusClient(window_)->FocusWindow(window_);
707 } 716 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 787
779 void WmWindowAura::SetSnapsChildrenToPhysicalPixelBoundary() { 788 void WmWindowAura::SetSnapsChildrenToPhysicalPixelBoundary() {
780 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); 789 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_);
781 } 790 }
782 791
783 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { 792 void WmWindowAura::SnapToPixelBoundaryIfNecessary() {
784 wm::SnapWindowToPixelBoundary(window_); 793 wm::SnapWindowToPixelBoundary(window_);
785 } 794 }
786 795
787 void WmWindowAura::SetChildrenUseExtendedHitRegion() { 796 void WmWindowAura::SetChildrenUseExtendedHitRegion() {
797 children_use_extended_hit_region_ = true;
798 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS)
799 return;
800
788 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, 801 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
789 -kResizeOutsideBoundsSize, 802 -kResizeOutsideBoundsSize,
790 -kResizeOutsideBoundsSize); 803 -kResizeOutsideBoundsSize);
791 gfx::Insets touch_extend = 804 gfx::Insets touch_extend =
792 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); 805 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch);
793 window_->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>( 806 window_->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>(
794 window_, mouse_extend, touch_extend)); 807 window_, mouse_extend, touch_extend));
795 } 808 }
796 809
797 std::unique_ptr<views::View> WmWindowAura::CreateViewWithRecreatedLayers() { 810 std::unique_ptr<views::View> WmWindowAura::CreateViewWithRecreatedLayers() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 window_->AddPreTargetHandler(handler); 847 window_->AddPreTargetHandler(handler);
835 } 848 }
836 849
837 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { 850 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) {
838 window_->RemovePreTargetHandler(handler); 851 window_->RemovePreTargetHandler(handler);
839 } 852 }
840 853
841 WmWindowAura::WmWindowAura(aura::Window* window) 854 WmWindowAura::WmWindowAura(aura::Window* window)
842 : window_(window), 855 : window_(window),
843 // Mirrors that of aura::Window. 856 // Mirrors that of aura::Window.
844 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { 857 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY),
858 use_empty_minimum_size_for_testing_(
859 default_use_empty_minimum_size_for_testing_) {
845 window_->AddObserver(this); 860 window_->AddObserver(this);
846 window_->SetProperty(kWmWindowKey, this); 861 window_->SetProperty(kWmWindowKey, this);
847 } 862 }
848 863
849 // static 864 // static
850 bool WmWindowAura::HasInstance(const aura::Window* window) { 865 bool WmWindowAura::HasInstance(const aura::Window* window) {
851 return window->GetProperty(kWmWindowKey) != nullptr; 866 return window->GetProperty(kWmWindowKey) != nullptr;
852 } 867 }
853 868
854 void WmWindowAura::OnWindowHierarchyChanging( 869 void WmWindowAura::OnWindowHierarchyChanging(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 observer.OnTransientChildAdded(this, Get(transient)); 967 observer.OnTransientChildAdded(this, Get(transient));
953 } 968 }
954 969
955 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, 970 void WmWindowAura::OnTransientChildRemoved(aura::Window* window,
956 aura::Window* transient) { 971 aura::Window* transient) {
957 for (auto& observer : transient_observers_) 972 for (auto& observer : transient_observers_)
958 observer.OnTransientChildRemoved(this, Get(transient)); 973 observer.OnTransientChildRemoved(this, Get(transient));
959 } 974 }
960 975
961 } // namespace ash 976 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_window_aura.h ('k') | ash/common/wm_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698