| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_IME_ENGINE_HANDLER_INTERFACE_H_ | 5 #ifndef UI_BASE_IME_IME_ENGINE_HANDLER_INTERFACE_H_ |
| 6 #define UI_BASE_IME_IME_ENGINE_HANDLER_INTERFACE_H_ | 6 #define UI_BASE_IME_IME_ENGINE_HANDLER_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // An attribute of the field defined at | 47 // An attribute of the field defined at |
| 48 // http://www.whatwg.org/specs/web-apps/current-work/multipage/ | 48 // http://www.whatwg.org/specs/web-apps/current-work/multipage/ |
| 49 // association-of-controls-and-forms.html#input-modalities | 49 // association-of-controls-and-forms.html#input-modalities |
| 50 // :-the-inputmode-attribute. | 50 // :-the-inputmode-attribute. |
| 51 TextInputMode mode; | 51 TextInputMode mode; |
| 52 // An antribute to indicate the flags for web input fields. Please refer to | 52 // An antribute to indicate the flags for web input fields. Please refer to |
| 53 // WebTextInputType. | 53 // WebTextInputType. |
| 54 int flags; | 54 int flags; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 struct KeyboardEvent { | |
| 58 KeyboardEvent(); | |
| 59 virtual ~KeyboardEvent(); | |
| 60 | |
| 61 std::string type; | |
| 62 std::string key; | |
| 63 std::string code; | |
| 64 int key_code; // only used by on-screen keyboards. | |
| 65 std::string extension_id; | |
| 66 bool alt_key; | |
| 67 bool ctrl_key; | |
| 68 bool shift_key; | |
| 69 bool caps_lock; | |
| 70 }; | |
| 71 | |
| 72 enum SegmentStyle { | |
| 73 SEGMENT_STYLE_UNDERLINE, | |
| 74 SEGMENT_STYLE_DOUBLE_UNDERLINE, | |
| 75 SEGMENT_STYLE_NO_UNDERLINE, | |
| 76 }; | |
| 77 | |
| 78 struct SegmentInfo { | |
| 79 int start; | |
| 80 int end; | |
| 81 SegmentStyle style; | |
| 82 }; | |
| 83 | |
| 84 virtual ~IMEEngineHandlerInterface() {} | 57 virtual ~IMEEngineHandlerInterface() {} |
| 85 | 58 |
| 86 // Called when the Chrome input field get the focus. | 59 // Called when the Chrome input field get the focus. |
| 87 virtual void FocusIn(const InputContext& input_context) = 0; | 60 virtual void FocusIn(const InputContext& input_context) = 0; |
| 88 | 61 |
| 89 // Called when the Chrome input field lose the focus. | 62 // Called when the Chrome input field lose the focus. |
| 90 virtual void FocusOut() = 0; | 63 virtual void FocusOut() = 0; |
| 91 | 64 |
| 92 // Called when the IME is enabled. | 65 // Called when the IME is enabled. |
| 93 virtual void Enable(const std::string& component_id) = 0; | 66 virtual void Enable(const std::string& component_id) = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 uint32_t anchor_pos, | 86 uint32_t anchor_pos, |
| 114 uint32_t offset_pos) = 0; | 87 uint32_t offset_pos) = 0; |
| 115 | 88 |
| 116 // Called when the composition bounds changed. | 89 // Called when the composition bounds changed. |
| 117 virtual void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) = 0; | 90 virtual void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) = 0; |
| 118 | 91 |
| 119 // Returns whether the engine is interested in key events. | 92 // Returns whether the engine is interested in key events. |
| 120 // If not, InputMethodChromeOS won't feed it with key events. | 93 // If not, InputMethodChromeOS won't feed it with key events. |
| 121 virtual bool IsInterestedInKeyEvent() const = 0; | 94 virtual bool IsInterestedInKeyEvent() const = 0; |
| 122 | 95 |
| 123 // Set the current composition and associated properties. | |
| 124 virtual bool SetComposition(int context_id, | |
| 125 const char* text, | |
| 126 int selection_start, | |
| 127 int selection_end, | |
| 128 int cursor, | |
| 129 const std::vector<SegmentInfo>& segments, | |
| 130 std::string* error) = 0; | |
| 131 | |
| 132 // Clear the current composition. | 96 // Clear the current composition. |
| 133 virtual bool ClearComposition(int context_id, std::string* error) = 0; | 97 virtual bool ClearComposition(int context_id, std::string* error) = 0; |
| 134 | 98 |
| 135 // Commit the specified text to the specified context. Fails if the context | 99 // Commit the specified text to the specified context. Fails if the context |
| 136 // is not focused. | 100 // is not focused. |
| 137 virtual bool CommitText(int context_id, | 101 virtual bool CommitText(int context_id, |
| 138 const char* text, | 102 const char* text, |
| 139 std::string* error) = 0; | 103 std::string* error) = 0; |
| 140 | 104 |
| 141 // Send the sequence of key events. | |
| 142 virtual bool SendKeyEvents(int context_id, | |
| 143 const std::vector<KeyboardEvent>& events) = 0; | |
| 144 | |
| 145 // Returns true if this IME is active, false if not. | 105 // Returns true if this IME is active, false if not. |
| 146 virtual bool IsActive() const = 0; | 106 virtual bool IsActive() const = 0; |
| 147 | 107 |
| 148 // Returns the current active input_component id. | 108 // Returns the current active input_component id. |
| 149 virtual const std::string& GetActiveComponentId() const = 0; | 109 virtual const std::string& GetActiveComponentId() const = 0; |
| 150 | 110 |
| 151 // Deletes |number_of_chars| unicode characters as the basis of |offset| from | 111 // Deletes |number_of_chars| unicode characters as the basis of |offset| from |
| 152 // the surrounding text. The |offset| is relative position based on current | 112 // the surrounding text. The |offset| is relative position based on current |
| 153 // caret. | 113 // caret. |
| 154 // NOTE: Currently we are falling back to backspace forwarding workaround, | 114 // NOTE: Currently we are falling back to backspace forwarding workaround, |
| 155 // because delete_surrounding_text is not supported in Chrome. So this | 115 // because delete_surrounding_text is not supported in Chrome. So this |
| 156 // function is restricted for only preceding text. | 116 // function is restricted for only preceding text. |
| 157 // TODO(nona): Support full spec delete surrounding text. | 117 // TODO(nona): Support full spec delete surrounding text. |
| 158 virtual bool DeleteSurroundingText(int context_id, | 118 virtual bool DeleteSurroundingText(int context_id, |
| 159 int offset, | 119 int offset, |
| 160 size_t number_of_chars, | 120 size_t number_of_chars, |
| 161 std::string* error) = 0; | 121 std::string* error) = 0; |
| 162 | |
| 163 // ChromeOS only APIs. | |
| 164 #if defined(OS_CHROMEOS) | 122 #if defined(OS_CHROMEOS) |
| 165 | 123 |
| 166 enum { | |
| 167 MENU_ITEM_MODIFIED_LABEL = 0x0001, | |
| 168 MENU_ITEM_MODIFIED_STYLE = 0x0002, | |
| 169 MENU_ITEM_MODIFIED_VISIBLE = 0x0004, | |
| 170 MENU_ITEM_MODIFIED_ENABLED = 0x0008, | |
| 171 MENU_ITEM_MODIFIED_CHECKED = 0x0010, | |
| 172 MENU_ITEM_MODIFIED_ICON = 0x0020, | |
| 173 }; | |
| 174 | |
| 175 enum MenuItemStyle { | |
| 176 MENU_ITEM_STYLE_NONE, | |
| 177 MENU_ITEM_STYLE_CHECK, | |
| 178 MENU_ITEM_STYLE_RADIO, | |
| 179 MENU_ITEM_STYLE_SEPARATOR, | |
| 180 }; | |
| 181 | |
| 182 enum CandidateWindowPosition { | |
| 183 WINDOW_POS_CURSOR, | |
| 184 WINDOW_POS_COMPOSITTION, | |
| 185 }; | |
| 186 | |
| 187 struct MenuItem { | |
| 188 MenuItem(); | |
| 189 virtual ~MenuItem(); | |
| 190 | |
| 191 std::string id; | |
| 192 std::string label; | |
| 193 MenuItemStyle style; | |
| 194 bool visible; | |
| 195 bool enabled; | |
| 196 bool checked; | |
| 197 | |
| 198 unsigned int modified; | |
| 199 std::vector<MenuItem> children; | |
| 200 }; | |
| 201 | |
| 202 struct UsageEntry { | |
| 203 std::string title; | |
| 204 std::string body; | |
| 205 }; | |
| 206 | |
| 207 struct Candidate { | |
| 208 Candidate(); | |
| 209 virtual ~Candidate(); | |
| 210 | |
| 211 std::string value; | |
| 212 int id; | |
| 213 std::string label; | |
| 214 std::string annotation; | |
| 215 UsageEntry usage; | |
| 216 std::vector<Candidate> candidates; | |
| 217 }; | |
| 218 | |
| 219 struct CandidateWindowProperty { | |
| 220 CandidateWindowProperty(); | |
| 221 virtual ~CandidateWindowProperty(); | |
| 222 int page_size; | |
| 223 bool is_cursor_visible; | |
| 224 bool is_vertical; | |
| 225 bool show_window_at_composition; | |
| 226 | |
| 227 // Auxiliary text is typically displayed in the footer of the candidate | |
| 228 // window. | |
| 229 std::string auxiliary_text; | |
| 230 bool is_auxiliary_text_visible; | |
| 231 }; | |
| 232 | |
| 233 // Called when a property is activated or changed. | 124 // Called when a property is activated or changed. |
| 234 virtual void PropertyActivate(const std::string& property_name) = 0; | 125 virtual void PropertyActivate(const std::string& property_name) = 0; |
| 235 | 126 |
| 236 // Called when the candidate in lookup table is clicked. The |index| is 0 | 127 // Called when the candidate in lookup table is clicked. The |index| is 0 |
| 237 // based candidate index in lookup table. | 128 // based candidate index in lookup table. |
| 238 virtual void CandidateClicked(uint32_t index) = 0; | 129 virtual void CandidateClicked(uint32_t index) = 0; |
| 239 | 130 |
| 240 // This function returns the current property of the candidate window. | |
| 241 // The caller can use the returned value as the default property and | |
| 242 // modify some of specified items. | |
| 243 virtual const CandidateWindowProperty& GetCandidateWindowProperty() const = 0; | |
| 244 | |
| 245 // Change the property of the candidate window and repaint the candidate | |
| 246 // window widget. | |
| 247 virtual void SetCandidateWindowProperty( | |
| 248 const CandidateWindowProperty& property) = 0; | |
| 249 | |
| 250 // Show or hide the candidate window. | 131 // Show or hide the candidate window. |
| 251 virtual bool SetCandidateWindowVisible(bool visible, std::string* error) = 0; | 132 virtual bool SetCandidateWindowVisible(bool visible, std::string* error) = 0; |
| 252 | 133 |
| 253 // Set the list of entries displayed in the candidate window. | |
| 254 virtual bool SetCandidates(int context_id, | |
| 255 const std::vector<Candidate>& candidates, | |
| 256 std::string* error) = 0; | |
| 257 | |
| 258 // Set the position of the cursor in the candidate window. | 134 // Set the position of the cursor in the candidate window. |
| 259 virtual bool SetCursorPosition(int context_id, | 135 virtual bool SetCursorPosition(int context_id, |
| 260 int candidate_id, | 136 int candidate_id, |
| 261 std::string* error) = 0; | 137 std::string* error) = 0; |
| 262 | |
| 263 // Set the list of items that appears in the language menu when this IME is | |
| 264 // active. | |
| 265 virtual bool SetMenuItems(const std::vector<MenuItem>& items) = 0; | |
| 266 | |
| 267 // Update the state of the menu items. | |
| 268 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) = 0; | |
| 269 | |
| 270 // Hides the input view window (from API call). | 138 // Hides the input view window (from API call). |
| 271 virtual void HideInputView() = 0; | 139 virtual void HideInputView() = 0; |
| 272 | 140 |
| 273 #endif // defined(OS_CHROMEOS) | 141 #endif // defined(OS_CHROMEOS) |
| 274 | |
| 275 protected: | 142 protected: |
| 276 IMEEngineHandlerInterface() {} | 143 IMEEngineHandlerInterface() {} |
| 277 }; | 144 }; |
| 278 | 145 |
| 279 } // namespace ui | 146 } // namespace ui |
| 280 | 147 |
| 281 #endif // UI_BASE_IME_IME_ENGINE_HANDLER_INTERFACE_H_ | 148 #endif // UI_BASE_IME_IME_ENGINE_HANDLER_INTERFACE_H_ |
| OLD | NEW |