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

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

Issue 67473002: Have ElementTraversal / NodeTraversal's next() methods take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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/HTMLLabelElement.cpp » ('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 914b7a2eb5715a534399024d0a987ae489820d18..74bf99bc3349d188f203dd8bc5391d4782d86c5b 100644
--- a/Source/core/html/HTMLFormElement.cpp
+++ b/Source/core/html/HTMLFormElement.cpp
@@ -548,20 +548,20 @@ unsigned HTMLFormElement::formElementIndexWithFormAttribute(Element* element, un
return left + 1;
}
-unsigned HTMLFormElement::formElementIndex(FormAssociatedElement* associatedElement)
+unsigned HTMLFormElement::formElementIndex(FormAssociatedElement& associatedElement)
{
- HTMLElement* associatedHTMLElement = toHTMLElement(associatedElement);
+ HTMLElement& associatedHTMLElement = toHTMLElement(associatedElement);
// Treats separately the case where this element has the form attribute
// for performance consideration.
- if (associatedHTMLElement->fastHasAttribute(formAttr)) {
- unsigned short position = compareDocumentPosition(associatedHTMLElement);
+ if (associatedHTMLElement.fastHasAttribute(formAttr)) {
+ unsigned short position = compareDocumentPosition(&associatedHTMLElement);
if (position & DOCUMENT_POSITION_PRECEDING) {
++m_associatedElementsBeforeIndex;
++m_associatedElementsAfterIndex;
- return HTMLFormElement::formElementIndexWithFormAttribute(associatedHTMLElement, 0, m_associatedElementsBeforeIndex - 1);
+ return HTMLFormElement::formElementIndexWithFormAttribute(&associatedHTMLElement, 0, m_associatedElementsBeforeIndex - 1);
}
if (position & DOCUMENT_POSITION_FOLLOWING && !(position & DOCUMENT_POSITION_CONTAINED_BY))
- return HTMLFormElement::formElementIndexWithFormAttribute(associatedHTMLElement, m_associatedElementsAfterIndex, m_associatedElements.size());
+ return HTMLFormElement::formElementIndexWithFormAttribute(&associatedHTMLElement, m_associatedElementsAfterIndex, m_associatedElements.size());
}
// Check for the special case where this element is the very last thing in
@@ -570,7 +570,7 @@ unsigned HTMLFormElement::formElementIndex(FormAssociatedElement* associatedElem
// that says "add this form element to the end of the array".
if (ElementTraversal::next(associatedHTMLElement, this)) {
unsigned i = m_associatedElementsBeforeIndex;
- for (Element* element = this; element; element = ElementTraversal::next(element, this)) {
+ for (Element* element = this; element; element = ElementTraversal::next(*element, this)) {
if (element == associatedHTMLElement) {
++m_associatedElementsAfterIndex;
return i;
@@ -585,9 +585,9 @@ unsigned HTMLFormElement::formElementIndex(FormAssociatedElement* associatedElem
return m_associatedElementsAfterIndex++;
}
-void HTMLFormElement::registerFormElement(FormAssociatedElement* e)
+void HTMLFormElement::registerFormElement(FormAssociatedElement& e)
{
- m_associatedElements.insert(formElementIndex(e), e);
+ m_associatedElements.insert(formElementIndex(e), &e);
}
void HTMLFormElement::removeFormElement(FormAssociatedElement* e)
« no previous file with comments | « Source/core/html/HTMLFormElement.h ('k') | Source/core/html/HTMLLabelElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698