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 #import "chrome/browser/ui/cocoa/version_independent_window.h" | 5 #import "chrome/browser/ui/cocoa/version_independent_window.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 | 9 |
10 @interface VersionIndependentWindow () | 10 @interface VersionIndependentWindow () |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // This method is directly called by NSWindow during a window resize on OSX | 26 // This method is directly called by NSWindow during a window resize on OSX |
27 // 10.10.0, beta 2. We must override it to prevent the content view from | 27 // 10.10.0, beta 2. We must override it to prevent the content view from |
28 // shrinking. | 28 // shrinking. |
29 - (void)setFrameSize:(NSSize)size { | 29 - (void)setFrameSize:(NSSize)size { |
30 if ([self superview]) | 30 if ([self superview]) |
31 size = [[self superview] bounds].size; | 31 size = [[self superview] bounds].size; |
32 [super setFrameSize:size]; | 32 [super setFrameSize:size]; |
33 } | 33 } |
34 | 34 |
| 35 // The contentView gets moved around during certain full-screen operations. |
| 36 // This is less than ideal, and should eventually be removed. |
| 37 - (void)viewDidMoveToSuperview { |
| 38 [self setFrame:[[self superview] bounds]]; |
| 39 } |
| 40 |
35 @end | 41 @end |
36 | 42 |
37 @implementation NSWindow (VersionIndependentWindow) | 43 @implementation NSWindow (VersionIndependentWindow) |
38 | 44 |
39 - (NSView*)cr_windowView { | 45 - (NSView*)cr_windowView { |
40 if ([self isKindOfClass:[VersionIndependentWindow class]]) { | 46 if ([self isKindOfClass:[VersionIndependentWindow class]]) { |
41 VersionIndependentWindow* window = | 47 VersionIndependentWindow* window = |
42 static_cast<VersionIndependentWindow*>(self); | 48 static_cast<VersionIndependentWindow*>(self); |
43 NSView* chromeWindowView = [window chromeWindowView]; | 49 NSView* chromeWindowView = [window chromeWindowView]; |
44 if (chromeWindowView) | 50 if (chromeWindowView) |
(...skipping 21 matching lines...) Expand all Loading... |
66 self = [super initWithContentRect:contentRect | 72 self = [super initWithContentRect:contentRect |
67 styleMask:windowStyle | 73 styleMask:windowStyle |
68 backing:bufferingType | 74 backing:bufferingType |
69 defer:deferCreation]; | 75 defer:deferCreation]; |
70 if (self) { | 76 if (self) { |
71 if ([VersionIndependentWindow | 77 if ([VersionIndependentWindow |
72 shouldUseFullSizeContentViewForStyle:windowStyle]) { | 78 shouldUseFullSizeContentViewForStyle:windowStyle]) { |
73 chromeWindowView_.reset([[FullSizeContentView alloc] init]); | 79 chromeWindowView_.reset([[FullSizeContentView alloc] init]); |
74 [chromeWindowView_ | 80 [chromeWindowView_ |
75 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 81 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 82 [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]]; |
76 [self setContentView:chromeWindowView_]; | 83 [self setContentView:chromeWindowView_]; |
77 [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]]; | |
78 } | 84 } |
79 } | 85 } |
80 return self; | 86 return self; |
81 } | 87 } |
82 | 88 |
83 #pragma mark - Private Methods | 89 #pragma mark - Private Methods |
84 | 90 |
85 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle { | 91 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle { |
86 return (windowStyle & NSTitledWindowMask) && base::mac::IsOSYosemiteOrLater(); | 92 return (windowStyle & NSTitledWindowMask) && base::mac::IsOSYosemiteOrLater(); |
87 } | 93 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return [super contentRectForFrameRect:fRect styleMask:aStyle]; | 140 return [super contentRectForFrameRect:fRect styleMask:aStyle]; |
135 } | 141 } |
136 | 142 |
137 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { | 143 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { |
138 if (chromeWindowView_) | 144 if (chromeWindowView_) |
139 return frameRect; | 145 return frameRect; |
140 return [super contentRectForFrameRect:frameRect]; | 146 return [super contentRectForFrameRect:frameRect]; |
141 } | 147 } |
142 | 148 |
143 @end | 149 @end |
OLD | NEW |