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

Unified Diff: chrome/common/gfx/url_elider.cc

Issue 259: Merge fix for 1362175 to Beta branch. (Closed) Base URL: svn://chrome-svn/chrome/branches/chrome_official_branch/src/
Patch Set: Created 12 years, 3 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/common/gfx/url_elider.cc
===================================================================
--- chrome/common/gfx/url_elider.cc (revision 1774)
+++ chrome/common/gfx/url_elider.cc (working copy)
@@ -194,24 +194,27 @@
url_path_number_of_elements--;
}
+ const int kMaxNumberOfUrlPathElementsAllowed = 1024;
+ if (url_path_number_of_elements <= 1 ||
+ url_path_number_of_elements > kMaxNumberOfUrlPathElementsAllowed) {
+ // No path to elide, or too long of a path (could overflow in loop below)
+ // Just elide this as a text string.
+ return ElideText(url_subdomain + url_domain + url_path_query_etc, font,
+ available_pixel_width);
+ }
+
// Start eliding the path and replacing elements by "../".
std::wstring an_ellipsis_and_a_slash(kEllipsis);
an_ellipsis_and_a_slash += '/';
int pixel_width_url_filename = font.GetStringWidth(url_filename);
int pixel_width_dot_dot_slash = font.GetStringWidth(an_ellipsis_and_a_slash);
int pixel_width_slash = font.GetStringWidth(L"/");
- int pixel_width_url_path_elements[256]; // Declared static for speed.
+ int pixel_width_url_path_elements[kMaxNumberOfUrlPathElementsAllowed];
for (int i = 0; i < url_path_number_of_elements; i++) {
pixel_width_url_path_elements[i] =
font.GetStringWidth(url_path_elements.at(i));
}
- if (url_path_number_of_elements <= 1) {
- // Nothing FITS - return domain and rest.
- return ElideText(url_subdomain + url_domain + url_path_query_etc, font,
- available_pixel_width);
- }
-
// Check with both subdomain and domain.
std::wstring elided_path;
int pixel_width_elided_path;
« 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