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

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: Trigger Auto Layout from chromeContentView, which covers all browser windows. 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
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 @interface ChromeContentView : NSView
tapted 2017/03/22 22:40:00 comment like // Subview of the NSWindow's content
Sidney San Martín 2017/03/22 23:29:59 Done.
67 @end
68
69 @implementation ChromeContentView
70
71 #pragma mark - NSView Overrides
tapted 2017/03/22 22:40:00 optional: a comment here like // NSView overrides
Sidney San Martín 2017/03/22 23:29:59 Done. Xcode likes `#pragma mark -` (there's a popu
72
73 // Since Auto Layout and frame-based layout behave differently in small but
74 // important ways (e.g. Auto Layout can restrict window resizing, frame-based
75 // layout doesn't log a warning when a view's autoresizing mask can't be
76 // maintained), ensure that it's on instead of letting it depend on content.
77 + (BOOL)requiresConstraintBasedLayout {
78 return YES;
79 }
80
81 @end
82
66 @implementation TabWindowController 83 @implementation TabWindowController
67 84
68 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip 85 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip
69 titleBar:(BOOL)hasTitleBar { 86 titleBar:(BOOL)hasTitleBar {
70 const CGFloat kDefaultWidth = 750; 87 const CGFloat kDefaultWidth = 750;
71 const CGFloat kDefaultHeight = 600; 88 const CGFloat kDefaultHeight = 600;
72 89
73 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight); 90 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
74 base::scoped_nsobject<FramedBrowserWindow> window( 91 base::scoped_nsobject<FramedBrowserWindow> window(
75 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 92 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
76 hasTabStrip:hasTabStrip]); 93 hasTabStrip:hasTabStrip]);
77 [window setReleasedWhenClosed:YES]; 94 [window setReleasedWhenClosed:YES];
78 [window setAutorecalculatesKeyViewLoop:YES]; 95 [window setAutorecalculatesKeyViewLoop:YES];
79 96
80 if ((self = [super initWithWindow:window])) { 97 if ((self = [super initWithWindow:window])) {
81 [[self window] setDelegate:self]; 98 [[self window] setDelegate:self];
82 99
83 chromeContentView_.reset([[NSView alloc] 100 chromeContentView_.reset([[ChromeContentView alloc]
tapted 2017/03/22 22:40:00 I think this will capture popups, but not packaged
Sidney San Martín 2017/03/22 23:29:59 Oh, good to know. I may be working on that change
84 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]); 101 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]);
85 [chromeContentView_ 102 [chromeContentView_
86 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 103 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
87 [chromeContentView_ setWantsLayer:YES]; 104 [chromeContentView_ setWantsLayer:YES];
88 [[[self window] contentView] addSubview:chromeContentView_]; 105 [[[self window] contentView] addSubview:chromeContentView_];
89 106
90 tabContentArea_.reset( 107 tabContentArea_.reset(
91 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]); 108 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
92 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | 109 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
93 NSViewHeightSizable]; 110 NSViewHeightSizable];
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 471
455 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { 472 - (void)windowWillEnterFullScreenNotification:(NSNotification*)notification {
456 [[visualEffectView_ animator] setAlphaValue:0.0]; 473 [[visualEffectView_ animator] setAlphaValue:0.0];
457 } 474 }
458 475
459 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification { 476 - (void)windowWillExitFullScreenNotification:(NSNotification*)notification {
460 [[visualEffectView_ animator] setAlphaValue:1.0]; 477 [[visualEffectView_ animator] setAlphaValue:1.0];
461 } 478 }
462 479
463 @end 480 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698