Chromium Code Reviews| Index: Source/core/html/HTMLFormControlElement.cpp |
| diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp |
| index e00bbcf4e274d11adb9fb8b1df71ab3c862c94ac..ec4811cc10ae7533e50fa88ead5849c661f8c2c5 100644 |
| --- a/Source/core/html/HTMLFormControlElement.cpp |
| +++ b/Source/core/html/HTMLFormControlElement.cpp |
| @@ -26,6 +26,7 @@ |
| #include "core/html/HTMLFormControlElement.h" |
| #include "core/events/Event.h" |
| +#include "core/html/HTMLDataListElement.h" |
| #include "core/html/HTMLFieldSetElement.h" |
| #include "core/html/HTMLFormElement.h" |
| #include "core/html/HTMLInputElement.h" |
| @@ -101,7 +102,7 @@ void HTMLFormControlElement::updateAncestorDisabledState() const |
| { |
| HTMLFieldSetElement* fieldSetAncestor = 0; |
| ContainerNode* legendAncestor = 0; |
| - for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { |
| + for (HTMLElement* ancestor = Traversal<HTMLElement>::firstAncestor(*this); ancestor; ancestor = Traversal<HTMLElement>::firstAncestor(*ancestor)) { |
| if (!legendAncestor && isHTMLLegendElement(*ancestor)) |
| legendAncestor = ancestor; |
| if (isHTMLFieldSetElement(*ancestor)) { |
| @@ -355,13 +356,9 @@ short HTMLFormControlElement::tabIndex() const |
| bool HTMLFormControlElement::recalcWillValidate() const |
| { |
| if (m_dataListAncestorState == Unknown) { |
| - for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { |
| - if (isHTMLDataListElement(*ancestor)) { |
| - m_dataListAncestorState = InsideDataList; |
| - break; |
| - } |
| - } |
| - if (m_dataListAncestorState == Unknown) |
| + if (Traversal<HTMLDataListElement>::firstAncestor(*this)) |
| + m_dataListAncestorState = InsideDataList; |
| + else |
| m_dataListAncestorState = NotInsideDataList; |
| } |
| return m_dataListAncestorState == NotInsideDataList && !isDisabledOrReadOnly(); |
| @@ -482,11 +479,9 @@ bool HTMLFormControlElement::isDefaultButtonForForm() const |
| HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node* node) |
| { |
| - for (; node; node = node->parentNode()) { |
| - if (node->isElementNode() && toElement(node)->isFormControlElement()) |
| - return toHTMLFormControlElement(node); |
| - } |
| - return 0; |
| + if (!node || isHTMLFormControlElement(*node)) |
| + return toHTMLFormControlElement(node); |
| + return Traversal<HTMLFormControlElement>::firstAncestor(*node); |
|
esprehn
2014/03/27 13:28:16
This also could have been firstAncestorOrSelf(node
|
| } |
| String HTMLFormControlElement::nameForAutofill() const |