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

Unified Diff: ui/views/controls/label.cc

Issue 14654018: Make Label's NO_ELIDE setting actually not elide, and change the default (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/label.cc
===================================================================
--- ui/views/controls/label.cc (revision 200651)
+++ ui/views/controls/label.cc (working copy)
@@ -366,7 +366,7 @@
line_height_ = 0;
is_multi_line_ = false;
allow_character_break_ = false;
- elide_behavior_ = NO_ELIDE;
+ elide_behavior_ = ELIDE_AT_END;
collapse_when_hidden_ = false;
directionality_mode_ = USE_UI_DIRECTIONALITY;
has_focus_border_ = false;
@@ -478,9 +478,10 @@
int* flags) const {
DCHECK(paint_text && text_bounds && flags);
- // TODO(msw): Use ElideRectangleText to support eliding multi-line text.
- if (elide_behavior_ == ELIDE_AS_EMAIL) {
- *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
+ // TODO(msw): Use ElideRectangleText to support eliding multi-line text. Once
+ // this is done, we can set NO_ELLIPSIS unconditionally at the bottom.
+ if (is_multi_line_ || (elide_behavior_ == NO_ELIDE)) {
+ *paint_text = text_;
} else if (elide_behavior_ == ELIDE_IN_MIDDLE) {
*paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
ui::ELIDE_IN_MIDDLE);
@@ -488,11 +489,14 @@
*paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
ui::ELIDE_AT_END);
} else {
- *paint_text = text_;
+ DCHECK_EQ(ELIDE_AS_EMAIL, elide_behavior_);
+ *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
}
*text_bounds = GetTextBounds();
*flags = ComputeDrawStringFlags();
+ if (!is_multi_line_ || (elide_behavior_ == NO_ELIDE))
+ *flags |= gfx::Canvas::NO_ELLIPSIS;
}
void Label::UpdateColorsFromTheme(const ui::NativeTheme* theme) {

Powered by Google App Engine
This is Rietveld 408576698