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