Skip to content

Commit

Permalink
Change gfx::ElideString() to take a size_t length.
Browse files Browse the repository at this point in the history
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/1656473004

Cr-Commit-Position: refs/heads/master@{#372834}
  • Loading branch information
leizleiz authored and Commit bot committed Feb 2, 2016
1 parent 4716ff8 commit bbf93ac
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions ash/system/cast/tray_cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace ash {

namespace {

const int kMaximumStatusStringLength = 100;
const size_t kMaximumStatusStringLength = 100;
const int kStopButtonRightPadding = 18;

// Returns the active CastConfigDelegate instance.
Expand Down Expand Up @@ -332,7 +332,7 @@ views::View* CastDuplexView::ActiveChildView() {
// Exposes an icon in the tray. |TrayCast| manages the visiblity of this.
class CastTrayView : public TrayItemView {
public:
CastTrayView(SystemTrayItem* tray_item);
explicit CastTrayView(SystemTrayItem* tray_item);
~CastTrayView() override;

// Called when the tray alignment changes so that the icon can recenter
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/external_protocol_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents,
const GURL& url)
: creation_time_(base::TimeTicks::Now()),
scheme_(url.scheme()) {
const int kMaxUrlWithoutSchemeSize = 256;
const size_t kMaxUrlWithoutSchemeSize = 256;
base::string16 elided_url_without_scheme;
gfx::ElideString(base::ASCIIToUTF16(url.possibly_invalid_spec()),
kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/cocoa/external_protocol_dialog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ - (id)initWithGURL:(const GURL*)url
l10n_util::GetNSStringWithFixup(
IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)];

const int kMaxUrlWithoutSchemeSize = 256;
const size_t kMaxUrlWithoutSchemeSize = 256;
base::string16 elided_url_without_scheme;
gfx::ElideString(base::ASCIIToUTF16(url_.possibly_invalid_spec()),
kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/external_protocol_dialog_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() {
}

base::string16 ExternalProtocolDialogDelegate::GetMessageText() const {
const int kMaxUrlWithoutSchemeSize = 256;
const int kMaxCommandSize = 256;
const size_t kMaxUrlWithoutSchemeSize = 256;
const size_t kMaxCommandSize = 256;
base::string16 elided_url_without_scheme;
base::string16 elided_command;
gfx::ElideString(base::ASCIIToUTF16(url().possibly_invalid_spec()),
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/frame/global_menu_bar_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const unsigned int kMostVisitedCount = 8;
const unsigned int kRecentlyClosedCount = 8;

// Menus more than this many chars long will get trimmed.
const int kMaximumMenuWidthInChars = 50;
const size_t kMaximumMenuWidthInChars = 50;

// Constants used in menu definitions.
const int MENU_SEPARATOR =-1;
Expand Down
4 changes: 2 additions & 2 deletions components/app_modal/javascript_app_modal_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void EnforceMaxPromptSize(const base::string16& in_string,
#else
// One-dimensional eliding. Trust the window system to break the string
// appropriately, but limit its overall length to something reasonable.
const int kMessageTextMaxSize = 2000;
const int kDefaultPromptMaxSize = 2000;
const size_t kMessageTextMaxSize = 2000;
const size_t kDefaultPromptMaxSize = 2000;
void EnforceMaxTextSize(const base::string16& in_string,
base::string16* out_string) {
gfx::ElideString(in_string, kMessageTextMaxSize, out_string);
Expand Down
2 changes: 1 addition & 1 deletion ios/web/navigation/navigation_item_impl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static int GetUniqueIDInConstructor() {
title = title.substr(slashpos + 1);
}

const int kMaxTitleChars = 4 * 1024;
const size_t kMaxTitleChars = 4 * 1024;
gfx::ElideString(title, kMaxTitleChars, &cached_display_title_);
return cached_display_title_;
}
Expand Down
2 changes: 1 addition & 1 deletion printing/printing_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ base::string16 SimplifyDocumentTitleWithLength(const base::string16& title,
std::remove_if(no_controls.begin(), no_controls.end(), &u_iscntrl),
no_controls.end());
base::string16 result;
gfx::ElideString(no_controls, static_cast<int>(length), &result);
gfx::ElideString(no_controls, length, &result);
return result;
}

Expand Down
5 changes: 2 additions & 3 deletions ui/gfx/text_elider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,9 @@ base::string16 ElideText(const base::string16& text,
}

bool ElideString(const base::string16& input,
int max_len,
size_t max_len,
base::string16* output) {
DCHECK_GE(max_len, 0);
if (static_cast<int>(input.length()) <= max_len) {
if (input.length() <= max_len) {
output->assign(input);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/gfx/text_elider.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ GFX_EXPORT base::string16 ElideFilename(const base::FilePath& filename,
// puts "Hell...Tom" in str and returns true.
// TODO(tsepez): Doesn't handle UTF-16 surrogate pairs properly.
// TODO(tsepez): Doesn't handle bidi properly.
GFX_EXPORT bool ElideString(const base::string16& input, int max_len,
GFX_EXPORT bool ElideString(const base::string16& input, size_t max_len,
base::string16* output);

// Reformat |input| into |output| so that it fits into a |max_rows| by
Expand Down
6 changes: 3 additions & 3 deletions ui/gfx/text_elider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ TEST(TextEliderTest, StringSlicerCombiningSurrogate) {
TEST(TextEliderTest, ElideString) {
struct TestData {
const char* input;
int max_len;
size_t max_len;
bool result;
const char* output;
} cases[] = {
Expand Down Expand Up @@ -831,7 +831,7 @@ TEST(TextEliderTest, MAYBE_ElideRectangleTextCheckLineWidth) {
EXPECT_LE(GetStringWidthF(lines[1], font_list), kAvailableWidth);
}

#ifdef OS_CHROMEOS
#if defined(OS_CHROMEOS)
// This test was created specifically to test a message from crbug.com/415213.
// It tests that width of concatenation of words equals sum of widths of the
// words.
Expand All @@ -846,7 +846,7 @@ TEST(TextEliderTest, ElideRectangleTextCheckConcatWidthEqualsSumOfWidths) {
#undef WIDTH
SetFontRenderParamsDeviceScaleFactor(1.0f);
}
#endif // OS_CHROMEOS
#endif // defined(OS_CHROMEOS)

// TODO(crbug.com/338784): Enable this on android.
#if defined(OS_ANDROID)
Expand Down

0 comments on commit bbf93ac

Please sign in to comment.