summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 16:45:47 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 16:45:47 +0000
commit2dd011df2acf628a0d23346a8a518000d18dd683 (patch)
tree9763823feb49b7bf628fc5cc9bb4c4941281f819 /chrome
parent381040385d42d13db97016e3d9e65e006f6c30f3 (diff)
downloadchromium_src-2dd011df2acf628a0d23346a8a518000d18dd683.zip
chromium_src-2dd011df2acf628a0d23346a8a518000d18dd683.tar.gz
chromium_src-2dd011df2acf628a0d23346a8a518000d18dd683.tar.bz2
Improve tab-closability of right-most tab.
BUG=21903 TEST=Open 20 tabs. Put mouse over close button of some tab in the middle and keep clicking to close tabs. When the tab below the mouse is right-most, closing it should cause the other tabs to grow so that another close box ends up below the cursor (until the remaining tabs have reached the maximum tab width). Review URL: http://codereview.chromium.org/196137 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm20
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 8c47c8e..f431c93 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -288,11 +288,21 @@ static const float kIndentLeavingSpaceForControls = 64.0;
if (contents)
UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile());
if ([self numberOfTabViews] > 1) {
- // Limit the width available for laying out tabs so that tabs are not
- // resized until a later time (when the mouse leaves the tab strip).
- // TODO(pinkerton): re-visit when handling tab overflow.
- NSView* penultimateTab = [self viewAtIndex:[tabArray_ count] - 2];
- availableResizeWidth_ = NSMaxX([penultimateTab frame]);
+ bool isClosingLastTab =
+ static_cast<size_t>(index) == [tabArray_ count] - 1;
+ if (!isClosingLastTab) {
+ // Limit the width available for laying out tabs so that tabs are not
+ // resized until a later time (when the mouse leaves the tab strip).
+ // TODO(pinkerton): re-visit when handling tab overflow.
+ NSView* penultimateTab = [self viewAtIndex:[tabArray_ count] - 2];
+ availableResizeWidth_ = NSMaxX([penultimateTab frame]);
+ } else {
+ // If the rightmost tab is closed, change the available width so that
+ // another tab's close button lands below the cursor (assuming the tabs
+ // are currently below their maximum width and can grow).
+ NSView* lastTab = [self viewAtIndex:[tabArray_ count] - 1];
+ availableResizeWidth_ = NSMaxX([lastTab frame]);
+ }
tabModel_->CloseTabContentsAt(index);
} else {
// Use the standard window close if this is the last tab