diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 19:53:23 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 19:53:23 +0000 |
commit | 41e342f3745b27ba8eeaa87187e3465de484c2a4 (patch) | |
tree | 450e86b869f04fe823e0a28465d7899ce0b9f590 /webkit | |
parent | e8cf47b31dde03bf5e14d10af9834eaf12cba3c5 (diff) | |
download | chromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.zip chromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.tar.gz chromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.tar.bz2 |
Fix for: State in small letters should be auto-filled from the profile.
BUG=38222
TEST=in the bug
Patch by George Yakovleg <georgey@chromium.org>
Review URL: http://codereview.chromium.org/2832064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/form_field.cc | 12 | ||||
-rw-r--r-- | webkit/glue/form_field.h | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc index 0d6ac1d..a0fbdef 100644 --- a/webkit/glue/form_field.cc +++ b/webkit/glue/form_field.cc @@ -7,11 +7,15 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/WebKit/chromium/public/WebOptionElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebSelectElement.h" using WebKit::WebFormControlElement; +using WebKit::WebElement; using WebKit::WebInputElement; +using WebKit::WebOptionElement; using WebKit::WebSelectElement; +using WebKit::WebVector; namespace webkit_glue { @@ -37,6 +41,14 @@ FormField::FormField(WebFormControlElement element) } else if (form_control_type_ == ASCIIToUTF16("select-one")) { WebSelectElement select_element = element.to<WebSelectElement>(); value_ = select_element.value(); + + // For select-one elements copy option strings. + WebVector<WebElement> list_items = select_element.listItems(); + option_strings_.reserve(list_items.size()); + for (size_t i = 0; i < list_items.size(); ++i) { + if (list_items[i].hasTagName("option")) + option_strings_.push_back(list_items[i].to<WebOptionElement>().value()); + } } TrimWhitespace(value_, TRIM_LEADING, &value_); diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h index 691d2af9..2a1ffcf 100644 --- a/webkit/glue/form_field.h +++ b/webkit/glue/form_field.h @@ -5,6 +5,8 @@ #ifndef WEBKIT_GLUE_FORM_FIELD_H_ #define WEBKIT_GLUE_FORM_FIELD_H_ +#include <vector> + #include "base/string16.h" #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" @@ -26,6 +28,11 @@ class FormField { const string16& value() const { return value_; } const string16& form_control_type() const { return form_control_type_; } int size() const { return size_; } + // Returns option string for elements for which they make sense (select-one, + // for example) for the rest of elements return an empty array. + const std::vector<string16>& option_strings() const { + return option_strings_; + } void set_label(const string16& label) { label_ = label; } void set_name(const string16& name) { name_ = name; } @@ -34,6 +41,9 @@ class FormField { form_control_type_ = form_control_type; } void set_size(int size) { size_ = size; } + void set_option_strings(const std::vector<string16>& strings) { + option_strings_ = strings; + } // Equality tests for identity which does not include |value_| or |size_|. // Use |StrictlyEqualsHack| method to test all members. @@ -52,6 +62,7 @@ class FormField { string16 value_; string16 form_control_type_; int size_; + std::vector<string16> option_strings_; }; // So we can compare FormFields with EXPECT_EQ(). |