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 #include "webkit/forms/form_field.h" | 5 #include "chrome/common/form_field_data.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 | 9 |
10 namespace webkit { | 10 FormFieldData::FormFieldData() |
11 namespace forms { | |
12 | |
13 FormField::FormField() | |
14 : max_length(0), | 11 : max_length(0), |
15 is_autofilled(false), | 12 is_autofilled(false), |
16 is_focusable(false), | 13 is_focusable(false), |
17 should_autocomplete(false) { | 14 should_autocomplete(false) { |
18 } | 15 } |
19 | 16 |
20 FormField::~FormField() { | 17 FormFieldData::~FormFieldData() { |
21 } | 18 } |
22 | 19 |
23 bool FormField::operator==(const FormField& field) const { | 20 bool FormFieldData::operator==(const FormFieldData& field) const { |
24 // A FormField stores a value, but the value is not part of the identity of | 21 // A FormFieldData stores a value, but the value is not part of the identity |
25 // the field, so we don't want to compare the values. | 22 // of the field, so we don't want to compare the values. |
26 return (label == field.label && | 23 return (label == field.label && |
27 name == field.name && | 24 name == field.name && |
28 form_control_type == field.form_control_type && | 25 form_control_type == field.form_control_type && |
29 autocomplete_type == field.autocomplete_type && | 26 autocomplete_type == field.autocomplete_type && |
30 max_length == field.max_length); | 27 max_length == field.max_length); |
31 } | 28 } |
32 | 29 |
33 bool FormField::operator!=(const FormField& field) const { | 30 bool FormFieldData::operator!=(const FormFieldData& field) const { |
34 return !operator==(field); | 31 return !operator==(field); |
35 } | 32 } |
36 | 33 |
37 bool FormField::operator<(const FormField& field) const { | 34 bool FormFieldData::operator<(const FormFieldData& field) const { |
38 if (label == field.label) | 35 if (label == field.label) |
39 return name < field.name; | 36 return name < field.name; |
40 | 37 |
41 return label < field.label; | 38 return label < field.label; |
42 } | 39 } |
43 | 40 |
44 std::ostream& operator<<(std::ostream& os, const FormField& field) { | 41 std::ostream& operator<<(std::ostream& os, const FormFieldData& field) { |
45 return os | 42 return os |
46 << UTF16ToUTF8(field.label) | 43 << UTF16ToUTF8(field.label) |
47 << " " | 44 << " " |
48 << UTF16ToUTF8(field.name) | 45 << UTF16ToUTF8(field.name) |
49 << " " | 46 << " " |
50 << UTF16ToUTF8(field.value) | 47 << UTF16ToUTF8(field.value) |
51 << " " | 48 << " " |
52 << UTF16ToUTF8(field.form_control_type) | 49 << UTF16ToUTF8(field.form_control_type) |
53 << " " | 50 << " " |
54 << UTF16ToUTF8(field.autocomplete_type) | 51 << UTF16ToUTF8(field.autocomplete_type) |
55 << " " | 52 << " " |
56 << field.max_length | 53 << field.max_length |
57 << " " | 54 << " " |
58 << (field.is_autofilled ? "true" : "false") | 55 << (field.is_autofilled ? "true" : "false") |
59 << " " | 56 << " " |
60 << (field.is_focusable ? "true" : "false") | 57 << (field.is_focusable ? "true" : "false") |
61 << " " | 58 << " " |
62 << (field.should_autocomplete ? "true" : "false"); | 59 << (field.should_autocomplete ? "true" : "false"); |
63 } | 60 } |
64 | |
65 } // namespace forms | |
66 } // namespace webkit | |
OLD | NEW |