diff options
| -rw-r--r-- | WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp index 332e134..ea389f7 100644 --- a/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp +++ b/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp @@ -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; } |
