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

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

Issue 1278973003: Revert of 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 lines = base::SplitString( 499 base::SplitString(render_text_->GetDisplayText(), '\n', &lines);
500 render_text_->GetDisplayText(), base::string16(1, '\n'),
501 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
502 } else { 500 } else {
503 gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width, 501 gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width,
504 std::numeric_limits<int>::max(), 502 std::numeric_limits<int>::max(),
505 render_text_->word_wrap_behavior(), &lines); 503 render_text_->word_wrap_behavior(), &lines);
506 } 504 }
507 return lines; 505 return lines;
508 } 506 }
509 507
510 gfx::Size Label::GetTextSize() const { 508 gfx::Size Label::GetTextSize() const {
511 gfx::Size size; 509 gfx::Size size;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 572 }
575 573
576 bool Label::ShouldShowDefaultTooltip() const { 574 bool Label::ShouldShowDefaultTooltip() const {
577 const gfx::Size text_size = GetTextSize(); 575 const gfx::Size text_size = GetTextSize();
578 const gfx::Size size = GetContentsBounds().size(); 576 const gfx::Size size = GetContentsBounds().size();
579 return !obscured() && (text_size.width() > size.width() || 577 return !obscured() && (text_size.width() > size.width() ||
580 (multi_line() && text_size.height() > size.height())); 578 (multi_line() && text_size.height() > size.height()));
581 } 579 }
582 580
583 } // namespace views 581 } // 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