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

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: after 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 d7a163c940ce59c30068fe47ec24778bb1128710..3c034135fa6f2db9fa8dce3f77d03ff35d289063 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -422,6 +422,11 @@ 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>. A possible future improvement
+// is to ignore <label for="valid_id"> since those are associated with other
Evan Stade 2015/03/16 23:35:36 isn't it pretty easy to do this? just check WebLab
Lei Zhang 2015/03/17 00:23:37 Yes, I just didn't get to it, so I just wrote a no
+// elements.
base::string16 InferLabelFromDivTable(const WebFormControlElement& element) {
WebNode node = element.parentNode();
bool looking_for_parent = true;
@@ -432,6 +437,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)
@@ -452,6 +458,8 @@ base::string16 InferLabelFromDivTable(const WebFormControlElement& element) {
}
looking_for_parent = false;
+ } else if (!looking_for_parent && HasTagName(node, kLabel)) {
+ 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