summaryrefslogtreecommitdiffstats
path: root/app/text_elider.h
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 21:19:02 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 21:19:02 +0000
commitaf4b9df213e776858d025ec39059831ce15904d0 (patch)
tree8eb5cf37b46397605469d6506329693b5735802e /app/text_elider.h
parented56a7a029ec8515ab30ba13ee1dcdb4721c32d4 (diff)
downloadchromium_src-af4b9df213e776858d025ec39059831ce15904d0.zip
chromium_src-af4b9df213e776858d025ec39059831ce15904d0.tar.gz
chromium_src-af4b9df213e776858d025ec39059831ce15904d0.tar.bz2
Last part of change for bug 49747.
Implements the two-dimensional elider in app/text_elider.cc, and calls it from js_modal_dialog to reformat the message text prior to displaying an alert box. The elider is implemented using the abstractions introduced in the previous CLs for bug 49747. BUG=49746 TEST=TextEliderTest.* Review URL: http://codereview.chromium.org/5964007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69981 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/text_elider.h')
-rw-r--r--app/text_elider.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/text_elider.h b/app/text_elider.h
index c0d6c33..d6da860 100644
--- a/app/text_elider.h
+++ b/app/text_elider.h
@@ -88,9 +88,11 @@ class SortedDisplayURL {
string16 display_url_;
};
-// Function to elide strings when the font information is unknown. As
-// opposed to the above functions, the ElideString() function operates
-// in terms of character units, not pixels.
+// Functions to elide strings when the font information is unknown. As
+// opposed to the above functions, the ElideString() and
+// ElideRectangleString() functions operate in terms of character units,
+// not pixels.
+
// If the size of |input| is more than |max_len|, this function returns
// true and |input| is shortened into |output| by removing chars in the
// middle (they are replaced with up to 3 dots, as size permits).
@@ -101,6 +103,17 @@ class SortedDisplayURL {
// TODO(tsepez): Doesn't handle bidi properly
bool ElideString(const std::wstring& input, int max_len, std::wstring* output);
+// Reformat |input| into |output| so that it fits into a |max_rows| by
+// |max_cols| rectangle of characters. Input newlines are respected, but
+// lines that are too long are broken into pieces, first at naturally
+// occuring whitespace boundaries, and then intra-word (respecting UTF-16
+// surrogate pairs) as necssary. Truncation (indicated by an added 3 dots)
+// occurs if the result is still too long. Returns true if the input had
+// to be truncated (and not just reformatted).
+bool ElideRectangleString(const string16& input, size_t max_rows,
+ size_t max_cols, string16* output);
+
+
} // namespace gfx.
#endif // APP_TEXT_ELIDER_H_