 Chromium Code Reviews
 Chromium Code Reviews Issue 6579050:
  Elides the beginning of tab titles that have common prefixes. ...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 6579050:
  Elides the beginning of tab titles that have common prefixes. ...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| Index: chrome/browser/ui/views/tabs/base_tab_strip.cc | 
| =================================================================== | 
| --- chrome/browser/ui/views/tabs/base_tab_strip.cc (revision 77295) | 
| +++ chrome/browser/ui/views/tabs/base_tab_strip.cc (working copy) | 
| @@ -4,10 +4,17 @@ | 
| #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 
| +#include <vector> | 
| + | 
| +#include "base/command_line.h" | 
| +#include "base/hash_tables.h" | 
| #include "base/logging.h" | 
| +#include "base/string_split.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" | 
| +#include "chrome/common/chrome_switches.h" | 
| 
sky
2011/03/11 00:00:45
Do we know this include anymore? In fact I suspect
 
MAD
2011/03/11 03:01:37
D'ho...ne.
Sorry about that...
 | 
| #include "views/widget/root_view.h" | 
| #include "views/window/window.h" | 
| @@ -141,6 +148,7 @@ | 
| TabData d = { tab, gfx::Rect() }; | 
| tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d); | 
| + UpdateCommonTitlePrefix(); | 
| AddChildView(tab); | 
| @@ -171,6 +179,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()) | 
| @@ -403,8 +412,32 @@ | 
| tab_data_.erase(tab_data_.begin() + tab_data_index); | 
| delete tab; | 
| + UpdateCommonTitlePrefix(); | 
| } | 
| +void BaseTabStrip::UpdateCommonTitlePrefix() { | 
| + std::vector<browser::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(browser::TitlePrefixMatcher::TitleInfo( | 
| + &tab_data_[tab_index].tab->data().title, tab_index)); | 
| + } | 
| + } | 
| + browser::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); | 
| 
sky
2011/03/11 00:00:45
Didn't we want a SchedulePaint here?
 
sky
2011/03/11 00:01:37
Never mind. I see it in BaseTab.
 | 
| + } | 
| + } | 
| +} | 
| + | 
| int BaseTabStrip::TabIndexOfTab(BaseTab* tab) const { | 
| for (int i = 0; i < tab_count(); ++i) { | 
| if (base_tab_at_tab_index(i) == tab) |