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 "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // is still a valid pointer, then reset it. | 98 // is still a valid pointer, then reset it. |
99 if (bridge_) { | 99 if (bridge_) { |
100 delegate_->OnNativeWidgetDestroying(); | 100 delegate_->OnNativeWidgetDestroying(); |
101 bridge_.reset(); | 101 bridge_.reset(); |
102 } | 102 } |
103 delegate_->OnNativeWidgetDestroyed(); | 103 delegate_->OnNativeWidgetDestroyed(); |
104 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 104 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
105 delete this; | 105 delete this; |
106 } | 106 } |
107 | 107 |
108 int NativeWidgetMac::SheetPositionY() { | |
109 NSWindow* ns_window = GetNativeWindow(); | |
110 return NSHeight([ns_window frame]) - NSMaxY([[ns_window contentView] frame]); | |
tapted
2015/08/26 07:27:48
If it makes it simpler... maybe make SheetPosition
jackhou1
2015/08/27 05:38:09
Done.
It makes the BrowserFrameMac version simple
| |
111 } | |
112 | |
108 //////////////////////////////////////////////////////////////////////////////// | 113 //////////////////////////////////////////////////////////////////////////////// |
109 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: | 114 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: |
110 | 115 |
111 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { | 116 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { |
112 ownership_ = params.ownership; | 117 ownership_ = params.ownership; |
113 base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]); | 118 base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]); |
114 [window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject. | 119 [window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject. |
115 bridge_->Init(window, params); | 120 bridge_->Init(window, params); |
116 | 121 |
117 // Only set always-on-top here if it is true since setting it may affect how | 122 // Only set always-on-top here if it is true since setting it may affect how |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 711 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
707 } | 712 } |
708 | 713 |
709 - (void)animationDidEnd:(NSAnimation*)animation { | 714 - (void)animationDidEnd:(NSAnimation*)animation { |
710 [window_ close]; | 715 [window_ close]; |
711 [animation_ setDelegate:nil]; | 716 [animation_ setDelegate:nil]; |
712 [self release]; | 717 [self release]; |
713 } | 718 } |
714 | 719 |
715 @end | 720 @end |
OLD | NEW |