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