| Index: ui/gfx/render_text.cc
|
| diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
|
| index 4e7281c11695d4b7b70beb85b36e04227f425936..20042c59aae6c0942d13d47a9e13654acb7480c6 100644
|
| --- a/ui/gfx/render_text.cc
|
| +++ b/ui/gfx/render_text.cc
|
| @@ -872,6 +872,42 @@ SelectionModel RenderText::GetSelectionModelForSelectionStart() {
|
| sel.is_reversed() ? CURSOR_BACKWARD : CURSOR_FORWARD);
|
| }
|
|
|
| +const Vector2d& RenderText::GetUpdatedDisplayOffset() {
|
| + UpdateCachedBoundsAndOffset();
|
| + return display_offset_;
|
| +}
|
| +
|
| +void RenderText::SetDisplayOffset(int horizontal_offset) {
|
| + const int extra_content = GetContentWidth() - display_rect_.width();
|
| +
|
| + int min_offset = 0;
|
| + int max_offset = 0;
|
| + if (extra_content > 0) {
|
| + switch (horizontal_alignment_) {
|
| + case ALIGN_LEFT:
|
| + min_offset = -extra_content;
|
| + break;
|
| + case ALIGN_RIGHT:
|
| + max_offset = extra_content;
|
| + break;
|
| + case ALIGN_CENTER:
|
| + min_offset = -extra_content / 2;
|
| + max_offset = extra_content / 2;
|
| + break;
|
| + default:
|
| + break;
|
| + }
|
| + }
|
| + if (horizontal_offset < min_offset)
|
| + horizontal_offset = min_offset;
|
| + else if (horizontal_offset > max_offset)
|
| + horizontal_offset = max_offset;
|
| +
|
| + cached_bounds_and_offset_valid_ = true;
|
| + display_offset_.set_x(horizontal_offset);
|
| + cursor_bounds_ = GetCursorBounds(selection_model_, insert_mode_);
|
| +}
|
| +
|
| RenderText::RenderText()
|
| : horizontal_alignment_(base::i18n::IsRTL() ? ALIGN_RIGHT : ALIGN_LEFT),
|
| directionality_mode_(DIRECTIONALITY_FROM_TEXT),
|
| @@ -898,11 +934,6 @@ RenderText::RenderText()
|
| cached_bounds_and_offset_valid_(false) {
|
| }
|
|
|
| -const Vector2d& RenderText::GetUpdatedDisplayOffset() {
|
| - UpdateCachedBoundsAndOffset();
|
| - return display_offset_;
|
| -}
|
| -
|
| SelectionModel RenderText::GetAdjacentSelectionModel(
|
| const SelectionModel& current,
|
| BreakType break_type,
|
|
|