| 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_BASE_IME_TEXT_INPUT_CLIENT_H_ | 5 #ifndef UI_BASE_IME_TEXT_INPUT_CLIENT_H_ |
| 6 #define UI_BASE_IME_TEXT_INPUT_CLIENT_H_ | 6 #define UI_BASE_IME_TEXT_INPUT_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "ui/base/ime/composition_text.h" | 11 #include "ui/base/ime/composition_text.h" |
| 12 #include "ui/base/ime/text_input_mode.h" | 12 #include "ui/base/ime/text_input_mode.h" |
| 13 #include "ui/base/ime/text_input_type.h" | 13 #include "ui/base/ime/text_input_type.h" |
| 14 #include "ui/base/range/range.h" | |
| 15 #include "ui/base/ui_export.h" | 14 #include "ui/base/ui_export.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
| 16 #include "ui/gfx/range/range.h" |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class Rect; | 19 class Rect; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 // An interface implemented by a View that needs text input support. | 24 // An interface implemented by a View that needs text input support. |
| 25 class UI_EXPORT TextInputClient { | 25 class UI_EXPORT TextInputClient { |
| 26 public: | 26 public: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 virtual bool GetCompositionCharacterBounds(uint32 index, gfx::Rect* rect) = 0; | 84 virtual bool GetCompositionCharacterBounds(uint32 index, gfx::Rect* rect) = 0; |
| 85 | 85 |
| 86 // Returns true if there is composition text. | 86 // Returns true if there is composition text. |
| 87 virtual bool HasCompositionText() = 0; | 87 virtual bool HasCompositionText() = 0; |
| 88 | 88 |
| 89 // Document content operations ---------------------------------------------- | 89 // Document content operations ---------------------------------------------- |
| 90 | 90 |
| 91 // Retrieves the UTF-16 based character range containing accessibled text in | 91 // Retrieves the UTF-16 based character range containing accessibled text in |
| 92 // the View. It must cover the composition and selection range. | 92 // the View. It must cover the composition and selection range. |
| 93 // Returns false if the information cannot be retrieved right now. | 93 // Returns false if the information cannot be retrieved right now. |
| 94 virtual bool GetTextRange(ui::Range* range) = 0; | 94 virtual bool GetTextRange(gfx::Range* range) = 0; |
| 95 | 95 |
| 96 // Retrieves the UTF-16 based character range of current composition text. | 96 // Retrieves the UTF-16 based character range of current composition text. |
| 97 // Returns false if the information cannot be retrieved right now. | 97 // Returns false if the information cannot be retrieved right now. |
| 98 virtual bool GetCompositionTextRange(ui::Range* range) = 0; | 98 virtual bool GetCompositionTextRange(gfx::Range* range) = 0; |
| 99 | 99 |
| 100 // Retrieves the UTF-16 based character range of current selection. | 100 // Retrieves the UTF-16 based character range of current selection. |
| 101 // Returns false if the information cannot be retrieved right now. | 101 // Returns false if the information cannot be retrieved right now. |
| 102 virtual bool GetSelectionRange(ui::Range* range) = 0; | 102 virtual bool GetSelectionRange(gfx::Range* range) = 0; |
| 103 | 103 |
| 104 // Selects the given UTF-16 based character range. Current composition text | 104 // Selects the given UTF-16 based character range. Current composition text |
| 105 // will be confirmed before selecting the range. | 105 // will be confirmed before selecting the range. |
| 106 // Returns false if the operation is not supported. | 106 // Returns false if the operation is not supported. |
| 107 virtual bool SetSelectionRange(const ui::Range& range) = 0; | 107 virtual bool SetSelectionRange(const gfx::Range& range) = 0; |
| 108 | 108 |
| 109 // Deletes contents in the given UTF-16 based character range. Current | 109 // Deletes contents in the given UTF-16 based character range. Current |
| 110 // composition text will be confirmed before deleting the range. | 110 // composition text will be confirmed before deleting the range. |
| 111 // The input caret will be moved to the place where the range gets deleted. | 111 // The input caret will be moved to the place where the range gets deleted. |
| 112 // ExtendSelectionAndDelete should be used instead as far as you are deleting | 112 // ExtendSelectionAndDelete should be used instead as far as you are deleting |
| 113 // characters around current caret. This function with the range based on | 113 // characters around current caret. This function with the range based on |
| 114 // GetSelectionRange has a race condition due to asynchronous IPCs between | 114 // GetSelectionRange has a race condition due to asynchronous IPCs between |
| 115 // browser and renderer. | 115 // browser and renderer. |
| 116 // Returns false if the operation is not supported. | 116 // Returns false if the operation is not supported. |
| 117 virtual bool DeleteRange(const ui::Range& range) = 0; | 117 virtual bool DeleteRange(const gfx::Range& range) = 0; |
| 118 | 118 |
| 119 // Retrieves the text content in a given UTF-16 based character range. | 119 // Retrieves the text content in a given UTF-16 based character range. |
| 120 // The result will be stored into |*text|. | 120 // The result will be stored into |*text|. |
| 121 // Returns false if the operation is not supported or the specified range | 121 // Returns false if the operation is not supported or the specified range |
| 122 // is out of the text range returned by GetTextRange(). | 122 // is out of the text range returned by GetTextRange(). |
| 123 virtual bool GetTextFromRange(const ui::Range& range, string16* text) = 0; | 123 virtual bool GetTextFromRange(const gfx::Range& range, string16* text) = 0; |
| 124 | 124 |
| 125 // Miscellaneous ------------------------------------------------------------ | 125 // Miscellaneous ------------------------------------------------------------ |
| 126 | 126 |
| 127 // Called whenever current keyboard layout or input method is changed, | 127 // Called whenever current keyboard layout or input method is changed, |
| 128 // especially the change of input locale and text direction. | 128 // especially the change of input locale and text direction. |
| 129 virtual void OnInputMethodChanged() = 0; | 129 virtual void OnInputMethodChanged() = 0; |
| 130 | 130 |
| 131 // Called whenever the user requests to change the text direction and layout | 131 // Called whenever the user requests to change the text direction and layout |
| 132 // alignment of the current text box. It's for supporting ctrl-shift on | 132 // alignment of the current text box. It's for supporting ctrl-shift on |
| 133 // Windows. | 133 // Windows. |
| 134 // Returns false if the operation is not supported. | 134 // Returns false if the operation is not supported. |
| 135 virtual bool ChangeTextDirectionAndLayoutAlignment( | 135 virtual bool ChangeTextDirectionAndLayoutAlignment( |
| 136 base::i18n::TextDirection direction) = 0; | 136 base::i18n::TextDirection direction) = 0; |
| 137 | 137 |
| 138 // Deletes the current selection plus the specified number of characters | 138 // Deletes the current selection plus the specified number of characters |
| 139 // before and after the selection or caret. This function should be used | 139 // before and after the selection or caret. This function should be used |
| 140 // instead of calling DeleteRange with GetSelectionRange, because | 140 // instead of calling DeleteRange with GetSelectionRange, because |
| 141 // GetSelectionRange may not be the latest value due to asynchronous of IPC | 141 // GetSelectionRange may not be the latest value due to asynchronous of IPC |
| 142 // between browser and renderer. | 142 // between browser and renderer. |
| 143 virtual void ExtendSelectionAndDelete(size_t before, size_t after) = 0; | 143 virtual void ExtendSelectionAndDelete(size_t before, size_t after) = 0; |
| 144 | 144 |
| 145 // Ensure the caret is within |rect|. |rect| is in screen coordinates and | 145 // Ensure the caret is within |rect|. |rect| is in screen coordinates and |
| 146 // may extend beyond the bounds of this TextInputClient. | 146 // may extend beyond the bounds of this TextInputClient. |
| 147 virtual void EnsureCaretInRect(const gfx::Rect& rect) = 0; | 147 virtual void EnsureCaretInRect(const gfx::Rect& rect) = 0; |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 } // namespace ui | 150 } // namespace ui |
| 151 | 151 |
| 152 #endif // UI_BASE_IME_TEXT_INPUT_CLIENT_H_ | 152 #endif // UI_BASE_IME_TEXT_INPUT_CLIENT_H_ |
| OLD | NEW |