Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: webkit/glue/form_field.cc

Issue 7576001: Refactor webkit_glue::FormField to remove hacky methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright header Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/form_field.h ('k') | webkit/glue/password_form_dom_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "webkit/glue/form_field.h" 5 #include "webkit/glue/form_field.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 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h"
12 12
13 using WebKit::WebFormControlElement; 13 using WebKit::WebFormControlElement;
14 using WebKit::WebElement; 14 using WebKit::WebElement;
15 using WebKit::WebInputElement; 15 using WebKit::WebInputElement;
16 using WebKit::WebOptionElement; 16 using WebKit::WebOptionElement;
17 using WebKit::WebSelectElement; 17 using WebKit::WebSelectElement;
18 using WebKit::WebVector; 18 using WebKit::WebVector;
19 19
20 namespace webkit_glue { 20 namespace webkit_glue {
21 21
22 FormField::FormField() 22 FormField::FormField()
23 : max_length(0), 23 : max_length(0),
24 is_autofilled(false) { 24 is_autofilled(false) {
25 } 25 }
26 26
27 FormField::FormField(const string16& label,
28 const string16& name,
29 const string16& value,
30 const string16& form_control_type,
31 int max_length,
32 bool is_autofilled)
33 : label(label),
34 name(name),
35 value(value),
36 form_control_type(form_control_type),
37 max_length(max_length),
38 is_autofilled(is_autofilled) {
39 }
40
41 FormField::~FormField() { 27 FormField::~FormField() {
42 } 28 }
43 29
44 bool FormField::operator==(const FormField& field) const { 30 bool FormField::operator==(const FormField& field) const {
45 // A FormField stores a value, but the value is not part of the identity of 31 // A FormField stores a value, but the value is not part of the identity of
46 // the field, so we don't want to compare the values. 32 // the field, so we don't want to compare the values.
47 return (label == field.label && 33 return (label == field.label &&
48 name == field.name && 34 name == field.name &&
49 form_control_type == field.form_control_type && 35 form_control_type == field.form_control_type &&
50 max_length == field.max_length); 36 max_length == field.max_length);
51 } 37 }
52 38
53 bool FormField::operator!=(const FormField& field) const { 39 bool FormField::operator!=(const FormField& field) const {
54 return !operator==(field); 40 return !operator==(field);
55 } 41 }
56 42
57 bool FormField::StrictlyEqualsHack(const FormField& field) const {
58 return (label == field.label &&
59 name == field.name &&
60 value == field.value &&
61 form_control_type == field.form_control_type &&
62 max_length == field.max_length);
63 }
64
65 std::ostream& operator<<(std::ostream& os, const FormField& field) { 43 std::ostream& operator<<(std::ostream& os, const FormField& field) {
66 return os 44 return os
67 << UTF16ToUTF8(field.label) 45 << UTF16ToUTF8(field.label)
68 << " " 46 << " "
69 << UTF16ToUTF8(field.name) 47 << UTF16ToUTF8(field.name)
70 << " " 48 << " "
71 << UTF16ToUTF8(field.value) 49 << UTF16ToUTF8(field.value)
72 << " " 50 << " "
73 << UTF16ToUTF8(field.form_control_type) 51 << UTF16ToUTF8(field.form_control_type)
74 << " " 52 << " "
75 << field.max_length; 53 << field.max_length
54 << " "
55 << (field.is_autofilled ? "true" : "false");
76 } 56 }
77 57
78 } // namespace webkit_glue 58 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/form_field.h ('k') | webkit/glue/password_form_dom_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698