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

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

Issue 870903002: Do not invoke DrawFadedString() if it knows it does not fade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 341
342 return false; 342 return false;
343 } 343 }
344 344
345 void Label::PaintText(gfx::Canvas* canvas, 345 void Label::PaintText(gfx::Canvas* canvas,
346 const base::string16& text, 346 const base::string16& text,
347 const gfx::Rect& text_bounds, 347 const gfx::Rect& text_bounds,
348 int flags) { 348 int flags) {
349 SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_; 349 SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_;
350 if (elide_behavior_ == gfx::FADE_TAIL) { 350 if (elide_behavior_ == gfx::FADE_TAIL &&
351 text_bounds.width() < GetTextSize().width()) {
351 canvas->DrawFadedString(text, font_list_, color, text_bounds, flags); 352 canvas->DrawFadedString(text, font_list_, color, text_bounds, flags);
352 } else { 353 } else {
353 canvas->DrawStringRectWithShadows(text, font_list_, color, text_bounds, 354 canvas->DrawStringRectWithShadows(text, font_list_, color, text_bounds,
354 line_height_, flags, shadows_); 355 line_height_, flags, shadows_);
355 } 356 }
356 357
357 if (HasFocus()) { 358 if (HasFocus()) {
358 gfx::Rect focus_bounds = text_bounds; 359 gfx::Rect focus_bounds = text_bounds;
359 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); 360 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
360 canvas->DrawFocusRect(focus_bounds); 361 canvas->DrawFocusRect(focus_bounds);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 603 }
603 604
604 bool Label::ShouldShowDefaultTooltip() const { 605 bool Label::ShouldShowDefaultTooltip() const {
605 const gfx::Size text_size = GetTextSize(); 606 const gfx::Size text_size = GetTextSize();
606 const gfx::Size size = GetContentsBounds().size(); 607 const gfx::Size size = GetContentsBounds().size();
607 return !obscured() && (text_size.width() > size.width() || 608 return !obscured() && (text_size.width() > size.width() ||
608 (multi_line_ && text_size.height() > size.height())); 609 (multi_line_ && text_size.height() > size.height()));
609 } 610 }
610 611
611 } // namespace views 612 } // 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