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

Unified Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 1003163003: Autofill: Search for standalone label tags while looking through divs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, correspondingControl Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/bug_465587.out ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/form_autofill_util.cc
diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc
index 5977300794df57f4e2269a4affb18d958c5abf51..1cd3d4f31a86dd1d0a06d6bce70b5714dcb78e43 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -535,6 +535,9 @@ base::string16 InferLabelFromTableRow(const WebFormControlElement& element) {
// a surrounding div table,
// e.g. <div>Some Text<span><input ...></span></div>
// e.g. <div>Some Text</div><div><input ...></div>
+//
+// Because this is already traversing the <div> structure, if it finds a <label>
+// sibling along the way, infer from that <label>.
base::string16 InferLabelFromDivTable(const WebFormControlElement& element) {
WebNode node = element.parentNode();
bool looking_for_parent = true;
@@ -545,6 +548,7 @@ base::string16 InferLabelFromDivTable(const WebFormControlElement& element) {
CR_DEFINE_STATIC_LOCAL(WebString, kDiv, ("div"));
CR_DEFINE_STATIC_LOCAL(WebString, kTable, ("table"));
CR_DEFINE_STATIC_LOCAL(WebString, kFieldSet, ("fieldset"));
+ CR_DEFINE_STATIC_LOCAL(WebString, kLabel, ("label"));
while (inferred_label.empty() && !node.isNull()) {
if (HasTagName(node, kDiv)) {
if (looking_for_parent)
@@ -565,6 +569,10 @@ base::string16 InferLabelFromDivTable(const WebFormControlElement& element) {
}
looking_for_parent = false;
+ } else if (!looking_for_parent && HasTagName(node, kLabel)) {
+ WebLabelElement label_element = node.to<WebLabelElement>();
+ if (label_element.correspondingControl().isNull())
+ inferred_label = FindChildText(node);
} else if (looking_for_parent &&
(HasTagName(node, kTable) || HasTagName(node, kFieldSet))) {
// If the element is in a table or fieldset, its label most likely is too.
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/bug_465587.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698