OLD | NEW |
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/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <climits> | 10 #include <climits> |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 if (available_width <= 0 || text.empty()) | 1374 if (available_width <= 0 || text.empty()) |
1375 return base::string16(); | 1375 return base::string16(); |
1376 if (behavior == ELIDE_EMAIL) | 1376 if (behavior == ELIDE_EMAIL) |
1377 return ElideEmail(text, available_width); | 1377 return ElideEmail(text, available_width); |
1378 if (text_width > 0 && text_width < available_width) | 1378 if (text_width > 0 && text_width < available_width) |
1379 return text; | 1379 return text; |
1380 | 1380 |
1381 TRACE_EVENT0("ui", "RenderText::Elide"); | 1381 TRACE_EVENT0("ui", "RenderText::Elide"); |
1382 | 1382 |
1383 // Create a RenderText copy with attributes that affect the rendering width. | 1383 // Create a RenderText copy with attributes that affect the rendering width. |
1384 scoped_ptr<RenderText> render_text = CreateInstanceOfSameType(); | 1384 std::unique_ptr<RenderText> render_text = CreateInstanceOfSameType(); |
1385 render_text->SetFontList(font_list_); | 1385 render_text->SetFontList(font_list_); |
1386 render_text->SetDirectionalityMode(directionality_mode_); | 1386 render_text->SetDirectionalityMode(directionality_mode_); |
1387 render_text->SetCursorEnabled(cursor_enabled_); | 1387 render_text->SetCursorEnabled(cursor_enabled_); |
1388 render_text->set_truncate_length(truncate_length_); | 1388 render_text->set_truncate_length(truncate_length_); |
1389 render_text->styles_ = styles_; | 1389 render_text->styles_ = styles_; |
1390 render_text->baselines_ = baselines_; | 1390 render_text->baselines_ = baselines_; |
1391 render_text->colors_ = colors_; | 1391 render_text->colors_ = colors_; |
1392 if (text_width == 0) { | 1392 if (text_width == 0) { |
1393 render_text->SetText(text); | 1393 render_text->SetText(text); |
1394 text_width = render_text->GetContentWidthF(); | 1394 text_width = render_text->GetContentWidthF(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1545 |
1546 SetDisplayOffset(display_offset_.x() + delta_x); | 1546 SetDisplayOffset(display_offset_.x() + delta_x); |
1547 } | 1547 } |
1548 | 1548 |
1549 void RenderText::DrawSelection(Canvas* canvas) { | 1549 void RenderText::DrawSelection(Canvas* canvas) { |
1550 for (const Rect& s : GetSubstringBounds(selection())) | 1550 for (const Rect& s : GetSubstringBounds(selection())) |
1551 canvas->FillRect(s, selection_background_focused_color_); | 1551 canvas->FillRect(s, selection_background_focused_color_); |
1552 } | 1552 } |
1553 | 1553 |
1554 } // namespace gfx | 1554 } // namespace gfx |
OLD | NEW |