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

Unified Diff: chrome/browser/ui/views/tabs/base_tab_strip.cc

Issue 6579050: Elides the beginning of tab titles that have common prefixes. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Elides the beginning of tab titles that have common prefixes. ... Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_renderer_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/base_tab_strip.cc
===================================================================
--- chrome/browser/ui/views/tabs/base_tab_strip.cc (revision 77820)
+++ chrome/browser/ui/views/tabs/base_tab_strip.cc (working copy)
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/tabs/base_tab_strip.h"
#include "base/logging.h"
+#include "chrome/browser/ui/title_prefix_matcher.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tabs/dragged_tab_controller.h"
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
@@ -137,6 +138,7 @@
TabData d = { tab, gfx::Rect() };
tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d);
+ UpdateCommonTitlePrefix();
AddChildView(tab);
@@ -167,6 +169,7 @@
BaseTab* tab = GetBaseTabAtModelIndex(model_index);
bool mini_state_changed = tab->data().mini != data.mini;
tab->SetData(data);
+ UpdateCommonTitlePrefix();
if (mini_state_changed) {
if (GetWindow() && GetWindow()->IsVisible())
@@ -425,8 +428,32 @@
tab_data_.erase(tab_data_.begin() + tab_data_index);
delete tab;
+ UpdateCommonTitlePrefix();
}
+void BaseTabStrip::UpdateCommonTitlePrefix() {
+ std::vector<TitlePrefixMatcher::TitleInfo> tab_title_infos;
+ for (int tab_index = 0; tab_index < tab_count(); ++tab_index) {
+ DCHECK(tab_data_[tab_index].tab != NULL);
+ if (!tab_data_[tab_index].tab->data().mini &&
+ !tab_data_[tab_index].tab->data().title.empty()) {
+ tab_title_infos.push_back(TitlePrefixMatcher::TitleInfo(
+ &tab_data_[tab_index].tab->data().title, tab_index));
+ }
+ }
+ TitlePrefixMatcher::CalculatePrefixLengths(&tab_title_infos);
+ for (size_t title_index = 0; title_index < tab_title_infos.size();
+ ++title_index) {
+ int tab_index = tab_title_infos[title_index].caller_value;
+ TabRendererData data = tab_data_[tab_index].tab->data();
+ if (data.common_prefix_length !=
+ tab_title_infos[title_index].prefix_length) {
+ data.common_prefix_length = tab_title_infos[title_index].prefix_length;
+ tab_data_[tab_index].tab->SetData(data);
+ }
+ }
+}
+
int BaseTabStrip::TabIndexOfTab(BaseTab* tab) const {
for (int i = 0; i < tab_count(); ++i) {
if (base_tab_at_tab_index(i) == tab)
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_renderer_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698