| 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 #ifndef UI_GFX_RENDER_TEXT_WIN_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_WIN_H_ |
| 6 #define UI_GFX_RENDER_TEXT_WIN_H_ | 6 #define UI_GFX_RENDER_TEXT_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <usp10.h> | 9 #include <usp10.h> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } // namespace internal | 58 } // namespace internal |
| 59 | 59 |
| 60 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. | 60 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. |
| 61 class RenderTextWin : public RenderText { | 61 class RenderTextWin : public RenderText { |
| 62 public: | 62 public: |
| 63 RenderTextWin(); | 63 RenderTextWin(); |
| 64 virtual ~RenderTextWin(); | 64 virtual ~RenderTextWin(); |
| 65 | 65 |
| 66 // Overridden from RenderText: | 66 // Overridden from RenderText: |
| 67 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; | 67 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; |
| 68 virtual int GetStringWidth() OVERRIDE; | 68 virtual Size GetStringSize() OVERRIDE; |
| 69 virtual void GetGlyphBounds(size_t index, |
| 70 ui::Range* xspan, |
| 71 int* height) OVERRIDE; |
| 69 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; | 72 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
| 70 virtual Rect GetCursorBounds(const SelectionModel& selection, | |
| 71 bool insert_mode) OVERRIDE; | |
| 72 | 73 |
| 73 protected: | 74 protected: |
| 74 // Overridden from RenderText: | 75 // Overridden from RenderText: |
| 75 virtual SelectionModel AdjacentCharSelectionModel( | 76 virtual SelectionModel AdjacentCharSelectionModel( |
| 76 const SelectionModel& selection, | 77 const SelectionModel& selection, |
| 77 VisualCursorDirection direction) OVERRIDE; | 78 VisualCursorDirection direction) OVERRIDE; |
| 78 virtual SelectionModel AdjacentWordSelectionModel( | 79 virtual SelectionModel AdjacentWordSelectionModel( |
| 79 const SelectionModel& selection, | 80 const SelectionModel& selection, |
| 80 VisualCursorDirection direction) OVERRIDE; | 81 VisualCursorDirection direction) OVERRIDE; |
| 81 virtual SelectionModel EdgeSelectionModel( | 82 virtual std::vector<Rect> GetSubstringBounds(ui::Range range) OVERRIDE; |
| 82 VisualCursorDirection direction) OVERRIDE; | |
| 83 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE; | |
| 84 virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE; | 83 virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE; |
| 85 virtual bool IsCursorablePosition(size_t position) OVERRIDE; | 84 virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
| 86 virtual void UpdateLayout() OVERRIDE; | 85 virtual void UpdateLayout() OVERRIDE; |
| 87 virtual void EnsureLayout() OVERRIDE; | 86 virtual void EnsureLayout() OVERRIDE; |
| 88 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; | 87 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 virtual size_t IndexOfAdjacentGrapheme( | 90 virtual size_t IndexOfAdjacentGrapheme( |
| 92 size_t index, | 91 size_t index, |
| 93 LogicalCursorDirection direction) OVERRIDE; | 92 LogicalCursorDirection direction) OVERRIDE; |
| 94 | 93 |
| 95 void ItemizeLogicalText(); | 94 void ItemizeLogicalText(); |
| 96 void LayoutVisualText(); | 95 void LayoutVisualText(); |
| 97 | 96 |
| 98 // Return the run index that contains the argument; or the length of the | 97 // Return the run index that contains the argument; or the length of the |
| 99 // |runs_| vector if argument exceeds the text length or width. | 98 // |runs_| vector if argument exceeds the text length or width. |
| 100 size_t GetRunContainingPosition(size_t position) const; | 99 size_t GetRunContainingCaret(const SelectionModel& caret) const; |
| 101 size_t GetRunContainingPoint(const Point& point) const; | 100 size_t GetRunContainingPoint(const Point& point) const; |
| 102 | 101 |
| 103 // Given a |run|, returns the SelectionModel that contains the logical first | 102 // Given a |run|, returns the SelectionModel that contains the logical first |
| 104 // or last caret position inside (not at a boundary of) the run. | 103 // or last caret position inside (not at a boundary of) the run. |
| 105 // The returned value represents a cursor/caret position without a selection. | 104 // The returned value represents a cursor/caret position without a selection. |
| 106 SelectionModel FirstSelectionModelInsideRun(internal::TextRun* run); | 105 SelectionModel FirstSelectionModelInsideRun(internal::TextRun* run); |
| 107 SelectionModel LastSelectionModelInsideRun(internal::TextRun* run); | 106 SelectionModel LastSelectionModelInsideRun(internal::TextRun* run); |
| 108 | 107 |
| 109 SCRIPT_CONTROL script_control_; | 108 SCRIPT_CONTROL script_control_; |
| 110 SCRIPT_STATE script_state_; | 109 SCRIPT_STATE script_state_; |
| 111 | 110 |
| 112 std::vector<internal::TextRun*> runs_; | 111 std::vector<internal::TextRun*> runs_; |
| 113 int string_width_; | 112 int string_width_; |
| 114 | 113 |
| 115 scoped_array<int> visual_to_logical_; | 114 scoped_array<int> visual_to_logical_; |
| 116 scoped_array<int> logical_to_visual_; | 115 scoped_array<int> logical_to_visual_; |
| 117 | 116 |
| 118 bool needs_layout_; | 117 bool needs_layout_; |
| 119 | 118 |
| 120 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); | 119 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); |
| 121 }; | 120 }; |
| 122 | 121 |
| 123 } // namespace gfx | 122 } // namespace gfx |
| 124 | 123 |
| 125 #endif // UI_GFX_RENDER_TEXT_WIN_H_ | 124 #endif // UI_GFX_RENDER_TEXT_WIN_H_ |
| OLD | NEW |