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

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

Issue 656723005: Use C++11 features in core/html (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: mike's comments Created 6 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/HTMLSelectElement.h ('k') | Source/core/html/HTMLShadowElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 85ed398ed99da09915fb16d58338bdb15a5fc9c6..d1e6f9927ba97e0aad9873adbe8a8f37e9d77a2c 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -240,7 +240,7 @@ void HTMLSelectElement::remove(int optionIndex)
String HTMLSelectElement::value() const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); i++) {
if (isHTMLOptionElement(items[i]) && toHTMLOptionElement(items[i])->selected())
return toHTMLOptionElement(items[i])->value();
@@ -256,7 +256,7 @@ void HTMLSelectElement::setValue(const String &value, bool sendEvents)
optionIndex = -1;
} else {
// Find the option with value() matching the given parameter and make it the current selection.
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); i++) {
if (isHTMLOptionElement(items[i])) {
if (toHTMLOptionElement(items[i])->value() == value)
@@ -284,7 +284,7 @@ void HTMLSelectElement::setValue(const String &value, bool sendEvents)
String HTMLSelectElement::suggestedValue() const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
if (isHTMLOptionElement(items[i]) && m_suggestedIndex >= 0) {
if (i == static_cast<unsigned>(m_suggestedIndex))
@@ -301,7 +301,7 @@ void HTMLSelectElement::setSuggestedValue(const String& value)
return;
}
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
unsigned optionIndex = 0;
for (unsigned i = 0; i < items.size(); ++i) {
if (isHTMLOptionElement(items[i])) {
@@ -497,11 +497,11 @@ void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& exceptionStat
break;
} while (++diff);
} else {
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
// Removing children fires mutation events, which might mutate the DOM further, so we first copy out a list
// of elements that we intend to remove then attempt to remove them one at a time.
- WillBeHeapVector<RefPtrWillBeMember<Element> > itemsToRemove;
+ WillBeHeapVector<RefPtrWillBeMember<Element>> itemsToRemove;
size_t optionIndex = 0;
for (size_t i = 0; i < items.size(); ++i) {
Element* item = items[i];
@@ -532,7 +532,7 @@ bool HTMLSelectElement::isRequiredFormControl() const
int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, int skip) const
{
ASSERT(direction == -1 || direction == 1);
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = this->listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = this->listItems();
int lastGoodIndex = listIndex;
int size = listItems.size();
for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex += direction) {
@@ -567,7 +567,7 @@ int HTMLSelectElement::previousSelectableListIndex(int startIndex) const
int HTMLSelectElement::firstSelectableListIndex() const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
int index = nextValidIndex(items.size(), SkipBackwards, INT_MAX);
if (static_cast<size_t>(index) == items.size())
return -1;
@@ -582,7 +582,7 @@ int HTMLSelectElement::lastSelectableListIndex() const
// Returns the index of the next valid item one page away from |startIndex| in direction |direction|.
int HTMLSelectElement::nextSelectableListIndexPageAway(int startIndex, SkipDirection direction) const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
// Can't use m_size because renderer forces a minimum size.
int pageSize = 0;
if (renderer()->isListBox())
@@ -623,7 +623,7 @@ void HTMLSelectElement::saveLastSelection()
}
m_lastOnChangeSelection.clear();
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
m_lastOnChangeSelection.append(isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected());
@@ -638,7 +638,7 @@ void HTMLSelectElement::setActiveSelectionAnchorIndex(int index)
// selection pivots around this anchor index.
m_cachedStateForActiveSelection.clear();
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected());
@@ -661,7 +661,7 @@ void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions, bool s
unsigned start = std::min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex);
unsigned end = std::max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex);
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl() || !toHTMLOptionElement(element)->renderer())
@@ -685,7 +685,7 @@ void HTMLSelectElement::listBoxOnChange()
{
ASSERT(!usesMenuList() || m_multiple);
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
// If the cached selection list is empty, or the size has changed, then fire
// dispatchFormControlChangeEvent, and return early.
@@ -745,13 +745,13 @@ void HTMLSelectElement::setOptionsChangedOnRenderer()
}
}
-const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& HTMLSelectElement::listItems() const
+const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& HTMLSelectElement::listItems() const
{
if (m_shouldRecalcListItems)
recalcListItems();
else {
#if ENABLE(ASSERT)
- WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > items = m_listItems;
+ WillBeHeapVector<RawPtrWillBeMember<HTMLElement>> items = m_listItems;
recalcListItems(false);
ASSERT(items == m_listItems);
#endif
@@ -854,7 +854,7 @@ int HTMLSelectElement::selectedIndex() const
unsigned index = 0;
// Return the number of the first option selected.
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (size_t i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
if (isHTMLOptionElement(*element)) {
@@ -893,7 +893,7 @@ void HTMLSelectElement::scrollTo(int listIndex)
return;
if (usesMenuList())
return;
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
int listSize = static_cast<int>(items.size());
if (listIndex >= listSize)
return;
@@ -932,7 +932,7 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
{
bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions);
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
int listIndex = optionToListIndex(optionIndex);
if (selectedIndex() != optionIndex && isAutofilled())
@@ -980,7 +980,7 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
int HTMLSelectElement::optionToListIndex(int optionIndex) const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
int listSize = static_cast<int>(items.size());
if (optionIndex < 0 || optionIndex >= listSize)
return -1;
@@ -999,7 +999,7 @@ int HTMLSelectElement::optionToListIndex(int optionIndex) const
int HTMLSelectElement::listToOptionIndex(int listIndex) const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
if (listIndex < 0 || listIndex >= static_cast<int>(items.size()) || !isHTMLOptionElement(*items[listIndex]))
return -1;
@@ -1034,7 +1034,7 @@ void HTMLSelectElement::dispatchBlurEvent(Element* newFocusedElement)
void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeElement)
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
if (element != excludeElement && isHTMLOptionElement(*element))
@@ -1044,7 +1044,7 @@ void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeEleme
FormControlState HTMLSelectElement::saveFormControlState() const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
size_t length = items.size();
FormControlState state;
for (unsigned i = 0; i < length; ++i) {
@@ -1063,7 +1063,7 @@ FormControlState HTMLSelectElement::saveFormControlState() const
size_t HTMLSelectElement::searchOptionsForValue(const String& value, size_t listIndexStart, size_t listIndexEnd) const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
size_t loopEndIndex = std::min(items.size(), listIndexEnd);
for (size_t i = listIndexStart; i < loopEndIndex; ++i) {
if (!isHTMLOptionElement(items[i]))
@@ -1078,7 +1078,7 @@ void HTMLSelectElement::restoreFormControlState(const FormControlState& state)
{
recalcListItems();
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
size_t itemsSize = items.size();
if (!itemsSize)
return;
@@ -1139,7 +1139,7 @@ bool HTMLSelectElement::appendFormData(FormDataList& list, bool)
return false;
bool successful = false;
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
@@ -1160,7 +1160,7 @@ void HTMLSelectElement::resetImpl()
HTMLOptionElement* firstOption = 0;
HTMLOptionElement* selectedOption = 0;
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
if (!isHTMLOptionElement(*element))
@@ -1257,7 +1257,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
const String& keyIdentifier = keyEvent->keyIdentifier();
bool handled = true;
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = this->listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = this->listItems();
int listIndex = optionToListIndex(selectedIndex());
if (keyIdentifier == "Down" || keyIdentifier == "Right")
@@ -1399,7 +1399,7 @@ int HTMLSelectElement::listIndexForEventTargetOption(const Event& event)
int HTMLSelectElement::listIndexForOption(const HTMLOptionElement& option)
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = this->listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = this->listItems();
size_t length = items.size();
for (size_t i = 0; i < length; ++i) {
if (items[i].get() == &option)
@@ -1425,7 +1425,7 @@ void HTMLSelectElement::handleMouseRelease()
void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = this->listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = this->listItems();
if (event->type() == EventTypeNames::gesturetap && event->isGestureEvent()) {
focus();
// Calling focus() may cause us to lose our renderer or change the render type, in which case do not want to handle the event.
@@ -1626,7 +1626,7 @@ void HTMLSelectElement::defaultEventHandler(Event* event)
int HTMLSelectElement::lastSelectedListIndex() const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (size_t i = items.size(); i;) {
HTMLElement* element = items[--i];
if (isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected())
@@ -1647,7 +1647,7 @@ int HTMLSelectElement::optionCount() const
String HTMLSelectElement::optionAtIndex(int index) const
{
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
HTMLElement* element = items[index];
if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl())
@@ -1682,7 +1682,7 @@ void HTMLSelectElement::accessKeySetSelectedIndex(int index)
accessKeyAction(false);
// If this index is already selected, unselect. otherwise update the selected index.
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
int listIndex = optionToListIndex(index);
if (listIndex >= 0) {
HTMLElement* element = items[listIndex];
@@ -1706,7 +1706,7 @@ unsigned HTMLSelectElement::length() const
{
unsigned options = 0;
- const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
if (isHTMLOptionElement(*items[i]))
++options;
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | Source/core/html/HTMLShadowElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698