| 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 | |
| 41 @end | 35 @end |
| 42 | 36 |
| 43 @implementation NSWindow (VersionIndependentWindow) | 37 @implementation NSWindow (VersionIndependentWindow) |
| 44 | 38 |
| 45 - (NSView*)cr_windowView { | 39 - (NSView*)cr_windowView { |
| 46 if ([self isKindOfClass:[VersionIndependentWindow class]]) { | 40 if ([self isKindOfClass:[VersionIndependentWindow class]]) { |
| 47 VersionIndependentWindow* window = | 41 VersionIndependentWindow* window = |
| 48 static_cast<VersionIndependentWindow*>(self); | 42 static_cast<VersionIndependentWindow*>(self); |
| 49 NSView* chromeWindowView = [window chromeWindowView]; | 43 NSView* chromeWindowView = [window chromeWindowView]; |
| 50 if (chromeWindowView) | 44 if (chromeWindowView) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 72 self = [super initWithContentRect:contentRect | 66 self = [super initWithContentRect:contentRect |
| 73 styleMask:windowStyle | 67 styleMask:windowStyle |
| 74 backing:bufferingType | 68 backing:bufferingType |
| 75 defer:deferCreation]; | 69 defer:deferCreation]; |
| 76 if (self) { | 70 if (self) { |
| 77 if ([VersionIndependentWindow | 71 if ([VersionIndependentWindow |
| 78 shouldUseFullSizeContentViewForStyle:windowStyle]) { | 72 shouldUseFullSizeContentViewForStyle:windowStyle]) { |
| 79 chromeWindowView_.reset([[FullSizeContentView alloc] init]); | 73 chromeWindowView_.reset([[FullSizeContentView alloc] init]); |
| 80 [chromeWindowView_ | 74 [chromeWindowView_ |
| 81 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 75 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 76 [self setContentView:chromeWindowView_]; |
| 82 [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]]; | 77 [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]]; |
| 83 [self setContentView:chromeWindowView_]; | |
| 84 } | 78 } |
| 85 } | 79 } |
| 86 return self; | 80 return self; |
| 87 } | 81 } |
| 88 | 82 |
| 89 #pragma mark - Private Methods | 83 #pragma mark - Private Methods |
| 90 | 84 |
| 91 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle { | 85 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle { |
| 92 return (windowStyle & NSTitledWindowMask) && base::mac::IsOSYosemiteOrLater(); | 86 return (windowStyle & NSTitledWindowMask) && base::mac::IsOSYosemiteOrLater(); |
| 93 } | 87 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return [super contentRectForFrameRect:fRect styleMask:aStyle]; | 134 return [super contentRectForFrameRect:fRect styleMask:aStyle]; |
| 141 } | 135 } |
| 142 | 136 |
| 143 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { | 137 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { |
| 144 if (chromeWindowView_) | 138 if (chromeWindowView_) |
| 145 return frameRect; | 139 return frameRect; |
| 146 return [super contentRectForFrameRect:frameRect]; | 140 return [super contentRectForFrameRect:frameRect]; |
| 147 } | 141 } |
| 148 | 142 |
| 149 @end | 143 @end |
| OLD | NEW |