| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| 15 #import "ui/base/cocoa/window_size_constants.h" | 15 #import "ui/base/cocoa/window_size_constants.h" |
| 16 #include "ui/gfx/font_list.h" | 16 #include "ui/gfx/font_list.h" |
| 17 #import "ui/gfx/mac/coordinate_conversion.h" | 17 #import "ui/gfx/mac/coordinate_conversion.h" |
| 18 #import "ui/gfx/mac/nswindow_frame_controls.h" | 18 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 19 #include "ui/native_theme/native_theme.h" | 19 #include "ui/native_theme/native_theme.h" |
| 20 #include "ui/native_theme/native_theme_mac.h" | 20 #include "ui/native_theme/native_theme_mac.h" |
| 21 #import "ui/views/cocoa/bridged_content_view.h" | 21 #import "ui/views/cocoa/bridged_content_view.h" |
| 22 #import "ui/views/cocoa/bridged_native_widget.h" | 22 #import "ui/views/cocoa/bridged_native_widget.h" |
| 23 #import "ui/views/cocoa/native_widget_mac_nswindow.h" | 23 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
| 24 #import "ui/views/cocoa/views_nswindow_delegate.h" | 24 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 #include "ui/views/widget/widget_mac_utils.h" |
| 26 #include "ui/views/window/native_frame_view.h" | 27 #include "ui/views/window/native_frame_view.h" |
| 27 | 28 |
| 28 // Self-owning animation delegate that starts a hide animation, then calls | 29 // Self-owning animation delegate that starts a hide animation, then calls |
| 29 // -[NSWindow close] when the animation ends, releasing itself. | 30 // -[NSWindow close] when the animation ends, releasing itself. |
| 30 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> { | 31 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> { |
| 31 @private | 32 @private |
| 32 base::scoped_nsobject<NSWindow> window_; | 33 base::scoped_nsobject<NSWindow> window_; |
| 33 base::scoped_nsobject<NSAnimation> animation_; | 34 base::scoped_nsobject<NSAnimation> animation_; |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 : nullptr; | 189 : nullptr; |
| 189 } | 190 } |
| 190 | 191 |
| 191 const ui::Layer* NativeWidgetMac::GetLayer() const { | 192 const ui::Layer* NativeWidgetMac::GetLayer() const { |
| 192 return bridge_ ? bridge_->layer() : nullptr; | 193 return bridge_ ? bridge_->layer() : nullptr; |
| 193 } | 194 } |
| 194 | 195 |
| 195 void NativeWidgetMac::ReorderNativeViews() { | 196 void NativeWidgetMac::ReorderNativeViews() { |
| 196 if (bridge_) | 197 if (bridge_) |
| 197 bridge_->SetRootView(GetWidget()->GetRootView()); | 198 bridge_->SetRootView(GetWidget()->GetRootView()); |
| 199 ReorderChildNSViews(GetWidget()); |
| 198 } | 200 } |
| 199 | 201 |
| 200 void NativeWidgetMac::ViewRemoved(View* view) { | 202 void NativeWidgetMac::ViewRemoved(View* view) { |
| 201 // TODO(tapted): Something for drag and drop might be needed here in future. | 203 // TODO(tapted): Something for drag and drop might be needed here in future. |
| 202 // See http://crbug.com/464581. A NOTIMPLEMENTED() here makes a lot of spam, | 204 // See http://crbug.com/464581. A NOTIMPLEMENTED() here makes a lot of spam, |
| 203 // so only emit it when a drag and drop could be likely. | 205 // so only emit it when a drag and drop could be likely. |
| 204 if (IsMouseButtonDown()) | 206 if (IsMouseButtonDown()) |
| 205 NOTIMPLEMENTED(); | 207 NOTIMPLEMENTED(); |
| 206 } | 208 } |
| 207 | 209 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 735 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
| 734 } | 736 } |
| 735 | 737 |
| 736 - (void)animationDidEnd:(NSAnimation*)animation { | 738 - (void)animationDidEnd:(NSAnimation*)animation { |
| 737 [window_ close]; | 739 [window_ close]; |
| 738 [animation_ setDelegate:nil]; | 740 [animation_ setDelegate:nil]; |
| 739 [self release]; | 741 [self release]; |
| 740 } | 742 } |
| 741 | 743 |
| 742 @end | 744 @end |
| OLD | NEW |