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

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

Issue 6783015: Improvements to tab title prefix eliding as per email discussions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 scoped_nsobject<TabContentsController> contentsController( 1096 scoped_nsobject<TabContentsController> contentsController(
1097 [[TabContentsController alloc] initWithContents:contents->tab_contents() 1097 [[TabContentsController alloc] initWithContents:contents->tab_contents()
1098 delegate:self]); 1098 delegate:self]);
1099 [tabContentsArray_ insertObject:contentsController atIndex:index]; 1099 [tabContentsArray_ insertObject:contentsController atIndex:index];
1100 1100
1101 // Make a new tab and add it to the strip. Keep track of its controller. 1101 // Make a new tab and add it to the strip. Keep track of its controller.
1102 TabController* newController = [self newTab]; 1102 TabController* newController = [self newTab];
1103 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; 1103 [newController setMini:tabStripModel_->IsMiniTab(modelIndex)];
1104 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; 1104 [newController setPinned:tabStripModel_->IsTabPinned(modelIndex)];
1105 [newController setApp:tabStripModel_->IsAppTab(modelIndex)]; 1105 [newController setApp:tabStripModel_->IsAppTab(modelIndex)];
1106 [newController setUrl:contents->tab_contents()->GetURL()];
1106 [tabArray_ insertObject:newController atIndex:index]; 1107 [tabArray_ insertObject:newController atIndex:index];
1107 NSView* newView = [newController view]; 1108 NSView* newView = [newController view];
1108 1109
1109 // Set the originating frame to just below the strip so that it animates 1110 // Set the originating frame to just below the strip so that it animates
1110 // upwards as it's being initially layed out. Oddly, this works while doing 1111 // upwards as it's being initially layed out. Oddly, this works while doing
1111 // something similar in |-layoutTabs| confuses the window server. 1112 // something similar in |-layoutTabs| confuses the window server.
1112 [newView setFrame:NSOffsetRect([newView frame], 1113 [newView setFrame:NSOffsetRect([newView frame],
1113 0, -[[self class] defaultTabHeight])]; 1114 0, -[[self class] defaultTabHeight])];
1114 1115
1115 [self setTabTitle:newController withContents:contents->tab_contents()]; 1116 [self setTabTitle:newController withContents:contents->tab_contents()];
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 TabController* tabController = [tabArray_ objectAtIndex:index]; 1492 TabController* tabController = [tabArray_ objectAtIndex:index];
1492 DCHECK([tabController isKindOfClass:[TabController class]]); 1493 DCHECK([tabController isKindOfClass:[TabController class]]);
1493 1494
1494 // Don't do anything if the change was already picked up by the move event. 1495 // Don't do anything if the change was already picked up by the move event.
1495 if (tabStripModel_->IsMiniTab(modelIndex) == [tabController mini]) 1496 if (tabStripModel_->IsMiniTab(modelIndex) == [tabController mini])
1496 return; 1497 return;
1497 1498
1498 [tabController setMini:tabStripModel_->IsMiniTab(modelIndex)]; 1499 [tabController setMini:tabStripModel_->IsMiniTab(modelIndex)];
1499 [tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; 1500 [tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)];
1500 [tabController setApp:tabStripModel_->IsAppTab(modelIndex)]; 1501 [tabController setApp:tabStripModel_->IsAppTab(modelIndex)];
1502 [tabController setUrl:contents->tab_contents()->GetURL()];
1501 [self updateFaviconForContents:contents->tab_contents() atIndex:modelIndex]; 1503 [self updateFaviconForContents:contents->tab_contents() atIndex:modelIndex];
1502 // If the tab is being restored and it's pinned, the mini state is set after 1504 // If the tab is being restored and it's pinned, the mini state is set after
1503 // the tab has already been rendered, so re-layout the tabstrip. In all other 1505 // the tab has already been rendered, so re-layout the tabstrip. In all other
1504 // cases, the state is set before the tab is rendered so this isn't needed. 1506 // cases, the state is set before the tab is rendered so this isn't needed.
1505 [self layoutTabs]; 1507 [self layoutTabs];
1506 1508
1507 [self updateCommonTitlePrefix]; 1509 [self updateCommonTitlePrefix];
1508 } 1510 }
1509 1511
1510 - (void)setFrameOfSelectedTab:(NSRect)frame { 1512 - (void)setFrameOfSelectedTab:(NSRect)frame {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 size_t tabIndex; 2035 size_t tabIndex;
2034 size_t tabCount = [tabArray_ count]; 2036 size_t tabCount = [tabArray_ count];
2035 2037
2036 // Add all tab titles to |tabTitleInfos|. 2038 // Add all tab titles to |tabTitleInfos|.
2037 for (tabIndex = 0; tabIndex < tabCount; ++tabIndex) { 2039 for (tabIndex = 0; tabIndex < tabCount; ++tabIndex) {
2038 TabController* tabController = [tabArray_ objectAtIndex:tabIndex]; 2040 TabController* tabController = [tabArray_ objectAtIndex:tabIndex];
2039 string16 title = base::SysNSStringToUTF16([tabController title]); 2041 string16 title = base::SysNSStringToUTF16([tabController title]);
2040 if (!title.empty() && ![tabController mini]) { 2042 if (!title.empty() && ![tabController mini]) {
2041 titles.push_back(new string16(title)); 2043 titles.push_back(new string16(title));
2042 tabTitleInfos.push_back(TitlePrefixMatcher::TitleInfo( 2044 tabTitleInfos.push_back(TitlePrefixMatcher::TitleInfo(
2043 titles[titles.size() - 1], tabIndex)); 2045 titles[titles.size() - 1], [tabController url], tabIndex));
2044 } 2046 }
2045 } 2047 }
2046 2048
2047 // Calculate the prefix length. 2049 // Calculate the prefix length.
2048 TitlePrefixMatcher::CalculatePrefixLengths(&tabTitleInfos); 2050 TitlePrefixMatcher::CalculatePrefixLengths(&tabTitleInfos);
2049 2051
2050 // Update the prefix length for each tab. 2052 // Update the prefix length for each tab.
2051 for (size_t infoIndex = 0; infoIndex < tabTitleInfos.size(); ++infoIndex) { 2053 for (size_t infoIndex = 0; infoIndex < tabTitleInfos.size(); ++infoIndex) {
2052 tabIndex = tabTitleInfos[infoIndex].caller_value; 2054 tabIndex = tabTitleInfos[infoIndex].caller_value;
2053 DCHECK(tabIndex < [tabArray_ count]); 2055 DCHECK(tabIndex < [tabArray_ count]);
(...skipping 30 matching lines...) Expand all
2084 } 2086 }
2085 2087
2086 NSString* menuTitle = 2088 NSString* menuTitle =
2087 l10n_util::GetNSStringWithFixup(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); 2089 l10n_util::GetNSStringWithFixup(IDS_PROFILES_CREATE_NEW_PROFILE_OPTION);
2088 [menu addItemWithTitle:menuTitle 2090 [menu addItemWithTitle:menuTitle
2089 action:NULL 2091 action:NULL
2090 keyEquivalent:@""]; 2092 keyEquivalent:@""];
2091 } 2093 }
2092 2094
2093 @end 2095 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698