diff options
author | Takano.Naoki@gmail.com <Takano.Naoki@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 16:40:23 +0000 |
---|---|---|
committer | Takano.Naoki@gmail.com <Takano.Naoki@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 16:40:23 +0000 |
commit | be83271cfe88a8d9cb127967baf08b2a96b25c33 (patch) | |
tree | 40c0cd1705b486403d00ad0c6545588882af9dbb | |
parent | 94add924939e44eeb73d8dfc3d54c170ca2fe11d (diff) | |
download | chromium_src-be83271cfe88a8d9cb127967baf08b2a96b25c33.zip chromium_src-be83271cfe88a8d9cb127967baf08b2a96b25c33.tar.gz chromium_src-be83271cfe88a8d9cb127967baf08b2a96b25c33.tar.bz2 |
Added <TH> tag to infer label.
<TH> tag is used for label in 12_register_pyramidcollection.com.html. So I added <TH> tag when infering label.
BUG=86134
TEST=Run 12_register_pyramidcollection.com.html
Review URL: http://codereview.chromium.org/7172006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89201 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 50 insertions, 22 deletions
diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc index 4226ee0..82292be 100644 --- a/chrome/renderer/autofill/form_manager.cc +++ b/chrome/renderer/autofill/form_manager.cc @@ -237,7 +237,9 @@ string16 InferLabelFromPrevious(const WebFormControlElement& element) { // Helper for |InferLabelForElement()| that infers a label, if possible, from // surrounding table structure, // e.g. <tr><td>Some Text</td><td><input ...></td></tr> +// or <tr><th>Some Text</th><td><input ...></td></tr> // or <tr><td><b>Some Text</b></td><td><b><input ...></b></td></tr> +// or <tr><th><b>Some Text</b></th><td><b><input ...></b></td></tr> string16 InferLabelFromTable(const WebFormControlElement& element) { WebNode parent = element.parentNode(); while (!parent.isNull() && parent.isElementNode() && @@ -250,7 +252,7 @@ string16 InferLabelFromTable(const WebFormControlElement& element) { string16 inferred_label; WebNode previous = parent; while (inferred_label.empty() && !previous.isNull()) { - if (HasTagName(previous, "td")) + if (HasTagName(previous, "td") || HasTagName(previous, "th")) inferred_label = FindChildText(previous.to<WebElement>()); previous = previous.previousSibling(); diff --git a/chrome/renderer/autofill/form_manager_browsertest.cc b/chrome/renderer/autofill/form_manager_browsertest.cc index b07959d..86f04e5 100644 --- a/chrome/renderer/autofill/form_manager_browsertest.cc +++ b/chrome/renderer/autofill/form_manager_browsertest.cc @@ -1094,6 +1094,32 @@ TEST_F(FormManagerTest, LabelsInferredFromTableCell) { "</FORM>"); } +TEST_F(FormManagerTest, LabelsInferredFromTableCellTH) { + ExpectJohnSmithLabels( + "<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" + "<TABLE>" + " <TR>" + " <TH>First name:</TH>" + " <TD><INPUT type=\"text\" id=\"firstname\" value=\"John\"/></TD>" + " </TR>" + " <TR>" + " <TH>Last name:</TH>" + " <TD><INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/></TD>" + " </TR>" + " <TR>" + " <TH>Email:</TH>" + " <TD><INPUT type=\"text\" id=\"email\"" + " value=\"john@example.com\"/></TD>" + " </TR>" + " <TR>" + " <TD></TD>" + " <TD>" + " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" + " </TD>" + " </TR>" + "</TABLE>" + "</FORM>"); +} TEST_F(FormManagerTest, LabelsInferredFromTableCellNested) { std::vector<string16> labels, names, values; diff --git a/chrome/test/data/autofill/heuristics/output/12_register_pyramidcollection.com.out b/chrome/test/data/autofill/heuristics/output/12_register_pyramidcollection.com.out index 5a1e327..ea6c509 100644 --- a/chrome/test/data/autofill/heuristics/output/12_register_pyramidcollection.com.out +++ b/chrome/test/data/autofill/heuristics/output/12_register_pyramidcollection.com.out @@ -1,21 +1,21 @@ -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE -UNKNOWN_TYPE +EMAIL_ADDRESS +NAME_FIRST +NAME_LAST +ADDRESS_HOME_LINE1 +ADDRESS_HOME_LINE2 +ADDRESS_HOME_CITY +ADDRESS_HOME_STATE +ADDRESS_HOME_COUNTRY +ADDRESS_HOME_ZIP +PHONE_HOME_WHOLE_NUMBER +PHONE_HOME_WHOLE_NUMBER +NAME_FIRST +NAME_LAST +ADDRESS_HOME_LINE1 +ADDRESS_HOME_LINE2 +ADDRESS_HOME_CITY +ADDRESS_HOME_STATE +ADDRESS_HOME_COUNTRY +ADDRESS_HOME_ZIP +PHONE_HOME_WHOLE_NUMBER +PHONE_HOME_WHOLE_NUMBER |