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

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

Issue 341713002: Remove Label::PaintText overrides. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 years, 6 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 | « ui/views/controls/label.h ('k') | ui/views/controls/label_unittest.cc » ('j') | 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 PaintText(canvas, paint_text, text_bounds, flags); 376 PaintText(canvas, paint_text, text_bounds, flags);
377 } 377 }
378 378
379 void Label::OnNativeThemeChanged(const ui::NativeTheme* theme) { 379 void Label::OnNativeThemeChanged(const ui::NativeTheme* theme) {
380 UpdateColorsFromTheme(theme); 380 UpdateColorsFromTheme(theme);
381 } 381 }
382 382
383 void Label::Init(const base::string16& text, const gfx::FontList& font_list) { 383 void Label::Init(const base::string16& text, const gfx::FontList& font_list) {
384 font_list_ = font_list; 384 font_list_ = font_list;
385 enabled_color_set_ = disabled_color_set_ = background_color_set_ = false; 385 enabled_color_set_ = disabled_color_set_ = background_color_set_ = false;
386 subpixel_rendering_enabled_ = true;
386 auto_color_readability_ = true; 387 auto_color_readability_ = true;
387 UpdateColorsFromTheme(ui::NativeTheme::instance()); 388 UpdateColorsFromTheme(ui::NativeTheme::instance());
388 horizontal_alignment_ = gfx::ALIGN_CENTER; 389 horizontal_alignment_ = gfx::ALIGN_CENTER;
389 line_height_ = 0; 390 line_height_ = 0;
390 is_multi_line_ = false; 391 is_multi_line_ = false;
391 is_obscured_ = false; 392 is_obscured_ = false;
392 allow_character_break_ = false; 393 allow_character_break_ = false;
393 elide_behavior_ = gfx::ELIDE_TAIL; 394 elide_behavior_ = gfx::ELIDE_TAIL;
394 collapse_when_hidden_ = false; 395 collapse_when_hidden_ = false;
395 directionality_mode_ = gfx::DIRECTIONALITY_FROM_UI; 396 directionality_mode_ = gfx::DIRECTIONALITY_FROM_UI;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 break; 433 break;
433 } 434 }
434 origin.Offset(0, std::max(0, (available.height() - text_size.height())) / 2); 435 origin.Offset(0, std::max(0, (available.height() - text_size.height())) / 2);
435 return gfx::Rect(origin, text_size); 436 return gfx::Rect(origin, text_size);
436 } 437 }
437 438
438 int Label::ComputeDrawStringFlags() const { 439 int Label::ComputeDrawStringFlags() const {
439 int flags = 0; 440 int flags = 0;
440 441
441 // We can't use subpixel rendering if the background is non-opaque. 442 // We can't use subpixel rendering if the background is non-opaque.
442 if (SkColorGetA(background_color_) != 0xFF) 443 if (SkColorGetA(background_color_) != 0xFF || !subpixel_rendering_enabled_)
443 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; 444 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
444 445
445 if (directionality_mode_ == gfx::DIRECTIONALITY_FORCE_LTR) { 446 if (directionality_mode_ == gfx::DIRECTIONALITY_FORCE_LTR) {
446 flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY; 447 flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY;
447 } else if (directionality_mode_ == gfx::DIRECTIONALITY_FORCE_RTL) { 448 } else if (directionality_mode_ == gfx::DIRECTIONALITY_FORCE_RTL) {
448 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; 449 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY;
449 } else if (directionality_mode_ == gfx::DIRECTIONALITY_FROM_TEXT) { 450 } else if (directionality_mode_ == gfx::DIRECTIONALITY_FROM_TEXT) {
450 base::i18n::TextDirection direction = 451 base::i18n::TextDirection direction =
451 base::i18n::GetFirstStrongCharacterDirection(layout_text()); 452 base::i18n::GetFirstStrongCharacterDirection(layout_text());
452 if (direction == base::i18n::RIGHT_TO_LEFT) 453 if (direction == base::i18n::RIGHT_TO_LEFT)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 cached_heights_[i] = gfx::Size(); 539 cached_heights_[i] = gfx::Size();
539 } 540 }
540 541
541 bool Label::ShouldShowDefaultTooltip() const { 542 bool Label::ShouldShowDefaultTooltip() const {
542 return !is_multi_line_ && !is_obscured_ && 543 return !is_multi_line_ && !is_obscured_ &&
543 gfx::GetStringWidth(layout_text(), font_list_) > 544 gfx::GetStringWidth(layout_text(), font_list_) >
544 GetAvailableRect().width(); 545 GetAvailableRect().width();
545 } 546 }
546 547
547 } // namespace views 548 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698