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

Unified Diff: ui/gfx/text_elider.cc

Issue 23731010: Move text_elider to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update3 Created 7 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 | « ui/gfx/text_elider.h ('k') | ui/gfx/text_elider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/text_elider.cc
diff --git a/ui/base/text/text_elider.cc b/ui/gfx/text_elider.cc
similarity index 97%
copy from ui/base/text/text_elider.cc
copy to ui/gfx/text_elider.cc
index 76dbb719946a0e4dec9cf6736fdc78a03cd284ce..bc4eb3bb858386904ccca086736b1df426d6cd70 100644
--- a/ui/base/text/text_elider.cc
+++ b/ui/gfx/text_elider.cc
@@ -7,7 +7,7 @@
// Note that several of the functions declared in text_elider.h are implemented
// in this file using helper classes in an unnamed namespace.
-#include "ui/base/text/text_elider.h"
+#include "ui/gfx/text_elider.h"
#include <string>
#include <vector>
@@ -30,7 +30,7 @@
#include "ui/gfx/text_utils.h"
#include "url/gurl.h"
-namespace ui {
+namespace gfx {
// U+2026 in utf8
const char kEllipsis[] = "\xE2\x80\xA6";
@@ -642,8 +642,6 @@ bool ElideString(const string16& input, int max_len, string16* output) {
return true;
}
-} // namespace ui
-
namespace {
// Internal class used to track progress of a rectangular string elide
@@ -814,7 +812,7 @@ class RectangleText {
RectangleText(const gfx::FontList& font_list,
int available_pixel_width,
int available_pixel_height,
- ui::WordWrapBehavior wrap_behavior,
+ WordWrapBehavior wrap_behavior,
std::vector<string16>* lines)
: font_list_(font_list),
line_height_(font_list.GetHeight()),
@@ -882,7 +880,7 @@ class RectangleText {
const int available_pixel_height_;
// The wrap behavior for words that are too long to fit on a single line.
- const ui::WordWrapBehavior wrap_behavior_;
+ const WordWrapBehavior wrap_behavior_;
// The current running width.
int current_width_;
@@ -938,8 +936,8 @@ int RectangleText::Finalize() {
}
if (last_line_ended_in_lf_)
lines_->push_back(string16());
- return (insufficient_width_ ? ui::INSUFFICIENT_SPACE_HORIZONTAL : 0) |
- (insufficient_height_ ? ui::INSUFFICIENT_SPACE_VERTICAL : 0);
+ return (insufficient_width_ ? INSUFFICIENT_SPACE_HORIZONTAL : 0) |
+ (insufficient_height_ ? INSUFFICIENT_SPACE_VERTICAL : 0);
}
void RectangleText::AddLine(const string16& line) {
@@ -984,8 +982,8 @@ int RectangleText::WrapWord(const string16& word) {
bool first_fragment = true;
while (!insufficient_height_ && !text.empty()) {
string16 fragment =
- ui::ElideText(text, font_list_, available_pixel_width_,
- ui::TRUNCATE_AT_END);
+ ElideText(text, font_list_, available_pixel_width_,
+ TRUNCATE_AT_END);
// At least one character has to be added at every line, even if the
// available space is too small.
if(fragment.empty())
@@ -1009,17 +1007,16 @@ int RectangleText::AddWordOverflow(const string16& word) {
lines_added++;
}
- if (wrap_behavior_ == ui::IGNORE_LONG_WORDS) {
+ if (wrap_behavior_ == IGNORE_LONG_WORDS) {
current_line_ = word;
current_width_ = available_pixel_width_;
- } else if (wrap_behavior_ == ui::WRAP_LONG_WORDS) {
+ } else if (wrap_behavior_ == WRAP_LONG_WORDS) {
lines_added += WrapWord(word);
} else {
- const ui::ElideBehavior elide_behavior =
- (wrap_behavior_ == ui::ELIDE_LONG_WORDS ? ui::ELIDE_AT_END :
- ui::TRUNCATE_AT_END);
+ const ElideBehavior elide_behavior =
+ (wrap_behavior_ == ELIDE_LONG_WORDS ? ELIDE_AT_END : TRUNCATE_AT_END);
const string16 elided_word =
- ui::ElideText(word, font_list_, available_pixel_width_, elide_behavior);
+ ElideText(word, font_list_, available_pixel_width_, elide_behavior);
AddToCurrentLine(elided_word);
insufficient_width_ = true;
}
@@ -1039,7 +1036,7 @@ int RectangleText::AddWord(const string16& word) {
// Append the non-trimmed word, in case more words are added after.
AddToCurrentLine(word);
} else {
- lines_added = AddWordOverflow(wrap_behavior_ == ui::IGNORE_LONG_WORDS ?
+ lines_added = AddWordOverflow(wrap_behavior_ == IGNORE_LONG_WORDS ?
trimmed : word);
}
return lines_added;
@@ -1075,8 +1072,6 @@ bool RectangleText::NewLine() {
} // namespace
-namespace ui {
-
bool ElideRectangleString(const string16& input, size_t max_rows,
size_t max_cols, bool strict, string16* output) {
RectangleString rect(max_rows, max_cols, strict, output);
@@ -1174,4 +1169,4 @@ string16 TruncateString(const string16& string, size_t length) {
return string.substr(0, index) + kElideString;
}
-} // namespace ui
+} // namespace gfx
« no previous file with comments | « ui/gfx/text_elider.h ('k') | ui/gfx/text_elider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698