| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 WebInputMethodController_h | 5 #ifndef WebInputMethodController_h |
| 6 #define WebInputMethodController_h | 6 #define WebInputMethodController_h |
| 7 | 7 |
| 8 #include "../platform/WebTextInputInfo.h" | 8 #include "../platform/WebTextInputInfo.h" |
| 9 #include "WebCompositionUnderline.h" | 9 #include "WebCompositionUnderline.h" |
| 10 #include "WebTextInputType.h" | 10 #include "WebTextInputType.h" |
| 11 #include "WebWidget.h" | 11 #include "WebWidget.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class WebRange; |
| 15 class WebString; | 16 class WebString; |
| 16 template <typename T> | 17 template <typename T> |
| 17 class WebVector; | 18 class WebVector; |
| 18 | 19 |
| 19 class WebInputMethodController { | 20 class WebInputMethodController { |
| 20 public: | 21 public: |
| 21 enum ConfirmCompositionBehavior { | 22 enum ConfirmCompositionBehavior { |
| 22 DoNotKeepSelection, | 23 DoNotKeepSelection, |
| 23 KeepSelection, | 24 KeepSelection, |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 virtual ~WebInputMethodController() {} | 27 virtual ~WebInputMethodController() {} |
| 27 // Called to inform the WebInputMethodController of a new composition text. | 28 |
| 28 // If selectionStart and selectionEnd has the same value, then it indicates | 29 // Called to inform the WebInputMethodController of a new composition text. If |
| 29 // the input caret position. If the text is empty, then the existing | 30 // selectionStart and selectionEnd has the same value, then it indicates the |
| 30 // composition text will be canceled. | 31 // input caret position. If the text is empty, then the existing composition |
| 31 // Returns true if the composition text was set successfully. | 32 // text will be canceled. |replacementRange| (when not null) is the range in |
| 33 // current text which should be replaced by |text|. Returns true if the |
| 34 // composition text was set successfully. |
| 32 virtual bool setComposition( | 35 virtual bool setComposition( |
| 33 const WebString& text, | 36 const WebString& text, |
| 34 const WebVector<WebCompositionUnderline>& underlines, | 37 const WebVector<WebCompositionUnderline>& underlines, |
| 38 const WebRange& replacementRange, |
| 35 int selectionStart, | 39 int selectionStart, |
| 36 int selectionEnd) = 0; | 40 int selectionEnd) = 0; |
| 37 | 41 |
| 38 // Called to inform the controller that deleting the ongoing composition if | 42 // Called to inform the controller to delete the ongoing composition if any, |
| 39 // any, inserting the specified text, and moving the caret according to | 43 // insert |text|, and move the caret according to |relativeCaretPosition|. |
| 40 // relativeCaretPosition. | 44 // |replacementRange| (when not null) is the range in current text which |
| 45 // should be replaced by |text|. |
| 41 virtual bool commitText(const WebString& text, | 46 virtual bool commitText(const WebString& text, |
| 42 const WebVector<WebCompositionUnderline>& underlines, | 47 const WebVector<WebCompositionUnderline>& underlines, |
| 48 const WebRange& replacementRange, |
| 43 int relativeCaretPosition) = 0; | 49 int relativeCaretPosition) = 0; |
| 44 | 50 |
| 45 // Called to inform the controller to confirm an ongoing composition. | 51 // Called to inform the controller to confirm an ongoing composition. |
| 46 virtual bool finishComposingText( | 52 virtual bool finishComposingText( |
| 47 ConfirmCompositionBehavior selectionBehavior) = 0; | 53 ConfirmCompositionBehavior selectionBehavior) = 0; |
| 48 | 54 |
| 49 // Returns information about the current text input of this controller. Note | 55 // Returns information about the current text input of this controller. Note |
| 50 // that this query can be expensive for long fields, as it returns the | 56 // that this query can be expensive for long fields, as it returns the |
| 51 // plain-text representation of the current editable element. Consider using | 57 // plain-text representation of the current editable element. Consider using |
| 52 // the lighter-weight textInputType() when appropriate. | 58 // the lighter-weight textInputType() when appropriate. |
| 53 virtual WebTextInputInfo textInputInfo() { return WebTextInputInfo(); } | 59 virtual WebTextInputInfo textInputInfo() { return WebTextInputInfo(); } |
| 54 | 60 |
| 55 // Returns the type of current text input of this controller. | 61 // Returns the type of current text input of this controller. |
| 56 virtual WebTextInputType textInputType() { return WebTextInputTypeNone; } | 62 virtual WebTextInputType textInputType() { return WebTextInputTypeNone; } |
| 57 }; | 63 }; |
| 58 | 64 |
| 59 } // namespace blink | 65 } // namespace blink |
| 60 #endif | 66 #endif |
| OLD | NEW |