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

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

Issue 65303008: Have ElementTraversal::firstWithin() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
Index: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 08de712583726bdb85064b38b5c91980faa4f546..9dbcd783037bc9aff0889abb064ee21e3db774d2 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -734,44 +734,44 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
HTMLOptionElement* foundSelected = 0;
HTMLOptionElement* firstOption = 0;
- for (Element* currentElement = ElementTraversal::firstWithin(this); currentElement; ) {
+ for (Element* currentElement = ElementTraversal::firstWithin(*this); currentElement; ) {
if (!currentElement->isHTMLElement()) {
currentElement = ElementTraversal::nextSkippingChildren(currentElement, this);
continue;
}
- HTMLElement* current = toHTMLElement(currentElement);
+ HTMLElement& current = toHTMLElement(*currentElement);
// optgroup tags may not nest. However, both FireFox and IE will
// flatten the tree automatically, so we follow suit.
// (http://www.w3.org/TR/html401/interact/forms.html#h-17.6)
if (isHTMLOptGroupElement(current)) {
- m_listItems.append(current);
+ m_listItems.append(&current);
if (Element* nextElement = ElementTraversal::firstWithin(current)) {
currentElement = nextElement;
continue;
}
}
- if (current->hasTagName(optionTag)) {
- m_listItems.append(current);
+ if (current.hasTagName(optionTag)) {
+ m_listItems.append(&current);
if (updateSelectedStates && !m_multiple) {
- HTMLOptionElement* option = toHTMLOptionElement(current);
+ HTMLOptionElement& option = toHTMLOptionElement(current);
if (!firstOption)
- firstOption = option;
- if (option->selected()) {
+ firstOption = &option;
+ if (option.selected()) {
if (foundSelected)
foundSelected->setSelectedState(false);
- foundSelected = option;
- } else if (m_size <= 1 && !foundSelected && !option->isDisabledFormControl()) {
- foundSelected = option;
+ foundSelected = &option;
+ } else if (m_size <= 1 && !foundSelected && !option.isDisabledFormControl()) {
+ foundSelected = &option;
foundSelected->setSelectedState(true);
}
}
}
- if (current->hasTagName(hrTag))
- m_listItems.append(current);
+ if (current.hasTagName(hrTag))
+ m_listItems.append(&current);
// In conforming HTML code, only <optgroup> and <option> will be found
// within a <select>. We call NodeTraversal::nextSkippingChildren so that we only step

Powered by Google App Engine
This is Rietveld 408576698