OSDN Git Service

Merge Chromium at r65505: Merge AutoFill change 64761
authorBen Murdoch <benm@google.com>
Fri, 19 Nov 2010 18:41:33 +0000 (18:41 +0000)
committerBen Murdoch <benm@google.com>
Mon, 22 Nov 2010 11:52:52 +0000 (11:52 +0000)
Merge in http://src.chromium.org/viewvc/chrome?view=rev&revision=64761

This is not part of the bigger autofill merge as this introdcues
a regression that we need to understand.

Change-Id: I08cfcefb93181e70a8a48d0c6da2217d3a5bbcf9

WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp

index 332e134..ea389f7 100644 (file)
@@ -202,21 +202,19 @@ string16 InferLabelFromTable(const HTMLFormControlElement& element) {
     while (parent && parent->isElementNode() && !static_cast<Element*>(parent)->hasTagName(tdTag))
         parent = parent->parentNode();
 
-    if (parent && parent->isElementNode()) {
-        Element* element = static_cast<Element*>(parent);
-        if (element->hasTagName(tdTag)) {
-            Node* previous = parent->previousSibling();
-
-            // Skip by any intervening text nodes.
-            while (previous && previous->isTextNode())
-                previous = previous->previousSibling();
-
-            if (previous && previous->isElementNode()) {
-                element = static_cast<Element*>(previous);
-                if (element->hasTagName(tdTag))
-                    inferred_label = FindChildText(element);
+    // Check all previous siblings, skipping non-element nodes, until we find a
+    // non-empty text block.
+    Node* previous = parent;
+    while(previous) {
+        if (previous->isElementNode()) {
+            Element* e = static_cast<Element*>(previous);
+            if (e->hasTagName(tdTag)) {
+                inferred_label = FindChildText(e);
+                if (!inferred_label.empty())
+                    break;
             }
         }
+        previous = previous->previousSibling();
     }
    return inferred_label;
 }