OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_FORMS_FORM_FIELD_H_ | 5 #ifndef CHROME_COMMON_FORM_FIELD_H_ |
6 #define WEBKIT_FORMS_FORM_FIELD_H_ | 6 #define CHROME_COMMON_FORM_FIELD_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "webkit/forms/webkit_forms_export.h" | |
12 | 11 |
13 namespace webkit { | 12 namespace chrome { |
14 namespace forms { | |
15 | 13 |
16 // Stores information about a field in a form. | 14 // Stores information about a field in a form. |
17 struct WEBKIT_FORMS_EXPORT FormField { | 15 struct FormField { |
18 FormField(); | 16 FormField(); |
19 virtual ~FormField(); | 17 virtual ~FormField(); |
20 | 18 |
21 // Equality tests for identity which does not include |value| or | 19 // Equality tests for identity which does not include |value| or |
22 // |is_autofilled|. | 20 // |is_autofilled|. |
23 // TODO(dhollowa): These operators need to be revised when we implement field | 21 // TODO(dhollowa): These operators need to be revised when we implement field |
24 // ids. | 22 // ids. |
25 bool operator==(const FormField& field) const; | 23 bool operator==(const FormField& field) const; |
26 bool operator!=(const FormField& field) const; | 24 bool operator!=(const FormField& field) const; |
27 // Comparsion operator exposed for STL map. Uses label, then name to sort. | 25 // Comparsion operator exposed for STL map. Uses label, then name to sort. |
28 bool operator<(const FormField& field) const; | 26 bool operator<(const FormField& field) const; |
29 | 27 |
30 string16 label; | 28 string16 label; |
31 string16 name; | 29 string16 name; |
32 string16 value; | 30 string16 value; |
33 string16 form_control_type; | 31 string16 form_control_type; |
34 string16 autocomplete_type; | 32 string16 autocomplete_type; |
35 size_t max_length; | 33 size_t max_length; |
36 bool is_autofilled; | 34 bool is_autofilled; |
37 bool is_focusable; | 35 bool is_focusable; |
38 bool should_autocomplete; | 36 bool should_autocomplete; |
39 | 37 |
40 // For the HTML snippet |<option value="US">United States</option>|, the | 38 // For the HTML snippet |<option value="US">United States</option>|, the |
41 // value is "US" and the contents are "United States". | 39 // value is "US" and the contents are "United States". |
42 std::vector<string16> option_values; | 40 std::vector<string16> option_values; |
43 std::vector<string16> option_contents; | 41 std::vector<string16> option_contents; |
44 }; | 42 }; |
45 | 43 |
46 // So we can compare FormFields with EXPECT_EQ(). | 44 // So we can compare FormFields with EXPECT_EQ(). |
47 WEBKIT_FORMS_EXPORT std::ostream& operator<<(std::ostream& os, | 45 std::ostream& operator<<(std::ostream& os, const FormField& field); |
48 const FormField& field); | |
49 | 46 |
50 } // namespace forms | 47 } // namespace chrome |
51 } // namespace webkit | |
52 | 48 |
53 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing |FormField|s | 49 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing |FormField|s |
54 // in test code. | 50 // in test code. |
55 #define EXPECT_FORM_FIELD_EQUALS(expected, actual) \ | 51 #define EXPECT_FORM_FIELD_EQUALS(expected, actual) \ |
56 do { \ | 52 do { \ |
57 EXPECT_EQ(expected.label, actual.label); \ | 53 EXPECT_EQ(expected.label, actual.label); \ |
58 EXPECT_EQ(expected.name, actual.name); \ | 54 EXPECT_EQ(expected.name, actual.name); \ |
59 EXPECT_EQ(expected.value, actual.value); \ | 55 EXPECT_EQ(expected.value, actual.value); \ |
60 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ | 56 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ |
61 EXPECT_EQ(expected.autocomplete_type, actual.autocomplete_type); \ | 57 EXPECT_EQ(expected.autocomplete_type, actual.autocomplete_type); \ |
62 EXPECT_EQ(expected.max_length, actual.max_length); \ | 58 EXPECT_EQ(expected.max_length, actual.max_length); \ |
63 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ | 59 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ |
64 } while (0) | 60 } while (0) |
65 | 61 |
66 #endif // WEBKIT_FORMS_FORM_FIELD_H_ | 62 #endif // CHROME_COMMON_FORM_FIELD_H_ |
OLD | NEW |