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

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

Issue 182053002: Have Node::highestAncestor() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reupload Created 6 years, 10 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/HTMLFormElement.h ('k') | Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFormElement.cpp
diff --git a/Source/core/html/HTMLFormElement.cpp b/Source/core/html/HTMLFormElement.cpp
index ab2c6b6d18be8684316bf0277d3cfb08a6e08fd6..714faf234c8f7edd64389a32e0fee3d35e547965 100644
--- a/Source/core/html/HTMLFormElement.cpp
+++ b/Source/core/html/HTMLFormElement.cpp
@@ -123,7 +123,7 @@ Node::InsertionNotificationRequest HTMLFormElement::insertedInto(ContainerNode*
}
template<class T>
-void notifyFormRemovedFromTree(const Vector<T*>& elements, Node* root)
+void notifyFormRemovedFromTree(const Vector<T*>& elements, Node& root)
{
size_t size = elements.size();
for (size_t i = 0; i < size; ++i)
@@ -136,7 +136,7 @@ void HTMLFormElement::removedFrom(ContainerNode* insertionPoint)
// We don't need to take care of form association by 'form' content
// attribute becuse IdTargetObserver handles it.
if (m_hasElementsAssociatedByParser) {
- Node* root = highestAncestor();
+ Node& root = highestAncestor();
if (!m_associatedElementsAreDirty) {
Vector<FormAssociatedElement*> elements(associatedElements());
notifyFormRemovedFromTree(elements, root);
@@ -574,10 +574,10 @@ PassRefPtr<HTMLCollection> HTMLFormElement::elements()
return ensureCachedHTMLCollection(FormControls);
}
-void HTMLFormElement::collectAssociatedElements(Node* root, Vector<FormAssociatedElement*>& elements) const
+void HTMLFormElement::collectAssociatedElements(Node& root, Vector<FormAssociatedElement*>& elements) const
{
elements.clear();
- for (Node* node = root; node; node = NodeTraversal::next(*node)) {
+ for (Node* node = &root; node; node = NodeTraversal::next(*node)) {
if (!node->isHTMLElement())
continue;
FormAssociatedElement* element = 0;
@@ -601,18 +601,19 @@ const Vector<FormAssociatedElement*>& HTMLFormElement::associatedElements() cons
HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this);
Node* scope = mutableThis;
if (m_hasElementsAssociatedByParser)
- scope = highestAncestor();
+ scope = &highestAncestor();
if (inDocument() && treeScope().idTargetObserverRegistry().hasObservers(fastGetAttribute(idAttr)))
scope = &treeScope().rootNode();
- collectAssociatedElements(scope, mutableThis->m_associatedElements);
+ ASSERT(scope);
+ collectAssociatedElements(*scope, mutableThis->m_associatedElements);
mutableThis->m_associatedElementsAreDirty = false;
return m_associatedElements;
}
-void HTMLFormElement::collectImageElements(Node* root, Vector<HTMLImageElement*>& elements)
+void HTMLFormElement::collectImageElements(Node& root, Vector<HTMLImageElement*>& elements)
{
elements.clear();
- for (Node* node = root; node; node = NodeTraversal::next(*node)) {
+ for (Node* node = &root; node; node = NodeTraversal::next(*node)) {
if (node->isHTMLElement() && node->hasTagName(imgTag) && toHTMLElement(node)->formOwner() == this)
elements.append(toHTMLImageElement(node));
}
@@ -622,7 +623,7 @@ const Vector<HTMLImageElement*>& HTMLFormElement::imageElements()
{
if (!m_imageElementsAreDirty)
return m_imageElements;
- collectImageElements(m_hasElementsAssociatedByParser ? highestAncestor() : this, m_imageElements);
+ collectImageElements(m_hasElementsAssociatedByParser ? highestAncestor() : *this, m_imageElements);
m_imageElementsAreDirty = false;
return m_imageElements;
}
« no previous file with comments | « Source/core/html/HTMLFormElement.h ('k') | Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698