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

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

Issue 607723002: mac: Refactor tab strip layout logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tabstrip_relayout_bug_base
Patch Set: Fix unit test. Created 6 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
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_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_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 int modelIndex = tabStripModel_->active_index(); 2195 int modelIndex = tabStripModel_->active_index();
2196 if (modelIndex < 0) 2196 if (modelIndex < 0)
2197 return nil; 2197 return nil;
2198 NSInteger index = [self indexFromModelIndex:modelIndex]; 2198 NSInteger index = [self indexFromModelIndex:modelIndex];
2199 if (index < 0 || 2199 if (index < 0 ||
2200 index >= (NSInteger)[tabContentsArray_ count]) 2200 index >= (NSInteger)[tabContentsArray_ count])
2201 return nil; 2201 return nil;
2202 return [tabContentsArray_ objectAtIndex:index]; 2202 return [tabContentsArray_ objectAtIndex:index];
2203 } 2203 }
2204 2204
2205 - (void)addWindowControls { 2205 - (void)addCustomWindowControls {
2206 if (!fullscreenWindowControls_) { 2206 if (!customWindowControls_) {
2207 // Make the container view. 2207 // Make the container view.
2208 CGFloat height = NSHeight([tabStripView_ frame]); 2208 CGFloat height = NSHeight([tabStripView_ frame]);
2209 NSRect frame = NSMakeRect(0, 0, [self leftIndentForControls], height); 2209 NSRect frame = NSMakeRect(0, 0, [self leftIndentForControls], height);
2210 fullscreenWindowControls_.reset([[NSView alloc] initWithFrame:frame]); 2210 customWindowControls_.reset([[NSView alloc] initWithFrame:frame]);
2211 [fullscreenWindowControls_ 2211 [customWindowControls_
2212 setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable]; 2212 setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
2213 2213
2214 // Add the traffic light buttons. The horizontal layout was determined by 2214 // Add the traffic light buttons. The horizontal layout was determined by
2215 // manual inspection on Yosemite. 2215 // manual inspection on Yosemite.
2216 CGFloat closeButtonX = 11; 2216 CGFloat closeButtonX = 11;
2217 CGFloat miniButtonX = 31; 2217 CGFloat miniButtonX = 31;
2218 CGFloat zoomButtonX = 51; 2218 CGFloat zoomButtonX = 51;
2219 2219
2220 NSUInteger styleMask = [[tabStripView_ window] styleMask]; 2220 NSUInteger styleMask = [[tabStripView_ window] styleMask];
2221 NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton 2221 NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton
2222 forStyleMask:styleMask]; 2222 forStyleMask:styleMask];
2223 2223
2224 // Vertically center the buttons in the tab strip. 2224 // Vertically center the buttons in the tab strip.
2225 CGFloat buttonY = floor((height - NSHeight([closeButton bounds])) / 2); 2225 CGFloat buttonY = floor((height - NSHeight([closeButton bounds])) / 2);
2226 [closeButton setFrameOrigin:NSMakePoint(closeButtonX, buttonY)]; 2226 [closeButton setFrameOrigin:NSMakePoint(closeButtonX, buttonY)];
2227 [fullscreenWindowControls_ addSubview:closeButton]; 2227 [customWindowControls_ addSubview:closeButton];
2228 2228
2229 NSButton* miniaturizeButton = 2229 NSButton* miniaturizeButton =
2230 [NSWindow standardWindowButton:NSWindowMiniaturizeButton 2230 [NSWindow standardWindowButton:NSWindowMiniaturizeButton
2231 forStyleMask:styleMask]; 2231 forStyleMask:styleMask];
2232 [miniaturizeButton setFrameOrigin:NSMakePoint(miniButtonX, buttonY)]; 2232 [miniaturizeButton setFrameOrigin:NSMakePoint(miniButtonX, buttonY)];
2233 [miniaturizeButton setEnabled:NO]; 2233 [miniaturizeButton setEnabled:NO];
2234 [fullscreenWindowControls_ addSubview:miniaturizeButton]; 2234 [customWindowControls_ addSubview:miniaturizeButton];
2235 2235
2236 NSButton* zoomButton = 2236 NSButton* zoomButton =
2237 [NSWindow standardWindowButton:NSWindowZoomButton 2237 [NSWindow standardWindowButton:NSWindowZoomButton
2238 forStyleMask:styleMask]; 2238 forStyleMask:styleMask];
2239 [fullscreenWindowControls_ addSubview:zoomButton]; 2239 [customWindowControls_ addSubview:zoomButton];
2240 [zoomButton setFrameOrigin:NSMakePoint(zoomButtonX, buttonY)]; 2240 [zoomButton setFrameOrigin:NSMakePoint(zoomButtonX, buttonY)];
2241 } 2241 }
2242 2242
2243 if (![permanentSubviews_ containsObject:fullscreenWindowControls_]) { 2243 if (![permanentSubviews_ containsObject:customWindowControls_]) {
2244 [self addSubviewToPermanentList:fullscreenWindowControls_]; 2244 [self addSubviewToPermanentList:customWindowControls_];
2245 [self regenerateSubviewList]; 2245 [self regenerateSubviewList];
2246 } 2246 }
2247 } 2247 }
2248 2248
2249 - (void)removeWindowControls { 2249 - (void)removeCustomWindowControls {
2250 if (fullscreenWindowControls_) 2250 if (customWindowControls_)
2251 [permanentSubviews_ removeObject:fullscreenWindowControls_]; 2251 [permanentSubviews_ removeObject:customWindowControls_];
2252 [self regenerateSubviewList]; 2252 [self regenerateSubviewList];
2253 } 2253 }
2254 2254
2255 - (void)themeDidChangeNotification:(NSNotification*)notification { 2255 - (void)themeDidChangeNotification:(NSNotification*)notification {
2256 [self setNewTabImages]; 2256 [self setNewTabImages];
2257 } 2257 }
2258 2258
2259 - (void)setNewTabImages { 2259 - (void)setNewTabImages {
2260 ThemeService *theme = 2260 ThemeService *theme =
2261 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]); 2261 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 } 2309 }
2310 2310
2311 NSRect GetSheetParentBoundsForParentView(NSView* view) { 2311 NSRect GetSheetParentBoundsForParentView(NSView* view) {
2312 // If the devtools view is open, it shrinks the size of the WebContents, so go 2312 // If the devtools view is open, it shrinks the size of the WebContents, so go
2313 // up the hierarchy to the devtools container view to avoid that. Note that 2313 // up the hierarchy to the devtools container view to avoid that. Note that
2314 // the devtools view is always in the hierarchy even if it is not open or it 2314 // the devtools view is always in the hierarchy even if it is not open or it
2315 // is detached. 2315 // is detached.
2316 NSView* devtools_view = [[[view superview] superview] superview]; 2316 NSView* devtools_view = [[[view superview] superview] superview];
2317 return [devtools_view convertRect:[devtools_view bounds] toView:nil]; 2317 return [devtools_view convertRect:[devtools_view bounds] toView:nil];
2318 } 2318 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698