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

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

Issue 1272823003: Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « ui/gl/gl_implementation.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); 489 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
490 focus_bounds.Intersect(GetLocalBounds()); 490 focus_bounds.Intersect(GetLocalBounds());
491 return focus_bounds; 491 return focus_bounds;
492 } 492 }
493 493
494 std::vector<base::string16> Label::GetLinesForWidth(int width) const { 494 std::vector<base::string16> Label::GetLinesForWidth(int width) const {
495 std::vector<base::string16> lines; 495 std::vector<base::string16> lines;
496 // |width| can be 0 when getting the default text size, in that case 496 // |width| can be 0 when getting the default text size, in that case
497 // the ideal lines (i.e. broken at newline characters) are wanted. 497 // the ideal lines (i.e. broken at newline characters) are wanted.
498 if (width <= 0) { 498 if (width <= 0) {
499 base::SplitString(render_text_->GetDisplayText(), '\n', &lines); 499 lines = base::SplitString(
500 render_text_->GetDisplayText(), base::string16(1, '\n'),
501 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
500 } else { 502 } else {
501 gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width, 503 gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width,
502 std::numeric_limits<int>::max(), 504 std::numeric_limits<int>::max(),
503 render_text_->word_wrap_behavior(), &lines); 505 render_text_->word_wrap_behavior(), &lines);
504 } 506 }
505 return lines; 507 return lines;
506 } 508 }
507 509
508 gfx::Size Label::GetTextSize() const { 510 gfx::Size Label::GetTextSize() const {
509 gfx::Size size; 511 gfx::Size size;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 574 }
573 575
574 bool Label::ShouldShowDefaultTooltip() const { 576 bool Label::ShouldShowDefaultTooltip() const {
575 const gfx::Size text_size = GetTextSize(); 577 const gfx::Size text_size = GetTextSize();
576 const gfx::Size size = GetContentsBounds().size(); 578 const gfx::Size size = GetContentsBounds().size();
577 return !obscured() && (text_size.width() > size.width() || 579 return !obscured() && (text_size.width() > size.width() ||
578 (multi_line() && text_size.height() > size.height())); 580 (multi_line() && text_size.height() > size.height()));
579 } 581 }
580 582
581 } // namespace views 583 } // namespace views
OLDNEW
« no previous file with comments | « ui/gl/gl_implementation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698