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

Unified Diff: chrome/renderer/autofill/form_manager.cc

Issue 6993053: Add <b> and <br> tags checking in infering labels. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix nit and test output. Created 9 years, 6 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 | « no previous file | chrome/renderer/autofill/form_manager_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/form_manager.cc
diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc
index adac984d4625f89433b13c3ae227f9a55ca6057a..40fc4976bed5c21e0c7ec1808dd5d1d4041caa80 100644
--- a/chrome/renderer/autofill/form_manager.cc
+++ b/chrome/renderer/autofill/form_manager.cc
@@ -153,29 +153,32 @@ string16 InferLabelFromPrevious(const WebFormControlElement& element) {
// If we didn't find text, check for previous paragraph.
// Eg. <p>Some Text</p><input ...>
- // Note the lack of whitespace between <p> and <input> elements.
+ // Eg. <b>Some Text</b><input ...>
+ // Note the lack of whitespace between (<p> or <b>) and <input> elements.
if (inferred_label.empty() && previous.isElementNode()) {
WebElement element = previous.to<WebElement>();
- if (element.hasTagName("p")) {
+ if (element.hasTagName("p") || element.hasTagName("b")) {
inferred_label = FindChildText(element);
}
}
// If we didn't find paragraph, check for previous paragraph to this.
// Eg. <p>Some Text</p> <input ...>
- // Note the whitespace between <p> and <input> elements.
+ // Eg. <b>Some Text</b> <input ...>
+ // Note the whitespace between (<p> or <b>) and <input> elements.
if (inferred_label.empty()) {
WebNode sibling = previous.previousSibling();
if (!sibling.isNull() && sibling.isElementNode()) {
WebElement element = sibling.to<WebElement>();
- if (element.hasTagName("p")) {
+ if (element.hasTagName("p") || element.hasTagName("b")) {
inferred_label = FindChildText(element);
}
}
}
- // Look for text node prior to <img> tag.
+ // Look for text node prior to <img> or <br> tag.
// Eg. Some Text<img/><input ...>
+ // Eg. Some Text<br/><input ...>
if (inferred_label.empty()) {
while (inferred_label.empty() && !previous.isNull()) {
if (previous.isTextNode()) {
@@ -183,7 +186,7 @@ string16 InferLabelFromPrevious(const WebFormControlElement& element) {
TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label);
} else if (previous.isElementNode()) {
WebElement element = previous.to<WebElement>();
- if (!element.hasTagName("img"))
+ if (!element.hasTagName("img") && !element.hasTagName("br"))
break;
} else {
break;
« no previous file with comments | « no previous file | chrome/renderer/autofill/form_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698