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

Side by Side Diff: views/controls/label.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « net/websockets/websocket_job_unittest.cc ('k') | webkit/glue/plugins/plugin_lib_mac.mm » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/label.h" 5 #include "views/controls/label.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, 224 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding,
225 kFocusBorderPadding, kFocusBorderPadding); 225 kFocusBorderPadding, kFocusBorderPadding);
226 } 226 }
227 return insets; 227 return insets;
228 } 228 }
229 229
230 void Label::SizeToFit(int max_width) { 230 void Label::SizeToFit(int max_width) {
231 DCHECK(is_multi_line_); 231 DCHECK(is_multi_line_);
232 232
233 std::vector<std::wstring> lines; 233 std::vector<std::wstring> lines;
234 SplitString(text_, L'\n', &lines); 234 base::SplitString(text_, L'\n', &lines);
235 235
236 int label_width = 0; 236 int label_width = 0;
237 for (std::vector<std::wstring>::const_iterator iter = lines.begin(); 237 for (std::vector<std::wstring>::const_iterator iter = lines.begin();
238 iter != lines.end(); ++iter) 238 iter != lines.end(); ++iter)
239 label_width = std::max(label_width, font_.GetStringWidth(*iter)); 239 label_width = std::max(label_width, font_.GetStringWidth(*iter));
240 240
241 label_width += GetInsets().width(); 241 label_width += GetInsets().width();
242 242
243 if (max_width > 0) 243 if (max_width > 0)
244 label_width = std::min(label_width, max_width); 244 label_width = std::min(label_width, max_width);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 *paint_text = gfx::ElideText(text_, font_, width(), true); 440 *paint_text = gfx::ElideText(text_, font_, width(), true);
441 } else { 441 } else {
442 *paint_text = text_; 442 *paint_text = text_;
443 } 443 }
444 444
445 *text_bounds = GetTextBounds(); 445 *text_bounds = GetTextBounds();
446 *flags = ComputeMultiLineFlags(); 446 *flags = ComputeMultiLineFlags();
447 } 447 }
448 448
449 } // namespace views 449 } // namespace views
OLDNEW
« no previous file with comments | « net/websockets/websocket_job_unittest.cc ('k') | webkit/glue/plugins/plugin_lib_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698