| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 module ui.mojom; | |
| 6 | |
| 7 import "ui/events/mojo/event.mojom"; | |
| 8 import "ui/gfx/geometry/mojo/geometry.mojom"; | |
| 9 | |
| 10 struct CompositionEvent { | |
| 11 CompositionEventType type; | |
| 12 | |
| 13 // Used when |type| is INSERT_CHAR. See the comments for | |
| 14 // ui::TextInputClient::InsertChar() for more information. | |
| 15 Event? key_event; | |
| 16 | |
| 17 // TODO(moshayedi): crbug.com/631524. Add fields required for other types of | |
| 18 // composition event. | |
| 19 }; | |
| 20 | |
| 21 enum CompositionEventType { | |
| 22 UPDATE, | |
| 23 CONFIRM, | |
| 24 CLEAR, | |
| 25 INSERT_CHAR, | |
| 26 INSERT_TEXT | |
| 27 }; | |
| 28 | |
| 29 // See comments for ui::TextInputType for more details. | |
| 30 enum TextInputType { | |
| 31 NONE, | |
| 32 TEXT, | |
| 33 PASSWORD, | |
| 34 SEARCH, | |
| 35 EMAIL, | |
| 36 NUMBER, | |
| 37 TELEPHONE, | |
| 38 URL, | |
| 39 DATE, | |
| 40 TIME, | |
| 41 DATETIME, | |
| 42 }; | |
| 43 | |
| 44 // See comments for ui::TextInputMode for more details. | |
| 45 enum TextInputMode { | |
| 46 DEFAULT, | |
| 47 VERBATIM, | |
| 48 LATIN, | |
| 49 LATIN_NAME, | |
| 50 LATIN_PROSE, | |
| 51 FULL_WIDTH_LATIN, | |
| 52 KANA, | |
| 53 KATAKANA, | |
| 54 NUMERIC, | |
| 55 TEL, | |
| 56 EMAIL, | |
| 57 URL, | |
| 58 }; | |
| 59 | |
| 60 // A service which provides the IMEDriver interface is responsible for doing | |
| 61 // the composition logic. After starting a session, it receives events from | |
| 62 // the client via the InputMethod interface, and sends composition events to | |
| 63 // the client via the TextInputClient. | |
| 64 interface IMEDriver { | |
| 65 // session_id is unique and generated by Mus. | |
| 66 StartSession(int32 session_id, TextInputClient client, | |
| 67 InputMethod& input_method); | |
| 68 CancelSession(int32 session_id); | |
| 69 }; | |
| 70 | |
| 71 // Clients use IME using the IMEServer interface which is provided by Mus. Mus | |
| 72 // does minimal processing and mostly just acts as lightweight proxy between | |
| 73 // the client app and the registered IME driver. | |
| 74 interface IMEServer { | |
| 75 StartSession(TextInputClient client, | |
| 76 InputMethod& input_method); | |
| 77 }; | |
| 78 | |
| 79 // An IME driver register should register itself to Mus using the IMERegistrar | |
| 80 // interface. | |
| 81 interface IMERegistrar { | |
| 82 RegisterDriver(IMEDriver driver); | |
| 83 }; | |
| 84 | |
| 85 // A client sends updates to the IME driver using the InputMethod interface. | |
| 86 // This interface is provided by IME drivers, and also by Mus as a lightweight | |
| 87 // proxy between IME drivers and clients. | |
| 88 interface InputMethod { | |
| 89 OnTextInputModeChanged(TextInputMode text_input_mode); | |
| 90 OnTextInputTypeChanged(TextInputType text_input_type); | |
| 91 | |
| 92 // Client sends |caret_bounds| in focused window coordinates, | |
| 93 // Mus translates it to global coordinates and sends it to IME app. | |
| 94 OnCaretBoundsChanged(gfx.mojom.Rect caret_bounds); | |
| 95 | |
| 96 // Called to process a key event. The callback function will be called to | |
| 97 // notify the client if the event was handled or not. A handled event may | |
| 98 // generate zero or more composition events which will be sent to the client | |
| 99 // by calling TextInputClient::OnCompositionEvent(). | |
| 100 ProcessKeyEvent(ui.mojom.Event key_event) => (bool handled); | |
| 101 | |
| 102 CancelComposition(); | |
| 103 }; | |
| 104 | |
| 105 // IME drivers send updates to clients using the TextInputClient interface. | |
| 106 interface TextInputClient { | |
| 107 // Corresponds to "input method result" functions of ui::TextInputClient. | |
| 108 // See comments for InputMethod::ProcessKeyEvent() for when this is called. | |
| 109 OnCompositionEvent(CompositionEvent event); | |
| 110 | |
| 111 // TODO(moshayedi): Add functions corresponding to ui::TextInputClient for: | |
| 112 // - Input text confirmation | |
| 113 // - Document content operations | |
| 114 // - Miscellaneous functions | |
| 115 // crbug.com/631527. | |
| 116 }; | |
| OLD | NEW |