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

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

Issue 2351183003: [Mac] Avoid "adding unknown subview" warning. (Closed)
Patch Set: Created 4 years, 3 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/mac_util.h"
12 #include "base/mac/scoped_objc_class_swizzler.h" 13 #include "base/mac/scoped_objc_class_swizzler.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
(...skipping 110 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 (base::mac::IsAtMostOS10_10()) {
143 // it is positioned below the buttons. 144 // Our content view overlaps the window control buttons, so we must
144 NSView* superview = [chromeWindowView_ superview]; 145 // ensureit is positioned below the buttons.
erikchen 2016/09/20 23:07:47 s/ensureit/ensure it/
shrike 2016/09/20 23:27:17 Done.
145 [chromeWindowView_ removeFromSuperview]; 146 NSView* superview = [chromeWindowView_ superview];
147 [chromeWindowView_ removeFromSuperview];
146 148
147 // Prevent the AppKit from generating a backtrace to include in it's 149 // Prevent the AppKit from generating a backtrace to include in it's
148 // complaint about our upcoming call to addSubview:positioned:relativeTo:. 150 // complaint about our upcoming call to
149 // See +load for more info. 151 // addSubview:positioned:relativeTo:. See +load for more info.
150 base::AutoReset<bool> disable_symbolication(&g_disable_callstacksymbols, 152 base::AutoReset<bool> disable_symbolication(&g_disable_callstacksymbols,
151 true); 153 true);
152 154
153 [superview addSubview:chromeWindowView_ 155 [superview addSubview:chromeWindowView_
154 positioned:NSWindowBelow 156 positioned:NSWindowBelow
155 relativeTo:nil]; 157 relativeTo:nil];
158 }
156 } 159 }
157 } 160 }
158 return self; 161 return self;
159 } 162 }
160 163
161 - (void)forceContentViewFrame:(NSRect)frame { 164 - (void)forceContentViewFrame:(NSRect)frame {
162 if ([chromeWindowView_ isKindOfClass:[FullSizeContentView class]]) { 165 if ([chromeWindowView_ isKindOfClass:[FullSizeContentView class]]) {
163 FullSizeContentView* contentView = 166 FullSizeContentView* contentView =
164 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_); 167 base::mac::ObjCCast<FullSizeContentView>(chromeWindowView_);
165 [contentView forceFrame:frame]; 168 [contentView forceFrame:frame];
(...skipping 30 matching lines...) Expand all
196 return [super contentRectForFrameRect:fRect styleMask:aStyle]; 199 return [super contentRectForFrameRect:fRect styleMask:aStyle];
197 } 200 }
198 201
199 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { 202 - (NSRect)contentRectForFrameRect:(NSRect)frameRect {
200 if (chromeWindowView_) 203 if (chromeWindowView_)
201 return frameRect; 204 return frameRect;
202 return [super contentRectForFrameRect:frameRect]; 205 return [super contentRectForFrameRect:frameRect];
203 } 206 }
204 207
205 @end 208 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698