Use modern for-loops in WebCore/html.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Oct 2015 13:31:14 +0000 (13:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Oct 2015 13:31:14 +0000 (13:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149662

Patch by Hunseop Jeong <hs85.jeong@samsung.com> on 2015-10-06
Reviewed by Darin Adler.

No new tests because there is no behavior change.

* html/DOMFormData.cpp:
(WebCore::DOMFormData::DOMFormData):
* html/EmailInputType.cpp:
(WebCore::EmailInputType::typeMismatchFor):
* html/FileInputType.cpp:
(WebCore::FileInputType::receiveDroppedFiles):
* html/FormController.cpp:
(WebCore::FormControlState::serializeTo):
(WebCore::FormControlState::deserialize):
(WebCore::SavedFormState::serializeTo):
(WebCore::SavedFormState::getReferencedFilePaths):
(WebCore::FormController::createSavedFormStateMap):
(WebCore::FormController::formElementsState):
(WebCore::FormController::restoreControlStateIn):
(WebCore::FormController::getReferencedFilePaths):
* html/HTMLAnchorElement.cpp:
(WebCore::hasNonEmptyBox):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::~HTMLCanvasElement):
(WebCore::HTMLCanvasElement::notifyObserversCanvasChanged):
(WebCore::HTMLCanvasElement::reset):
(WebCore::HTMLCanvasElement::paintsIntoCanvasBuffer):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::length):
* html/HTMLFormControlsCollection.cpp:
(WebCore::firstNamedItem):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::~HTMLFormElement):
(WebCore::HTMLFormElement::formWouldHaveSecureSubmission):
(WebCore::HTMLFormElement::removedFrom):
(WebCore::HTMLFormElement::length):
(WebCore::HTMLFormElement::submitImplicitly):
(WebCore::HTMLFormElement::validateInteractively):
(WebCore::HTMLFormElement::getTextFieldValues):
(WebCore::HTMLFormElement::submit):
(WebCore::HTMLFormElement::reset):
(WebCore::HTMLFormElement::defaultButton):
(WebCore::HTMLFormElement::checkInvalidControlsAndCollectUnhandled):
(WebCore::HTMLFormElement::removeFromPastNamesMap):
(WebCore::HTMLFormElement::documentDidResumeFromPageCache):
* html/HTMLInputElement.cpp:
(WebCore::parseAcceptAttribute):
* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::HTMLKeygenElement):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setMediaGroup):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::index):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::saveLastSelection):
(WebCore::HTMLSelectElement::setActiveSelectionAnchorIndex):
(WebCore::HTMLSelectElement::setActiveSelectionEndIndex):
(WebCore::HTMLSelectElement::selectedIndex):
(WebCore::HTMLSelectElement::deselectItemsWithoutValidation):
(WebCore::HTMLSelectElement::saveFormControlState):
(WebCore::HTMLSelectElement::restoreFormControlState):
(WebCore::HTMLSelectElement::appendFormData):
(WebCore::HTMLSelectElement::reset):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::setDefaultValue):
* html/InputType.cpp:
(WebCore::populateInputTypeFactoryMap):
* html/MediaController.cpp:
(MediaController::duration):
(MediaController::setCurrentTime):
(MediaController::play):
(MediaController::setPlaybackRate):
(MediaController::setVolume):
(MediaController::setMuted):
(playbackStateWaiting):
(MediaController::updateMediaElements):
(MediaController::bringElementUpToSpeed):
(MediaController::isBlocked):
(MediaController::hasEnded):
(MediaController::asyncEventTimerFired):
(MediaController::clearPositionTimerFired):
(MediaController::hasAudio):
(MediaController::hasVideo):
(MediaController::hasClosedCaptions):
(MediaController::setClosedCaptionsVisible):
(MediaController::supportsScanning):
(MediaController::beginScrubbing):
(MediaController::endScrubbing):
(MediaController::canPlay):
(MediaController::isLiveStream):
(MediaController::hasCurrentSrc):
(MediaController::returnToRealtime):
* html/MediaFragmentURIParser.cpp:
(WebCore::MediaFragmentURIParser::parseTimeFragment):
* html/PublicURLManager.cpp:
(WebCore::PublicURLManager::revoke):
(WebCore::PublicURLManager::stop):
* html/canvas/WebGLBuffer.cpp:
(WebCore::WebGLBuffer::getCachedMaxIndex):
(WebCore::WebGLBuffer::setCachedMaxIndex):
(WebCore::WebGLBuffer::setTarget):
* html/canvas/WebGLContextGroup.cpp:
(WebCore::WebGLContextGroup::loseContextGroup):
* html/canvas/WebGLDrawBuffers.cpp:
(WebCore::WebGLDrawBuffers::satisfiesWebGLRequirements):
* html/canvas/WebGLFramebuffer.cpp:
(WebCore::WebGLFramebuffer::removeAttachmentFromBoundFramebuffer):
(WebCore::WebGLFramebuffer::checkStatus):
(WebCore::WebGLFramebuffer::deleteObjectImpl):
(WebCore::WebGLFramebuffer::initializeAttachments):
(WebCore::WebGLFramebuffer::drawBuffers):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase):
(WebCore::WebGLRenderingContextBase::deleteTexture):
* html/canvas/WebGLVertexArrayObject.cpp:
(WebCore::WebGLVertexArrayObject::deleteObjectImpl):
* html/canvas/WebGLVertexArrayObjectOES.cpp:
(WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
* html/parser/AtomicHTMLToken.h:
(WebCore::AtomicHTMLToken::initializeAttributes):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
* html/parser/HTMLFormattingElementList.cpp:
(WebCore::HTMLFormattingElementList::ensureNoahsArkCondition):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
* html/parser/XSSAuditor.cpp:
(WebCore::semicolonSeparatedValueContainsJavaScriptURL):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::invalidate):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
(WebCore::MediaControlTextTrackContainerElement::updateActiveCuesFontSize):
* html/track/AudioTrackList.cpp:
(AudioTrackList::getTrackById):
* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::newCuesAvailable):
(WebCore::LoadableTextTrack::newRegionsAvailable):
* html/track/TextTrackCueList.cpp:
(WebCore::TextTrackCueList::getCueById):
(WebCore::TextTrackCueList::activeCues):
* html/track/TextTrackList.cpp:
(TextTrackList::getTrackIndexRelativeToRenderedTracks):
(TextTrackList::invalidateTrackIndexesAfterTrack):
* html/track/TrackListBase.cpp:
(TrackListBase::isAnyTrackEnabled):
* html/track/VideoTrackList.cpp:
(VideoTrackList::getTrackById):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190613 268f45cc-cd09-0410-ab3c-d52691b4dbfc

40 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/DOMFormData.cpp
Source/WebCore/html/EmailInputType.cpp
Source/WebCore/html/FileInputType.cpp
Source/WebCore/html/FormController.cpp
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLFieldSetElement.cpp
Source/WebCore/html/HTMLFormControlsCollection.cpp
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLKeygenElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/html/MediaController.cpp
Source/WebCore/html/MediaFragmentURIParser.cpp
Source/WebCore/html/PublicURLManager.cpp
Source/WebCore/html/canvas/WebGLBuffer.cpp
Source/WebCore/html/canvas/WebGLContextGroup.cpp
Source/WebCore/html/canvas/WebGLDrawBuffers.cpp
Source/WebCore/html/canvas/WebGLFramebuffer.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObject.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp
Source/WebCore/html/parser/AtomicHTMLToken.h
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLFormattingElementList.cpp
Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Source/WebCore/html/parser/XSSAuditor.cpp
Source/WebCore/html/shadow/ContentDistributor.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/track/AudioTrackList.cpp
Source/WebCore/html/track/LoadableTextTrack.cpp
Source/WebCore/html/track/TextTrackCueList.cpp
Source/WebCore/html/track/TextTrackList.cpp
Source/WebCore/html/track/TrackListBase.cpp
Source/WebCore/html/track/VideoTrackList.cpp

