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

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

Issue 196137: Improve tab-closability of right-most tab. (Closed)
Patch Set: Created 11 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 | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/tab_strip_controller.h" 5 #import "chrome/browser/cocoa/tab_strip_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/mac_util.h" 9 #include "base/mac_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 DCHECK([sender isKindOfClass:[NSView class]]); 281 DCHECK([sender isKindOfClass:[NSView class]]);
282 if ([hoveredTab_ isEqual:sender]) { 282 if ([hoveredTab_ isEqual:sender]) {
283 hoveredTab_ = nil; 283 hoveredTab_ = nil;
284 } 284 }
285 int index = [self indexForTabView:sender]; 285 int index = [self indexForTabView:sender];
286 if (tabModel_->ContainsIndex(index)) { 286 if (tabModel_->ContainsIndex(index)) {
287 TabContents* contents = tabModel_->GetTabContentsAt(index); 287 TabContents* contents = tabModel_->GetTabContentsAt(index);
288 if (contents) 288 if (contents)
289 UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile()); 289 UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile());
290 if ([self numberOfTabViews] > 1) { 290 if ([self numberOfTabViews] > 1) {
291 // Limit the width available for laying out tabs so that tabs are not 291 if (static_cast<size_t>(index) != [tabArray_ count] - 1) {
pink (ping after 24hrs) 2009/09/16 14:37:16 i'd reverse the if/else cases here. check for the
292 // resized until a later time (when the mouse leaves the tab strip). 292 // Limit the width available for laying out tabs so that tabs are not
293 // TODO(pinkerton): re-visit when handling tab overflow. 293 // resized until a later time (when the mouse leaves the tab strip).
294 NSView* penultimateTab = [self viewAtIndex:[tabArray_ count] - 2]; 294 // TODO(pinkerton): re-visit when handling tab overflow.
295 availableResizeWidth_ = NSMaxX([penultimateTab frame]); 295 NSView* penultimateTab = [self viewAtIndex:[tabArray_ count] - 2];
296 availableResizeWidth_ = NSMaxX([penultimateTab frame]);
297 } else {
298 // If the rightmost tab is closed, change the available width so that
299 // another tab's close button lands below the cursor (assuming the tabs
300 // are currently below their maximum width and can grow).
301 NSView* lastTab = [self viewAtIndex:[tabArray_ count] - 1];
302 availableResizeWidth_ = NSMaxX([lastTab frame]);
303 }
296 tabModel_->CloseTabContentsAt(index); 304 tabModel_->CloseTabContentsAt(index);
297 } else { 305 } else {
298 // Use the standard window close if this is the last tab 306 // Use the standard window close if this is the last tab
299 // this prevents the tab from being removed from the model until after 307 // this prevents the tab from being removed from the model until after
300 // the window dissapears 308 // the window dissapears
301 [[tabView_ window] performClose:nil]; 309 [[tabView_ window] performClose:nil];
302 } 310 }
303 } 311 }
304 } 312 }
305 313
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 BrowserWindowController* controller = 977 BrowserWindowController* controller =
970 (BrowserWindowController*)[[switchView_ window] windowController]; 978 (BrowserWindowController*)[[switchView_ window] windowController];
971 DCHECK(index >= 0); 979 DCHECK(index >= 0);
972 if (index >= 0) { 980 if (index >= 0) {
973 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; 981 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
974 } 982 }
975 } 983 }
976 984
977 985
978 @end 986 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698