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 SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ | 5 #ifndef SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ |
6 #define SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ | 6 #define SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "services/ui/public/interfaces/ime/ime.mojom-shared.h" | 9 #include "services/ui/public/interfaces/ime/ime.mojom-shared.h" |
| 10 #include "ui/base/ime/candidate_window.h" |
10 #include "ui/base/ime/composition_text.h" | 11 #include "ui/base/ime/composition_text.h" |
11 #include "ui/base/ime/composition_underline.h" | 12 #include "ui/base/ime/composition_underline.h" |
12 #include "ui/base/ime/text_input_mode.h" | 13 #include "ui/base/ime/text_input_mode.h" |
13 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 | 17 |
17 template <> | 18 template <> |
| 19 struct StructTraits<ui::mojom::CandidateWindowPropertiesDataView, |
| 20 ui::CandidateWindow::CandidateWindowProperty> { |
| 21 static int32_t page_size( |
| 22 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 23 return p.page_size; |
| 24 } |
| 25 static bool vertical(const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 26 return p.is_vertical; |
| 27 } |
| 28 static std::string auxiliary_text( |
| 29 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 30 return p.auxiliary_text; |
| 31 } |
| 32 static bool auxiliary_text_visible( |
| 33 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 34 return p.is_auxiliary_text_visible; |
| 35 } |
| 36 static int32_t cursor_position( |
| 37 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 38 return p.cursor_position; |
| 39 } |
| 40 static bool cursor_visible( |
| 41 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 42 return p.is_cursor_visible; |
| 43 } |
| 44 static ui::mojom::CandidateWindowPosition window_position( |
| 45 const ui::CandidateWindow::CandidateWindowProperty& p) { |
| 46 return p.show_window_at_composition |
| 47 ? ui::mojom::CandidateWindowPosition::COMPOSITION |
| 48 : ui::mojom::CandidateWindowPosition::CURSOR; |
| 49 } |
| 50 static bool Read(ui::mojom::CandidateWindowPropertiesDataView data, |
| 51 ui::CandidateWindow::CandidateWindowProperty* out); |
| 52 }; |
| 53 |
| 54 template <> |
| 55 struct StructTraits<ui::mojom::CandidateWindowEntryDataView, |
| 56 ui::CandidateWindow::Entry> { |
| 57 static std::string value(const ui::CandidateWindow::Entry& e) { |
| 58 return base::UTF16ToUTF8(e.value); |
| 59 } |
| 60 static std::string label(const ui::CandidateWindow::Entry& e) { |
| 61 return base::UTF16ToUTF8(e.label); |
| 62 } |
| 63 static std::string annotation(const ui::CandidateWindow::Entry& e) { |
| 64 return base::UTF16ToUTF8(e.annotation); |
| 65 } |
| 66 static std::string description_title(const ui::CandidateWindow::Entry& e) { |
| 67 return base::UTF16ToUTF8(e.description_title); |
| 68 } |
| 69 static std::string description_body(const ui::CandidateWindow::Entry& e) { |
| 70 return base::UTF16ToUTF8(e.description_body); |
| 71 } |
| 72 static bool Read(ui::mojom::CandidateWindowEntryDataView data, |
| 73 ui::CandidateWindow::Entry* out); |
| 74 }; |
| 75 |
| 76 template <> |
18 struct StructTraits<ui::mojom::CompositionUnderlineDataView, | 77 struct StructTraits<ui::mojom::CompositionUnderlineDataView, |
19 ui::CompositionUnderline> { | 78 ui::CompositionUnderline> { |
20 static uint32_t start_offset(const ui::CompositionUnderline& c) { | 79 static uint32_t start_offset(const ui::CompositionUnderline& c) { |
21 return c.start_offset; | 80 return c.start_offset; |
22 } | 81 } |
23 static uint32_t end_offset(const ui::CompositionUnderline& c) { | 82 static uint32_t end_offset(const ui::CompositionUnderline& c) { |
24 return c.end_offset; | 83 return c.end_offset; |
25 } | 84 } |
26 static uint32_t color(const ui::CompositionUnderline& c) { return c.color; } | 85 static uint32_t color(const ui::CompositionUnderline& c) { return c.color; } |
27 static uint32_t thick(const ui::CompositionUnderline& c) { return c.thick; } | 86 static uint32_t thick(const ui::CompositionUnderline& c) { return c.thick; } |
(...skipping 27 matching lines...) Expand all Loading... |
55 | 114 |
56 template <> | 115 template <> |
57 struct EnumTraits<ui::mojom::TextInputType, ui::TextInputType> { | 116 struct EnumTraits<ui::mojom::TextInputType, ui::TextInputType> { |
58 static ui::mojom::TextInputType ToMojom(ui::TextInputType text_input_type); | 117 static ui::mojom::TextInputType ToMojom(ui::TextInputType text_input_type); |
59 static bool FromMojom(ui::mojom::TextInputType input, ui::TextInputType* out); | 118 static bool FromMojom(ui::mojom::TextInputType input, ui::TextInputType* out); |
60 }; | 119 }; |
61 | 120 |
62 } // namespace mojo | 121 } // namespace mojo |
63 | 122 |
64 #endif // SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ | 123 #endif // SERVICES_UI_PUBLIC_INTERFACES_IME_IME_STRUCT_TRAITS_H_ |
OLD | NEW |