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

Unified Diff: chrome/browser/android/vr_shell/textures/url_bar_texture.cc

Issue 2944923002: VR: Add ellipsis on truncated URLs. (Closed)
Patch Set: Comment some non-trivial logic. Created 3 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/android/vr_shell/textures/url_bar_texture.cc
diff --git a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
index 561063e5d1e9f91da6a7d8949b3607e73357053e..97cae9ca717e47eb583ac21dd735dba4c7dffa57 100644
--- a/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
+++ b/chrome/browser/android/vr_shell/textures/url_bar_texture.cc
@@ -299,23 +299,25 @@ void UrlBarTexture::RenderUrl(const gfx::Size& texture_size,
render_text->SetFontList(font_list);
render_text->SetColor(SK_ColorBLACK);
render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- render_text->SetElideBehavior(gfx::TRUNCATE);
+ render_text->SetElideBehavior(gfx::ELIDE_TAIL);
+ render_text->SetText(text);
+ render_text->SetDisplayRect(bounds);
+ // Until we can properly elide a URL, we need to bail if the origin portion
+ // cannot be displayed in its entirety.
base::string16 mandatory_prefix = text;
int length = parsed.CountCharactersBefore(url::Parsed::PORT, false);
if (length > 0)
mandatory_prefix = text.substr(0, length);
- gfx::Rect expanded_bounds = bounds;
- expanded_bounds.set_width(2 * bounds.width());
- render_text->SetDisplayRect(expanded_bounds);
- render_text->SetText(mandatory_prefix);
-
- if (render_text->GetStringSize().width() > bounds.width()) {
+ // Ellipsis-based eliding replaces the last character in the string with an
+ // ellipsis, so to reliably check that the origin is intact, check both length
+ // and string equality.
+ if (render_text->GetDisplayText().size() < mandatory_prefix.size() ||
+ render_text->GetDisplayText().substr(0, mandatory_prefix.size()) !=
+ mandatory_prefix) {
failure_callback_.Run(UiUnsupportedMode::kCouldNotElideURL);
}
- render_text->SetText(text);
- render_text->SetDisplayRect(bounds);
vr_shell::RenderTextWrapper vr_render_text(render_text.get());
ApplyUrlStyling(text, parsed, security_level_, &vr_render_text,
color_scheme());
« 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