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

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

Issue 1539583003: Convert Pass()→std::move() in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_runner.cc » ('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) 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 <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/profiler/scoped_tracker.h" 15 #include "base/profiler/scoped_tracker.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "ui/accessibility/ax_view_state.h" 18 #include "ui/accessibility/ax_view_state.h"
18 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/color_utils.h" 20 #include "ui/gfx/color_utils.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 render_text_->CreateInstanceOfSameType()); 334 render_text_->CreateInstanceOfSameType());
334 render_text->SetHorizontalAlignment(alignment); 335 render_text->SetHorizontalAlignment(alignment);
335 render_text->SetDirectionalityMode(directionality); 336 render_text->SetDirectionalityMode(directionality);
336 render_text->SetElideBehavior(elide_behavior); 337 render_text->SetElideBehavior(elide_behavior);
337 render_text->SetObscured(obscured()); 338 render_text->SetObscured(obscured());
338 render_text->SetMinLineHeight(line_height()); 339 render_text->SetMinLineHeight(line_height());
339 render_text->SetFontList(font_list()); 340 render_text->SetFontList(font_list());
340 render_text->set_shadows(shadows()); 341 render_text->set_shadows(shadows());
341 render_text->SetCursorEnabled(false); 342 render_text->SetCursorEnabled(false);
342 render_text->SetText(text); 343 render_text->SetText(text);
343 return render_text.Pass(); 344 return render_text;
344 } 345 }
345 346
346 void Label::PaintText(gfx::Canvas* canvas) { 347 void Label::PaintText(gfx::Canvas* canvas) {
347 MaybeBuildRenderTextLines(); 348 MaybeBuildRenderTextLines();
348 for (size_t i = 0; i < lines_.size(); ++i) 349 for (size_t i = 0; i < lines_.size(); ++i)
349 lines_[i]->Draw(canvas); 350 lines_[i]->Draw(canvas);
350 } 351 }
351 352
352 void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) { 353 void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) {
353 if (previous_bounds.size() != size()) 354 if (previous_bounds.size() != size())
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // Text eliding is not supported for multi-lined Labels. 445 // Text eliding is not supported for multi-lined Labels.
445 // TODO(mukai): Add multi-lined elided text support. 446 // TODO(mukai): Add multi-lined elided text support.
446 gfx::ElideBehavior elide_behavior = 447 gfx::ElideBehavior elide_behavior =
447 multi_line() ? gfx::NO_ELIDE : elide_behavior_; 448 multi_line() ? gfx::NO_ELIDE : elide_behavior_;
448 if (!multi_line() || render_text_->MultilineSupported()) { 449 if (!multi_line() || render_text_->MultilineSupported()) {
449 scoped_ptr<gfx::RenderText> render_text = 450 scoped_ptr<gfx::RenderText> render_text =
450 CreateRenderText(text(), alignment, directionality, elide_behavior); 451 CreateRenderText(text(), alignment, directionality, elide_behavior);
451 render_text->SetDisplayRect(rect); 452 render_text->SetDisplayRect(rect);
452 render_text->SetMultiline(multi_line()); 453 render_text->SetMultiline(multi_line());
453 render_text->SetWordWrapBehavior(render_text_->word_wrap_behavior()); 454 render_text->SetWordWrapBehavior(render_text_->word_wrap_behavior());
454 lines_.push_back(render_text.Pass()); 455 lines_.push_back(std::move(render_text));
455 } else { 456 } else {
456 std::vector<base::string16> lines = GetLinesForWidth(rect.width()); 457 std::vector<base::string16> lines = GetLinesForWidth(rect.width());
457 if (lines.size() > 1) 458 if (lines.size() > 1)
458 rect.set_height(std::max(line_height(), font_list().GetHeight())); 459 rect.set_height(std::max(line_height(), font_list().GetHeight()));
459 460
460 const int bottom = GetContentsBounds().bottom(); 461 const int bottom = GetContentsBounds().bottom();
461 for (size_t i = 0; i < lines.size() && rect.y() <= bottom; ++i) { 462 for (size_t i = 0; i < lines.size() && rect.y() <= bottom; ++i) {
462 scoped_ptr<gfx::RenderText> line = 463 scoped_ptr<gfx::RenderText> line =
463 CreateRenderText(lines[i], alignment, directionality, elide_behavior); 464 CreateRenderText(lines[i], alignment, directionality, elide_behavior);
464 line->SetDisplayRect(rect); 465 line->SetDisplayRect(rect);
465 lines_.push_back(line.Pass()); 466 lines_.push_back(std::move(line));
466 rect.set_y(rect.y() + rect.height()); 467 rect.set_y(rect.y() + rect.height());
467 } 468 }
468 // Append the remaining text to the last visible line. 469 // Append the remaining text to the last visible line.
469 for (size_t i = lines_.size(); i < lines.size(); ++i) 470 for (size_t i = lines_.size(); i < lines.size(); ++i)
470 lines_.back()->SetText(lines_.back()->text() + lines[i]); 471 lines_.back()->SetText(lines_.back()->text() + lines[i]);
471 } 472 }
472 RecalculateColors(); 473 RecalculateColors();
473 } 474 }
474 475
475 gfx::Rect Label::GetFocusBounds() { 476 gfx::Rect Label::GetFocusBounds() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 575 }
575 576
576 bool Label::ShouldShowDefaultTooltip() const { 577 bool Label::ShouldShowDefaultTooltip() const {
577 const gfx::Size text_size = GetTextSize(); 578 const gfx::Size text_size = GetTextSize();
578 const gfx::Size size = GetContentsBounds().size(); 579 const gfx::Size size = GetContentsBounds().size();
579 return !obscured() && (text_size.width() > size.width() || 580 return !obscured() && (text_size.width() > size.width() ||
580 (multi_line() && text_size.height() > size.height())); 581 (multi_line() && text_size.height() > size.height()));
581 } 582 }
582 583
583 } // namespace views 584 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/image_view.cc ('k') | ui/views/controls/menu/menu_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698