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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 1189553002: Omnibox: Force text field to LTR context if it is a URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite comment with an example. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 6507e2ae111f3164cc15de27cb0f8eea9fbd44c2..080f3fd3ae9abc649b9c0f069a44809bd29620c3 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -601,6 +601,16 @@ int OmniboxViewViews::GetOmniboxTextLength() const {
void OmniboxViewViews::EmphasizeURLComponents() {
if (!location_bar_view_)
return;
+
+ // If the current contents is a URL, force left-to-right rendering at the
+ // paragraph level. Right-to-left runs are still rendered RTL, but will not
+ // flip the whole URL around. For example (if "ABC" is Hebrew), this will
+ // render "ABC.com" as "CBA.com", rather than "com.CBA".
+ bool text_is_url = model()->CurrentTextIsURL();
+ GetRenderText()->SetDirectionalityMode(text_is_url
+ ? gfx::DIRECTIONALITY_FORCE_LTR
+ : gfx::DIRECTIONALITY_FROM_TEXT);
+
// See whether the contents are a URL with a non-empty host portion, which we
// should emphasize. To check for a URL, rather than using the type returned
// by Parse(), ask the model, which will check the desired page transition for
@@ -612,8 +622,7 @@ void OmniboxViewViews::EmphasizeURLComponents() {
text(), ChromeAutocompleteSchemeClassifier(profile()), &scheme, &host);
bool grey_out_url = text().substr(scheme.begin, scheme.len) ==
base::UTF8ToUTF16(extensions::kExtensionScheme);
- bool grey_base = model()->CurrentTextIsURL() &&
- (host.is_nonempty() || grey_out_url);
+ bool grey_base = text_is_url && (host.is_nonempty() || grey_out_url);
SetColor(location_bar_view_->GetColor(
security_level_,
grey_base ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
@@ -629,7 +638,7 @@ void OmniboxViewViews::EmphasizeURLComponents() {
// editing; and in some cases, e.g. for "site:foo.com" searches, the parser
// may have incorrectly identified a qualifier as a scheme.
SetStyle(gfx::DIAGONAL_STRIKE, false);
- if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
+ if (!model()->user_input_in_progress() && text_is_url &&
scheme.is_nonempty() && (security_level_ != connection_security::NONE)) {
SkColor security_color = location_bar_view_->GetColor(
security_level_, LocationBarView::SECURITY_TEXT);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698