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

Side by Side Diff: ui/views/controls/tabbed_pane/tabbed_pane.cc

Issue 137533011: Clean-up: Avoids unnecessary font list creation in views::Tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 "ui/views/controls/tabbed_pane/tabbed_pane.h" 5 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
9 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/font_list.h" 12 #include "ui/gfx/font_list.h"
12 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
13 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" 14 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
14 #include "ui/views/layout/layout_manager.h" 15 #include "ui/views/layout/layout_manager.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
17 namespace { 18 namespace {
18 19
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bounds.Inset(0, 1, 0, 0); 153 bounds.Inset(0, 1, 0, 0);
153 bounds.ClampToCenteredSize(preferred_title_size_); 154 bounds.ClampToCenteredSize(preferred_title_size_);
154 title_->SetBoundsRect(bounds); 155 title_->SetBoundsRect(bounds);
155 } 156 }
156 157
157 void Tab::SetState(TabState tab_state) { 158 void Tab::SetState(TabState tab_state) {
158 if (tab_state == tab_state_) 159 if (tab_state == tab_state_)
159 return; 160 return;
160 tab_state_ = tab_state; 161 tab_state_ = tab_state;
161 162
163 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
162 switch (tab_state) { 164 switch (tab_state) {
163 case TAB_INACTIVE: 165 case TAB_INACTIVE:
164 title_->SetEnabledColor(kTabTitleColor_Inactive); 166 title_->SetEnabledColor(kTabTitleColor_Inactive);
165 title_->SetFontList(gfx::FontList()); 167 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BaseFont));
sadrul 2014/01/16 14:29:41 Just so I understand: this (and the change in line
Yuki 2014/01/16 14:53:27 My understanding is that 1. When Tab::SetState(TAB
sadrul 2014/01/16 15:17:31 I was not asking whether it was necessary to call
Yuki 2014/01/16 15:31:02 Yes, they're equivalent. The default instance of
166 break; 168 break;
167 case TAB_ACTIVE: 169 case TAB_ACTIVE:
168 title_->SetEnabledColor(kTabTitleColor_Active); 170 title_->SetEnabledColor(kTabTitleColor_Active);
169 title_->SetFontList( 171 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont));
170 gfx::FontList().DeriveFontListWithSizeDeltaAndStyle(
171 0, gfx::Font::BOLD));
172 break; 172 break;
173 case TAB_HOVERED: 173 case TAB_HOVERED:
174 title_->SetEnabledColor(kTabTitleColor_Hovered); 174 title_->SetEnabledColor(kTabTitleColor_Hovered);
175 title_->SetFontList(gfx::FontList()); 175 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BaseFont));
176 break; 176 break;
177 } 177 }
178 SchedulePaint(); 178 SchedulePaint();
179 } 179 }
180 180
181 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {} 181 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {}
182 182
183 TabStrip::~TabStrip() {} 183 TabStrip::~TabStrip() {}
184 184
185 gfx::Size TabStrip::GetPreferredSize() { 185 gfx::Size TabStrip::GetPreferredSize() {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 selected_tab->NotifyAccessibilityEvent( 366 selected_tab->NotifyAccessibilityEvent(
367 ui::AccessibilityTypes::EVENT_FOCUS, true); 367 ui::AccessibilityTypes::EVENT_FOCUS, true);
368 } 368 }
369 } 369 }
370 370
371 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) { 371 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) {
372 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; 372 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST;
373 } 373 }
374 374
375 } // namespace views 375 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698