1 // Copyright 2015 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.
5 #include "components/view_manager/type_converters.h"
7 #include "base/basictypes.h"
8 #include "base/macros.h"
12 #define TEXT_INPUT_TYPE_ASSERT(NAME) \
13 COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_TYPE_##NAME) == \
14 static_cast<int32>(ui::TEXT_INPUT_TYPE_##NAME), \
15 text_input_type_should_match)
16 TEXT_INPUT_TYPE_ASSERT(NONE
);
17 TEXT_INPUT_TYPE_ASSERT(TEXT
);
18 TEXT_INPUT_TYPE_ASSERT(PASSWORD
);
19 TEXT_INPUT_TYPE_ASSERT(SEARCH
);
20 TEXT_INPUT_TYPE_ASSERT(EMAIL
);
21 TEXT_INPUT_TYPE_ASSERT(NUMBER
);
22 TEXT_INPUT_TYPE_ASSERT(TELEPHONE
);
23 TEXT_INPUT_TYPE_ASSERT(URL
);
24 TEXT_INPUT_TYPE_ASSERT(DATE
);
25 TEXT_INPUT_TYPE_ASSERT(DATE_TIME
);
26 TEXT_INPUT_TYPE_ASSERT(DATE_TIME_LOCAL
);
27 TEXT_INPUT_TYPE_ASSERT(MONTH
);
28 TEXT_INPUT_TYPE_ASSERT(TIME
);
29 TEXT_INPUT_TYPE_ASSERT(WEEK
);
30 TEXT_INPUT_TYPE_ASSERT(TEXT_AREA
);
31 TEXT_INPUT_TYPE_ASSERT(LAST
);
33 #define TEXT_INPUT_FLAG_ASSERT(NAME) \
34 COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_FLAG_##NAME) == \
35 static_cast<int32>(ui::TEXT_INPUT_FLAG_##NAME), \
36 text_input_flag_should_match)
37 TEXT_INPUT_FLAG_ASSERT(NONE
);
38 TEXT_INPUT_FLAG_ASSERT(AUTO_COMPLETE_ON
);
39 TEXT_INPUT_FLAG_ASSERT(AUTO_COMPLETE_OFF
);
40 TEXT_INPUT_FLAG_ASSERT(AUTO_CORRECT_ON
);
41 TEXT_INPUT_FLAG_ASSERT(AUTO_CORRECT_OFF
);
42 TEXT_INPUT_FLAG_ASSERT(SPELL_CHECK_ON
);
43 TEXT_INPUT_FLAG_ASSERT(SPELL_CHECK_OFF
);
44 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_NONE
);
45 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_CHARACTERS
);
46 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_WORDS
);
47 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_SENTENCES
);
48 TEXT_INPUT_FLAG_ASSERT(ALL
);
51 ui::TextInputType TypeConverter
<ui::TextInputType
, TextInputType
>::Convert(
52 const TextInputType
& input
) {
53 return static_cast<ui::TextInputType
>(input
);
58 TypeConverter
<ui::TextInputState
, TextInputStatePtr
>::Convert(
59 const TextInputStatePtr
& input
) {
60 return ui::TextInputState(ConvertTo
<ui::TextInputType
>(input
->type
),
62 input
->text
.To
<std::string
>(),
63 input
->selection_start
,
65 input
->composition_start
,
66 input
->composition_end
,
67 input
->can_compose_inline
);