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

Side by Side Diff: ui/base/text/text_elider.cc

Issue 8552002: net: Move UnescapeRule into the net namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/escape.cc ('k') | webkit/blob/view_blob_internals_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "ui/base/text/text_elider.h" 7 #include "ui/base/text/text_elider.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // kerning/ligatures/etc. issues potentially wrong by assuming that the width of 111 // kerning/ligatures/etc. issues potentially wrong by assuming that the width of
112 // a rendered string is always the sum of the widths of its substrings. Also I 112 // a rendered string is always the sum of the widths of its substrings. Also I
113 // suspect it could be made simpler. 113 // suspect it could be made simpler.
114 string16 ElideUrl(const GURL& url, 114 string16 ElideUrl(const GURL& url,
115 const gfx::Font& font, 115 const gfx::Font& font,
116 int available_pixel_width, 116 int available_pixel_width,
117 const std::string& languages) { 117 const std::string& languages) {
118 // Get a formatted string and corresponding parsing of the url. 118 // Get a formatted string and corresponding parsing of the url.
119 url_parse::Parsed parsed; 119 url_parse::Parsed parsed;
120 string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, 120 string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll,
121 UnescapeRule::SPACES, &parsed, NULL, NULL); 121 net::UnescapeRule::SPACES, &parsed, NULL, NULL);
122 if (available_pixel_width <= 0) 122 if (available_pixel_width <= 0)
123 return url_string; 123 return url_string;
124 124
125 // If non-standard or not file type, return plain eliding. 125 // If non-standard or not file type, return plain eliding.
126 if (!(url.SchemeIsFile() || url.IsStandard())) 126 if (!(url.SchemeIsFile() || url.IsStandard()))
127 return ElideText(url_string, font, available_pixel_width, false); 127 return ElideText(url_string, font, available_pixel_width, false);
128 128
129 // Now start eliding url_string to fit within available pixel width. 129 // Now start eliding url_string to fit within available pixel width.
130 // Fist pass - check to see whether entire url_string fits. 130 // Fist pass - check to see whether entire url_string fits.
131 int pixel_width_url_string = font.GetStringWidth(url_string); 131 int pixel_width_url_string = font.GetStringWidth(url_string);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 return CutString(text, lo, elide_in_middle, true); 391 return CutString(text, lo, elide_in_middle, true);
392 } 392 }
393 393
394 SortedDisplayURL::SortedDisplayURL(const GURL& url, 394 SortedDisplayURL::SortedDisplayURL(const GURL& url,
395 const std::string& languages) { 395 const std::string& languages) {
396 net::AppendFormattedHost(url, languages, &sort_host_); 396 net::AppendFormattedHost(url, languages, &sort_host_);
397 string16 host_minus_www = net::StripWWW(sort_host_); 397 string16 host_minus_www = net::StripWWW(sort_host_);
398 url_parse::Parsed parsed; 398 url_parse::Parsed parsed;
399 display_url_ = net::FormatUrl(url, languages, 399 display_url_ = net::FormatUrl(url, languages,
400 net::kFormatUrlOmitAll, UnescapeRule::SPACES, &parsed, &prefix_end_, 400 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, &parsed, &prefix_end_,
401 NULL); 401 NULL);
402 if (sort_host_.length() > host_minus_www.length()) { 402 if (sort_host_.length() > host_minus_www.length()) {
403 prefix_end_ += sort_host_.length() - host_minus_www.length(); 403 prefix_end_ += sort_host_.length() - host_minus_www.length();
404 sort_host_.swap(host_minus_www); 404 sort_host_.swap(host_minus_www);
405 } 405 }
406 } 406 }
407 407
408 SortedDisplayURL::SortedDisplayURL() : prefix_end_(0) { 408 SortedDisplayURL::SortedDisplayURL() : prefix_end_(0) {
409 } 409 }
410 410
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 index = char_iterator.getIndex(); 729 index = char_iterator.getIndex();
730 } else { 730 } else {
731 // String has leading whitespace, return the elide string. 731 // String has leading whitespace, return the elide string.
732 return kElideString; 732 return kElideString;
733 } 733 }
734 } 734 }
735 return string.substr(0, index) + kElideString; 735 return string.substr(0, index) + kElideString;
736 } 736 }
737 737
738 } // namespace ui 738 } // namespace ui
OLDNEW
« no previous file with comments | « net/base/escape.cc ('k') | webkit/blob/view_blob_internals_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698