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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 for (; selection_max < text().length(); ++selection_max) | 677 for (; selection_max < text().length(); ++selection_max) |
678 if (iter.IsEndOfWord(selection_max) || iter.IsStartOfWord(selection_max)) | 678 if (iter.IsEndOfWord(selection_max) || iter.IsStartOfWord(selection_max)) |
679 break; | 679 break; |
680 | 680 |
681 const bool reversed = selection().is_reversed(); | 681 const bool reversed = selection().is_reversed(); |
682 MoveCursorTo(reversed ? selection_max : selection_min, false); | 682 MoveCursorTo(reversed ? selection_max : selection_min, false); |
683 MoveCursorTo(reversed ? selection_min : selection_max, true); | 683 MoveCursorTo(reversed ? selection_min : selection_max, true); |
684 } | 684 } |
685 | 685 |
686 const Range& RenderText::GetCompositionRange() const { | |
687 return composition_range_; | |
688 } | |
689 | |
690 void RenderText::SetCompositionRange(const Range& composition_range) { | 686 void RenderText::SetCompositionRange(const Range& composition_range) { |
691 CHECK(!composition_range.IsValid() || | 687 CHECK(!composition_range.IsValid() || |
692 Range(0, text_.length()).Contains(composition_range)); | 688 Range(0, text_.length()).Contains(composition_range)); |
693 composition_range_.set_end(composition_range.end()); | 689 composition_range_.set_end(composition_range.end()); |
694 composition_range_.set_start(composition_range.start()); | 690 composition_range_.set_start(composition_range.start()); |
695 // TODO(oshima|msw): Altering composition underlines shouldn't | 691 // TODO(oshima|msw): Altering composition underlines shouldn't |
696 // require layout changes. It's currently necessary because | 692 // require layout changes. It's currently necessary because |
697 // RenderTextHarfBuzz paints text decorations by run, and | 693 // RenderTextHarfBuzz paints text decorations by run, and |
698 // RenderTextMac applies all styles during layout. | 694 // RenderTextMac applies all styles during layout. |
699 OnLayoutTextAttributeChanged(false); | 695 OnLayoutTextAttributeChanged(false); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 | 1503 |
1508 SetDisplayOffset(display_offset_.x() + delta_x); | 1504 SetDisplayOffset(display_offset_.x() + delta_x); |
1509 } | 1505 } |
1510 | 1506 |
1511 void RenderText::DrawSelection(Canvas* canvas) { | 1507 void RenderText::DrawSelection(Canvas* canvas) { |
1512 for (const Rect& s : GetSubstringBounds(selection())) | 1508 for (const Rect& s : GetSubstringBounds(selection())) |
1513 canvas->FillRect(s, selection_background_focused_color_); | 1509 canvas->FillRect(s, selection_background_focused_color_); |
1514 } | 1510 } |
1515 | 1511 |
1516 } // namespace gfx | 1512 } // namespace gfx |
OLD | NEW |