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

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

Issue 10695101: Remove code that forces text directionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 8 years, 5 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') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index f907f9f51ae1959ce9f051b9c277938bc8d9f45a..70130e8998712ee3fc07cacdc8b0dc2b86e2ee34 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -112,12 +112,15 @@ void Label::ClearEmbellishing() {
}
void Label::SetHorizontalAlignment(Alignment alignment) {
- // If the View's UI layout is right-to-left and directionality_mode_ is
- // USE_UI_DIRECTIONALITY, we need to flip the alignment so that the alignment
- // settings take into account the text directionality.
- if (base::i18n::IsRTL() && (directionality_mode_ == USE_UI_DIRECTIONALITY) &&
- (alignment != ALIGN_CENTER))
+ // TODO(msw): Change Alignment to LEADING/TRAILING?
+ // TODO(msw): Check (and potentially flip) the alignment when setting text?
+ // TODO(msw): Check against multi-line label regressions (not RenderText)...
+ // If the string's directionality is right-to-left, flip the alignment.
+ if (base::i18n::GetFirstStrongCharacterDirection(text()) ==
+ base::i18n::RIGHT_TO_LEFT &&
+ alignment != ALIGN_CENTER) {
alignment = (alignment == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT;
+ }
if (horiz_alignment_ != alignment) {
horiz_alignment_ = alignment;
SchedulePaint();
@@ -373,7 +376,6 @@ void Label::Init(const string16& text, const gfx::Font& font) {
elide_in_middle_ = false;
is_email_ = false;
collapse_when_hidden_ = false;
- directionality_mode_ = USE_UI_DIRECTIONALITY;
paint_as_focused_ = false;
has_focus_border_ = false;
enabled_shadow_color_ = 0;
@@ -444,15 +446,6 @@ int Label::ComputeDrawStringFlags() const {
if (SkColorGetA(background_color_) != 0xFF)
flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
- if (directionality_mode_ == AUTO_DETECT_DIRECTIONALITY) {
- base::i18n::TextDirection direction =
- base::i18n::GetFirstStrongCharacterDirection(text_);
- 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 flags;
@@ -499,18 +492,10 @@ void Label::CalculateDrawStringParams(string16* paint_text,
// preference and use it when calling ElideUrl.
*paint_text =
ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::string());
-
- // An URLs is always treated as an LTR text and therefore we should
- // explicitly mark it as such if the locale is RTL so that URLs containing
- // Hebrew or Arabic characters are displayed correctly.
- //
- // Note that we don't check the View's UI layout setting in order to
- // determine whether or not to insert the special Unicode formatting
- // characters. We use the locale settings because an URL is always treated
- // as an LTR string, even if its containing view does not use an RTL UI
- // layout.
- *paint_text = base::i18n::GetDisplayStringInLTRDirectionality(
- *paint_text);
+ // Ensure that URLs have LTR directionality.
+ // TODO(msw): Check cases like "/\x05d0", "://\x05d0".
+ DCHECK_EQ(base::i18n::GetFirstStrongCharacterDirection(*paint_text),
+ base::i18n::LEFT_TO_RIGHT);
} else if (is_email_) {
*paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
} else if (elide_in_middle_) {
« 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