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

Unified Diff: Source/core/html/parser/HTMLTreeBuilder.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/HTMLOptionElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLTreeBuilder.cpp
diff --git a/Source/core/html/parser/HTMLTreeBuilder.cpp b/Source/core/html/parser/HTMLTreeBuilder.cpp
index d75d7a30f7437865ee0cb6c96bcc02b3bb4163a9..54ebd67c82273ce61b1894688d7945980e69548f 100644
--- a/Source/core/html/parser/HTMLTreeBuilder.cpp
+++ b/Source/core/html/parser/HTMLTreeBuilder.cpp
@@ -35,6 +35,7 @@
#include "XMLNames.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/dom/DocumentFragment.h"
+#include "core/dom/ElementTraversal.h"
#include "core/html/HTMLDocument.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/parser/AtomicHTMLToken.h"
@@ -133,18 +134,10 @@ static bool isFormattingTag(const AtomicString& tagName)
return tagName == aTag || isNonAnchorFormattingTag(tagName);
}
-static HTMLFormElement* closestFormAncestor(Element* element)
+static HTMLFormElement* closestFormAncestor(Element& element)
{
ASSERT(isMainThread());
- while (element) {
- if (isHTMLFormElement(*element))
- return toHTMLFormElement(element);
- ContainerNode* parent = element->parentNode();
- if (!parent || !parent->isElementNode())
- return 0;
- element = toElement(parent);
- }
- return 0;
+ return Traversal<HTMLFormElement>::firstAncestorOrSelf(element);
}
class HTMLTreeBuilder::CharacterTokenBuffer {
@@ -315,7 +308,7 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* f
m_templateInsertionModes.append(TemplateContentsMode);
resetInsertionModeAppropriately();
- m_tree.setForm(closestFormAncestor(contextElement));
+ m_tree.setForm(closestFormAncestor(*contextElement));
}
}
« no previous file with comments | « Source/core/html/HTMLOptionElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698