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

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp

Issue 2556043002: Avoid WTF::Vector::at() and operator[] in core/html. (Closed)
Patch Set: _ Created 4 years 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: third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp b/third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp
index d9185f583cff3b9991cf2c3cd999981059afc620..68013998e211578fcf499303f3e1fcc2fd17e6d0 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormControlsCollection.cpp
@@ -108,9 +108,9 @@ static HTMLElement* firstNamedItem(const ListedElement::List& elementsArray,
const String& name) {
DCHECK(attrName == idAttr || attrName == nameAttr);
- for (unsigned i = 0; i < elementsArray.size(); ++i) {
- HTMLElement* element = toHTMLElement(elementsArray[i]);
- if (elementsArray[i]->isEnumeratable() &&
+ for (const auto& listedElement : elementsArray) {
+ HTMLElement* element = toHTMLElement(listedElement);
+ if (listedElement->isEnumeratable() &&
element->fastGetAttribute(attrName) == name)
return element;
}
@@ -136,10 +136,7 @@ void HTMLFormControlsCollection::updateIdNameCache() const {
NamedItemCache* cache = NamedItemCache::create();
HashSet<StringImpl*> foundInputElements;
- const ListedElement::List& elementsArray = listedElements();
-
- for (unsigned i = 0; i < elementsArray.size(); ++i) {
- ListedElement* listedElement = elementsArray[i];
+ for (const auto& listedElement : listedElements()) {
if (listedElement->isEnumeratable()) {
HTMLElement* element = toHTMLElement(listedElement);
const AtomicString& idAttrVal = element->getIdAttribute();
@@ -158,10 +155,7 @@ void HTMLFormControlsCollection::updateIdNameCache() const {
// HTMLFormControlsCollection doesn't support named getter for IMG
// elements. However we still need to handle IMG elements here because
// HTMLFormElement named getter relies on this.
- const HeapVector<Member<HTMLImageElement>>& imageElementsArray =
- formImageElements();
- for (unsigned i = 0; i < imageElementsArray.size(); ++i) {
- HTMLImageElement* element = imageElementsArray[i];
+ for (const auto& element : formImageElements()) {
const AtomicString& idAttrVal = element->getIdAttribute();
const AtomicString& nameAttrVal = element->getNameAttribute();
if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.impl()))
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLFormElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698