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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_window_controller.mm

Issue 2738623002: [Mac] Turn on Auto Layout for browser windows. (Closed)
Patch Set: Nits. Created 3 years, 9 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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_unittest.mm ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tabs/tab_window_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/sdk_forward_declarations.h" 8 #import "base/mac/sdk_forward_declarations.h"
9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 9 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
10 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 10 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 - (BOOL)hasDarkTheme { 56 - (BOOL)hasDarkTheme {
57 return [[self parentWindow] hasDarkTheme]; 57 return [[self parentWindow] hasDarkTheme];
58 } 58 }
59 59
60 - (BOOL)inIncognitoModeWithSystemTheme { 60 - (BOOL)inIncognitoModeWithSystemTheme {
61 return [[self parentWindow] inIncognitoModeWithSystemTheme]; 61 return [[self parentWindow] inIncognitoModeWithSystemTheme];
62 } 62 }
63 63
64 @end 64 @end
65 65
66 // Subview of the window's contentView, contains everything but the tab strip.
67 @interface ChromeContentView : NSView
68 @end
69
70 @implementation ChromeContentView
71
72 // NSView overrides.
73
74 // Since Auto Layout and frame-based layout behave differently in small but
75 // important ways (e.g. Auto Layout can restrict window resizing, frame-based
76 // layout doesn't log a warning when a view's autoresizing mask can't be
77 // maintained), ensure that it's on instead of letting it depend on content.
78 + (BOOL)requiresConstraintBasedLayout {
79 return YES;
80 }
81
82 @end
83
66 @implementation TabWindowController 84 @implementation TabWindowController
67 85
68 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip 86 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip
69 titleBar:(BOOL)hasTitleBar { 87 titleBar:(BOOL)hasTitleBar {
70 const CGFloat kDefaultWidth = 750; 88 const CGFloat kDefaultWidth = 750;
71 const CGFloat kDefaultHeight = 600; 89 const CGFloat kDefaultHeight = 600;
72 90
73 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight); 91 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
74 base::scoped_nsobject<FramedBrowserWindow> window( 92 base::scoped_nsobject<FramedBrowserWindow> window(
75 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 93 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
76 hasTabStrip:hasTabStrip]); 94 hasTabStrip:hasTabStrip]);
77 [window setReleasedWhenClosed:YES]; 95 [window setReleasedWhenClosed:YES];
78 [window setAutorecalculatesKeyViewLoop:YES]; 96 [window setAutorecalculatesKeyViewLoop:YES];
79 97
80 if ((self = [super initWithWindow:window])) { 98 if ((self = [super initWithWindow:window])) {
81 [[self window] setDelegate:self]; 99 [[self window] setDelegate:self];
82 100
83 chromeContentView_.reset([[NSView alloc] 101 chromeContentView_.reset([[ChromeContentView alloc]
84 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]); 102 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]);
85 [chromeContentView_ 103 [chromeContentView_
86 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 104 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
87 [chromeContentView_ setWantsLayer:YES]; 105 [chromeContentView_ setWantsLayer:YES];
88 [[[self window] contentView] addSubview:chromeContentView_]; 106 [[[self window] contentView] addSubview:chromeContentView_];
89 107
90 tabContentArea_.reset( 108 tabContentArea_.reset(
91 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]); 109 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
92 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | 110 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
93 NSViewHeightSizable]; 111 NSViewHeightSizable];
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 472
455 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { 473 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification {
456 [[visualEffectView_ animator] setAlphaValue:0.0]; 474 [[visualEffectView_ animator] setAlphaValue:0.0];
457 } 475 }
458 476
459 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification { 477 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification {
460 [[visualEffectView_ animator] setAlphaValue:1.0]; 478 [[visualEffectView_ animator] setAlphaValue:1.0];
461 } 479 }
462 480
463 @end 481 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698