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

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: 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 48ce4fcd4c0be408f1336a7cb0938b2281a4ea8f..a19773eb99fe9adca8d47f2306e0d7cec5e7905f 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -602,6 +602,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. This still allows text to be rendered from right to left,
+ // but any LTR or neutral characters (e.g. digits) at the start will always be
+ // rendered on the left.
Peter Kasting 2015/06/15 22:39:24 This second sentence is a bit unclear. If you nee
Matt Giuca 2015/06/16 00:21:32 Done.
+ 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
@@ -613,8 +623,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));
@@ -630,7 +639,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_ != ConnectionSecurityHelper::NONE)) {
SkColor security_color = location_bar_view_->GetColor(
« 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