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