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

Side by Side Diff: chrome/browser/ui/cocoa/full_size_content_window.mm

Issue 1408033010: Fix for Exit Fullscreen Animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comment Created 5 years, 1 month 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 | « chrome/browser/ui/cocoa/full_size_content_window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/full_size_content_window.h" 5 #import "chrome/browser/ui/cocoa/full_size_content_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 9
10 @interface FullSizeContentWindow () 10 @interface FullSizeContentWindow ()
11 11
12 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle; 12 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle;
13 13
14 @end 14 @end
15 15
16 // This view always takes the size of its superview. It is intended to be used 16 // This view always takes the size of its superview. It is intended to be used
17 // as a NSWindow's contentView. It is needed because NSWindow's implementation 17 // as a NSWindow's contentView. It is needed because NSWindow's implementation
18 // explicitly resizes the contentView at inopportune times. 18 // explicitly resizes the contentView at inopportune times.
19 @interface FullSizeContentView : NSView 19 @interface FullSizeContentView : NSView {
20 BOOL forceFrameFlag_;
21 }
20 22
21 // This method allows us to set the content view size since setFrameSize is 23 // This method allows us to set the content view size since setFrameSize is
22 // overridden to prevent the view from shrinking. 24 // overridden to prevent the view from shrinking.
23 - (void)forceFrameSize:(NSSize)size; 25 - (void)forceFrame:(NSRect)frame;
24 26
25 @end 27 @end
26 28
27 @implementation FullSizeContentView 29 @implementation FullSizeContentView
28 30
29 // This method is directly called by AppKit during a live window resize. 31 // This method is directly called by AppKit during a live window resize.
30 // Override it to prevent the content view from shrinking. 32 // Override it to prevent the content view from shrinking.
31 - (void)setFrameSize:(NSSize)size { 33 - (void)setFrameSize:(NSSize)size {
32 if ([self superview]) 34 if ([self superview] && !forceFrameFlag_)
33 size = [[self superview] bounds].size; 35 size = [[self superview] bounds].size;
34 [super setFrameSize:size]; 36 [super setFrameSize:size];
35 } 37 }
36 38
37 - (void)forceFrameSize:(NSSize)size { 39 - (void)forceFrame:(NSRect)frame {
38 [super setFrameSize:size]; 40 forceFrameFlag_ = YES;
41 [super setFrame:frame];
42 forceFrameFlag_ = NO;
39 } 43 }
40 44
41 @end 45 @end
42 46
43 @implementation FullSizeContentWindow 47 @implementation FullSizeContentWindow
44 48
45 #pragma mark - Lifecycle 49 #pragma mark - Lifecycle
46 50
47 - (instancetype)init { 51 - (instancetype)init {
48 NOTREACHED(); 52 NOTREACHED();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 NSView* superview = [chromeWindowView_ superview]; 88 NSView* superview = [chromeWindowView_ superview];
85 [chromeWindowView_ removeFromSuperview]; 89 [chromeWindowView_ removeFromSuperview];
86 [superview addSubview:chromeWindowView_ 90 [superview addSubview:chromeWindowView_
87 positioned:NSWindowBelow 91 positioned:NSWindowBelow
88 relativeTo:nil]; 92 relativeTo:nil];
89 } 93 }
90 } 94 }
91 return self; 95 return self;
92 } 96 }
93 97
94 - (void)forceContentViewSize:(NSSize)size { 98 - (void)forceContentViewFrame:(NSRect)frame {
95 FullSizeContentView* contentView = 99 FullSizeContentView* contentView =
96 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_); 100 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_);
97 [contentView forceFrameSize:size]; 101 [contentView forceFrame:frame];
98 } 102 }
99 103
100 #pragma mark - Private Methods 104 #pragma mark - Private Methods
101 105
102 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle { 106 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle {
103 return windowStyle & NSTitledWindowMask; 107 return windowStyle & NSTitledWindowMask;
104 } 108 }
105 109
106 #pragma mark - NSWindow Overrides 110 #pragma mark - NSWindow Overrides
107 111
(...skipping 15 matching lines...) Expand all
123 return [super contentRectForFrameRect:fRect styleMask:aStyle]; 127 return [super contentRectForFrameRect:fRect styleMask:aStyle];
124 } 128 }
125 129
126 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { 130 - (NSRect)contentRectForFrameRect:(NSRect)frameRect {
127 if (chromeWindowView_) 131 if (chromeWindowView_)
128 return frameRect; 132 return frameRect;
129 return [super contentRectForFrameRect:frameRect]; 133 return [super contentRectForFrameRect:frameRect];
130 } 134 }
131 135
132 @end 136 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/full_size_content_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698