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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/views/controls/slider_unittest.cc ('k') | ui/views/controls/styled_label_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/styled_label.h" 5 #include "ui/views/controls/styled_label.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 14 matching lines...) Expand all
25 namespace { 25 namespace {
26 26
27 // Calculates the height of a line of text. Currently returns the height of 27 // Calculates the height of a line of text. Currently returns the height of
28 // a label. 28 // a label.
29 int CalculateLineHeight(const gfx::FontList& font_list) { 29 int CalculateLineHeight(const gfx::FontList& font_list) {
30 Label label; 30 Label label;
31 label.SetFontList(font_list); 31 label.SetFontList(font_list);
32 return label.GetPreferredSize().height(); 32 return label.GetPreferredSize().height();
33 } 33 }
34 34
35 scoped_ptr<Label> CreateLabelRange( 35 std::unique_ptr<Label> CreateLabelRange(
36 const base::string16& text, 36 const base::string16& text,
37 const gfx::FontList& font_list, 37 const gfx::FontList& font_list,
38 const StyledLabel::RangeStyleInfo& style_info, 38 const StyledLabel::RangeStyleInfo& style_info,
39 views::LinkListener* link_listener) { 39 views::LinkListener* link_listener) {
40 scoped_ptr<Label> result; 40 std::unique_ptr<Label> result;
41 41
42 if (style_info.is_link) { 42 if (style_info.is_link) {
43 Link* link = new Link(text); 43 Link* link = new Link(text);
44 link->set_listener(link_listener); 44 link->set_listener(link_listener);
45 link->SetUnderline((style_info.font_style & gfx::Font::UNDERLINE) != 0); 45 link->SetUnderline((style_info.font_style & gfx::Font::UNDERLINE) != 0);
46 result.reset(link); 46 result.reset(link);
47 } else { 47 } else {
48 result.reset(new Label(text)); 48 result.reset(new Label(text));
49 } 49 }
50 50
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 break; 300 break;
301 } 301 }
302 302
303 x = 0; 303 x = 0;
304 line++; 304 line++;
305 continue; 305 continue;
306 } 306 }
307 307
308 base::string16 chunk = substrings[0]; 308 base::string16 chunk = substrings[0];
309 309
310 scoped_ptr<Label> label; 310 std::unique_ptr<Label> label;
311 if (position >= range.start()) { 311 if (position >= range.start()) {
312 const RangeStyleInfo& style_info = current_range->style_info; 312 const RangeStyleInfo& style_info = current_range->style_info;
313 313
314 if (style_info.disable_line_wrapping && chunk.size() < range.length() && 314 if (style_info.disable_line_wrapping && chunk.size() < range.length() &&
315 position == range.start() && x != 0) { 315 position == range.start() && x != 0) {
316 // If the chunk should not be wrapped, try to fit it entirely on the 316 // If the chunk should not be wrapped, try to fit it entirely on the
317 // next line. 317 // next line.
318 x = 0; 318 x = 0;
319 line++; 319 line++;
320 continue; 320 continue;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 DCHECK_LE(used_width, width); 373 DCHECK_LE(used_width, width);
374 // The user-specified line height only applies to interline spacing, so the 374 // The user-specified line height only applies to interline spacing, so the
375 // final line's height is unaffected. 375 // final line's height is unaffected.
376 int total_height = line * line_height + 376 int total_height = line * line_height +
377 CalculateLineHeight(font_list_) + GetInsets().height(); 377 CalculateLineHeight(font_list_) + GetInsets().height();
378 calculated_size_ = gfx::Size(used_width + GetInsets().width(), total_height); 378 calculated_size_ = gfx::Size(used_width + GetInsets().width(), total_height);
379 return calculated_size_; 379 return calculated_size_;
380 } 380 }
381 381
382 } // namespace views 382 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider_unittest.cc ('k') | ui/views/controls/styled_label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698