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 module ui.mojom; | 5 module ui.mojom; |
6 | 6 |
7 import "mojo/common/rtl.mojom"; | |
7 import "ui/events/mojo/event.mojom"; | 8 import "ui/events/mojo/event.mojom"; |
8 import "ui/gfx/geometry/mojo/geometry.mojom"; | 9 import "ui/gfx/geometry/mojo/geometry.mojom"; |
9 import "ui/gfx/range/mojo/range.mojom"; | 10 import "ui/gfx/range/mojo/range.mojom"; |
10 | 11 |
11 // Represents an underlined segment of text currently composed by IME. | 12 // Represents an underlined segment of text currently composed by IME. |
12 // Corresponds to ui::CompositionUnderline. | 13 // Corresponds to ui::CompositionUnderline. |
13 struct CompositionUnderline { | 14 struct CompositionUnderline { |
14 uint32 start_offset; | 15 uint32 start_offset; |
15 uint32 end_offset; | 16 uint32 end_offset; |
16 bool thick; | 17 bool thick; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 EMAIL, | 64 EMAIL, |
64 URL, | 65 URL, |
65 }; | 66 }; |
66 | 67 |
67 // A service which provides the IMEDriver interface is responsible for doing | 68 // A service which provides the IMEDriver interface is responsible for doing |
68 // the composition logic. After starting a session, it receives events from | 69 // the composition logic. After starting a session, it receives events from |
69 // the client via the InputMethod interface, and sends composition events to | 70 // the client via the InputMethod interface, and sends composition events to |
70 // the client via the TextInputClient. | 71 // the client via the TextInputClient. |
71 interface IMEDriver { | 72 interface IMEDriver { |
72 // session_id is unique and generated by Mus. | 73 // session_id is unique and generated by Mus. |
73 StartSession(int32 session_id, TextInputClient client, | 74 StartSession(int32 session_id, TextInputClientInformation client_info, |
74 InputMethod& input_method); | 75 TextInputClient client, InputMethod& input_method); |
75 CancelSession(int32 session_id); | 76 CancelSession(int32 session_id); |
76 }; | 77 }; |
77 | 78 |
78 // Clients use IME using the IMEServer interface which is provided by Mus. Mus | 79 // Clients use IME using the IMEServer interface which is provided by Mus. Mus |
79 // does minimal processing and mostly just acts as lightweight proxy between | 80 // does minimal processing and mostly just acts as lightweight proxy between |
80 // the client app and the registered IME driver. | 81 // the client app and the registered IME driver. |
81 interface IMEServer { | 82 interface IMEServer { |
82 StartSession(TextInputClient client, | 83 StartSession(TextInputClientInformation client_info, TextInputClient client, |
83 InputMethod& input_method); | 84 InputMethod& input_method); |
84 }; | 85 }; |
85 | 86 |
86 // An IME driver register should register itself to Mus using the IMERegistrar | 87 // An IME driver register should register itself to Mus using the IMERegistrar |
87 // interface. | 88 // interface. |
88 interface IMERegistrar { | 89 interface IMERegistrar { |
89 RegisterDriver(IMEDriver driver); | 90 RegisterDriver(IMEDriver driver); |
90 }; | 91 }; |
91 | 92 |
92 // A client sends updates to the IME driver using the InputMethod interface. | 93 // A client sends updates to the IME driver using the InputMethod interface. |
93 // This interface is provided by IME drivers, and also by Mus as a lightweight | 94 // This interface is provided by IME drivers, and also by Mus as a lightweight |
94 // proxy between IME drivers and clients. | 95 // proxy between IME drivers and clients. |
95 interface InputMethod { | 96 interface InputMethod { |
96 OnTextInputModeChanged(TextInputMode text_input_mode); | 97 OnTextInputModeChanged(TextInputMode text_input_mode); |
97 OnTextInputTypeChanged(TextInputType text_input_type); | 98 OnTextInputTypeChanged(TextInputType text_input_type); |
98 | 99 |
99 // Client sends |caret_bounds| in focused window coordinates, | 100 // Client sends |caret_bounds| in focused window coordinates, |
100 // Mus translates it to global coordinates and sends it to IME app. | 101 // Mus translates it to global coordinates and sends it to IME app. |
101 OnCaretBoundsChanged(gfx.mojom.Rect caret_bounds); | 102 OnCaretBoundsChanged(gfx.mojom.Rect caret_bounds); |
102 | 103 |
103 // Called to process a key event. The callback function will be called to | 104 // Called to process a key event. The callback function will be called to |
104 // notify the client if the event was handled or not. A handled event may | 105 // notify the client if the event was handled or not. A handled event may |
105 // generate zero or more composition events which will be sent to the client | 106 // generate zero or more composition events which will be sent to the client |
106 // using the "input method result" functions of TextInputClient interface. | 107 // using the "input method result" functions of TextInputClient interface. |
107 ProcessKeyEvent(ui.mojom.Event key_event) => (bool handled); | 108 ProcessKeyEvent(ui.mojom.Event key_event) => (bool handled); |
108 | 109 |
109 CancelComposition(); | 110 CancelComposition(); |
110 }; | 111 }; |
111 | 112 |
113 // Contains information about a TextInputClient required by an IMEDriver. Client | |
114 // sends the initial state when starting a session, and can update some of these | |
115 // variables using methods in InputMethod. | |
116 struct TextInputClientInformation { | |
sky
2017/01/13 20:32:41
Information -> Data or Details?
| |
117 TextInputType text_input_type; | |
118 TextInputMode text_input_mode; | |
119 mojo.common.mojom.TextDirection text_direction; | |
120 int32 text_input_flags; | |
121 gfx.mojom.Rect caret_bounds; | |
sky
2017/01/13 20:32:41
Would it make sense to move TextInputClient and In
Hadi
2017/01/13 21:47:52
Yes, I think it'll make the code simpler. Done.
| |
122 }; | |
123 | |
112 // IME drivers send updates to clients using the TextInputClient interface. | 124 // IME drivers send updates to clients using the TextInputClient interface. |
113 interface TextInputClient { | 125 interface TextInputClient { |
114 // Functions corresponding to "input method result" functions of | 126 // Functions corresponding to "input method result" functions of |
115 // ui::TextInputClient. See comments for InputMethod::ProcessKeyEvent() for | 127 // ui::TextInputClient. See comments for InputMethod::ProcessKeyEvent() for |
116 // when these are called. | 128 // when these are called. |
117 | 129 |
118 // Sets composition text and attributes. See comments for | 130 // Sets composition text and attributes. See comments for |
119 // ui::TextInputClient::SetCompositionText() for more details. | 131 // ui::TextInputClient::SetCompositionText() for more details. |
120 SetCompositionText(CompositionText composition); | 132 SetCompositionText(CompositionText composition); |
121 | 133 |
(...skipping 12 matching lines...) Expand all Loading... | |
134 // the character is not processed. See ui::TextInputClient::InsertChar() | 146 // the character is not processed. See ui::TextInputClient::InsertChar() |
135 // for more details. | 147 // for more details. |
136 InsertChar(ui.mojom.Event event); | 148 InsertChar(ui.mojom.Event event); |
137 | 149 |
138 // TODO(moshayedi): Add functions corresponding to ui::TextInputClient for: | 150 // TODO(moshayedi): Add functions corresponding to ui::TextInputClient for: |
139 // - Input context information | 151 // - Input context information |
140 // - Document content operations | 152 // - Document content operations |
141 // - Miscellaneous functions | 153 // - Miscellaneous functions |
142 // crbug.com/631527. | 154 // crbug.com/631527. |
143 }; | 155 }; |
OLD | NEW |