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

Unified Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 201293002: Add Traversal<*Element>::firstAncestor() API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add firstAncestorOrSelf() Created 6 years, 9 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 | « Source/core/html/HTMLEmbedElement.cpp ('k') | Source/core/html/HTMLFrameElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index e00bbcf4e274d11adb9fb8b1df71ab3c862c94ac..4c5c185d6b08396a673e36c4c50a63697f90cfc8 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)
+ return 0;
+ return Traversal<HTMLFormControlElement>::firstAncestorOrSelf(*node);
}
String HTMLFormControlElement::nameForAutofill() const
« no previous file with comments | « Source/core/html/HTMLEmbedElement.cpp ('k') | Source/core/html/HTMLFrameElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698