OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 DCHECK_LE(model.selection_start(), text().length()); | 504 DCHECK_LE(model.selection_start(), text().length()); |
505 selection_model_.set_selection_start(model.selection_start()); | 505 selection_model_.set_selection_start(model.selection_start()); |
506 DCHECK_LE(model.selection_end(), text().length()); | 506 DCHECK_LE(model.selection_end(), text().length()); |
507 selection_model_.set_selection_end(model.selection_end()); | 507 selection_model_.set_selection_end(model.selection_end()); |
508 DCHECK_LT(model.caret_pos(), | 508 DCHECK_LT(model.caret_pos(), |
509 std::max(text().length(), static_cast<size_t>(1))); | 509 std::max(text().length(), static_cast<size_t>(1))); |
510 selection_model_.set_caret_pos(model.caret_pos()); | 510 selection_model_.set_caret_pos(model.caret_pos()); |
511 selection_model_.set_caret_placement(model.caret_placement()); | 511 selection_model_.set_caret_placement(model.caret_placement()); |
512 | 512 |
513 cached_bounds_and_offset_valid_ = false; | 513 cached_bounds_and_offset_valid_ = false; |
| 514 UpdateLayout(); |
514 } | 515 } |
515 | 516 |
516 size_t RenderText::GetIndexOfPreviousGrapheme(size_t position) { | 517 size_t RenderText::GetIndexOfPreviousGrapheme(size_t position) { |
517 return IndexOfAdjacentGrapheme(position, false); | 518 return IndexOfAdjacentGrapheme(position, false); |
518 } | 519 } |
519 | 520 |
520 void RenderText::ApplyCompositionAndSelectionStyles( | 521 void RenderText::ApplyCompositionAndSelectionStyles( |
521 StyleRanges* style_ranges) const { | 522 StyleRanges* style_ranges) const { |
522 // TODO(msw): This pattern ought to be reconsidered; what about composition | 523 // TODO(msw): This pattern ought to be reconsidered; what about composition |
523 // and selection overlaps, retain existing local style features? | 524 // and selection overlaps, retain existing local style features? |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 void RenderText::DrawCursor(Canvas* canvas) { | 612 void RenderText::DrawCursor(Canvas* canvas) { |
612 // Paint cursor. Replace cursor is drawn as rectangle for now. | 613 // Paint cursor. Replace cursor is drawn as rectangle for now. |
613 // TODO(msw): Draw a better cursor with a better indication of association. | 614 // TODO(msw): Draw a better cursor with a better indication of association. |
614 if (cursor_visible() && focused()) { | 615 if (cursor_visible() && focused()) { |
615 Rect r(GetUpdatedCursorBounds()); | 616 Rect r(GetUpdatedCursorBounds()); |
616 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); | 617 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); |
617 } | 618 } |
618 } | 619 } |
619 | 620 |
620 } // namespace gfx | 621 } // namespace gfx |
OLD | NEW |