OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/common/form_field_data.h" | 5 #include "components/autofill/core/common/form_field_data.h" |
6 | 6 |
7 #include <tuple> | |
8 | |
9 #include "base/pickle.h" | 7 #include "base/pickle.h" |
10 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
12 | 10 |
13 namespace autofill { | 11 namespace autofill { |
14 | 12 |
15 namespace { | 13 namespace { |
16 | 14 |
17 // Increment this anytime pickle format is modified as well as provide | 15 // Increment this anytime pickle format is modified as well as provide |
18 // deserialization routine from previous kPickleVersion format. | 16 // deserialization routine from previous kPickleVersion format. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // of a drop-down are currently not considered part of the identity of | 110 // of a drop-down are currently not considered part of the identity of |
113 // a form element. This is debatable, since one might base heuristics | 111 // a form element. This is debatable, since one might base heuristics |
114 // on the types of elements that are available. Alternatively, one | 112 // on the types of elements that are available. Alternatively, one |
115 // could imagine some forms that dynamically change the element | 113 // could imagine some forms that dynamically change the element |
116 // contents (say, insert years starting from the current year) that | 114 // contents (say, insert years starting from the current year) that |
117 // should not be considered changes in the structure of the form. | 115 // should not be considered changes in the structure of the form. |
118 } | 116 } |
119 | 117 |
120 bool FormFieldData::operator<(const FormFieldData& field) const { | 118 bool FormFieldData::operator<(const FormFieldData& field) const { |
121 // Like operator==, this ignores the value. | 119 // Like operator==, this ignores the value. |
| 120 if (label < field.label) return true; |
| 121 if (label > field.label) return false; |
| 122 if (name < field.name) return true; |
| 123 if (name > field.name) return false; |
| 124 if (form_control_type < field.form_control_type) return true; |
| 125 if (form_control_type > field.form_control_type) return false; |
| 126 if (autocomplete_attribute < field.autocomplete_attribute) return true; |
| 127 if (autocomplete_attribute > field.autocomplete_attribute) return false; |
| 128 if (max_length < field.max_length) return true; |
| 129 if (max_length > field.max_length) return false; |
122 // Skip |is_checked| and |is_autofilled| as in SameFieldAs. | 130 // Skip |is_checked| and |is_autofilled| as in SameFieldAs. |
| 131 if (is_checkable < field.is_checkable) return true; |
| 132 if (is_checkable > field.is_checkable) return false; |
| 133 if (is_focusable < field.is_focusable) return true; |
| 134 if (is_focusable > field.is_focusable) return false; |
| 135 if (should_autocomplete < field.should_autocomplete) return true; |
| 136 if (should_autocomplete > field.should_autocomplete) return false; |
| 137 if (role < field.role) return true; |
| 138 if (role > field.role) return false; |
| 139 if (text_direction < field.text_direction) return true; |
| 140 if (text_direction > field.text_direction) return false; |
123 // See operator== above for why we don't check option_values/contents. | 141 // See operator== above for why we don't check option_values/contents. |
124 return std::tie(label, name, form_control_type, autocomplete_attribute, | 142 return false; |
125 max_length, is_checkable, is_focusable, should_autocomplete, | |
126 role, text_direction) < | |
127 std::tie(field.label, field.name, field.form_control_type, | |
128 field.autocomplete_attribute, field.max_length, | |
129 field.is_checkable, field.is_focusable, | |
130 field.should_autocomplete, field.role, field.text_direction); | |
131 } | 143 } |
132 | 144 |
133 void SerializeFormFieldData(const FormFieldData& field_data, | 145 void SerializeFormFieldData(const FormFieldData& field_data, |
134 base::Pickle* pickle) { | 146 base::Pickle* pickle) { |
135 pickle->WriteInt(kPickleVersion); | 147 pickle->WriteInt(kPickleVersion); |
136 pickle->WriteString16(field_data.label); | 148 pickle->WriteString16(field_data.label); |
137 pickle->WriteString16(field_data.name); | 149 pickle->WriteString16(field_data.name); |
138 pickle->WriteString16(field_data.value); | 150 pickle->WriteString16(field_data.value); |
139 pickle->WriteString(field_data.form_control_type); | 151 pickle->WriteString(field_data.form_control_type); |
140 pickle->WriteString(field_data.autocomplete_attribute); | 152 pickle->WriteString(field_data.autocomplete_attribute); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 << " " << field.autocomplete_attribute << " " << field.max_length | 205 << " " << field.autocomplete_attribute << " " << field.max_length |
194 << " " << (field.is_autofilled ? "true" : "false") << " " | 206 << " " << (field.is_autofilled ? "true" : "false") << " " |
195 << (field.is_checked ? "true" : "false") << " " | 207 << (field.is_checked ? "true" : "false") << " " |
196 << (field.is_checkable ? "true" : "false") << " " | 208 << (field.is_checkable ? "true" : "false") << " " |
197 << (field.is_focusable ? "true" : "false") << " " | 209 << (field.is_focusable ? "true" : "false") << " " |
198 << (field.should_autocomplete ? "true" : "false") << " " | 210 << (field.should_autocomplete ? "true" : "false") << " " |
199 << field.role << " " << field.text_direction; | 211 << field.role << " " << field.text_direction; |
200 } | 212 } |
201 | 213 |
202 } // namespace autofill | 214 } // namespace autofill |
OLD | NEW |