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 <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 else | 1400 else |
1401 new_text += base::i18n::kRightToLeftMark; | 1401 new_text += base::i18n::kRightToLeftMark; |
1402 } | 1402 } |
1403 render_text->SetText(new_text); | 1403 render_text->SetText(new_text); |
1404 } | 1404 } |
1405 | 1405 |
1406 // Restore styles and baselines without breaking multi-character graphemes. | 1406 // Restore styles and baselines without breaking multi-character graphemes. |
1407 render_text->styles_ = styles_; | 1407 render_text->styles_ = styles_; |
1408 for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) | 1408 for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) |
1409 RestoreBreakList(render_text.get(), render_text->styles_[style]); | 1409 RestoreBreakList(render_text.get(), render_text->styles_[style]); |
1410 RestoreBreakList(render_text.get(), baselines_); | 1410 RestoreBreakList(render_text.get(), render_text->baselines_); |
1411 | 1411 |
1412 // We check the width of the whole desired string at once to ensure we | 1412 // We check the width of the whole desired string at once to ensure we |
1413 // handle kerning/ligatures/etc. correctly. | 1413 // handle kerning/ligatures/etc. correctly. |
1414 const float guess_width = render_text->GetContentWidthF(); | 1414 const float guess_width = render_text->GetContentWidthF(); |
1415 if (guess_width == available_width) | 1415 if (guess_width == available_width) |
1416 break; | 1416 break; |
1417 if (guess_width > available_width) { | 1417 if (guess_width > available_width) { |
1418 hi = guess - 1; | 1418 hi = guess - 1; |
1419 // Move back on the loop terminating condition when the guess is too wide. | 1419 // Move back on the loop terminating condition when the guess is too wide. |
1420 if (hi < lo) | 1420 if (hi < lo) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 | 1507 |
1508 SetDisplayOffset(display_offset_.x() + delta_x); | 1508 SetDisplayOffset(display_offset_.x() + delta_x); |
1509 } | 1509 } |
1510 | 1510 |
1511 void RenderText::DrawSelection(Canvas* canvas) { | 1511 void RenderText::DrawSelection(Canvas* canvas) { |
1512 for (const Rect& s : GetSubstringBounds(selection())) | 1512 for (const Rect& s : GetSubstringBounds(selection())) |
1513 canvas->FillRect(s, selection_background_focused_color_); | 1513 canvas->FillRect(s, selection_background_focused_color_); |
1514 } | 1514 } |
1515 | 1515 |
1516 } // namespace gfx | 1516 } // namespace gfx |
OLD | NEW |