OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // So we get don't get enter/exit on children and don't prematurely stop the | 432 // So we get don't get enter/exit on children and don't prematurely stop the |
433 // hover. | 433 // hover. |
434 set_notify_enter_exit_on_child(true); | 434 set_notify_enter_exit_on_child(true); |
435 | 435 |
436 set_id(VIEW_ID_TAB); | 436 set_id(VIEW_ID_TAB); |
437 | 437 |
438 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 438 title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
439 title_->SetElideBehavior(gfx::FADE_TAIL); | 439 title_->SetElideBehavior(gfx::FADE_TAIL); |
440 title_->SetHandlesTooltips(false); | 440 title_->SetHandlesTooltips(false); |
441 title_->SetAutoColorReadabilityEnabled(false); | 441 title_->SetAutoColorReadabilityEnabled(false); |
| 442 title_->set_collapse_when_hidden(true); |
442 title_->SetText(CoreTabHelper::GetDefaultTitle()); | 443 title_->SetText(CoreTabHelper::GetDefaultTitle()); |
443 AddChildView(title_); | 444 AddChildView(title_); |
444 | 445 |
445 SetEventTargeter( | 446 SetEventTargeter( |
446 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 447 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
447 | 448 |
448 // Add the Close Button. | 449 // Add the Close Button. |
449 close_button_ = new TabCloseButton(this); | 450 close_button_ = new TabCloseButton(this); |
450 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 451 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
451 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 452 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; | 806 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; |
806 int title_width = lb.width() - title_left; | 807 int title_width = lb.width() - title_left; |
807 if (showing_media_indicator_) { | 808 if (showing_media_indicator_) { |
808 title_width = media_indicator_button_->x() - kViewSpacing - title_left; | 809 title_width = media_indicator_button_->x() - kViewSpacing - title_left; |
809 } else if (close_button_->visible()) { | 810 } else if (close_button_->visible()) { |
810 // Allow the title to overlay the close button's empty border padding. | 811 // Allow the title to overlay the close button's empty border padding. |
811 title_width = close_button_->x() + close_button_->GetInsets().left() - | 812 title_width = close_button_->x() + close_button_->GetInsets().left() - |
812 kViewSpacing - title_left; | 813 kViewSpacing - title_left; |
813 } | 814 } |
814 gfx::Rect rect(title_left, lb.y(), std::max(title_width, 0), lb.height()); | 815 gfx::Rect rect(title_left, lb.y(), std::max(title_width, 0), lb.height()); |
815 const int title_height = title_->GetPreferredSize().height(); | 816 const int title_height = title_->GetHeightForWidth(title_width); |
816 if (title_height > rect.height()) { | 817 if (title_height > rect.height()) { |
817 rect.set_y(lb.y() - (title_height - rect.height()) / 2); | 818 rect.set_y(lb.y() - (title_height - rect.height()) / 2); |
818 rect.set_height(title_height); | 819 rect.set_height(title_height); |
819 } | 820 } |
820 title_->SetBoundsRect(rect); | 821 title_->SetBoundsRect(rect); |
821 } | 822 } |
822 title_->SetVisible(show_title); | 823 title_->SetVisible(show_title); |
823 } | 824 } |
824 | 825 |
825 void Tab::OnThemeChanged() { | 826 void Tab::OnThemeChanged() { |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 const gfx::ImageSkia& image) { | 1600 const gfx::ImageSkia& image) { |
1600 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1601 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1601 ImageCacheEntry entry; | 1602 ImageCacheEntry entry; |
1602 entry.resource_id = resource_id; | 1603 entry.resource_id = resource_id; |
1603 entry.scale_factor = scale_factor; | 1604 entry.scale_factor = scale_factor; |
1604 entry.image = image; | 1605 entry.image = image; |
1605 image_cache_->push_front(entry); | 1606 image_cache_->push_front(entry); |
1606 if (image_cache_->size() > kMaxImageCacheSize) | 1607 if (image_cache_->size() > kMaxImageCacheSize) |
1607 image_cache_->pop_back(); | 1608 image_cache_->pop_back(); |
1608 } | 1609 } |
OLD | NEW |