summaryrefslogtreecommitdiffstats
path: root/webkit/forms/form_field.h
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 02:25:08 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 02:25:08 +0000
commit9c4bf23a4cde497b8bad3f89b60457841470618c (patch)
tree9674d3732608fb126f685bd9b780fe5a8bd7fe14 /webkit/forms/form_field.h
parent57dcbc4dd5cbb0f88b348b775ad0a2b130bcafdd (diff)
downloadchromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.zip
chromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.tar.gz
chromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.tar.bz2
Group forms-related files in webkit/glue in a forms/ subdirectory.
BUG=none TEST=compiles Review URL: http://codereview.chromium.org/8680040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/forms/form_field.h')
-rw-r--r--webkit/forms/form_field.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/webkit/forms/form_field.h b/webkit/forms/form_field.h
new file mode 100644
index 0000000..d1b17c0
--- /dev/null
+++ b/webkit/forms/form_field.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FORMS_FORM_FIELD_H_
+#define WEBKIT_FORMS_FORM_FIELD_H_
+
+#include <vector>
+
+#include "base/string16.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h"
+#include "webkit/forms/webkit_forms_export.h"
+
+namespace webkit {
+namespace forms {
+
+// Stores information about a field in a form.
+struct WEBKIT_FORMS_EXPORT FormField {
+ FormField();
+ virtual ~FormField();
+
+ // Equality tests for identity which does not include |value| or
+ // |is_autofilled|.
+ // TODO(dhollowa): These operators need to be revised when we implement field
+ // ids.
+ bool operator==(const FormField& field) const;
+ bool operator!=(const FormField& field) const;
+
+ string16 label;
+ string16 name;
+ string16 value;
+ string16 form_control_type;
+ string16 autocomplete_type;
+ size_t max_length;
+ bool is_autofilled;
+ bool is_focusable;
+ bool should_autocomplete;
+
+ // For the HTML snippet |<option value="US">United States</option>|, the
+ // value is "US" and the contents are "United States".
+ std::vector<string16> option_values;
+ std::vector<string16> option_contents;
+};
+
+// So we can compare FormFields with EXPECT_EQ().
+WEBKIT_FORMS_EXPORT std::ostream& operator<<(std::ostream& os,
+ const FormField& field);
+
+} // namespace forms
+} // namespace webkit
+
+// Prefer to use this macro in place of |EXPECT_EQ()| for comparing |FormField|s
+// in test code.
+#define EXPECT_FORM_FIELD_EQUALS(expected, actual) \
+ do { \
+ EXPECT_EQ(expected.label, actual.label); \
+ EXPECT_EQ(expected.name, actual.name); \
+ EXPECT_EQ(expected.value, actual.value); \
+ EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
+ EXPECT_EQ(expected.autocomplete_type, actual.autocomplete_type); \
+ EXPECT_EQ(expected.max_length, actual.max_length); \
+ EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
+ } while (0)
+
+#endif // WEBKIT_FORMS_FORM_FIELD_H_