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

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

Issue 520733004: mac, yosemite: Resize button causes fullscreen effect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against top of tree. Created 6 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
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_window_controller.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 (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 "chrome/browser/ui/cocoa/fast_resize_view.h" 8 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
9 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 9 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 @end 45 @end
46 46
47 @implementation TabWindowController 47 @implementation TabWindowController
48 48
49 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip { 49 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip {
50 NSRect contentRect = NSMakeRect(60, 229, 750, 600); 50 NSRect contentRect = NSMakeRect(60, 229, 750, 600);
51 base::scoped_nsobject<FramedBrowserWindow> window( 51 base::scoped_nsobject<FramedBrowserWindow> window(
52 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 52 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
53 hasTabStrip:hasTabStrip]); 53 hasTabStrip:hasTabStrip]);
54 [self moveContentViewToBack:[window contentView]];
54 [window setReleasedWhenClosed:YES]; 55 [window setReleasedWhenClosed:YES];
55 [window setAutorecalculatesKeyViewLoop:YES]; 56 [window setAutorecalculatesKeyViewLoop:YES];
56 57
57 if ((self = [super initWithWindow:window])) { 58 if ((self = [super initWithWindow:window])) {
58 [[self window] setDelegate:self]; 59 [[self window] setDelegate:self];
59 60
60 tabContentArea_.reset([[FastResizeView alloc] initWithFrame: 61 tabContentArea_.reset([[FastResizeView alloc] initWithFrame:
61 NSMakeRect(0, 0, 750, 600)]); 62 NSMakeRect(0, 0, 750, 600)]);
62 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | 63 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
63 NSViewHeightSizable]; 64 NSViewHeightSizable];
64 [[[self window] contentView] addSubview:tabContentArea_]; 65 [[[self window] contentView] addSubview:tabContentArea_];
65 66
66 tabStripView_.reset([[TabStripView alloc] initWithFrame: 67 tabStripView_.reset([[TabStripView alloc] initWithFrame:
67 NSMakeRect(0, 0, 750, 37)]); 68 NSMakeRect(0, 0, 750, 37)]);
68 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | 69 [tabStripView_ setAutoresizingMask:NSViewWidthSizable |
69 NSViewMinYMargin]; 70 NSViewMinYMargin];
70 if (hasTabStrip) 71 if (hasTabStrip)
71 [self addTabStripToWindow]; 72 [self insertTabStripView:tabStripView_ intoWindow:[self window]];
72 } 73 }
73 return self; 74 return self;
74 } 75 }
75 76
76 - (TabStripView*)tabStripView { 77 - (TabStripView*)tabStripView {
77 return tabStripView_; 78 return tabStripView_;
78 } 79 }
79 80
80 - (FastResizeView*)tabContentArea { 81 - (FastResizeView*)tabContentArea {
81 return tabContentArea_; 82 return tabContentArea_;
82 } 83 }
83 84
84 // Add the top tab strop to the window, above the content box and add it to the
85 // view hierarchy as a sibling of the content view so it can overlap with the
86 // window frame.
87 - (void)addTabStripToWindow {
88 // The frame doesn't matter. This class relies on subclasses to do tab strip
89 // layout.
90 NSView* contentParent = [[self window] cr_windowView];
91 [contentParent addSubview:tabStripView_];
92 }
93
94 - (void)removeOverlay { 85 - (void)removeOverlay {
95 [self setUseOverlay:NO]; 86 [self setUseOverlay:NO];
96 if (closeDeferred_) { 87 if (closeDeferred_) {
97 // See comment in BrowserWindowCocoa::Close() about orderOut:. 88 // See comment in BrowserWindowCocoa::Close() about orderOut:.
98 [[self window] orderOut:self]; 89 [[self window] orderOut:self];
99 [[self window] performClose:self]; // Autoreleases the controller. 90 [[self window] performClose:self]; // Autoreleases the controller.
100 } 91 }
101 } 92 }
102 93
103 - (void)showOverlay { 94 - (void)showOverlay {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 138
148 [overlayWindow_ orderFront:nil]; 139 [overlayWindow_ orderFront:nil];
149 } else if (!useOverlay && overlayWindow_) { 140 } else if (!useOverlay && overlayWindow_) {
150 DCHECK(originalContentView_); 141 DCHECK(originalContentView_);
151 142
152 // Return the original window's tab strip view and content view to their 143 // Return the original window's tab strip view and content view to their
153 // places. The TabStripView always needs to be in front of the window's 144 // places. The TabStripView always needs to be in front of the window's
154 // content view and therefore it should always be added after the content 145 // content view and therefore it should always be added after the content
155 // view is set. 146 // view is set.
156 [window setContentView:originalContentView_]; 147 [window setContentView:originalContentView_];
157 [[window cr_windowView] addSubview:[self tabStripView]]; 148 [self moveContentViewToBack:originalContentView_];
149 [self insertTabStripView:[self tabStripView] intoWindow:window];
158 [[window cr_windowView] updateTrackingAreas]; 150 [[window cr_windowView] updateTrackingAreas];
159 151
160 [focusBeforeOverlay_ restoreFocusInWindow:window]; 152 [focusBeforeOverlay_ restoreFocusInWindow:window];
161 focusBeforeOverlay_.reset(); 153 focusBeforeOverlay_.reset();
162 154
163 [window display]; 155 [window display];
164 [window removeChildWindow:overlayWindow_]; 156 [window removeChildWindow:overlayWindow_];
165 157
166 [overlayWindow_ orderOut:nil]; 158 [overlayWindow_ orderOut:nil];
167 [overlayWindow_ release]; 159 [overlayWindow_ release];
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return YES; 277 return YES;
286 } 278 }
287 279
288 // Tell the window that it needs to call performClose: as soon as the current 280 // Tell the window that it needs to call performClose: as soon as the current
289 // drag is complete. This prevents a window (and its overlay) from going away 281 // drag is complete. This prevents a window (and its overlay) from going away
290 // during a drag. 282 // during a drag.
291 - (void)deferPerformClose { 283 - (void)deferPerformClose {
292 closeDeferred_ = YES; 284 closeDeferred_ = YES;
293 } 285 }
294 286
287 - (void)moveContentViewToBack:(NSView*)cv {
288 base::scoped_nsobject<NSView> contentView([cv retain]);
289 NSView* superview = [contentView superview];
290 [contentView removeFromSuperview];
291 [superview addSubview:contentView positioned:NSWindowBelow relativeTo:nil];
292 }
293
294 - (void)insertTabStripView:(NSView*)tabStripView intoWindow:(NSWindow*)window {
295 NSView* contentParent = [window cr_windowView];
296 if (contentParent == [[window contentView] superview]) {
297 // Add the tab strip directly above the content view, if they are siblings.
298 [contentParent addSubview:tabStripView
299 positioned:NSWindowAbove
300 relativeTo:[window contentView]];
301 } else {
302 [contentParent addSubview:tabStripView];
303 }
304 }
305
295 // Called when the size of the window content area has changed. Override to 306 // Called when the size of the window content area has changed. Override to
296 // position specific views. Base class implementation does nothing. 307 // position specific views. Base class implementation does nothing.
297 - (void)layoutSubviews { 308 - (void)layoutSubviews {
298 NOTIMPLEMENTED(); 309 NOTIMPLEMENTED();
299 } 310 }
300 311
301 @end 312 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698