Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: services/ui/public/interfaces/ime/ime_struct_traits.cc

Issue 2626383002: IME for Mus: EnumTraits for TextInputMode and TextInputType. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "services/ui/public/interfaces/ime/ime_struct_traits.h" 5 #include "services/ui/public/interfaces/ime/ime_struct_traits.h"
6 6
7 #include "ui/gfx/range/mojo/range_struct_traits.h" 7 #include "ui/gfx/range/mojo/range_struct_traits.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 10
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 // static 26 // static
27 bool StructTraits<ui::mojom::CompositionTextDataView, ui::CompositionText>:: 27 bool StructTraits<ui::mojom::CompositionTextDataView, ui::CompositionText>::
28 Read(ui::mojom::CompositionTextDataView data, ui::CompositionText* out) { 28 Read(ui::mojom::CompositionTextDataView data, ui::CompositionText* out) {
29 return !data.is_null() && data.ReadText(&out->text) && 29 return !data.is_null() && data.ReadText(&out->text) &&
30 data.ReadUnderlines(&out->underlines) && 30 data.ReadUnderlines(&out->underlines) &&
31 data.ReadSelection(&out->selection); 31 data.ReadSelection(&out->selection);
32 } 32 }
33 33
34 // static
35 ui::mojom::TextInputMode
36 EnumTraits<ui::mojom::TextInputMode, ui::TextInputMode>::ToMojom(
37 ui::TextInputMode text_input_mode) {
38 switch (text_input_mode) {
39 case ui::TEXT_INPUT_MODE_DEFAULT:
40 return ui::mojom::TextInputMode::DEFAULT;
41 case ui::TEXT_INPUT_MODE_VERBATIM:
42 return ui::mojom::TextInputMode::VERBATIM;
43 case ui::TEXT_INPUT_MODE_LATIN:
44 return ui::mojom::TextInputMode::LATIN;
45 case ui::TEXT_INPUT_MODE_LATIN_NAME:
46 return ui::mojom::TextInputMode::LATIN_NAME;
47 case ui::TEXT_INPUT_MODE_LATIN_PROSE:
48 return ui::mojom::TextInputMode::LATIN_PROSE;
49 case ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN:
50 return ui::mojom::TextInputMode::FULL_WIDTH_LATIN;
51 case ui::TEXT_INPUT_MODE_KANA:
52 return ui::mojom::TextInputMode::KANA;
53 case ui::TEXT_INPUT_MODE_KANA_NAME:
54 return ui::mojom::TextInputMode::KANA_NAME;
55 case ui::TEXT_INPUT_MODE_KATAKANA:
56 return ui::mojom::TextInputMode::KATAKANA;
57 case ui::TEXT_INPUT_MODE_NUMERIC:
58 return ui::mojom::TextInputMode::NUMERIC;
59 case ui::TEXT_INPUT_MODE_TEL:
60 return ui::mojom::TextInputMode::TEL;
61 case ui::TEXT_INPUT_MODE_EMAIL:
62 return ui::mojom::TextInputMode::EMAIL;
63 case ui::TEXT_INPUT_MODE_URL:
64 return ui::mojom::TextInputMode::URL;
65 }
66 NOTREACHED();
67 return ui::mojom::TextInputMode::DEFAULT;
68 }
69
70 // static
71 bool EnumTraits<ui::mojom::TextInputMode, ui::TextInputMode>::FromMojom(
72 ui::mojom::TextInputMode input,
73 ui::TextInputMode* out) {
74 switch (input) {
75 case ui::mojom::TextInputMode::DEFAULT:
76 *out = ui::TEXT_INPUT_MODE_DEFAULT;
77 return true;
78 case ui::mojom::TextInputMode::VERBATIM:
79 *out = ui::TEXT_INPUT_MODE_VERBATIM;
80 return true;
81 case ui::mojom::TextInputMode::LATIN:
82 *out = ui::TEXT_INPUT_MODE_LATIN;
83 return true;
84 case ui::mojom::TextInputMode::LATIN_NAME:
85 *out = ui::TEXT_INPUT_MODE_LATIN_NAME;
86 return true;
87 case ui::mojom::TextInputMode::LATIN_PROSE:
88 *out = ui::TEXT_INPUT_MODE_LATIN_PROSE;
89 return true;
90 case ui::mojom::TextInputMode::FULL_WIDTH_LATIN:
91 *out = ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN;
92 return true;
93 case ui::mojom::TextInputMode::KANA:
94 *out = ui::TEXT_INPUT_MODE_KANA;
95 return true;
96 case ui::mojom::TextInputMode::KANA_NAME:
97 *out = ui::TEXT_INPUT_MODE_KANA_NAME;
98 return true;
99 case ui::mojom::TextInputMode::KATAKANA:
100 *out = ui::TEXT_INPUT_MODE_KATAKANA;
101 return true;
102 case ui::mojom::TextInputMode::NUMERIC:
103 *out = ui::TEXT_INPUT_MODE_NUMERIC;
104 return true;
105 case ui::mojom::TextInputMode::TEL:
106 *out = ui::TEXT_INPUT_MODE_TEL;
107 return true;
108 case ui::mojom::TextInputMode::EMAIL:
109 *out = ui::TEXT_INPUT_MODE_EMAIL;
110 return true;
111 case ui::mojom::TextInputMode::URL:
112 *out = ui::TEXT_INPUT_MODE_URL;
113 return true;
114 }
115 return false;
116 }
117
118 // static
119 ui::mojom::TextInputType
120 EnumTraits<ui::mojom::TextInputType, ui::TextInputType>::ToMojom(
121 ui::TextInputType text_input_type) {
122 switch (text_input_type) {
123 case ui::TEXT_INPUT_TYPE_NONE:
124 return ui::mojom::TextInputType::NONE;
125 case ui::TEXT_INPUT_TYPE_TEXT:
126 return ui::mojom::TextInputType::TEXT;
127 case ui::TEXT_INPUT_TYPE_PASSWORD:
128 return ui::mojom::TextInputType::PASSWORD;
129 case ui::TEXT_INPUT_TYPE_SEARCH:
130 return ui::mojom::TextInputType::SEARCH;
131 case ui::TEXT_INPUT_TYPE_EMAIL:
132 return ui::mojom::TextInputType::EMAIL;
133 case ui::TEXT_INPUT_TYPE_NUMBER:
134 return ui::mojom::TextInputType::NUMBER;
135 case ui::TEXT_INPUT_TYPE_TELEPHONE:
136 return ui::mojom::TextInputType::TELEPHONE;
137 case ui::TEXT_INPUT_TYPE_URL:
138 return ui::mojom::TextInputType::URL;
139 case ui::TEXT_INPUT_TYPE_DATE:
140 return ui::mojom::TextInputType::DATE;
141 case ui::TEXT_INPUT_TYPE_DATE_TIME:
142 return ui::mojom::TextInputType::DATETIME;
143 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
144 return ui::mojom::TextInputType::DATETIME_LOCAL;
145 case ui::TEXT_INPUT_TYPE_MONTH:
146 return ui::mojom::TextInputType::MONTH;
147 case ui::TEXT_INPUT_TYPE_TIME:
148 return ui::mojom::TextInputType::TIME;
149 case ui::TEXT_INPUT_TYPE_WEEK:
150 return ui::mojom::TextInputType::WEEK;
151 case ui::TEXT_INPUT_TYPE_TEXT_AREA:
152 return ui::mojom::TextInputType::TEXT_AREA;
153 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
154 return ui::mojom::TextInputType::CONTENT_EDITABLE;
155 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
156 return ui::mojom::TextInputType::DATETIME_FIELD;
157 }
158 NOTREACHED();
159 return ui::mojom::TextInputType::NONE;
160 }
161
162 // static
163 bool EnumTraits<ui::mojom::TextInputType, ui::TextInputType>::FromMojom(
164 ui::mojom::TextInputType input,
165 ui::TextInputType* out) {
166 switch (input) {
167 case ui::mojom::TextInputType::NONE:
168 *out = ui::TEXT_INPUT_TYPE_NONE;
169 return true;
170 case ui::mojom::TextInputType::TEXT:
171 *out = ui::TEXT_INPUT_TYPE_TEXT;
172 return true;
173 case ui::mojom::TextInputType::PASSWORD:
174 *out = ui::TEXT_INPUT_TYPE_PASSWORD;
175 return true;
176 case ui::mojom::TextInputType::SEARCH:
177 *out = ui::TEXT_INPUT_TYPE_SEARCH;
178 return true;
179 case ui::mojom::TextInputType::EMAIL:
180 *out = ui::TEXT_INPUT_TYPE_EMAIL;
181 return true;
182 case ui::mojom::TextInputType::NUMBER:
183 *out = ui::TEXT_INPUT_TYPE_NUMBER;
184 return true;
185 case ui::mojom::TextInputType::TELEPHONE:
186 *out = ui::TEXT_INPUT_TYPE_TELEPHONE;
187 return true;
188 case ui::mojom::TextInputType::URL:
189 *out = ui::TEXT_INPUT_TYPE_URL;
190 return true;
191 case ui::mojom::TextInputType::DATE:
192 *out = ui::TEXT_INPUT_TYPE_DATE;
193 return true;
194 case ui::mojom::TextInputType::DATETIME:
195 *out = ui::TEXT_INPUT_TYPE_DATE_TIME;
196 return true;
197 case ui::mojom::TextInputType::DATETIME_LOCAL:
198 *out = ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL;
199 return true;
200 case ui::mojom::TextInputType::MONTH:
201 *out = ui::TEXT_INPUT_TYPE_MONTH;
202 return true;
203 case ui::mojom::TextInputType::TIME:
204 *out = ui::TEXT_INPUT_TYPE_TIME;
205 return true;
206 case ui::mojom::TextInputType::WEEK:
207 *out = ui::TEXT_INPUT_TYPE_WEEK;
208 return true;
209 case ui::mojom::TextInputType::TEXT_AREA:
210 *out = ui::TEXT_INPUT_TYPE_TEXT_AREA;
211 return true;
212 case ui::mojom::TextInputType::CONTENT_EDITABLE:
213 *out = ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE;
214 return true;
215 case ui::mojom::TextInputType::DATETIME_FIELD:
216 *out = ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD;
217 return true;
218 }
219 return false;
220 }
221
34 } // namespace mojo 222 } // namespace mojo
OLDNEW
« no previous file with comments | « services/ui/public/interfaces/ime/ime_struct_traits.h ('k') | services/ui/public/interfaces/ime/ime_struct_traits_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698