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

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

Issue 9569025: Fix right-to-left script text truncation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
===================================================================
--- ui/views/controls/label.cc (revision 123286)
+++ ui/views/controls/label.cc (working copy)
@@ -215,7 +215,7 @@
w = std::max(0, w - GetInsets().width());
int h = font_.GetHeight();
gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h,
- ComputeMultiLineFlags());
+ ComputeDrawStringFlags());
return h + GetInsets().height();
}
@@ -290,7 +290,7 @@
int h = font_.GetHeight();
// For single-line strings, ignore the available width and calculate how
// wide the text wants to be.
- int flags = ComputeMultiLineFlags();
+ int flags = ComputeDrawStringFlags();
if (!is_multi_line_)
flags |= gfx::Canvas::NO_ELLIPSIS;
gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, flags);
@@ -426,11 +426,22 @@
return gfx::Rect(text_origin, text_size);
}
-int Label::ComputeMultiLineFlags() const {
+int Label::ComputeDrawStringFlags() const {
+ int flags = 0;
+
+ if (directionality_mode_ == AUTO_DETECT_DIRECTIONALITY) {
+ base::i18n::TextDirection direction =
+ base::i18n::GetFirstStrongCharacterDirection(GetText());
+ if (direction == base::i18n::RIGHT_TO_LEFT)
+ flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY;
+ else
+ flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY;
+ }
+
if (!is_multi_line_)
- return 0;
+ return flags;
- int flags = gfx::Canvas::MULTI_LINE;
+ flags |= gfx::Canvas::MULTI_LINE;
#if !defined(OS_WIN)
// Don't elide multiline labels on Linux.
// Todo(davemoore): Do we depend on eliding multiline text?
@@ -452,6 +463,7 @@
flags |= gfx::Canvas::TEXT_ALIGN_RIGHT;
break;
}
+
return flags;
}
@@ -492,16 +504,7 @@
}
*text_bounds = GetTextBounds();
- *flags = ComputeMultiLineFlags();
-
- if (directionality_mode_ == AUTO_DETECT_DIRECTIONALITY) {
- base::i18n::TextDirection direction =
- base::i18n::GetFirstStrongCharacterDirection(GetText());
- if (direction == base::i18n::RIGHT_TO_LEFT)
- *flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY;
- else
- *flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY;
- }
+ *flags = ComputeDrawStringFlags();
}
} // namespace views
« no previous file with comments | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698