index e54657bc47d0cb6aed4d9c1db7720dccea7e3411..333c2ea260429c85724f3f66ca882aceaf6e8dc7 100644 (file)
@@ -1,3 +1,158 @@
+2015-10-06  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        Use modern for-loops in WebCore/html.
+        https://bugs.webkit.org/show_bug.cgi?id=149662
+
+        Reviewed by Darin Adler.
+
+        No new tests because there is no behavior change.
+
+        * html/DOMFormData.cpp:
+        (WebCore::DOMFormData::DOMFormData):
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::typeMismatchFor):
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::receiveDroppedFiles):
+        * html/FormController.cpp:
+        (WebCore::FormControlState::serializeTo):
+        (WebCore::FormControlState::deserialize):
+        (WebCore::SavedFormState::serializeTo):
+        (WebCore::SavedFormState::getReferencedFilePaths):
+        (WebCore::FormController::createSavedFormStateMap):
+        (WebCore::FormController::formElementsState):
+        (WebCore::FormController::restoreControlStateIn):
+        (WebCore::FormController::getReferencedFilePaths):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::hasNonEmptyBox):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::~HTMLCanvasElement):
+        (WebCore::HTMLCanvasElement::notifyObserversCanvasChanged):
+        (WebCore::HTMLCanvasElement::reset):
+        (WebCore::HTMLCanvasElement::paintsIntoCanvasBuffer):
+        * html/HTMLFieldSetElement.cpp:
+        (WebCore::HTMLFieldSetElement::length):
+        * html/HTMLFormControlsCollection.cpp:
+        (WebCore::firstNamedItem):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::~HTMLFormElement):
+        (WebCore::HTMLFormElement::formWouldHaveSecureSubmission):
+        (WebCore::HTMLFormElement::removedFrom):
+        (WebCore::HTMLFormElement::length):
+        (WebCore::HTMLFormElement::submitImplicitly):
+        (WebCore::HTMLFormElement::validateInteractively):
+        (WebCore::HTMLFormElement::getTextFieldValues):
+        (WebCore::HTMLFormElement::submit):
+        (WebCore::HTMLFormElement::reset):
+        (WebCore::HTMLFormElement::defaultButton):
+        (WebCore::HTMLFormElement::checkInvalidControlsAndCollectUnhandled):
+        (WebCore::HTMLFormElement::removeFromPastNamesMap):
+        (WebCore::HTMLFormElement::documentDidResumeFromPageCache):
+        * html/HTMLInputElement.cpp:
+        (WebCore::parseAcceptAttribute):
+        * html/HTMLKeygenElement.cpp:
+        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setMediaGroup):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::index):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::saveLastSelection):
+        (WebCore::HTMLSelectElement::setActiveSelectionAnchorIndex):
+        (WebCore::HTMLSelectElement::setActiveSelectionEndIndex):
+        (WebCore::HTMLSelectElement::selectedIndex):
+        (WebCore::HTMLSelectElement::deselectItemsWithoutValidation):
+        (WebCore::HTMLSelectElement::saveFormControlState):
+        (WebCore::HTMLSelectElement::restoreFormControlState):
+        (WebCore::HTMLSelectElement::appendFormData):
+        (WebCore::HTMLSelectElement::reset):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::setDefaultValue):
+        * html/InputType.cpp:
+        (WebCore::populateInputTypeFactoryMap):
+        * html/MediaController.cpp:
+        (MediaController::duration):
+        (MediaController::setCurrentTime):
+        (MediaController::play):
+        (MediaController::setPlaybackRate):
+        (MediaController::setVolume):
+        (MediaController::setMuted):
+        (playbackStateWaiting):
+        (MediaController::updateMediaElements):
+        (MediaController::bringElementUpToSpeed):
+        (MediaController::isBlocked):
+        (MediaController::hasEnded):
+        (MediaController::asyncEventTimerFired):
+        (MediaController::clearPositionTimerFired):
+        (MediaController::hasAudio):
+        (MediaController::hasVideo):
+        (MediaController::hasClosedCaptions):
+        (MediaController::setClosedCaptionsVisible):
+        (MediaController::supportsScanning):
+        (MediaController::beginScrubbing):
+        (MediaController::endScrubbing):
+        (MediaController::canPlay):
+        (MediaController::isLiveStream):
+        (MediaController::hasCurrentSrc):
+        (MediaController::returnToRealtime):
+        * html/MediaFragmentURIParser.cpp:
+        (WebCore::MediaFragmentURIParser::parseTimeFragment):
+        * html/PublicURLManager.cpp:
+        (WebCore::PublicURLManager::revoke):
+        (WebCore::PublicURLManager::stop):
+        * html/canvas/WebGLBuffer.cpp:
+        (WebCore::WebGLBuffer::getCachedMaxIndex):
+        (WebCore::WebGLBuffer::setCachedMaxIndex):
+        (WebCore::WebGLBuffer::setTarget):
+        * html/canvas/WebGLContextGroup.cpp:
+        (WebCore::WebGLContextGroup::loseContextGroup):
+        * html/canvas/WebGLDrawBuffers.cpp:
+        (WebCore::WebGLDrawBuffers::satisfiesWebGLRequirements):
+        * html/canvas/WebGLFramebuffer.cpp:
+        (WebCore::WebGLFramebuffer::removeAttachmentFromBoundFramebuffer):
+        (WebCore::WebGLFramebuffer::checkStatus):
+        (WebCore::WebGLFramebuffer::deleteObjectImpl):
+        (WebCore::WebGLFramebuffer::initializeAttachments):
+        (WebCore::WebGLFramebuffer::drawBuffers):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase):
+        (WebCore::WebGLRenderingContextBase::deleteTexture):
+        * html/canvas/WebGLVertexArrayObject.cpp:
+        (WebCore::WebGLVertexArrayObject::deleteObjectImpl):
+        * html/canvas/WebGLVertexArrayObjectOES.cpp:
+        (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
+        * html/parser/AtomicHTMLToken.h:
+        (WebCore::AtomicHTMLToken::initializeAttributes):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement):
+        * html/parser/HTMLFormattingElementList.cpp:
+        (WebCore::HTMLFormattingElementList::ensureNoahsArkCondition):
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
+        * html/parser/XSSAuditor.cpp:
+        (WebCore::semicolonSeparatedValueContainsJavaScriptURL):
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::invalidate):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
+        (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
+        (WebCore::MediaControlTextTrackContainerElement::updateActiveCuesFontSize):
+        * html/track/AudioTrackList.cpp:
+        (AudioTrackList::getTrackById):
+        * html/track/LoadableTextTrack.cpp:
+        (WebCore::LoadableTextTrack::newCuesAvailable):
+        (WebCore::LoadableTextTrack::newRegionsAvailable):
+        * html/track/TextTrackCueList.cpp:
+        (WebCore::TextTrackCueList::getCueById):
+        (WebCore::TextTrackCueList::activeCues):
+        * html/track/TextTrackList.cpp:
+        (TextTrackList::getTrackIndexRelativeToRenderedTracks):
+        (TextTrackList::invalidateTrackIndexesAfterTrack):
+        * html/track/TrackListBase.cpp:
+        (TrackListBase::isAnyTrackEnabled):
+        * html/track/VideoTrackList.cpp:
+        (VideoTrackList::getTrackById):
+
 2015-10-06  Alex Christensen  <achristensen@webkit.org>
 
         Report error when main resource is blocked by content blocker
index 9a7ce21f478c7459394f2256674a1b339454fe50..4bb68d7de94bf2ae1ed10eb7473a4a31a8243563 100644 (file)
@@ -47,10 +47,9 @@ DOMFormData::DOMFormData(HTMLFormElement* form)
     if (!form)
         return;
 
-    for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
-        FormAssociatedElement& element = *form->associatedElements()[i];
-        if (!element.asHTMLElement().isDisabledFormControl())
-            element.appendFormData(*this, true);
+    for (auto& element : form->associatedElements()) {
+        if (!element->asHTMLElement().isDisabledFormControl())
+            element->appendFormData(*this, true);
     }
 }
 
index 68f35dbfbe4d9cc08d87561dd3ad941b93cba5e5..dae1782948a43527ce101d79d9773273b4ac0303 100644 (file)
@@ -65,8 +65,8 @@ bool EmailInputType::typeMismatchFor(const String& value) const
         return !isValidEmailAddress(value);
     Vector<String> addresses;
     value.split(',', true, addresses);
