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

Side by Side Diff: chrome/common/gfx/text_elider.h

Issue 113143: Move color_utils, text_elider, drag_utils, accessibility_types, standard_layo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/gfx/color_utils.cc ('k') | chrome/common/gfx/text_elider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_GFX_TEXT_ELIDER_H_
6 #define CHROME_COMMON_GFX_TEXT_ELIDER_H_
7
8 #include <unicode/coll.h>
9 #include <unicode/uchar.h>
10
11 #include "app/gfx/chrome_font.h"
12 #include "base/basictypes.h"
13 #include "base/string16.h"
14
15 class FilePath;
16 class GURL;
17
18 namespace url_parse {
19 struct Parsed;
20 }
21
22 // TODO(port): this file should deal in string16s rather than wstrings.
23 namespace gfx {
24
25 // A function to get URL string from a GURL that will be suitable for display
26 // to the user. The parsing of the URL may change because various parts of the
27 // string will change lengths. The new parsing will be placed in the given out
28 // parameter. |prefix_end| is set to the end of the prefix (spec and separator
29 // characters before host).
30 // |languages|, |new_parsed|, and |prefix_end| may all be empty or NULL.
31 std::wstring GetCleanStringFromUrl(const GURL& url,
32 const std::wstring& languages,
33 url_parse::Parsed* new_parsed,
34 size_t* prefix_end);
35
36 // This function takes a GURL object and elides it. It returns a string
37 // which composed of parts from subdomain, domain, path, filename and query.
38 // A "..." is added automatically at the end if the elided string is bigger
39 // than the available pixel width. For available pixel width = 0, empty
40 // string is returned. |languages| is a comma separted list of ISO 639
41 // language codes and is used to determine what characters are understood
42 // by a user. It should come from |prefs::kAcceptLanguages|.
43 //
44 // Note: in RTL locales, if the URL returned by this function is going to be
45 // displayed in the UI, then it is likely that the string needs to be marked
46 // as an LTR string (using l10n_util::WrapStringWithLTRFormatting()) so that it
47 // is displayed properly in an RTL context. Please refer to
48 // http://crbug.com/6487 for more information.
49 std::wstring ElideUrl(const GURL& url,
50 const ChromeFont& font,
51 int available_pixel_width,
52 const std::wstring& languages);
53
54 std::wstring ElideText(const std::wstring& text,
55 const ChromeFont& font,
56 int available_pixel_width);
57
58 // Elide a filename to fit a given pixel width, with an emphasis on not hiding
59 // the extension unless we have to. If filename contains a path, the path will
60 // be removed if filename doesn't fit into available_pixel_width.
61 std::wstring ElideFilename(const FilePath& filename,
62 const ChromeFont& font,
63 int available_pixel_width);
64
65 // SortedDisplayURL maintains a string from a URL suitable for display to the
66 // use. SortedDisplayURL also provides a function used for comparing two
67 // SortedDisplayURLs for use in visually ordering the SortedDisplayURLs.
68 //
69 // SortedDisplayURL is relatively cheap and supports value semantics.
70 class SortedDisplayURL {
71 public:
72 SortedDisplayURL(const GURL& url, const std::wstring& languages);
73 SortedDisplayURL() {}
74
75 // Compares this SortedDisplayURL to |url| using |collator|. Returns a value
76 // < 0, = 1 or > 0 as to whether this url is less then, equal to or greater
77 // than the supplied url.
78 int Compare(const SortedDisplayURL& other, Collator* collator) const;
79
80 // Returns the display string for the URL.
81 const string16& display_url() const { return display_url_; }
82
83 private:
84 // Returns everything after the host. This is used by Compare if the hosts
85 // match.
86 string16 AfterHost() const;
87
88 // Host name minus 'www.'. Used by Compare.
89 string16 sort_host_;
90
91 // End of the prefix (spec and separator) in display_url_.
92 size_t prefix_end_;
93
94 string16 display_url_;
95 };
96
97 } // namespace gfx.
98
99 #endif // CHROME_COMMON_GFX_TEXT_ELIDER_H_
OLDNEW
« no previous file with comments | « chrome/common/gfx/color_utils.cc ('k') | chrome/common/gfx/text_elider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698