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

Unified Diff: chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 384018: Added a flag to the Canvas class which allows forcing an RTL directionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/autocomplete/autocomplete.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
===================================================================
--- chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc (revision 31579)
+++ chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc (working copy)
@@ -147,7 +147,8 @@
const std::wstring& text,
int style,
int x,
- int y);
+ int y,
+ bool force_rtl_directionality);
// Gets the font and text color for a fragment with the specified style.
gfx::Font GetFragmentFont(int style) const;
@@ -513,10 +514,20 @@
int style = classifications[i].style;
if (force_dim)
style |= ACMatchClassification::DIM;
+
+ // We specify RTL directionlity explicitly only if the run is an RTL run
+ // and we can't specify the string directionlaity using an LRE/PDF pair.
+ // Note that URLs are always displayed using LTR directionality
+ // (regardless of the locale) and therefore they are excluded.
+ const bool force_rtl_directionality =
+ !(classifications[i].style & ACMatchClassification::URL) &&
+ (run_direction == UBIDI_RTL) &&
+ (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT);
+
if (text_start < text_end) {
x += DrawStringFragment(canvas,
text.substr(text_start, text_end - text_start),
- style, x, y);
+ style, x, y, force_rtl_directionality);
}
}
}
@@ -528,16 +539,19 @@
const std::wstring& text,
int style,
int x,
- int y) {
+ int y,
+ bool force_rtl_directionality) {
gfx::Font display_font = GetFragmentFont(style);
// Clamp text width to the available width within the popup so we elide if
// necessary.
int string_width = std::min(display_font.GetStringWidth(text),
width() - kRowRightPadding - x);
int string_left = mirroring_context_->GetLeft(x, x + string_width);
+ const int flags = force_rtl_directionality ?
+ gfx::Canvas::FORCE_RTL_DIRECTIONALITY : 0;
canvas->DrawStringInt(text, GetFragmentFont(style),
GetFragmentTextColor(style), string_left, y,
- string_width, display_font.height());
+ string_width, display_font.height(), flags);
return string_width;
}
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698