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

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

Issue 2404783002: [Mac] Avoid "adding unknown subview" warning. (Closed)
Patch Set: Merged with head Created 4 years, 2 months 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
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 <crt_externs.h> 7 #include <crt_externs.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/mac/scoped_objc_class_swizzler.h" 12 #include "base/mac/scoped_objc_class_swizzler.h"
13 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
13 14
14 @interface FullSizeContentWindow () 15 @interface FullSizeContentWindow ()
15 16
16 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle; 17 + (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle;
17 18
18 @end 19 @end
19 20
20 // This view always takes the size of its superview. It is intended to be used 21 // This view always takes the size of its superview. It is intended to be used
21 // as a NSWindow's contentView. It is needed because NSWindow's implementation 22 // as a NSWindow's contentView. It is needed because NSWindow's implementation
22 // explicitly resizes the contentView at inopportune times. 23 // explicitly resizes the contentView at inopportune times.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (self) { 133 if (self) {
133 if (wantsViewsOverTitlebar && 134 if (wantsViewsOverTitlebar &&
134 [FullSizeContentWindow 135 [FullSizeContentWindow
135 shouldUseFullSizeContentViewForStyle:windowStyle]) { 136 shouldUseFullSizeContentViewForStyle:windowStyle]) {
136 chromeWindowView_.reset([[FullSizeContentView alloc] init]); 137 chromeWindowView_.reset([[FullSizeContentView alloc] init]);
137 [chromeWindowView_ 138 [chromeWindowView_
138 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 139 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
139 [self setContentView:chromeWindowView_]; 140 [self setContentView:chromeWindowView_];
140 [chromeWindowView_ setFrame:[[chromeWindowView_ superview] bounds]]; 141 [chromeWindowView_ setFrame:[[chromeWindowView_ superview] bounds]];
141 142
142 // Our content view overlaps the window control buttons, so we must ensure 143 if (!chrome::ShouldUseFullSizeContentView()) {
143 // it is positioned below the buttons. 144 // Chrome content view overlaps the window control buttons. Adding
144 NSView* superview = [chromeWindowView_ superview]; 145 // subview above the window's content view ensures that content view is
145 [chromeWindowView_ removeFromSuperview]; 146 // positioned below the buttons.
147 NSView* superview = [chromeWindowView_ superview];
148 [chromeWindowView_ removeFromSuperview];
146 149
147 // Prevent the AppKit from generating a backtrace to include in it's 150 // Prevent the AppKit from generating a backtrace to include in it's
148 // complaint about our upcoming call to addSubview:positioned:relativeTo:. 151 // complaint about our upcoming call to
149 // See +load for more info. 152 // addSubview:positioned:relativeTo:. See +load for more info.
150 base::AutoReset<bool> disable_symbolication(&g_disable_callstacksymbols, 153 base::AutoReset<bool> disable_symbolication(&g_disable_callstacksymbols,
151 true); 154 true);
152 155
153 [superview addSubview:chromeWindowView_ 156 [superview addSubview:chromeWindowView_
154 positioned:NSWindowBelow 157 positioned:NSWindowBelow
155 relativeTo:nil]; 158 relativeTo:nil];
159 }
156 } 160 }
157 } 161 }
158 return self; 162 return self;
159 } 163 }
160 164
161 - (void)forceContentViewFrame:(NSRect)frame { 165 - (void)forceContentViewFrame:(NSRect)frame {
162 if ([chromeWindowView_ isKindOfClass:[FullSizeContentView class]]) { 166 if ([chromeWindowView_ isKindOfClass:[FullSizeContentView class]]) {
163 FullSizeContentView* contentView = 167 FullSizeContentView* contentView =
164 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_); 168 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_);
165 [contentView forceFrame:frame]; 169 [contentView forceFrame:frame];
(...skipping 30 matching lines...) Expand all
196 return [super contentRectForFrameRect:fRect styleMask:aStyle]; 200 return [super contentRectForFrameRect:fRect styleMask:aStyle];
197 } 201 }
198 202
199 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { 203 - (NSRect)contentRectForFrameRect:(NSRect)frameRect {
200 if (chromeWindowView_) 204 if (chromeWindowView_)
201 return frameRect; 205 return frameRect;
202 return [super contentRectForFrameRect:frameRect]; 206 return [super contentRectForFrameRect:frameRect];
203 } 207 }
204 208
205 @end 209 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698