-    for (unsigned i = 0; i < addresses.size(); ++i) {
-        if (!isValidEmailAddress(stripLeadingAndTrailingHTMLSpaces(addresses[i])))
+    for (auto& address : addresses) {
+        if (!isValidEmailAddress(stripLeadingAndTrailingHTMLSpaces(address)))
             return true;
     }
     return false;
index 489d79938fcfd226fc994c260e6e55353c54af29..21d5ee330ea737f9750ff516d0301300007f9c19 100644 (file)
@@ -399,8 +399,8 @@ bool FileInputType::receiveDroppedFiles(const DragData& dragData)
     HTMLInputElement* input = &element();
 
     Vector<FileChooserFileInfo> files;
-    for (unsigned i = 0; i < paths.size(); ++i)
-        files.append(FileChooserFileInfo(paths[i]));
+    for (auto& path : paths)
+        files.append(FileChooserFileInfo(path));
 
     if (input->fastHasAttribute(multipleAttr))
         filesChosen(files);
index b7df2d4dc79248b3792938ff485dd1a0e6d70829..63ef0734d21d93b3d643300c3da75b263d05a765 100644 (file)
@@ -55,8 +55,8 @@ void FormControlState::serializeTo(Vector<String>& stateVector) const
 {
     ASSERT(!isFailure());
     stateVector.append(String::number(m_values.size()));
-    for (size_t i = 0; i < m_values.size(); ++i)
-        stateVector.append(m_values[i].isNull() ? emptyString() : m_values[i]);
+    for (auto& value : m_values)
+        stateVector.append(value.isNull() ? emptyString() : value);
 }
 
 FormControlState FormControlState::deserialize(const Vector<String>& stateVector, size_t& index)
@@ -222,13 +222,12 @@ std::unique_ptr<SavedFormState> SavedFormState::deserialize(const Vector<String>
 void SavedFormState::serializeTo(Vector<String>& stateVector) const
 {
     stateVector.append(String::number(m_controlStateCount));
-    for (FormElementStateMap::const_iterator it = m_stateForNewFormElements.begin(); it != m_stateForNewFormElements.end(); ++it) {
-        const FormElementKey& key = it->key;
-        const Deque<FormControlState>& queue = it->value;
-        for (Deque<FormControlState>::const_iterator queIterator = queue.begin(); queIterator != queue.end(); ++queIterator) {
+    for (auto& element : m_stateForNewFormElements) {
+        const FormElementKey& key = element.key;
+        for (auto& state : element.value) {
             stateVector.append(key.name());
             stateVector.append(key.type());
-            queIterator->serializeTo(stateVector);
+            state.serializeTo(stateVector);
         }
     }
 }
@@ -265,15 +264,12 @@ FormControlState SavedFormState::takeControlState(const AtomicString& name, cons
 Vector<String> SavedFormState::getReferencedFilePaths() const
 {
     Vector<String> toReturn;
-    for (FormElementStateMap::const_iterator it = m_stateForNewFormElements.begin(); it != m_stateForNewFormElements.end(); ++it) {
-        const FormElementKey& key = it->key;
-        if (!equal(key.type(), "file", 4))
+    for (auto& element : m_stateForNewFormElements) {
+        if (!equal(element.key.type(), "file", 4))
             continue;
-        const Deque<FormControlState>& queue = it->value;
-        for (Deque<FormControlState>::const_iterator queIterator = queue.begin(); queIterator != queue.end(); ++queIterator) {
-            const Vector<FileChooserFileInfo>& selectedFiles = HTMLInputElement::filesFromFileInputFormControlState(*queIterator);
-            for (size_t i = 0; i < selectedFiles.size(); ++i)
-                toReturn.append(selectedFiles[i].path);
+        for (auto& state : element.value) {
+            for (auto& file : HTMLInputElement::filesFromFileInputFormControlState(state))
+                toReturn.append(file.path);
         }
     }
     return toReturn;
@@ -398,8 +394,7 @@ std::unique_ptr<FormController::SavedFormStateMap> FormController::createSavedFo
 {
     FormKeyGenerator keyGenerator;
     auto stateMap = std::make_unique<SavedFormStateMap>();
-    for (FormElementListHashSet::const_iterator it = controlList.begin(); it != controlList.end(); ++it) {
-        HTMLFormControlElementWithState* control = it->get();
+    for (auto& control : controlList) {
         if (!control->shouldSaveAndRestoreFormControlState())
             continue;
         auto& formState = stateMap->add(keyGenerator.formKey(*control).impl(), nullptr).iterator->value;
@@ -416,9 +411,9 @@ Vector<String> FormController::formElementsState() const
     Vector<String> stateVector;
     stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4);
     stateVector.append(formStateSignature());
-    for (SavedFormStateMap::const_iterator it = stateMap->begin(); it != stateMap->end(); ++it) {
-        stateVector.append(it->key.get());
-        it->value->serializeTo(stateVector);
+    for (auto& state : *stateMap) {
+        stateVector.append(state.key.get());
+        state.value->serializeTo(stateVector);
     }
     bool hasOnlySignature = stateVector.size() == 1;
     if (hasOnlySignature)
@@ -489,11 +484,10 @@ void FormController::restoreControlStateFor(HTMLFormControlElementWithState& con
 
 void FormController::restoreControlStateIn(HTMLFormElement& form)
 {
-    const Vector<FormAssociatedElement*>& elements = form.associatedElements();
-    for (size_t i = 0; i < elements.size(); ++i) {
-        if (!elements[i]->isFormControlElementWithState())
+    for (auto& element : form.associatedElements()) {
+        if (!element->isFormControlElementWithState())
             continue;
-        HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(elements[i]);
+        HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(element);
         if (!control->shouldSaveAndRestoreFormControlState())
             continue;
         if (ownerFormForState(*control) != &form)
@@ -509,8 +503,8 @@ Vector<String> FormController::getReferencedFilePaths(const Vector<String>& stat
     Vector<String> toReturn;
     SavedFormStateMap map;
     formStatesFromStateVector(stateVector, map);
-    for (SavedFormStateMap::const_iterator it = map.begin(), end = map.end(); it != end; ++it)
-        toReturn.appendVector(it->value->getReferencedFilePaths());
+    for (auto& state : map.values())
+        toReturn.appendVector(state->getReferencedFilePaths());
     return toReturn;
 }
 
index 171b0eeb791a57092b2e83d41d9e66aa936ca42b..27702507fa4cf9d8bd0f468051dd01b9b378fc19 100644 (file)
@@ -121,9 +121,8 @@ static bool hasNonEmptyBox(RenderBoxModelObject* renderer)
     // pass in 0,0 for the layout point instead of calling localToAbsolute?
     Vector<IntRect> rects;
     renderer->absoluteRects(rects, flooredLayoutPoint(renderer->localToAbsolute()));
-    size_t size = rects.size();
-    for (size_t i = 0; i < size; ++i) {
-        if (!rects[i].isEmpty())
+    for (auto& rect : rects) {
+        if (!rect.isEmpty())
             return true;
     }
 
index 44df93c25c4251a330223a58355bfd9546611edf..03ec7df98931a3421debebc4dc0d154aa972a84c 100644 (file)
@@ -99,8 +99,8 @@ Ref<HTMLCanvasElement> HTMLCanvasElement::create(const QualifiedName& tagName, D
 
 HTMLCanvasElement::~HTMLCanvasElement()
 {
-    for (auto it = m_observers.begin(), end = m_observers.end(); it != end; ++it)
-        (*it)->canvasDestroyed(*this);
+    for (auto& observer : m_observers)
+        observer->canvasDestroyed(*this);
 
     m_context = nullptr; // Ensure this goes away before the ImageBuffer.
 }
@@ -284,8 +284,8 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect)
 
 void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect& rect)
 {
-    for (auto it = m_observers.begin(), end = m_observers.end(); it != end; ++it)
-        (*it)->canvasChanged(*this, rect);
+    for (auto& observer : m_observers)
+        observer->canvasChanged(*this, rect);
 }
 
 void HTMLCanvasElement::reset()
@@ -344,8 +344,8 @@ void HTMLCanvasElement::reset()
         }
     }
 
-    for (auto it = m_observers.begin(), end = m_observers.end(); it != end; ++it)
-        (*it)->canvasResized(*this);
+    for (auto& observer : m_observers)
+        observer->canvasResized(*this);
 }
 
 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const
index 400a0bae0ed94fe053fd63571b40aac98fbac8dd..2f6abf08ce8c1e3dd86483f91d2da3903e2197b9 100644 (file)
@@ -193,8 +193,8 @@ unsigned HTMLFieldSetElement::length() const
 {
     refreshElementsIfNeeded();
     unsigned length = 0;
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        if (m_associatedElements[i]->isEnumeratable())
+    for (auto& element : m_associatedElements) {
+        if (element->isEnumeratable())
             ++length;
     }
     return length;
index 30250bb264b498f888821e078918fed76d833e9a..193602d6c9c0b5bf05e858c3f3905ee74289218b 100644 (file)
@@ -103,19 +103,18 @@ static HTMLElement* firstNamedItem(const Vector<FormAssociatedElement*>& element
 {
     ASSERT(attrName == idAttr || attrName == nameAttr);
 
-    for (unsigned i = 0; i < elementsArray.size(); ++i) {
-        HTMLElement& element = elementsArray[i]->asHTMLElement();
-        if (elementsArray[i]->isEnumeratable() && element.fastGetAttribute(attrName) == name)
+    for (auto& entry : elementsArray) {
+        HTMLElement& element = entry->asHTMLElement();
+        if (entry->isEnumeratable() && element.fastGetAttribute(attrName) == name)
             return &element;
     }
 
     if (!imageElementsArray)
         return 0;
 
-    for (unsigned i = 0; i < imageElementsArray->size(); ++i) {
-        HTMLImageElement& element = *(*imageElementsArray)[i];
-        if (element.fastGetAttribute(attrName) == name)
-            return &element;
+    for (auto& element : *imageElementsArray) {
+        if (element->fastGetAttribute(attrName) == name)
+            return element;
     }
 
     return nullptr;
index 6aa0f5f2d36802661de8f837df7cf3da36fd211f..5f62cf7d8da7128fbfa4a76807c188953b13771c 100644 (file)
@@ -86,10 +86,10 @@ HTMLFormElement::~HTMLFormElement()
     if (!shouldAutocomplete())
         document().unregisterForPageCacheSuspensionCallbacks(this);
 
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i)
-        m_associatedElements[i]->formWillBeDestroyed();
-    for (unsigned i = 0; i < m_imageElements.size(); ++i)
-        m_imageElements[i]->m_form = 0;
+    for (auto& associatedElement : m_associatedElements)
+        associatedElement->formWillBeDestroyed();
+    for (auto& imageElement : m_imageElements)
+        imageElement->m_form = nullptr;
 }
 
 bool HTMLFormElement::formWouldHaveSecureSubmission(const String& url)
@@ -147,8 +147,8 @@ void HTMLFormElement::removedFrom(ContainerNode& insertionPoint)
 {
     Node* root = findRoot(this);
     Vector<FormAssociatedElement*> associatedElements(m_associatedElements);
-    for (unsigned i = 0; i < associatedElements.size(); ++i)
-        associatedElements[i]->formRemovedFromTree(root);
+    for (auto& associatedElement : associatedElements)
+        associatedElement->formRemovedFromTree(root);
     HTMLElement::removedFrom(insertionPoint);
 }
 
@@ -165,9 +165,10 @@ void HTMLFormElement::handleLocalEvents(Event& event)
 unsigned HTMLFormElement::length() const
 {
     unsigned len = 0;
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i)
-        if (m_associatedElements[i]->isEnumeratable())
+    for (auto& associatedElement : m_associatedElements) {
+        if (associatedElement->isEnumeratable())
             ++len;
+    }
     return len;
 }
 
@@ -179,8 +180,7 @@ Node* HTMLFormElement::item(unsigned index)
 void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmissionTrigger)
 {
     unsigned submissionTriggerCount = 0;
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        FormAssociatedElement* formAssociatedElement = m_associatedElements[i];
+    for (auto& formAssociatedElement : m_associatedElements) {
         if (!is<HTMLFormControlElement>(*formAssociatedElement))
             continue;
         HTMLFormControlElement& formElement = downcast<HTMLFormControlElement>(*formAssociatedElement);
@@ -221,9 +221,9 @@ bool HTMLFormElement::validateInteractively(Event* event)
     if (submitElement && submitElement->formNoValidate())
         return true;
 
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        if (is<HTMLFormControlElement>(*m_associatedElements[i]))
-            downcast<HTMLFormControlElement>(*m_associatedElements[i]).hideVisibleValidationMessage();
+    for (auto& associatedElement : m_associatedElements) {
+        if (is<HTMLFormControlElement>(*associatedElement))
+            downcast<HTMLFormControlElement>(*associatedElement).hideVisibleValidationMessage();
     }
 
     Vector<RefPtr<FormAssociatedElement>> unhandledInvalidControls;
@@ -239,8 +239,8 @@ bool HTMLFormElement::validateInteractively(Event* event)
     Ref<HTMLFormElement> protect(*this);
 
     // Focus on the first focusable control and show a validation message.
-    for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
-        HTMLElement& element = unhandledInvalidControls[i]->asHTMLElement();
+    for (auto& control : unhandledInvalidControls) {
+        HTMLElement& element = control->asHTMLElement();
         if (element.inDocument() && element.isFocusable()) {
             element.scrollIntoViewIfNeeded(false);
             element.focus();
@@ -252,13 +252,12 @@ bool HTMLFormElement::validateInteractively(Event* event)
 
     // Warn about all of unfocusable controls.
     if (document().frame()) {
-        for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
-            FormAssociatedElement& control = *unhandledInvalidControls[i];
-            HTMLElement& element = control.asHTMLElement();
+        for (auto& control : unhandledInvalidControls) {
+            HTMLElement& element = control->asHTMLElement();
             if (element.inDocument() && element.isFocusable())
                 continue;
             String message("An invalid form control with name='%name' is not focusable.");
-            message.replace("%name", control.name());
+            message.replace("%name", control->name());
             document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, message);
         }
     }
@@ -312,9 +311,8 @@ void HTMLFormElement::getTextFieldValues(StringPairVector& fieldNamesAndValues)
     ASSERT_ARG(fieldNamesAndValues, fieldNamesAndValues.isEmpty());
 
     fieldNamesAndValues.reserveCapacity(m_associatedElements.size());
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        FormAssociatedElement& control = *m_associatedElements[i];
-        HTMLElement& element = control.asHTMLElement();
+    for (auto& associatedElement : m_associatedElements) {
+        HTMLElement& element = associatedElement->asHTMLElement();
         if (!is<HTMLInputElement>(element))
             continue;
         HTMLInputElement& input = downcast<HTMLInputElement>(element);
@@ -342,8 +340,7 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
     RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton;
     bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
 
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        FormAssociatedElement* associatedElement = m_associatedElements[i];
+    for (auto& associatedElement : m_associatedElements) {
         if (!is<HTMLFormControlElement>(*associatedElement))
             continue;
         if (needButtonActivation) {
@@ -382,9 +379,9 @@ void HTMLFormElement::reset()
         return;
     }
 
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        if (is<HTMLFormControlElement>(*m_associatedElements[i]))
-            downcast<HTMLFormControlElement>(*m_associatedElements[i]).reset();
+    for (auto& associatedElement : m_associatedElements) {
+        if (is<HTMLFormControlElement>(*associatedElement))
+            downcast<HTMLFormControlElement>(*associatedElement).reset();
     }
 
     m_isInResetFunction = false;
@@ -692,10 +689,10 @@ bool HTMLFormElement::wasUserSubmitted() const
 
 HTMLFormControlElement* HTMLFormElement::defaultButton() const
 {
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        if (!is<HTMLFormControlElement>(*m_associatedElements[i]))
+    for (auto& associatedElement : m_associatedElements) {
+        if (!is<HTMLFormControlElement>(*associatedElement))
             continue;
-        HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*m_associatedElements[i]);
+        HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*associatedElement);
         if (control.isSuccessfulSubmitButton())
             return &control;
     }
@@ -716,12 +713,12 @@ bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<Form
     // HTMLFormControlElement::checkValidity() might change m_associatedElements.
     Vector<RefPtr<FormAssociatedElement>> elements;
     elements.reserveCapacity(m_associatedElements.size());
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i)
-        elements.append(m_associatedElements[i]);
+    for (auto& associatedElement : m_associatedElements)
+        elements.append(associatedElement);
     bool hasInvalidControls = false;
-    for (unsigned i = 0; i < elements.size(); ++i) {
-        if (elements[i]->form() == this && is<HTMLFormControlElement>(*elements[i])) {
-            HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*elements[i]);
+    for (auto& element : elements) {
+        if (element->form() == this && is<HTMLFormControlElement>(*element)) {
+            HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*element);
             if (!control.checkValidity(&unhandledInvalidControls) && control.form() == this)
                 hasInvalidControls = true;
         }
@@ -777,10 +774,9 @@ void HTMLFormElement::removeFromPastNamesMap(FormNamedItem* item)
     if (!m_pastNamesMap)
         return;
 
-    PastNamesMap::iterator end = m_pastNamesMap->end();
-    for (PastNamesMap::iterator it = m_pastNamesMap->begin(); it != end; ++it) {
-        if (it->value == item)
-            it->value = 0; // Keep looping. Single element can have multiple names.
+    for (auto& pastName : m_pastNamesMap->values()) {
+        if (pastName == item)
+            pastName = nullptr; // Keep looping. Single element can have multiple names.
     }
 }
 
@@ -813,9 +809,9 @@ void HTMLFormElement::documentDidResumeFromPageCache()
 {
     ASSERT(!shouldAutocomplete());
 
-    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
-        if (is<HTMLFormControlElement>(*m_associatedElements[i]))
-            downcast<HTMLFormControlElement>(*m_associatedElements[i]).reset();
+    for (auto& associatedElement : m_associatedElements) {
+        if (is<HTMLFormControlElement>(*associatedElement))
+            downcast<HTMLFormControlElement>(*associatedElement).reset();
     }
 }
 
index be09868e865b9df66758ab689d93a801d2936432..130d004367a641ed040882d1e0939da320176771 100644 (file)
@@ -1224,8 +1224,8 @@ static Vector<String> parseAcceptAttribute(const String& acceptString, bool (*pr
 
     Vector<String> splitTypes;
     acceptString.split(',', false, splitTypes);
-    for (size_t i = 0; i < splitTypes.size(); ++i) {
-        String trimmedType = stripLeadingAndTrailingHTMLSpaces(splitTypes[i]);
+    for (auto& splitType : splitTypes) {
+        String trimmedType = stripLeadingAndTrailingHTMLSpaces(splitType);
         if (trimmedType.isEmpty())
             continue;
         if (!predicate(trimmedType))
index 4a63b00a4a4134b58cf245feb692f8a46616bf19..7be02e646a9754ce9f031a2a209cfafa61602efe 100644 (file)
@@ -74,10 +74,10 @@ inline HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Docume
     getSupportedKeySizes(keys);
 
     Ref<HTMLSelectElement> select = KeygenSelectElement::create(document);
-    for (size_t i = 0; i < keys.size(); ++i) {
+    for (auto& key : keys) {
         Ref<HTMLOptionElement> option = HTMLOptionElement::create(document);
         select->appendChild(option.copyRef(), IGNORE_EXCEPTION);
-        option->appendChild(Text::create(document, keys[i]), IGNORE_EXCEPTION);
+        option->appendChild(Text::create(document, key), IGNORE_EXCEPTION);
     }
 
     ensureUserAgentShadowRoot().appendChild(WTF::move(select), IGNORE_EXCEPTION);
index 074c141455d033997c5f2581cc056be6b20b952d..3d8c2ad0340a1509ab1911a33bebbfad24df410c 100644 (file)
@@ -5724,15 +5724,15 @@ void HTMLMediaElement::setMediaGroup(const String& group)
     // 4. If there is another media element whose Document is the same as m's Document (even if one or both
     // of these elements are not actually in the Document), 
     HashSet<HTMLMediaElement*> elements = documentToElementSetMap().get(&document());
-    for (HashSet<HTMLMediaElement*>::iterator i = elements.begin(); i != elements.end(); ++i) {
-        if (*i == this)
+    for (auto& element : elements) {
+        if (element == this)
             continue;
 
         // and which also has a mediagroup attribute, and whose mediagroup attribute has the same value as
         // the new value of m's mediagroup attribute,        
-        if ((*i)->mediaGroup() == group) {
+        if (element->mediaGroup() == group) {
             //  then let controller be that media element's current media controller.
-            setController((*i)->controller());
+            setController(element->controller());
             return;
         }
     }
index ed9caea15a6213382c20d1df674caa8e2a9f22bb..124d1698e1da9be8d188030222782df8b7395fdc 100644 (file)
@@ -156,12 +156,10 @@ int HTMLOptionElement::index() const
 
     int optionIndex = 0;
 
-    const Vector<HTMLElement*>& items = selectElement->listItems();
-    size_t length = items.size();
-    for (size_t i = 0; i < length; ++i) {
-        if (!is<HTMLOptionElement>(*items[i]))
+    for (auto& item : selectElement->listItems()) {
+        if (!is<HTMLOptionElement>(*item))
             continue;
-        if (items[i] == this)
+        if (item == this)
             return optionIndex;
         ++optionIndex;
     }
index 4f104580132273fdedf12578d4b1bb610eccaf05..886e423d4805b9ed235b32a952eadf7c33e96d48 100644 (file)
@@ -608,11 +608,8 @@ void HTMLSelectElement::saveLastSelection()
     }
 
     m_lastOnChangeSelection.clear();
-    const Vector<HTMLElement*>& items = listItems();
-    for (unsigned i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems())
         m_lastOnChangeSelection.append(is<HTMLOptionElement>(*element) && downcast<HTMLOptionElement>(*element).selected());
-    }
 }
 
 void HTMLSelectElement::setActiveSelectionAnchorIndex(int index)
@@ -623,11 +620,8 @@ void HTMLSelectElement::setActiveSelectionAnchorIndex(int index)
     // selection pivots around this anchor index.
     m_cachedStateForActiveSelection.clear();
 
-    const Vector<HTMLElement*>& items = listItems();
-    for (unsigned i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems())
         m_cachedStateForActiveSelection.append(is<HTMLOptionElement>(*element) && downcast<HTMLOptionElement>(*element).selected());
-    }
 }
 
 void HTMLSelectElement::setActiveSelectionEndIndex(int index)
@@ -843,9 +837,7 @@ int HTMLSelectElement::selectedIndex() const
     unsigned index = 0;
 
     // Return the number of the first option selected.
-    const Vector<HTMLElement*>& items = listItems();
-    for (size_t i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems()) {
         if (is<HTMLOptionElement>(*element)) {
             if (downcast<HTMLOptionElement>(*element).selected())
                 return index;
@@ -971,9 +963,7 @@ void HTMLSelectElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
 
 void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeElement)
 {
-    const Vector<HTMLElement*>& items = listItems();
-    for (unsigned i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems()) {
         if (element != excludeElement && is<HTMLOptionElement>(*element))
             downcast<HTMLOptionElement>(*element).setSelectedState(false);
     }
@@ -981,13 +971,11 @@ void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeEleme
 
 FormControlState HTMLSelectElement::saveFormControlState() const
 {
-    const Vector<HTMLElement*>& items = listItems();
-    size_t length = items.size();
     FormControlState state;
-    for (unsigned i = 0; i < length; ++i) {
-        if (!is<HTMLOptionElement>(*items[i]))
+    for (auto& element : listItems()) {
+        if (!is<HTMLOptionElement>(*element))
             continue;
-        HTMLOptionElement& option = downcast<HTMLOptionElement>(*items[i]);
+        HTMLOptionElement& option = downcast<HTMLOptionElement>(*element);
         if (!option.selected())
             continue;
         state.append(option.value());
@@ -1019,10 +1007,10 @@ void HTMLSelectElement::restoreFormControlState(const FormControlState& state)
     if (!itemsSize)
         return;
 
-    for (size_t i = 0; i < itemsSize; ++i) {
-        if (!is<HTMLOptionElement>(*items[i]))
+    for (auto& element : items) {
+        if (!is<HTMLOptionElement>(*element))
             continue;
-        downcast<HTMLOptionElement>(*items[i]).setSelectedState(false);
+        downcast<HTMLOptionElement>(*element).setSelectedState(false);
     }
 
     if (!multiple()) {
@@ -1063,10 +1051,7 @@ bool HTMLSelectElement::appendFormData(FormDataList& list, bool)
         return false;
 
     bool successful = false;
-    const Vector<HTMLElement*>& items = listItems();
-
-    for (unsigned i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems()) {
         if (is<HTMLOptionElement>(*element) && downcast<HTMLOptionElement>(*element).selected() && !downcast<HTMLOptionElement>(*element).isDisabledFormControl()) {
             list.appendData(name, downcast<HTMLOptionElement>(*element).value());
             successful = true;
@@ -1084,9 +1069,7 @@ void HTMLSelectElement::reset()
     HTMLOptionElement* firstOption = nullptr;
     HTMLOptionElement* selectedOption = nullptr;
 
-    const Vector<HTMLElement*>& items = listItems();
-    for (unsigned i = 0; i < items.size(); ++i) {
-        HTMLElement* element = items[i];
+    for (auto& element : listItems()) {
         if (!is<HTMLOptionElement>(*element))
             continue;
 
index a2de730c5e7c9d1e5c20d90b2d423c28ee4dc5e0..7e3ba76543d17445b614c94ca042dc09e50de77e 100644 (file)
@@ -410,9 +410,8 @@ void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
     for (Text* textNode = TextNodeTraversal::firstChild(*this); textNode; textNode = TextNodeTraversal::nextSibling(*textNode))
         textNodes.append(*textNode);
 
-    size_t size = textNodes.size();
-    for (size_t i = 0; i < size; ++i)
-        removeChild(textNodes[i].get(), IGNORE_EXCEPTION);
+    for (auto& textNode : textNodes)
+        removeChild(textNode.get(), IGNORE_EXCEPTION);
 
     // Normalize line endings.
     String value = defaultValue;
index 607cebe22cfda882f4045629deceed532bdc2bbf..422e88ca107abf5559e836ccf5214bd92f938b60 100644 (file)
@@ -140,10 +140,10 @@ static void populateInputTypeFactoryMap(InputTypeFactoryMap& map)
         // No need to register "text" because it is the default type.
     };
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(inputTypes); ++i) {
-        auto conditionalFunction = inputTypes[i].conditionalFunction;
+    for (auto& inputType : inputTypes) {
+        auto conditionalFunction = inputType.conditionalFunction;
         if (!conditionalFunction || (RuntimeEnabledFeatures::sharedFeatures().*conditionalFunction)())
-            map.add(inputTypes[i].nameFunction(), inputTypes[i].factoryFunction);
+            map.add(inputType.nameFunction(), inputType.factoryFunction);
     }
 }
 
index dcb3249f0a58b2f5fa9901aa5cd047c58e1456f2..963724467687404ed62ee37d014ef4d653370721 100644 (file)
@@ -132,8 +132,8 @@ double MediaController::duration() const
     // FIXME: Investigate caching the maximum duration and only updating the cached value
     // when the slaved media elements' durations change.
     double maxDuration = 0;
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        double duration = m_mediaElements[index]->duration();
+    for (auto& mediaElement : m_mediaElements) {
+        double duration = mediaElement->duration();
         if (std::isnan(duration))
             continue;
         maxDuration = std::max(maxDuration, duration);
@@ -170,8 +170,8 @@ void MediaController::setCurrentTime(double time)
     m_clock->setCurrentTime(time);
     
     // Seek each slaved media element to the new playback position relative to the media element timeline.
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->seek(MediaTime::createWithDouble(time));
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->seek(MediaTime::createWithDouble(time));
 
     scheduleTimeupdateEvent();
     m_resetCurrentTimeInNextPlay = false;
@@ -194,8 +194,8 @@ void MediaController::play()
 {
     // When the play() method is invoked, the user agent must invoke the play method of each
     // slaved media element in turn,
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->play();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->play();
 
     // and then invoke the unpause method of the MediaController.
     unpause();
@@ -242,8 +242,8 @@ void MediaController::setPlaybackRate(double rate)
     // playback rate to the new value,
     m_clock->setPlayRate(rate);
 
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->updatePlaybackRate();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->updatePlaybackRate();
 
     // then queue a task to fire a simple event named ratechange at the MediaController.
     scheduleEvent(eventNames().ratechangeEvent);
@@ -268,8 +268,8 @@ void MediaController::setVolume(double level, ExceptionCode& code)
     // and queue a task to fire a simple event named volumechange at the MediaController.
     scheduleEvent(eventNames().volumechangeEvent);
 
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->updateVolume();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->updateVolume();
 }
 
 void MediaController::setMuted(bool flag)
@@ -284,8 +284,8 @@ void MediaController::setMuted(bool flag)
     // and queue a task to fire a simple event named volumechange at the MediaController.
     scheduleEvent(eventNames().volumechangeEvent);
 
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->updateVolume();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->updateVolume();
 }
 
 static const AtomicString& playbackStateWaiting()
@@ -472,8 +472,8 @@ void MediaController::updatePlaybackState()
 
 void MediaController::updateMediaElements()
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->updatePlayState();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->updatePlayState();
 }
 
 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element)
@@ -498,8 +498,7 @@ bool MediaController::isBlocked() const
         return false;
     
     bool allPaused = true;
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        HTMLMediaElement* element = m_mediaElements[index];
+    for (auto& element : m_mediaElements) {
         //  or if any of its slaved media elements are blocked media elements,
         if (element->isBlocked())
             return true;
@@ -529,8 +528,8 @@ bool MediaController::hasEnded() const
         return false;
     
     bool allHaveEnded = true;
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (!m_mediaElements[index]->ended())
+    for (auto& mediaElement : m_mediaElements) {
+        if (!mediaElement->ended())
             allHaveEnded = false;
     }
     return allHaveEnded;
@@ -548,9 +547,8 @@ void MediaController::asyncEventTimerFired()
     Vector<RefPtr<Event>> pendingEvents;
 
     m_pendingEvents.swap(pendingEvents);
-    size_t count = pendingEvents.size();
-    for (size_t index = 0; index < count; ++index)
-        dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION);
+    for (auto& pendingEvent : pendingEvents)
+        dispatchEvent(pendingEvent.release(), IGNORE_EXCEPTION);
 }
 
 void MediaController::clearPositionTimerFired()
@@ -560,8 +558,8 @@ void MediaController::clearPositionTimerFired()
 
 bool MediaController::hasAudio() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (m_mediaElements[index]->hasAudio())
+    for (auto& mediaElement : m_mediaElements) {
+        if (mediaElement->hasAudio())
             return true;
     }
     return false;
@@ -569,8 +567,8 @@ bool MediaController::hasAudio() const
 
 bool MediaController::hasVideo() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (m_mediaElements[index]->hasVideo())
+    for (auto& mediaElement : m_mediaElements) {
+        if (mediaElement->hasVideo())
             return true;
     }
     return false;
@@ -578,8 +576,8 @@ bool MediaController::hasVideo() const
 
 bool MediaController::hasClosedCaptions() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (m_mediaElements[index]->hasClosedCaptions())
+    for (auto& mediaElement : m_mediaElements) {
+        if (mediaElement->hasClosedCaptions())
             return true;
     }
     return false;
@@ -588,14 +586,14 @@ bool MediaController::hasClosedCaptions() const
 void MediaController::setClosedCaptionsVisible(bool visible)
 {
     m_closedCaptionsVisible = visible;
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->setClosedCaptionsVisible(visible);
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->setClosedCaptionsVisible(visible);
 }
 
 bool MediaController::supportsScanning() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (!m_mediaElements[index]->supportsScanning())
+    for (auto& mediaElement : m_mediaElements) {
+        if (!mediaElement->supportsScanning())
             return false;
     }
     return true;
@@ -603,16 +601,16 @@ bool MediaController::supportsScanning() const
 
 void MediaController::beginScrubbing()
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->beginScrubbing();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->beginScrubbing();
     if (m_playbackState == PLAYING)
         m_clock->stop();
 }
 
 void MediaController::endScrubbing()
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->endScrubbing();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->endScrubbing();
     if (m_playbackState == PLAYING)
         m_clock->start();
 }
@@ -634,8 +632,8 @@ bool MediaController::canPlay() const
     if (m_paused)
         return true;
 
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (!m_mediaElements[index]->canPlay())
+    for (auto& mediaElement : m_mediaElements) {
+        if (!mediaElement->canPlay())
             return false;
     }
     return true;
@@ -643,8 +641,8 @@ bool MediaController::canPlay() const
 
 bool MediaController::isLiveStream() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (!m_mediaElements[index]->isLiveStream())
+    for (auto& mediaElement : m_mediaElements) {
+        if (!mediaElement->isLiveStream())
             return false;
     }
     return true;
@@ -652,8 +650,8 @@ bool MediaController::isLiveStream() const
 
 bool MediaController::hasCurrentSrc() const
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index) {
-        if (!m_mediaElements[index]->hasCurrentSrc())
+    for (auto& mediaElement : m_mediaElements) {
+        if (!mediaElement->hasCurrentSrc())
             return false;
     }
     return true;
@@ -661,8 +659,8 @@ bool MediaController::hasCurrentSrc() const
 
 void MediaController::returnToRealtime()
 {
-    for (size_t index = 0; index < m_mediaElements.size(); ++index)
-        m_mediaElements[index]->returnToRealtime();
+    for (auto& mediaElement : m_mediaElements)
+        mediaElement->returnToRealtime();
 }
 
 // The spec says to fire periodic timeupdate events (those sent while playing) every
index 723b53097b27b311648e239d6697773a01c5dd86..e64eba961d45e665d2374fcb5999b2049004cbab 100644 (file)
@@ -161,9 +161,7 @@ void MediaFragmentURIParser::parseTimeFragment()
 
     m_timeFormat = Invalid;
 
-    for (unsigned i = 0; i < m_fragments.size(); ++i) {
-        std::pair<String, String>& fragment = m_fragments[i];
-
+    for (auto& fragment : m_fragments) {
         ASSERT(fragment.first.is8Bit());
         ASSERT(fragment.second.is8Bit());
 
index cd3c462c64679e879b1d99f414767c6f12827218..417f97c36c6cbacc1de1e7780c54fb481902d456 100644 (file)
@@ -57,10 +57,10 @@ void PublicURLManager::registerURL(SecurityOrigin* origin, const URL& url, URLRe
 
 void PublicURLManager::revoke(const URL& url)
 {
-    for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
-        if (i->value.contains(url.string())) {
-            i->key->unregisterURL(url);
-            i->value.remove(url.string());
+    for (auto& registry : m_registryToURL) {
+        if (registry.value.contains(url.string())) {
+            registry.key->unregisterURL(url);
+            registry.value.remove(url.string());
             break;
         }
     }
@@ -72,9 +72,9 @@ void PublicURLManager::stop()
         return;
 
     m_isStopped = true;
-    for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
-        for (URLSet::iterator j = i->value.begin(); j != i->value.end(); ++j)
-            i->key->unregisterURL(URL(ParsedURLString, *j));
+    for (auto& registry : m_registryToURL) {
+        for (auto& url : registry.value)
+            registry.key->unregisterURL(URL(ParsedURLString, url));
     }
 
     m_registryToURL.clear();
index e327cf09b7f37d0fea1131d55f7f0f9c27fc8282..e5b0867d07c36b6844fadebf25560480942f1a77 100644 (file)
@@ -166,23 +166,24 @@ GC3Dsizeiptr WebGLBuffer::byteLength() const
 
 int WebGLBuffer::getCachedMaxIndex(GC3Denum type)
 {
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_maxIndexCache); ++i)
-        if (m_maxIndexCache[i].type == type)
-            return m_maxIndexCache[i].maxIndex;
+    for (auto& cache : m_maxIndexCache) {
+        if (cache.type == type)
+            return cache.maxIndex;
+    }
     return -1;
 }
 
 void WebGLBuffer::setCachedMaxIndex(GC3Denum type, int value)
 {
-    size_t numEntries = WTF_ARRAY_LENGTH(m_maxIndexCache);
-    for (size_t i = 0; i < numEntries; ++i)
-        if (m_maxIndexCache[i].type == type) {
-            m_maxIndexCache[i].maxIndex = value;
+    for (auto& cache : m_maxIndexCache) {
+        if (cache.type == type) {
+            cache.maxIndex = value;
             return;
         }
+    }
     m_maxIndexCache[m_nextAvailableCacheEntry].type = type;
     m_maxIndexCache[m_nextAvailableCacheEntry].maxIndex = value;
-    m_nextAvailableCacheEntry = (m_nextAvailableCacheEntry + 1) % numEntries;
+    m_nextAvailableCacheEntry = (m_nextAvailableCacheEntry + 1) % WTF_ARRAY_LENGTH(m_maxIndexCache);
 }
 
 void WebGLBuffer::setTarget(GC3Denum target)
index baa4b21c77168e4b1283572d24c06299326d00fb..2133f33efc8ce0987b49833cbc10fc75912a0822 100644 (file)
@@ -90,8 +90,8 @@ void WebGLContextGroup::detachAndRemoveAllObjects()
 
 void WebGLContextGroup::loseContextGroup(WebGLRenderingContextBase::LostContextMode mode)
 {
-    for (HashSet<WebGLRenderingContextBase*>::iterator it = m_contexts.begin(); it != m_contexts.end(); ++it)
-        (*it)->loseContextImpl(mode);
+    for (auto& context : m_contexts)
+        context->loseContextImpl(mode);
 
     detachAndRemoveAllObjects();
 }
index bceaebf2809fc16de6cfec80f653e1a6db36b8de..e8c209f58e03f835c095cc0ea6ab4063237667d1 100644 (file)
@@ -173,8 +173,8 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web
         context->deleteTexture(depth);
     if (supportsDepthStencil)
         context->deleteTexture(depthStencil);
-    for (size_t i = 0; i < colors.size(); ++i)
-        context->deleteTexture(colors[i]);
+    for (auto& color : colors)
+        context->deleteTexture(color);
     return ok;
 }
 
index 60399a373952d65d36b9f63b35d87be68c8cbc34..7317ed20f860a2f6bb64e63d5e28fa889d1371d6 100644 (file)
@@ -371,10 +371,10 @@ void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(WebGLSharedObject* a
     bool checkMore = true;
     do {
         checkMore = false;
-        for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
-            WebGLAttachment* attachmentObject = it->value.get();
+        for (auto& entry : m_attachments) {
+            WebGLAttachment* attachmentObject = entry.value.get();
             if (attachmentObject->isSharedObject(attachment)) {
-                GC3Denum attachmentType = it->key;
+                GC3Denum attachmentType = entry.key;
                 attachmentObject->unattach(context()->graphicsContext3D(), attachmentType);
                 removeAttachmentFromBoundFramebuffer(attachmentType);
                 checkMore = true;
@@ -423,9 +423,9 @@ GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const
     bool haveDepth = false;
     bool haveStencil = false;
     bool haveDepthStencil = false;
-    for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
-        WebGLAttachment* attachment = it->value.get();
-        if (!isAttachmentComplete(attachment, it->key, reason))
+    for (auto& entry : m_attachments) {
+        WebGLAttachment* attachment = entry.value.get();
+        if (!isAttachmentComplete(attachment, entry.key, reason))
             return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
         if (!attachment->isValid()) {
             *reason = "attachment is not valid";
@@ -441,7 +441,7 @@ GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const
             *reason = "attachment is an unsupported format";
             return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
         }
-        switch (it->key) {
+        switch (entry.key) {
         case GraphicsContext3D::DEPTH_ATTACHMENT:
             haveDepth = true;
             break;
@@ -498,8 +498,8 @@ bool WebGLFramebuffer::hasStencilBuffer() const
 
 void WebGLFramebuffer::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
 {
-    for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments.end(); ++it)
-        it->value->onDetached(context3d);
+    for (auto& attachment : m_attachments.values())
+        attachment->onDetached(context3d);
 
     context3d->deleteFramebuffer(object);
 }
@@ -509,9 +509,9 @@ bool WebGLFramebuffer::initializeAttachments(GraphicsContext3D* g3d, const char*
     ASSERT(object());
     GC3Dbitfield mask = 0;
 
-    for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
-        GC3Denum attachmentType = it->key;
-        WebGLAttachment* attachment = it->value.get();
+    for (auto& entry : m_attachments) {
+        GC3Denum attachmentType = entry.key;
+        WebGLAttachment* attachment = entry.value.get();
         if (!attachment->isInitialized())
            mask |= GraphicsContext3D::getClearBitsByAttachmentType(attachmentType);
     }
@@ -600,8 +600,8 @@ void WebGLFramebuffer::drawBuffers(const Vector<GC3Denum>& bufs)
 {
     m_drawBuffers = bufs;
     m_filteredDrawBuffers.resize(m_drawBuffers.size());
-    for (size_t i = 0; i < m_filteredDrawBuffers.size(); ++i)
-        m_filteredDrawBuffers[i] = GraphicsContext3D::NONE;
+    for (auto& buffer : m_filteredDrawBuffers)
+        buffer = GraphicsContext3D::NONE;
     drawBuffersIfNecessary(true);
 }
 
index 6dae8020134b7bf88145004fdb2bc20744fcc08d..a4aa7a7b39a82989ea318b4c0758c7b249db8b96 100644 (file)
@@ -594,9 +594,9 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase()
     m_framebufferBinding = nullptr;
     m_renderbufferBinding = nullptr;
 
-    for (size_t i = 0; i < m_textureUnits.size(); ++i) {
-        m_textureUnits[i].texture2DBinding = nullptr;
-        m_textureUnits[i].textureCubeMapBinding = nullptr;
+    for (auto& textureUnit : m_textureUnits) {
+        textureUnit.texture2DBinding = nullptr;
+        textureUnit.textureCubeMapBinding = nullptr;
     }
 
     m_blackTexture2D = nullptr;
@@ -1514,11 +1514,11 @@ void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture)
 {
     if (!deleteObject(texture))
         return;
-    for (size_t i = 0; i < m_textureUnits.size(); ++i) {
-        if (texture == m_textureUnits[i].texture2DBinding)
-            m_textureUnits[i].texture2DBinding = nullptr;
-        if (texture == m_textureUnits[i].textureCubeMapBinding)
-            m_textureUnits[i].textureCubeMapBinding = nullptr;
+    for (auto& textureUnit : m_textureUnits) {
+        if (texture == textureUnit.texture2DBinding)
+            textureUnit.texture2DBinding = nullptr;
+        if (texture == textureUnit.textureCubeMapBinding)
+            textureUnit.textureCubeMapBinding = nullptr;
     }
     if (m_framebufferBinding)
         m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture);
index 63356e033dbaa9334790536ea21d614025289cd1..6e815ef235de52b0db004f65860243c01094c569 100644 (file)
@@ -68,8 +68,7 @@ void WebGLVertexArrayObject::deleteObjectImpl(GraphicsContext3D* context3d, Plat
     if (m_boundElementArrayBuffer)
         m_boundElementArrayBuffer->onDetached(context3d);
     
-    for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
-        VertexAttribState& state = m_vertexAttribState[i];
+    for (auto& state : m_vertexAttribState) {
         if (state.bufferBinding)
             state.bufferBinding->onDetached(context3d);
     }
index 5be2e4c8963c151eb22a2fd62f94bb718524d978..d13595252594f302fc1d422b8b97d77b0fb02065 100644 (file)
@@ -71,8 +71,7 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P
     if (m_boundElementArrayBuffer)
         m_boundElementArrayBuffer->onDetached(context3d);
 
-    for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
-        VertexAttribState& state = m_vertexAttribState[i];
+    for (auto& state : m_vertexAttribState) {
         if (state.bufferBinding)
             state.bufferBinding->onDetached(context3d);
     }
index cc5a21555b0858ee36a202d9521c3aebff53af55..98ea0d818d4cd73bdf48d8f7810cebd41441eb19 100644 (file)
@@ -186,8 +186,7 @@ inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList
         return;
 
     m_attributes.reserveInitialCapacity(size);
-    for (unsigned i = 0; i < size; ++i) {
-        const HTMLToken::Attribute& attribute = attributes[i];
+    for (auto& attribute : attributes) {
         if (attribute.name.isEmpty())
             continue;
 
index af93abd8ba5651f46a571f2ee5221103f0dffbc4..420c0f157f621a281556c961c36075cdc9ff1d59 100644 (file)
@@ -274,8 +274,7 @@ void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken*
     if (token->attributes().isEmpty())
         return;
 
-    for (unsigned i = 0; i < token->attributes().size(); ++i) {
-        const Attribute& tokenAttribute = token->attributes().at(i);
+    for (auto& tokenAttribute : token->attributes()) {
         if (!element->elementData() || !element->findAttributeByName(tokenAttribute.name()))
             element->setAttribute(tokenAttribute.name(), tokenAttribute.value());
     }
index 44edf1c430ba144e7cec39b1e1b5e46088ded69b..7cc0bfbe46b3e4efb6ad7adeb3e9a3c3af7f593f 100644 (file)
@@ -170,13 +170,8 @@ void HTMLFormattingElementList::ensureNoahsArkCondition(HTMLStackItem* newItem)
     Vector<HTMLStackItem*> remainingCandidates;
     remainingCandidates.reserveInitialCapacity(candidates.size());
 
-    const Vector<Attribute>& attributes = newItem->attributes();
-    for (size_t i = 0; i < attributes.size(); ++i) {
-        const Attribute& attribute = attributes[i];
-
-        for (size_t j = 0; j < candidates.size(); ++j) {
-            HTMLStackItem* candidate = candidates[j];
-
+    for (auto& attribute : newItem->attributes()) {
+        for (auto& candidate : candidates) {
             // These properties should already have been checked by tryToEnsureNoahsArkConditionQuickly.
             ASSERT(newItem->attributes().size() == candidate->attributes().size());
             ASSERT(newItem->localName() == candidate->localName() && newItem->namespaceURI() == candidate->namespaceURI());
index d4aad1290ca53809af587aa7782ba39a9dc9ce85..d039fa2793752fce643efd79fb8d96089ef8716d 100644 (file)
@@ -103,9 +103,9 @@ public:
         if (m_tagId >= TagId::Unknown)
             return;
 
-        for (HTMLToken::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) {
-            AtomicString attributeName(iter->name);
-            String attributeValue = StringImpl::create8BitIfPossible(iter->value);
+        for (auto& attribute : attributes) {
+            AtomicString attributeName(attribute.name);
+            String attributeValue = StringImpl::create8BitIfPossible(attribute.value);
             processAttribute(attributeName, attributeValue);
         }
 
index 82c5edc4f980c338f0dbb9a6d6f3cc0c364a906e..d9ae12a90618bbdc96e4f39665f42028a309671d 100644 (file)
@@ -197,8 +197,8 @@ static bool semicolonSeparatedValueContainsJavaScriptURL(const String& value)
 {
     Vector<String> valueList;
     value.split(';', valueList);
-    for (size_t i = 0; i < valueList.size(); ++i) {
-        if (protocolIsJavaScript(valueList[i]))
+    for (auto& value : valueList) {
+        if (protocolIsJavaScript(value))
             return true;
     }
     return false;
index dcf5851285be0fc3aa60156ef1088f46df657382..6daedb8d4ee2d4a7a7f653452626f3d62b46cbe5 100644 (file)
@@ -78,13 +78,11 @@ void ContentDistributor::distribute(Element* host)
     m_validity = Valid;
 
     if (ShadowRoot* root = host->shadowRoot()) {
-        const Vector<RefPtr<InsertionPoint>>& insertionPoints = ensureInsertionPointList(root);
-        for (size_t i = 0; i < insertionPoints.size(); ++i) {
-            InsertionPoint* point = insertionPoints[i].get();
+        for (auto& point : ensureInsertionPointList(root)) {
             if (!point->isActive())
                 continue;
 
-            distributeSelectionsTo(point, host);
+            distributeSelectionsTo(point.get(), host);
         }
     }
 }
@@ -95,10 +93,9 @@ bool ContentDistributor::invalidate(Element* host)
     bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint.isEmpty();
 
     if (ShadowRoot* root = host->shadowRoot()) {
-        const Vector<RefPtr<InsertionPoint>>& insertionPoints = ensureInsertionPointList(root);
-        for (size_t i = 0; i < insertionPoints.size(); ++i) {
+        for (auto& point : ensureInsertionPointList(root)) {
             needsReattach = true;
-            insertionPoints[i]->clearDistribution();
+            point->clearDistribution();
         }
     }
 
index be967d7aa00bce122d697d6436092415da4060a1..265bbd7ddcff598ccc96d90414d25e9576032f0a 100644 (file)
@@ -743,9 +743,7 @@ void MediaControlClosedCaptionsTrackListElement::updateDisplay()
     RefPtr<Element> offMenuItem;
     bool trackMenuItemSelected = false;
 
-    for (unsigned i = 0, length = m_menuItems.size(); i < length; ++i) {
-        RefPtr<Element> trackItem = m_menuItems[i];
-
+    for (auto& trackItem : m_menuItems) {
         RefPtr<TextTrack> textTrack;
         MenuItemToTrackMap::iterator iter = m_menuToTrackMap.find(trackItem.get());
         if (iter == m_menuToTrackMap.end())
@@ -812,8 +810,7 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
     appendChild(WTF::move(captionsHeader));
     Ref<Element> captionsMenuList = document().createElement(ulTag, ASSERT_NO_EXCEPTION);
 
-    for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) {
-        RefPtr<TextTrack> textTrack = tracksForMenu[i];
+    for (auto& textTrack : tracksForMenu) {
         Ref<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
         menuItem->appendChild(document().createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
         captionsMenuList->appendChild(menuItem.copyRef());
@@ -1224,10 +1221,9 @@ void MediaControlTextTrackContainerElement::updateActiveCuesFontSize()
     float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
     float fontScale = document().page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
     m_fontSize = lroundf(smallestDimension * fontScale);
-    
-    CueList activeCues = mediaElement->currentlyActiveCues();
-    for (size_t i = 0; i < activeCues.size(); ++i) {
-        TextTrackCue* cue = activeCues[i].data();
+
+    for (auto& activeCue : mediaElement->currentlyActiveCues()) {
+        TextTrackCue* cue = activeCue.data();
         if (!cue->isRenderable())
             continue;
 
index 5edad8eaa0a69f90052fb0c6273404e59d1ab4be..6aaa32efe5177a17a6a9e6ad74317534ed4bb18c 100644 (file)
@@ -74,8 +74,8 @@ AudioTrack* AudioTrackList::item(unsigned index) const
 
 AudioTrack* AudioTrackList::getTrackById(const AtomicString& id) const
 {
-    for (size_t i = 0; i < m_inbandTracks.size(); ++i) {
-        AudioTrack* track = toAudioTrack(m_inbandTracks[i].get());
+    for (auto& inbandTrack : m_inbandTracks) {
+        AudioTrack* track = toAudioTrack(inbandTrack.get());
         if (track->id() == id)
             return track;
     }
index 845547a95360c286c4c895c76ccd3864dd3097e3..bd5f0379f045842f24633ccc5b1c3d34e7a44695 100644 (file)
@@ -110,9 +110,9 @@ void LoadableTextTrack::newCuesAvailable(TextTrackLoader* loader)
     if (!m_cues)
         m_cues = TextTrackCueList::create();    
 
-    for (size_t i = 0; i < newCues.size(); ++i) {
-        newCues[i]->setTrack(this);
-        m_cues->add(newCues[i]);
+    for (auto& newCue : newCues) {
+        newCue->setTrack(this);
+        m_cues->add(newCue);
     }
 
     if (client())
@@ -136,9 +136,9 @@ void LoadableTextTrack::newRegionsAvailable(TextTrackLoader* loader)
     Vector<RefPtr<VTTRegion>> newRegions;
     m_loader->getNewRegions(newRegions);
 
-    for (size_t i = 0; i < newRegions.size(); ++i) {
-        newRegions[i]->setTrack(this);
-        regions()->add(newRegions[i]);
+    for (auto& newRegion : newRegions) {
+        newRegion->setTrack(this);
+        regions()->add(newRegion);
     }
 }
 
index e8566c2597ef889a0fbb27e9e234f9223609c65c..6b39299dd390a4b7c6d4fb13e076290f2b81d64a 100644 (file)
@@ -54,9 +54,9 @@ TextTrackCue* TextTrackCueList::item(unsigned index) const
 
 TextTrackCue* TextTrackCueList::getCueById(const String& id) const
 {
-    for (size_t i = 0; i < m_list.size(); ++i) {
-        if (m_list[i]->id() == id)
-            return m_list[i].get();
+    for (auto& cue : m_list) {
+        if (cue->id() == id)
+            return cue.get();
     }
     return 0;
 }
@@ -67,8 +67,7 @@ TextTrackCueList* TextTrackCueList::activeCues()
         m_activeCues = create();
 
     m_activeCues->clear();
-    for (size_t i = 0; i < m_list.size(); ++i) {
-        RefPtr<TextTrackCue> cue = m_list[i];
+    for (auto& cue : m_list) {
         if (cue->isActive())
             m_activeCues->add(cue);
     }
index 159fb3ddf5dca4b4acc17b93410240ff2208b673..fdbbc49e0f58674e4972818b5a663c7b9221ea5c 100644 (file)
@@ -72,29 +72,29 @@ int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack)
     // Calculate the "Let n be the number of text tracks whose text track mode is showing and that are in the media element's list of text tracks before track."
     int trackIndex = 0;
 
-    for (size_t i = 0; i < m_elementTracks.size(); ++i) {
-        if (!toTextTrack(m_elementTracks[i].get())->isRendered())
+    for (auto& elementTrack : m_elementTracks) {
+        if (!toTextTrack(elementTrack.get())->isRendered())
             continue;
 
-        if (m_elementTracks[i] == textTrack)
+        if (elementTrack == textTrack)
             return trackIndex;
         ++trackIndex;
     }
 
-    for (size_t i = 0; i < m_addTrackTracks.size(); ++i) {
-        if (!toTextTrack(m_addTrackTracks[i].get())->isRendered())
+    for (auto& addTrack : m_addTrackTracks) {
+        if (!toTextTrack(addTrack.get())->isRendered())
             continue;
 
-        if (m_addTrackTracks[i] == textTrack)
+        if (addTrack == textTrack)
             return trackIndex;
         ++trackIndex;
     }
 
-    for (size_t i = 0; i < m_inbandTracks.size(); ++i) {
-        if (!toTextTrack(m_inbandTracks[i].get())->isRendered())
+    for (auto& inbandTrack : m_inbandTracks) {
+        if (!toTextTrack(inbandTrack.get())->isRendered())
             continue;
 
-        if (m_inbandTracks[i] == textTrack)
+        if (inbandTrack == textTrack)
             return trackIndex;
         ++trackIndex;
     }
@@ -149,14 +149,14 @@ void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track)
 
     if (track->trackType() == TextTrack::TrackElement) {
         tracks = &m_elementTracks;
-        for (size_t i = 0; i < m_addTrackTracks.size(); ++i)
-            toTextTrack(m_addTrackTracks[i].get())->invalidateTrackIndex();
-        for (size_t i = 0; i < m_inbandTracks.size(); ++i)
-            toTextTrack(m_inbandTracks[i].get())->invalidateTrackIndex();
+        for (auto& addTrack : m_addTrackTracks)
+            toTextTrack(addTrack.get())->invalidateTrackIndex();
+        for (auto& inbandTrack : m_inbandTracks)
+            toTextTrack(inbandTrack.get())->invalidateTrackIndex();
     } else if (track->trackType() == TextTrack::AddTrack) {
         tracks = &m_addTrackTracks;
-        for (size_t i = 0; i < m_inbandTracks.size(); ++i)
-            toTextTrack(m_inbandTracks[i].get())->invalidateTrackIndex();
+        for (auto& inbandTrack : m_inbandTracks)
+            toTextTrack(inbandTrack.get())->invalidateTrackIndex();
     } else if (track->trackType() == TextTrack::InBand)
         tracks = &m_inbandTracks;
     else
index 4d915a716d93f08c731c91308326fd1cc612fe98..b0c04d9eb2019503706fb8dbdd51ad8b82f89f76 100644 (file)
@@ -159,8 +159,7 @@ void TrackListBase::scheduleChangeEvent()
 
 bool TrackListBase::isAnyTrackEnabled() const
 {
-    for (size_t i = 0; i < m_inbandTracks.size(); ++i) {
-        TrackBase* track = m_inbandTracks[i].get();
+    for (auto& track : m_inbandTracks) {
         if (track->enabled())
             return true;
     }
index 2cd545369d5448ec7bed5f8b5ee47d88662963a1..426b2a025ae173d066dd316af019a2b37150ed8c 100644 (file)
@@ -73,8 +73,8 @@ VideoTrack* VideoTrackList::item(unsigned index) const
 
 VideoTrack* VideoTrackList::getTrackById(const AtomicString& id) const
 {
-    for (size_t i = 0; i < length(); ++i) {
-        VideoTrack* track = toVideoTrack(m_inbandTracks[i].get());
+    for (auto& inbandTracks : m_inbandTracks) {
+        VideoTrack* track = toVideoTrack(inbandTracks.get());
         if (track->id() == id)
             return track;
     }