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

Unified Diff: chrome/renderer/form_manager.cc

Issue 4249002: AutoFill: Fix two heuristic issues with nrm.org. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 2 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
Index: chrome/renderer/form_manager.cc
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index 5287d61ecf97732319b04866c9c317a507d4d894..8a5d5596f88ac4ad8c9c169014f5a45670610e3d 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -108,12 +108,10 @@ string16 InferLabelFromPrevious(
// 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.
- if (inferred_label.empty()) {
- if (previous.isElementNode()) {
- WebElement element = previous.to<WebElement>();
- if (element.hasTagName("p")) {
- inferred_label = FindChildText(element);
- }
+ if (inferred_label.empty() && previous.isElementNode()) {
+ WebElement element = previous.to<WebElement>();
+ if (element.hasTagName("p")) {
+ inferred_label = FindChildText(element);
}
}
@@ -121,9 +119,9 @@ string16 InferLabelFromPrevious(
// Eg. <p>Some Text</p> <input ...>
// Note the whitespace between <p> and <input> elements.
if (inferred_label.empty()) {
- previous = previous.previousSibling();
- if (!previous.isNull() && previous.isElementNode()) {
- WebElement element = previous.to<WebElement>();
+ WebNode sibling = previous.previousSibling();
+ if (!sibling.isNull() && sibling.isElementNode()) {
+ WebElement element = sibling.to<WebElement>();
if (element.hasTagName("p")) {
inferred_label = FindChildText(element);
}
@@ -185,19 +183,12 @@ string16 InferLabelFromTable(
!parent.to<WebElement>().hasTagName("td"))
parent = parent.parentNode();
- if (parent.isNull() || !parent.isElementNode())
- return string16();
-
- WebElement e = parent.to<WebElement>();
- if (e.isNull() || !e.hasTagName("td"))
- return string16();
-
// Check all previous siblings, skipping non-element nodes, until we find a
// non-empty text block.
- WebNode previous = parent.previousSibling();
+ WebNode previous = parent;
while (!previous.isNull()) {
if (previous.isElementNode()) {
- e = previous.to<WebElement>();
+ WebElement e = previous.to<WebElement>();
if (e.hasTagName("td")) {
inferred_label = FindChildText(e);
if (!inferred_label.empty())

Powered by Google App Engine
This is Rietveld 408576698