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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 867003002: Cache gfx::RenderText instances in views::Label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not overuse the memory Created 5 years, 10 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
« no previous file with comments | « no previous file | ui/app_list/views/app_list_item_view.h » ('j') | ui/gfx/render_text.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/views/app_list_item_view.h » ('j') | ui/gfx/render_text.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698