diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 15:49:10 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 15:49:10 +0000 |
commit | 152c76a49742732b72d061032979d5b27ca2af28 (patch) | |
tree | 7702f714691d747cdce76b3c4751e2ddc33228b5 /chrome/renderer | |
parent | 5ea28dea56c771da6bdf7471c14844332129f718 (diff) | |
download | chromium_src-152c76a49742732b72d061032979d5b27ca2af28.zip chromium_src-152c76a49742732b72d061032979d5b27ca2af28.tar.gz chromium_src-152c76a49742732b72d061032979d5b27ca2af28.tar.bz2 |
AutoFill Re-enable labeling input elements.
Over-reverted. Adding back in.
BUG=40306
TEST=FormManagerTest.*
TBR=jhawkins@chromium.org
Related to:
http://codereview.chromium.org/1519026
Committed revision 43922.
Review URL: http://codereview.chromium.org/1578022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/form_manager.cc | 19 | ||||
-rw-r--r-- | chrome/renderer/form_manager_unittest.cc | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc index 042edab..98c5513 100644 --- a/chrome/renderer/form_manager.cc +++ b/chrome/renderer/form_manager.cc @@ -148,6 +148,25 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element, if (form_fields.empty()) return false; + // Loop through the label elements inside the form element. For each label + // element, get the corresponding form control element, use the form control + // element's name as a key into the <name, FormField> map to find the + // previously created FormField and set the FormField's label to the + // innerText() of the label element. + WebNodeList labels = element.getElementsByTagName("label"); + for (unsigned i = 0; i < labels.length(); ++i) { + WebLabelElement label = labels.item(i).toElement<WebLabelElement>(); + WebFormControlElement field_element = + label.correspondingControl().toElement<WebFormControlElement>(); + if (field_element.isNull() || !field_element.isFormControlElement()) + continue; + + std::map<string16, FormField*>::iterator iter = + name_map.find(field_element.nameForAutofill()); + if (iter != name_map.end()) + iter->second->set_label(label.innerText()); + } + // Copy the created FormFields into the resulting FormData object. for (ScopedVector<FormField>::const_iterator iter = form_fields.begin(); iter != form_fields.end(); ++iter) { diff --git a/chrome/renderer/form_manager_unittest.cc b/chrome/renderer/form_manager_unittest.cc index 0bf4ae3b..281ff16 100644 --- a/chrome/renderer/form_manager_unittest.cc +++ b/chrome/renderer/form_manager_unittest.cc @@ -422,8 +422,7 @@ TEST_F(FormManagerTest, Reset) { ASSERT_EQ(0U, forms.size()); } -// http://crbug.com/40306 -TEST_F(FormManagerTest, DISABLED_Labels) { +TEST_F(FormManagerTest, Labels) { LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" " <LABEL for=\"firstname\"> First name: </LABEL>" " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |