Use modern for-loops in WebCore/page.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jun 2015 20:52:42 +0000 (20:52 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jun 2015 20:52:42 +0000 (20:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145455

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

No new tests, no behavior changes.

* page/Chrome.cpp:
(WebCore::Chrome::notifyPopupOpeningObservers):
* page/ContentSecurityPolicy.cpp:
(WebCore::CSPSourceList::matches):
(WebCore::CSPDirectiveList::gatherReportURIs):
(WebCore::ContentSecurityPolicy::copyStateFrom):
(WebCore::isAllowedByAll):
(WebCore::isAllowedByAllWithState):
(WebCore::isAllowedByAllWithContext):
(WebCore::isAllowedByAllWithURL):
(WebCore::ContentSecurityPolicy::evalDisabledErrorMessage):
(WebCore::ContentSecurityPolicy::allowPluginType):
(WebCore::ContentSecurityPolicy::reflectedXSSDisposition):
(WebCore::ContentSecurityPolicy::gatherReportURIs):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchAllPendingBeforeUnloadEvents):
(WebCore::DOMWindow::dispatchAllPendingUnloadEvents):
(WebCore::DOMWindow::willDestroyCachedFrame):
(WebCore::DOMWindow::willDestroyDocumentInFrame):
(WebCore::DOMWindow::willDetachDocumentFromFrame):
(WebCore::DOMWindow::disconnectDOMWindowProperties):
(WebCore::DOMWindow::reconnectDOMWindowProperties):
(WebCore::DOMWindow::getMatchedCSSRules):
* page/DeviceController.cpp:
(WebCore::DeviceController::dispatchDeviceEvent):
(WebCore::DeviceController::fireDeviceEvent):
* page/EventHandler.cpp:
(WebCore::EventHandler::updateMouseEventTargetNode):
(WebCore::EventHandler::handleTouchEvent):
* page/FocusController.cpp:
(WebCore::FocusController::setIsVisibleAndActiveInternal):
* page/Frame.cpp:
(WebCore::Frame::orientationChanged):
(WebCore::Frame::injectUserScriptsForWorld):
* page/FrameView.cpp:
(WebCore::FrameView::scrollContentsFastPath):
(WebCore::FrameView::serviceScriptedAnimations):
(WebCore::FrameView::trackedRepaintRectsAsText):
(WebCore::FrameView::updateWidgetPositions):
(WebCore::FrameView::notifyWidgets):
* page/Page.cpp:
(WebCore::networkStateChanged):
(WebCore::Page::stringToViewMode):
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment):
(WebCore::Page::refreshPlugins):
(WebCore::Page::lockAllOverlayScrollbarsToHidden):
(WebCore::Page::pluginViews):
(WebCore::Page::storageBlockingStateChanged):
(WebCore::Page::setIsVisibleInternal):
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferencesChanged):
* page/PageGroupLoadDeferrer.cpp:
(WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
(WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeFrame):
* page/Performance.cpp:
(WebCore::Performance::webkitGetEntriesByType):
(WebCore::Performance::webkitGetEntriesByName):
* page/PerformanceResourceTiming.cpp:
(WebCore::passesTimingAllowCheck):
* page/PerformanceUserTiming.cpp:
(WebCore::convertToEntrySequence):
* page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::isAccessWhiteListed):
* page/UserContentURLPattern.cpp:
(WebCore::UserContentURLPattern::matchesPatterns):
* page/WindowFeatures.cpp:
(WebCore::WindowFeatures::parseDialogFeatures):
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::updateAnimations):
(WebCore::AnimationControllerPrivate::fireEventsAndUpdateStyle):
(WebCore::AnimationControllerPrivate::suspendAnimationsForDocument):
(WebCore::AnimationControllerPrivate::resumeAnimationsForDocument):
(WebCore::AnimationControllerPrivate::numberOfActiveAnimations):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::ShorthandPropertyWrapper::equals):
(WebCore::ShorthandPropertyWrapper::blend):
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::setStateScrollingNodeSnapOffsetsAsFloat):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::absoluteNonFastScrollableRegionForFrame):
(WebCore::ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects):

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

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/ContentSecurityPolicy.cpp
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DeviceController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/PageGroupLoadDeferrer.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/page/Performance.cpp
Source/WebCore/page/PerformanceResourceTiming.cpp
Source/WebCore/page/PerformanceUserTiming.cpp
Source/WebCore/page/SecurityPolicy.cpp
Source/WebCore/page/UserContentURLPattern.cpp
Source/WebCore/page/WindowFeatures.cpp
Source/WebCore/page/animation/AnimationController.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

index c5fc1b6..e031849 100644 (file)
@@ -1,3 +1,98 @@
+2015-06-03  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        Use modern for-loops in WebCore/page.
+        https://bugs.webkit.org/show_bug.cgi?id=145455
+
+        Reviewed by Darin Adler.
+
+        No new tests, no behavior changes.
+
+        * page/Chrome.cpp:
+        (WebCore::Chrome::notifyPopupOpeningObservers):
+        * page/ContentSecurityPolicy.cpp:
+        (WebCore::CSPSourceList::matches):
+        (WebCore::CSPDirectiveList::gatherReportURIs):
+        (WebCore::ContentSecurityPolicy::copyStateFrom):
+        (WebCore::isAllowedByAll):
+        (WebCore::isAllowedByAllWithState):
+        (WebCore::isAllowedByAllWithContext):
+        (WebCore::isAllowedByAllWithURL):
+        (WebCore::ContentSecurityPolicy::evalDisabledErrorMessage):
+        (WebCore::ContentSecurityPolicy::allowPluginType):
+        (WebCore::ContentSecurityPolicy::reflectedXSSDisposition):
+        (WebCore::ContentSecurityPolicy::gatherReportURIs):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::populate):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::dispatchAllPendingBeforeUnloadEvents):
+        (WebCore::DOMWindow::dispatchAllPendingUnloadEvents):
+        (WebCore::DOMWindow::willDestroyCachedFrame):
+        (WebCore::DOMWindow::willDestroyDocumentInFrame):
+        (WebCore::DOMWindow::willDetachDocumentFromFrame):
+        (WebCore::DOMWindow::disconnectDOMWindowProperties):
+        (WebCore::DOMWindow::reconnectDOMWindowProperties):
+        (WebCore::DOMWindow::getMatchedCSSRules):
+        * page/DeviceController.cpp:
+        (WebCore::DeviceController::dispatchDeviceEvent):
+        (WebCore::DeviceController::fireDeviceEvent):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateMouseEventTargetNode):
+        (WebCore::EventHandler::handleTouchEvent):
+        * page/FocusController.cpp:
+        (WebCore::FocusController::setIsVisibleAndActiveInternal):
+        * page/Frame.cpp:
+        (WebCore::Frame::orientationChanged):
+        (WebCore::Frame::injectUserScriptsForWorld):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollContentsFastPath):
+        (WebCore::FrameView::serviceScriptedAnimations):
+        (WebCore::FrameView::trackedRepaintRectsAsText):
+        (WebCore::FrameView::updateWidgetPositions):
+        (WebCore::FrameView::notifyWidgets):
+        * page/Page.cpp:
+        (WebCore::networkStateChanged):
+        (WebCore::Page::stringToViewMode):
+        (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment):
+        (WebCore::Page::refreshPlugins):
+        (WebCore::Page::lockAllOverlayScrollbarsToHidden):
+        (WebCore::Page::pluginViews):
+        (WebCore::Page::storageBlockingStateChanged):
+        (WebCore::Page::setIsVisibleInternal):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::captionPreferencesChanged):
+        * page/PageGroupLoadDeferrer.cpp:
+        (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
+        (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeFrame):
+        * page/Performance.cpp:
+        (WebCore::Performance::webkitGetEntriesByType):
+        (WebCore::Performance::webkitGetEntriesByName):
+        * page/PerformanceResourceTiming.cpp:
+        (WebCore::passesTimingAllowCheck):
+        * page/PerformanceUserTiming.cpp:
+        (WebCore::convertToEntrySequence):
+        * page/SecurityPolicy.cpp:
+        (WebCore::SecurityPolicy::isAccessWhiteListed):
+        * page/UserContentURLPattern.cpp:
+        (WebCore::UserContentURLPattern::matchesPatterns):
+        * page/WindowFeatures.cpp:
+        (WebCore::WindowFeatures::parseDialogFeatures):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::updateAnimations):
+        (WebCore::AnimationControllerPrivate::fireEventsAndUpdateStyle):
+        (WebCore::AnimationControllerPrivate::suspendAnimationsForDocument):
+        (WebCore::AnimationControllerPrivate::resumeAnimationsForDocument):
+        (WebCore::AnimationControllerPrivate::numberOfActiveAnimations):
+        * page/animation/CSSPropertyAnimation.cpp:
+        (WebCore::ShorthandPropertyWrapper::equals):
+        (WebCore::ShorthandPropertyWrapper::blend):
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::setStateScrollingNodeSnapOffsetsAsFloat):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::absoluteNonFastScrollableRegionForFrame):
+        (WebCore::ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects):
+
 2015-06-03  Daniel Bates  <dabates@apple.com>
 
         AutoFill button should not be shown in read-only or disabled field
index be285fd..5b58961 100644 (file)
@@ -635,8 +635,8 @@ void Chrome::unregisterPopupOpeningObserver(PopupOpeningObserver* observer)
 void Chrome::notifyPopupOpeningObservers() const
 {
     const Vector<PopupOpeningObserver*> observers(m_popupOpeningObservers);
-    for (size_t i = 0; i < observers.size(); ++i)
-        observers[i]->willOpenPopup();
+    for (auto& observer : observers)
+        observer->willOpenPopup();
 }
 
 void Chrome::didBeginTrackingPotentialLongMousePress(const IntPoint& mouseDownPosition, const HitTestResult& hitTestResult)
index dc9072a..f1ed9ad 100644 (file)
@@ -343,8 +343,8 @@ bool CSPSourceList::matches(const URL& url)
 
     URL effectiveURL = SecurityOrigin::shouldUseInnerURL(url) ? SecurityOrigin::extractInnerURL(url) : url;
 
-    for (size_t i = 0; i < m_list.size(); ++i) {
-        if (m_list[i].matches(effectiveURL))
+    for (auto& entry : m_list) {
+        if (entry.matches(effectiveURL))
             return true;
     }
 
@@ -1100,8 +1100,8 @@ bool CSPDirectiveList::allowConnectToSource(const URL& url, ContentSecurityPolic
 
 void CSPDirectiveList::gatherReportURIs(DOMStringList& list) const
 {
-    for (size_t i = 0; i < m_reportURIs.size(); ++i)
-        list.append(m_reportURIs[i].string());
+    for (auto& uri : m_reportURIs)
+        list.append(uri.string());
 }
 
 bool CSPDirectiveList::allowFormAction(const URL& url, ContentSecurityPolicy::ReportingStatus reportingStatus) const
@@ -1352,8 +1352,8 @@ ContentSecurityPolicy::~ContentSecurityPolicy()
 void ContentSecurityPolicy::copyStateFrom(const ContentSecurityPolicy* other) 
 {
     ASSERT(m_policies.isEmpty());
-    for (CSPDirectiveListVector::const_iterator iter = other->m_policies.begin(); iter != other->m_policies.end(); ++iter)
-        didReceiveHeader((*iter)->header(), (*iter)->headerType());
+    for (auto& policy : other->m_policies)
+        didReceiveHeader(policy->header(), policy->headerType());
 }
 
 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType type)
@@ -1401,8 +1401,8 @@ ContentSecurityPolicy::HeaderType ContentSecurityPolicy::deprecatedHeaderType()
 template<bool (CSPDirectiveList::*allowed)(ContentSecurityPolicy::ReportingStatus) const>
 bool isAllowedByAll(const CSPDirectiveListVector& policies, ContentSecurityPolicy::ReportingStatus reportingStatus)
 {
-    for (size_t i = 0; i < policies.size(); ++i) {
-        if (!(policies[i].get()->*allowed)(reportingStatus))
+    for (auto& policy : policies) {
+        if (!(policy.get()->*allowed)(reportingStatus))
             return false;
     }
     return true;
@@ -1411,8 +1411,8 @@ bool isAllowedByAll(const CSPDirectiveListVector& policies, ContentSecurityPolic
 template<bool (CSPDirectiveList::*allowed)(JSC::ExecState* state, ContentSecurityPolicy::ReportingStatus) const>
 bool isAllowedByAllWithState(const CSPDirectiveListVector& policies, JSC::ExecState* state, ContentSecurityPolicy::ReportingStatus reportingStatus)
 {
-    for (size_t i = 0; i < policies.size(); ++i) {
-        if (!(policies[i].get()->*allowed)(state, reportingStatus))
+    for (auto& policy : policies) {
+        if (!(policy.get()->*allowed)(state, reportingStatus))
             return false;
     }
     return true;
@@ -1421,8 +1421,8 @@ bool isAllowedByAllWithState(const CSPDirectiveListVector& policies, JSC::ExecSt
 template<bool (CSPDirectiveList::*allowed)(const String&, const WTF::OrdinalNumber&, ContentSecurityPolicy::ReportingStatus) const>
 bool isAllowedByAllWithContext(const CSPDirectiveListVector& policies, const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus)
 {
-    for (size_t i = 0; i < policies.size(); ++i) {
-        if (!(policies[i].get()->*allowed)(contextURL, contextLine, reportingStatus))
+    for (auto& policy : policies) {
+        if (!(policy.get()->*allowed)(contextURL, contextLine, reportingStatus))
             return false;
     }
     return true;
@@ -1434,8 +1434,8 @@ bool isAllowedByAllWithURL(const CSPDirectiveListVector& policies, const URL& ur
     if (SchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol()))
         return true;
 
-    for (size_t i = 0; i < policies.size(); ++i) {
-        if (!(policies[i].get()->*allowFromURL)(url, reportingStatus))
+    for (auto& policy : policies) {
+        if (!(policy.get()->*allowFromURL)(url, reportingStatus))
             return false;
     }
     return true;
@@ -1470,17 +1470,17 @@ bool ContentSecurityPolicy::allowEval(JSC::ExecState* state, ContentSecurityPoli
 
 String ContentSecurityPolicy::evalDisabledErrorMessage() const
 {
-    for (size_t i = 0; i < m_policies.size(); ++i) {
-        if (!m_policies[i]->allowEval(0, SuppressReport))
-            return m_policies[i]->evalDisabledErrorMessage();
+    for (auto& policy : m_policies) {
+        if (!policy->allowEval(0, SuppressReport))
+            return policy->evalDisabledErrorMessage();
     }
     return String();
 }
 
 bool ContentSecurityPolicy::allowPluginType(const String& type, const String& typeAttribute, const URL& url, ContentSecurityPolicy::ReportingStatus reportingStatus) const
 {
-    for (size_t i = 0; i < m_policies.size(); ++i) {
-        if (!m_policies[i]->allowPluginType(type, typeAttribute, url, reportingStatus))
+    for (auto& policy : m_policies) {
+        if (!policy->allowPluginType(type, typeAttribute, url, reportingStatus))
             return false;
     }
     return true;
@@ -1544,17 +1544,17 @@ bool ContentSecurityPolicy::isActive() const
 ContentSecurityPolicy::ReflectedXSSDisposition ContentSecurityPolicy::reflectedXSSDisposition() const
 {
     ReflectedXSSDisposition disposition = ReflectedXSSUnset;
-    for (size_t i = 0; i < m_policies.size(); ++i) {
-        if (m_policies[i]->reflectedXSSDisposition() > disposition)
-            disposition = std::max(disposition, m_policies[i]->reflectedXSSDisposition());
+    for (auto& policy : m_policies) {
+        if (policy->reflectedXSSDisposition() > disposition)
+            disposition = std::max(disposition, policy->reflectedXSSDisposition());
     }
     return disposition;
 }
 
 void ContentSecurityPolicy::gatherReportURIs(DOMStringList& list) const
 {
-    for (size_t i = 0; i < m_policies.size(); ++i)
-        m_policies[i]->gatherReportURIs(list);
+    for (auto& policy : m_policies)
+        policy->gatherReportURIs(list);
 }
 
 SecurityOrigin* ContentSecurityPolicy::securityOrigin() const
index d24fb31..e29c4f6 100644 (file)
@@ -959,8 +959,7 @@ void ContextMenuController::populate()
                 bool badGrammar;
                 Vector<String> guesses = frame->editor().guessesForMisspelledOrUngrammatical(misspelling, badGrammar);
                 if (misspelling || badGrammar) {
-                    size_t size = guesses.size();
-                    if (!size) {
+                    if (guesses.isEmpty()) {
                         // If there's bad grammar but no suggestions (e.g., repeated word), just leave off the suggestions
                         // list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit)
                         if (misspelling) {
@@ -968,8 +967,7 @@ void ContextMenuController::populate()
                             appendItem(*separatorItem(), m_contextMenu.get());
                         }
                     } else {
-                        for (unsigned i = 0; i < size; i++) {
-                            const String &guess = guesses[i];
+                        for (const auto& guess : guesses) {
                             if (!guess.isEmpty()) {
                                 ContextMenuItem item(ActionType, ContextMenuItemTagSpellingGuess, guess);
                                 appendItem(item, m_contextMenu.get());
@@ -1002,8 +1000,8 @@ void ContextMenuController::populate()
                 // Spelling and grammar checking is mutually exclusive with dictation alternatives.
                 Vector<String> dictationAlternatives = m_context.hitTestResult().dictationAlternatives();
                 if (!dictationAlternatives.isEmpty()) {
-                    for (size_t i = 0; i < dictationAlternatives.size(); ++i) {
-                        ContextMenuItem item(ActionType, ContextMenuItemTagDictationAlternative, dictationAlternatives[i]);
+                    for (auto& alternative : dictationAlternatives) {
+                        ContextMenuItem item(ActionType, ContextMenuItemTagDictationAlternative, alternative);
                         appendItem(item, m_contextMenu.get());
                     }
                     appendItem(*separatorItem(), m_contextMenu.get());
index 19d168b..0bab73b 100644 (file)
@@ -256,22 +256,21 @@ bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
 
     Vector<Ref<DOMWindow>> windows;
     windows.reserveInitialCapacity(set.size());
-    for (auto it = set.begin(), end = set.end(); it != end; ++it)
-        windows.uncheckedAppend(*it->key);
+    for (auto& window : set)
+        windows.uncheckedAppend(*window.key);
 
-    for (Ref<DOMWindow>& windowRef : windows) {
-        DOMWindow& window = windowRef;
-        if (!set.contains(&window))
+    for (auto& window : windows) {
+        if (!set.contains(window.ptr()))
             continue;
 
-        Frame* frame = window.frame();
+        Frame* frame = window->frame();
         if (!frame)
             continue;
 
         if (!frame->loader().shouldClose())
             return false;
 
-        window.enableSuddenTermination();
+        window->enableSuddenTermination();
     }
 
     alreadyDispatched = true;
@@ -299,15 +298,14 @@ void DOMWindow::dispatchAllPendingUnloadEvents()
     for (auto& keyValue : set)
         windows.uncheckedAppend(*keyValue.key);
 
-    for (Ref<DOMWindow>& windowRef : windows) {
-        DOMWindow& window = windowRef;
-        if (!set.contains(&window))
+    for (auto& window : windows) {
+        if (!set.contains(window.ptr()))
             continue;
 
-        window.dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window.document());
-        window.dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window.document());
+        window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
+        window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
 
-        window.enableSuddenTermination();
+        window->enableSuddenTermination();
     }
 
     alreadyDispatched = true;
@@ -495,8 +493,8 @@ void DOMWindow::willDestroyCachedFrame()
     // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInCachedFrame.
     Vector<DOMWindowProperty*> properties;
     copyToVector(m_properties, properties);
-    for (size_t i = 0; i < properties.size(); ++i)
-        properties[i]->willDestroyGlobalObjectInCachedFrame();
+    for (auto& property : properties)
+        property->willDestroyGlobalObjectInCachedFrame();
 }
 
 void DOMWindow::willDestroyDocumentInFrame()
@@ -505,8 +503,8 @@ void DOMWindow::willDestroyDocumentInFrame()
     // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInFrame.
     Vector<DOMWindowProperty*> properties;
     copyToVector(m_properties, properties);
-    for (size_t i = 0; i < properties.size(); ++i)
-        properties[i]->willDestroyGlobalObjectInFrame();
+    for (auto& property : properties)
+        property->willDestroyGlobalObjectInFrame();
 }
 
 void DOMWindow::willDetachDocumentFromFrame()
@@ -515,8 +513,8 @@ void DOMWindow::willDetachDocumentFromFrame()
     // unregister themselves from the DOMWindow as a result of the call to willDetachGlobalObjectFromFrame.
     Vector<DOMWindowProperty*> properties;
     copyToVector(m_properties, properties);
-    for (size_t i = 0; i < properties.size(); ++i)
-        properties[i]->willDetachGlobalObjectFromFrame();
+    for (auto& property : properties)
+        property->willDetachGlobalObjectFromFrame();
 }
 
 #if ENABLE(GAMEPAD)
@@ -571,8 +569,8 @@ void DOMWindow::disconnectDOMWindowProperties()
     // unregister themselves from the DOMWindow as a result of the call to disconnectFrameForPageCache.
     Vector<DOMWindowProperty*> properties;
     copyToVector(m_properties, properties);
-    for (size_t i = 0; i < properties.size(); ++i)
-        properties[i]->disconnectFrameForPageCache();
+    for (auto& property : properties)
+        property->disconnectFrameForPageCache();
 }
 
 void DOMWindow::reconnectDOMWindowProperties()
@@ -582,8 +580,8 @@ void DOMWindow::reconnectDOMWindowProperties()
     // unregister themselves from the DOMWindow as a result of the call to reconnectFromPageCache.
     Vector<DOMWindowProperty*> properties;
     copyToVector(m_properties, properties);
-    for (size_t i = 0; i < properties.size(); ++i)
-        properties[i]->reconnectFrameFromPageCache(m_frame);
+    for (auto& property : properties)
+        property->reconnectFrameFromPageCache(m_frame);
 }
 
 void DOMWindow::resetDOMWindowProperties()
@@ -1453,8 +1451,8 @@ PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const St
         return 0;
 
     RefPtr<StaticCSSRuleList> ruleList = StaticCSSRuleList::create();
-    for (unsigned i = 0; i < matchedRules.size(); ++i)
-        ruleList->rules().append(matchedRules[i]->createCSSOMWrapper());
+    for (auto& rule : matchedRules)
+        ruleList->rules().append(rule->createCSSOMWrapper());
 
     return ruleList.release();
 }
index bd5ba19..925754e 100644 (file)
@@ -76,11 +76,10 @@ void DeviceController::dispatchDeviceEvent(PassRefPtr<Event> prpEvent)
     RefPtr<Event> event = prpEvent;
     Vector<RefPtr<DOMWindow>> listenerVector;
     copyToVector(m_listeners, listenerVector);
-    for (size_t i = 0; i < listenerVector.size(); ++i) {
-        if (listenerVector[i]->document()
-            && !listenerVector[i]->document()->activeDOMObjectsAreSuspended()
-            && !listenerVector[i]->document()->activeDOMObjectsAreStopped())
-        listenerVector[i]->dispatchEvent(event);
+    for (auto& listener : listenerVector) {
+        auto document = listener->document();
+        if (document && !document->activeDOMObjectsAreSuspended() && !document->activeDOMObjectsAreStopped())
+            listener->dispatchEvent(event);
     }
 }
 
@@ -92,11 +91,10 @@ void DeviceController::fireDeviceEvent()
     Vector<RefPtr<DOMWindow>> listenerVector;
     copyToVector(m_lastEventListeners, listenerVector);
     m_lastEventListeners.clear();
-    for (size_t i = 0; i < listenerVector.size(); ++i) {
-        if (listenerVector[i]->document()
-            && !listenerVector[i]->document()->activeDOMObjectsAreSuspended()
-            && !listenerVector[i]->document()->activeDOMObjectsAreStopped())
-        listenerVector[i]->dispatchEvent(getLastEvent());
+    for (auto& listener : listenerVector) {
+        auto document = listener->document();
+        if (document && !document->activeDOMObjectsAreSuspended() && !document->activeDOMObjectsAreStopped())
+            listener->dispatchEvent(getLastEvent());
     }
 }
 
index dba2df6..95c4362 100644 (file)
@@ -2555,9 +2555,9 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
                 m_lastElementUnderMouse->dispatchMouseEvent(platformMouseEvent, eventNames().mouseoutEvent, 0, m_elementUnderMouse.get());
 
             // Send mouseleave to the node hierarchy no longer under the mouse.
-            for (size_t i = 0; i < leftElementsChain.size(); ++i) {
-                if (hasCapturingMouseLeaveListener || leftElementsChain[i]->hasEventListeners(eventNames().mouseleaveEvent))
-                    leftElementsChain[i]->dispatchMouseEvent(platformMouseEvent, eventNames().mouseleaveEvent, 0, m_elementUnderMouse.get());
+            for (auto& chain : leftElementsChain) {
+                if (hasCapturingMouseLeaveListener || chain->hasEventListeners(eventNames().mouseleaveEvent))
+                    chain->dispatchMouseEvent(platformMouseEvent, eventNames().mouseleaveEvent, 0, m_elementUnderMouse.get());
             }
 
             // Send mouseover event to the new node.
@@ -2565,9 +2565,9 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
                 m_elementUnderMouse->dispatchMouseEvent(platformMouseEvent, eventNames().mouseoverEvent, 0, m_lastElementUnderMouse.get());
 
             // Send mouseleave event to the nodes hierarchy under the mouse.
-            for (size_t i = 0, size = enteredElementsChain.size(); i < size; ++i) {
-                if (hasCapturingMouseEnterListener || enteredElementsChain[i]->hasEventListeners(eventNames().mouseenterEvent))
-                    enteredElementsChain[i]->dispatchMouseEvent(platformMouseEvent, eventNames().mouseenterEvent, 0, m_lastElementUnderMouse.get());
+            for (auto& chain : enteredElementsChain) {
+                if (hasCapturingMouseEnterListener || chain->hasEventListeners(eventNames().mouseenterEvent))
+                    chain->dispatchMouseEvent(platformMouseEvent, eventNames().mouseenterEvent, 0, m_lastElementUnderMouse.get());
             }
         }
         m_lastElementUnderMouse = m_elementUnderMouse;
@@ -3859,19 +3859,16 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
 
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture, m_frame.document());
 
-    unsigned i;
     bool freshTouchEvents = true;
     bool allTouchReleased = true;
-    for (i = 0; i < points.size(); ++i) {
-        const PlatformTouchPoint& point = points[i];
+    for (auto& point : points) {
         if (point.state() != PlatformTouchPoint::TouchPressed)
             freshTouchEvents = false;
         if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled)
             allTouchReleased = false;
     }
 
-    for (i = 0; i < points.size(); ++i) {
-        const PlatformTouchPoint& point = points[i];
+    for (auto& point : points) {
         PlatformTouchPoint::State pointState = point.state();
         LayoutPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos());
 
@@ -4015,10 +4012,9 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
         bool isTouchCancelEvent = (state == PlatformTouchPoint::TouchCancelled);
         RefPtr<TouchList>& effectiveTouches(isTouchCancelEvent ? emptyList : touches);
         const AtomicString& stateName(eventNameForTouchPointState(static_cast<PlatformTouchPoint::State>(state)));
-        const EventTargetSet& targetsForState = changedTouches[state].m_targets;
 
-        for (EventTargetSet::const_iterator it = targetsForState.begin(); it != targetsForState.end(); ++it) {
-            EventTarget* touchEventTarget = it->get();
+        for (auto& taget : changedTouches[state].m_targets) {
+            EventTarget* touchEventTarget = taget.get();
             RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : touchesByTarget.get(touchEventTarget));
             ASSERT(targetTouches);
 
index d8d25cf..77c387f 100644 (file)
@@ -700,8 +700,7 @@ void FocusController::setIsVisibleAndActiveInternal(bool contentIsVisible)
         if (!scrollableAreas)
             continue;
 
-        for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
-            ScrollableArea* scrollableArea = *it;
+        for (auto& scrollableArea : *scrollableAreas) {
             ASSERT(scrollableArea->scrollbarsCanBeActive() || m_page.shouldSuppressScrollbarAnimations());
 
             contentAreaDidShowOrHide(scrollableArea, contentIsVisible);
index e591cf4..b25c40e 100644 (file)
@@ -295,9 +295,9 @@ void Frame::orientationChanged()
     for (Frame* frame = this; frame; frame = frame->tree().traverseNext())
         frames.append(*frame);
 
-    for (unsigned i = 0; i < frames.size(); i++) {
-        if (Document* doc = frames[i]->document())
-            doc->dispatchWindowEvent(Event::create(eventNames().orientationchangeEvent, false, false));
+    for (auto& frame : frames) {
+        if (Document* document = frame->document())
+            document->dispatchWindowEvent(Event::create(eventNames().orientationchangeEvent, false, false));
     }
 }
 
@@ -719,10 +719,7 @@ void Frame::injectUserScriptsForWorld(DOMWrapperWorld& world, const UserScriptVe
     if (!doc)
         return;
 
-    Vector<ScriptSourceCode> sourceCode;
-    unsigned count = userScripts.size();
-    for (unsigned i = 0; i < count; ++i) {
-        UserScript* script = userScripts[i].get();
+    for (auto& script : userScripts) {
         if (script->injectedFrames() == InjectInTopFrameOnly && ownerElement())
             continue;
 
index e16e33e..97a6401 100644 (file)
@@ -1878,10 +1878,7 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect
     hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
 
     // 2) update the area of fixed objects that has been invalidated
-    Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
-    size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
-    for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
-        IntRect updateRect = subRectsToUpdate[i];
+    for (auto& updateRect : regionToUpdate.rects()) {
         IntRect scrolledRect = updateRect;
         scrolledRect.move(scrollDelta);
         updateRect.unite(scrolledRect);
@@ -2682,8 +2679,8 @@ void FrameView::serviceScriptedAnimations(double monotonicAnimationStartTime)
     for (auto* frame = m_frame.ptr(); frame; frame = frame->tree().traverseNext())
         documents.append(frame->document());
 
-    for (size_t i = 0; i < documents.size(); ++i)
-        documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime);
+    for (auto& document : documents)
+        document->serviceScriptedAnimations(monotonicAnimationStartTime);
 }
 #endif
 
@@ -4416,8 +4413,8 @@ String FrameView::trackedRepaintRectsAsText() const
     TextStream ts;
     if (!m_trackedRepaintRects.isEmpty()) {
         ts << "(repaint rects\n";
-        for (size_t i = 0; i < m_trackedRepaintRects.size(); ++i)
-            ts << "  (rect " << LayoutUnit(m_trackedRepaintRects[i].x()) << " " << LayoutUnit(m_trackedRepaintRects[i].y()) << " " << LayoutUnit(m_trackedRepaintRects[i].width()) << " " << LayoutUnit(m_trackedRepaintRects[i].height()) << ")\n";
+        for (auto& rect : m_trackedRepaintRects)
+            ts << "  (rect " << LayoutUnit(rect.x()) << " " << LayoutUnit(rect.y()) << " " << LayoutUnit(rect.width()) << " " << LayoutUnit(rect.height()) << ")\n";
         ts << ")\n";
     }
     return ts.release();
@@ -4741,20 +4738,16 @@ void FrameView::updateWidgetPositions()
     // updateWidgetPosition() can possibly cause layout to be re-entered (via plug-ins running
     // scripts in response to NPP_SetWindow, for example), so we need to keep the Widgets
     // alive during enumeration.
-    auto protectedWidgets = collectAndProtectWidgets(m_widgetsInRenderTree);
-
-    for (unsigned i = 0, size = protectedWidgets.size(); i < size; ++i) {
-        if (RenderWidget* renderWidget = RenderWidget::find(protectedWidgets[i].get()))
+    for (auto& widget : collectAndProtectWidgets(m_widgetsInRenderTree)) {
+        if (RenderWidget* renderWidget = RenderWidget::find(widget.get()))
             renderWidget->updateWidgetPosition();
     }
 }
 
 void FrameView::notifyWidgets(WidgetNotification notification)
 {
-    auto protectedWidgets = collectAndProtectWidgets(m_widgetsInRenderTree);
-
-    for (unsigned i = 0, size = protectedWidgets.size(); i < size; ++i)
-        protectedWidgets[i]->notifyWidget(notification);
+    for (auto& widget : collectAndProtectWidgets(m_widgetsInRenderTree))
+        widget->notifyWidget(notification);
 }
 
 void FrameView::setExposedRect(FloatRect exposedRect)
index ea431ed..36a5996 100644 (file)
@@ -121,15 +121,15 @@ static void networkStateChanged(bool isOnLine)
     Vector<Ref<Frame>> frames;
     
     // Get all the frames of all the pages in all the page groups
-    for (auto it = allPages->begin(), end = allPages->end(); it != end; ++it) {
-        for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext())
+    for (auto& page : *allPages) {
+        for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
             frames.append(*frame);
-        InspectorInstrumentation::networkStateChanged(*it);
+        InspectorInstrumentation::networkStateChanged(page);
     }
 
     AtomicString eventName = isOnLine ? eventNames().onlineEvent : eventNames().offlineEvent;
-    for (unsigned i = 0; i < frames.size(); i++)
-        frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false));
+    for (auto& frame : frames)
+        frame->document()->dispatchWindowEvent(Event::create(eventName, false, false));
 }
 
 static const ViewState::Flags PageInitialViewState = ViewState::IsVisible | ViewState::IsInWindow;
@@ -401,9 +401,9 @@ static const ViewModeInfo viewModeMap[viewModeMapSize] = {
 
 Page::ViewMode Page::stringToViewMode(const String& text)
 {
-    for (int i = 0; i < viewModeMapSize; ++i) {
-        if (text == viewModeMap[i].name)
-            return viewModeMap[i].type;
+    for (auto& mode : viewModeMap) {
+        if (text == mode.name)
+            return mode.type;
     }
     return Page::ViewModeInvalid;
 }
@@ -482,9 +482,8 @@ void Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment()
 {
     if (!allPages)
         return;
-    HashSet<Page*>::iterator end = allPages->end();
-    for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
-        for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+    for (auto& page : *allPages) {
+        for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
             // If a change in the global environment has occurred, we need to
             // make sure all the properties a recomputed, therefore we invalidate
             // the properties cache.
@@ -492,6 +491,7 @@ void Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment()
                 styleResolver->invalidateMatchedPropertiesCache();
             frame->document()->scheduleForcedStyleRecalc();
         }
+    }
 }
 
 void Page::setNeedsRecalcStyleInAllFrames()
@@ -511,21 +511,20 @@ void Page::refreshPlugins(bool reload)
 
     Vector<Ref<Frame>> framesNeedingReload;
 
-    for (auto it = allPages->begin(), end = allPages->end(); it != end; ++it) {
-        Page& page = **it;
-        page.m_pluginData.clear();
+    for (auto& page : *allPages) {
+        page->m_pluginData.clear();
 
         if (!reload)
             continue;
         
-        for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
+        for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
             if (frame->loader().subframeLoader().containsPlugins())
                 framesNeedingReload.append(*frame);
         }
     }
 
-    for (size_t i = 0; i < framesNeedingReload.size(); ++i)
-        framesNeedingReload[i]->loader().reload();
+    for (auto& frame : framesNeedingReload)
+        frame->loader().reload();
 }
 
 PluginData& Page::pluginData() const
@@ -900,10 +899,8 @@ void Page::lockAllOverlayScrollbarsToHidden(bool lockOverlayScrollbars)
         if (!scrollableAreas)
             continue;
 
-        for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
-            ScrollableArea* scrollableArea = *it;
+        for (auto& scrollableArea : *scrollableAreas)
             scrollableArea->lockOverlayScrollbarStateToHidden(lockOverlayScrollbars);
-        }
     }
 }
     
@@ -1176,10 +1173,9 @@ Vector<Ref<PluginViewBase>> Page::pluginViews()
         if (!view)
             break;
 
-        for (auto it = view->children().begin(), end = view->children().end(); it != end; ++it) {
-            Widget& widget = **it;
-            if (is<PluginViewBase>(widget))
-                views.append(downcast<PluginViewBase>(widget));
+        for (auto& widget : view->children()) {
+            if (is<PluginViewBase>(*widget))
+                views.append(downcast<PluginViewBase>(*widget));
         }
     }
 
@@ -1193,10 +1189,8 @@ void Page::storageBlockingStateChanged()
 
     // Collect the PluginViews in to a vector to ensure that action the plug-in takes
     // from below storageBlockingStateChanged does not affect their lifetime.
-    auto views = pluginViews();
-
-    for (unsigned i = 0; i < views.size(); ++i)
-        views[i]->storageBlockingStateChanged();
+    for (auto& view : pluginViews())
+        view->storageBlockingStateChanged();
 }
 
 void Page::enableLegacyPrivateBrowsing(bool privateBrowsingEnabled)
@@ -1312,8 +1306,8 @@ void Page::setIsVisibleInternal(bool isVisible)
     for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
         documents.append(*frame->document());
 
-    for (size_t i = 0, size = documents.size(); i < size; ++i)
-        documents[i]->visibilityStateChanged();
+    for (auto& document : documents)
+        document->visibilityStateChanged();
 
     if (!isVisible) {
         if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
index a08a929..9cf7d56 100644 (file)
@@ -109,8 +109,8 @@ void PageGroup::removePage(Page& page)
 #if ENABLE(VIDEO_TRACK)
 void PageGroup::captionPreferencesChanged()
 {
-    for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it)
-        (*it)->captionPreferencesChanged();
+    for (auto& page : m_pages)
+        page->captionPreferencesChanged();
     PageCache::singleton().markPagesForCaptionPreferencesChanged();
 }
 
index b5f1ca3..3523eda 100644 (file)
@@ -33,11 +33,7 @@ namespace WebCore {
 
 PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page& page, bool deferSelf)
 {
-    const HashSet<Page*>& pages = page.group().pages();
-
-    HashSet<Page*>::const_iterator end = pages.end();
-    for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
-        Page* otherPage = *it;
+    for (auto& otherPage : page.group().pages()) {
         if ((deferSelf || otherPage != &page)) {
             if (!otherPage->defersLoading()) {
                 m_deferredFrames.append(&otherPage->mainFrame());
@@ -50,16 +46,16 @@ PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page& page, bool deferSelf)
         }
     }
 
-    size_t count = m_deferredFrames.size();
-    for (size_t i = 0; i < count; ++i)
-        if (Page* page = m_deferredFrames[i]->page())
+    for (auto& deferredFrame : m_deferredFrames) {
+        if (Page* page = deferredFrame->page())
             page->setDefersLoading(true);
+    }
 }
 
 PageGroupLoadDeferrer::~PageGroupLoadDeferrer()
 {
-    for (size_t i = 0; i < m_deferredFrames.size(); ++i) {
-        if (Page* page = m_deferredFrames[i]->page()) {
+    for (auto& deferredFrame : m_deferredFrames) {
+        if (Page* page = deferredFrame->page()) {
             page->setDefersLoading(false);
 
             for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
index 6e38b62..e8141cb 100644 (file)
@@ -221,8 +221,7 @@ void PageSerializer::serializeFrame(Frame* frame)
     m_resources->append(Resource(url, document->suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length())));
     m_resourceURLs.add(url);
 
-    for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++iter) {
-        Node* node = *iter;
+    for (auto& node : nodes) {
         if (!is<Element>(*node))
             continue;
 
index b639911..64896b9 100644 (file)
@@ -118,8 +118,8 @@ PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByType(const Strin
 
 #if ENABLE(RESOURCE_TIMING)
     if (equalIgnoringCase(entryType, "resource"))
-        for (Vector<RefPtr<PerformanceEntry>>::const_iterator resource = m_resourceTimingBuffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
-            entries->append(*resource);
+        for (auto& resource : m_resourceTimingBuffer)
+            entries->append(resource);
 #endif // ENABLE(RESOURCE_TIMING)
 
 #if ENABLE(USER_TIMING)
@@ -141,9 +141,10 @@ PassRefPtr<PerformanceEntryList> Performance::webkitGetEntriesByName(const Strin
 
 #if ENABLE(RESOURCE_TIMING)
     if (entryType.isNull() || equalIgnoringCase(entryType, "resource"))
-        for (Vector<RefPtr<PerformanceEntry>>::const_iterator resource = m_resourceTimingBuffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
-            if ((*resource)->name() == name)
-                entries->append(*resource);
+        for (auto& resource : m_resourceTimingBuffer) {
+            if (resource->name() == name)
+                entries->append(resource);
+        }
 #endif // ENABLE(RESOURCE_TIMING)
 
 #if ENABLE(USER_TIMING)
index 9c97cc0..a46ac24 100644 (file)
@@ -68,9 +68,10 @@ static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r
     const String& securityOrigin = requestingDocument->securityOrigin()->toString();
     Vector<String> timingAllowOrigins;
     timingAllowOriginString.split(' ', timingAllowOrigins);
-    for (size_t i = 0; i < timingAllowOrigins.size(); ++i)
-        if (timingAllowOrigins[i] == securityOrigin)
+    for (auto& origin : timingAllowOrigins) {
+        if (origin == securityOrigin)
             return true;
+    }
 
     return false;
 }
index 1b9e576..a80022e 100644 (file)
@@ -165,8 +165,8 @@ static Vector<RefPtr<PerformanceEntry> > convertToEntrySequence(const Performanc
 {
     Vector<RefPtr<PerformanceEntry> > entries;
 
-    for (PerformanceEntryMap::const_iterator it = performanceEntryMap.begin(); it != performanceEntryMap.end(); ++it)
-        entries.appendVector(it->value);
+    for (auto& entry : performanceEntryMap.values())
+        entries.appendVector(entry);
 
     return entries;
 }
index 581b5cb..e39814b 100644 (file)
@@ -111,10 +111,10 @@ bool SecurityPolicy::allowSubstituteDataAccessToLocal()
 bool SecurityPolicy::isAccessWhiteListed(const SecurityOrigin* activeOrigin, const SecurityOrigin* targetOrigin)
 {
     if (OriginAccessWhiteList* list = originAccessMap().get(activeOrigin->toString())) {
-        for (size_t i = 0; i < list->size();  ++i) {
-           if (list->at(i).matchesOrigin(*targetOrigin))
-               return true;
-       }
+        for (auto& entry : *list) {
+            if (entry.matchesOrigin(*targetOrigin))
+                return true;
+        }
     }
     return false;
 }
index df7706f..2ea18ec 100644 (file)
@@ -37,9 +37,8 @@ bool UserContentURLPattern::matchesPatterns(const URL& url, const Vector<String>
     // If there is no whitelist at all, then all URLs are assumed to be in the whitelist.
     bool matchesWhitelist = whitelist.isEmpty();
     if (!matchesWhitelist) {
-        size_t whitelistSize = whitelist.size();
-        for (size_t i = 0; i < whitelistSize; ++i) {
-            UserContentURLPattern contentPattern(whitelist[i]);
+        for (auto& entry : whitelist) {
+            UserContentURLPattern contentPattern(entry);
             if (contentPattern.matches(url)) {
                 matchesWhitelist = true;
                 break;
@@ -49,9 +48,8 @@ bool UserContentURLPattern::matchesPatterns(const URL& url, const Vector<String>
 
     bool matchesBlacklist = false;
     if (!blacklist.isEmpty()) {
-        size_t blacklistSize = blacklist.size();
-        for (size_t i = 0; i < blacklistSize; ++i) {
-            UserContentURLPattern contentPattern(blacklist[i]);
+        for (auto& entry : blacklist) {
+            UserContentURLPattern contentPattern(entry);
             if (contentPattern.matches(url)) {
                 matchesBlacklist = true;
                 break;
index 0829887..1774dcf 100644 (file)
@@ -240,10 +240,7 @@ void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap
 {
     Vector<String> vector;
     string.split(';', vector);
-    size_t size = vector.size();
-    for (size_t i = 0; i < size; ++i) {
-        const String& featureString = vector[i];
-
+    for (auto& featureString : vector) {
         size_t separatorPosition = featureString.find('=');
         size_t colonPosition = featureString.find(':');
         if (separatorPosition != notFound && colonPosition != notFound)
index c547623..7885cac 100644 (file)
@@ -115,9 +115,8 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/*
     double timeToNextService = -1;
     bool calledSetChanged = false;
 
-    auto end = m_compositeAnimations.end();
-    for (auto it = m_compositeAnimations.begin(); it != end; ++it) {
-        CompositeAnimation& animation = *it->value;
+    for (auto& compositeAnimation : m_compositeAnimations) {
+        CompositeAnimation& animation = *compositeAnimation.value;
         if (!animation.isSuspended() && animation.hasAnimations()) {
             double t = animation.timeToNextService();
             if (t != -1 && (t < timeToNextService || timeToNextService == -1))
@@ -125,7 +124,7 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/*
             if (!timeToNextService) {
                 if (callSetChanged != CallSetChanged)
                     break;
-                Element* element = it->key->element();
+                Element* element = compositeAnimation.key->element();
                 ASSERT(element);
                 ASSERT(!element->document().inPageCache());
                 element->setNeedsStyleRecalc(SyntheticStyleChange);
@@ -192,17 +191,16 @@ void AnimationControllerPrivate::fireEventsAndUpdateStyle()
 
     // fire all the events
     Vector<EventToDispatch> eventsToDispatch = WTF::move(m_eventsToDispatch);
-    Vector<EventToDispatch>::const_iterator eventsToDispatchEnd = eventsToDispatch.end();
-    for (Vector<EventToDispatch>::const_iterator it = eventsToDispatch.begin(); it != eventsToDispatchEnd; ++it) {
-        Element* element = it->element.get();
-        if (it->eventType == eventNames().transitionendEvent)
-            element->dispatchEvent(TransitionEvent::create(it->eventType, it->name, it->elapsedTime, PseudoElement::pseudoElementNameForEvents(element->pseudoId())));
+    for (auto& event : eventsToDispatch) {
+        Element& element = *event.element;
+        if (event.eventType == eventNames().transitionendEvent)
+            element.dispatchEvent(TransitionEvent::create(event.eventType, event.name, event.elapsedTime, PseudoElement::pseudoElementNameForEvents(element.pseudoId())));
         else
-            element->dispatchEvent(AnimationEvent::create(it->eventType, it->name, it->elapsedTime));
+            element.dispatchEvent(AnimationEvent::create(event.eventType, event.name, event.elapsedTime));
     }
 
-    for (unsigned i = 0, size = m_elementChangesToDispatch.size(); i < size; ++i)
-        m_elementChangesToDispatch[i]->setNeedsStyleRecalc(SyntheticStyleChange);
+    for (auto& change : m_elementChangesToDispatch)
+        change->setNeedsStyleRecalc(SyntheticStyleChange);
 
     m_elementChangesToDispatch.clear();
 
@@ -311,9 +309,9 @@ void AnimationControllerPrivate::suspendAnimationsForDocument(Document* document
 {
     AnimationPrivateUpdateBlock updateBlock(*this);
 
-    for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) {
-        if (&it->key->document() == document)
-            it->value->suspendAnimations();
+    for (auto& animation : m_compositeAnimations) {
+        if (&animation.key->document() == document)
+            animation.value->suspendAnimations();
     }
 
     updateAnimationTimer();
@@ -323,9 +321,9 @@ void AnimationControllerPrivate::resumeAnimationsForDocument(Document* document)
 {
     AnimationPrivateUpdateBlock updateBlock(*this);
 
-    for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) {
-        if (&it->key->document() == document)
-            it->value->resumeAnimations();
+    for (auto& animation : m_compositeAnimations) {
+        if (&animation.key->document() == document)
+            animation.value->resumeAnimations();
     }
 
     updateAnimationTimer();
@@ -435,9 +433,9 @@ unsigned AnimationControllerPrivate::numberOfActiveAnimations(Document* document
 {
     unsigned count = 0;
     
-    for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) {
-        if (&it->key->document() == document)
-            count += it->value->numberOfActiveAnimations();
+    for (auto& animation : m_compositeAnimations) {
+        if (&animation.key->document() == document)
+            count += animation.value->numberOfActiveAnimations();
     }
 
     return count;
index a8dbbd0..93057db 100644 (file)
@@ -1044,9 +1044,8 @@ public:
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-        Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWrappers.end();
-        for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_propertyWrappers.begin(); it != end; ++it) {
-            if (!(*it)->equals(a, b))
+        for (auto& wrapper : m_propertyWrappers) {
+            if (!wrapper->equals(a, b))
                 return false;
         }
         return true;
@@ -1054,9 +1053,8 @@ public:
 
     virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
     {
-        Vector<AnimationPropertyWrapperBase*>::const_iterator end = m_propertyWrappers.end();
-        for (Vector<AnimationPropertyWrapperBase*>::const_iterator it = m_propertyWrappers.begin(); it != end; ++it)
-            (*it)->blend(anim, dst, a, b, progress);
+        for (auto& wrapper : m_propertyWrappers)
+            wrapper->blend(anim, dst, a, b, progress);
     }
 
     const Vector<AnimationPropertyWrapperBase*>& propertyWrappers() const { return m_propertyWrappers; }
index f7db200..55cb842 100644 (file)
@@ -67,8 +67,8 @@ static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrolli
     // FIXME: Incorporate current page scale factor in snapping to device pixel. Perhaps we should just convert to float here and let UI process do the pixel snapping?
     Vector<float> snapOffsetsAsFloat;
     snapOffsetsAsFloat.reserveInitialCapacity(snapOffsets.size());
-    for (size_t i = 0; i < snapOffsets.size(); ++i)
-        snapOffsetsAsFloat.append(roundToDevicePixel(snapOffsets[i], deviceScaleFactor, false));
+    for (auto& offset : snapOffsets)
+        snapOffsetsAsFloat.append(roundToDevicePixel(offset, deviceScaleFactor, false));
 
     if (axis == ScrollEventAxis::Horizontal)
         node.setHorizontalSnapOffsets(snapOffsetsAsFloat);
index 333afc8..5c52ba0 100644 (file)
@@ -128,8 +128,7 @@ Region ScrollingCoordinator::absoluteNonFastScrollableRegionForFrame(const Frame
     // to not ask for regions at bad times.
 
     if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) {
-        for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
-            ScrollableArea* scrollableArea = *it;
+        for (auto& scrollableArea : *scrollableAreas) {
             // Composited scrollable areas can be scrolled off the main thread.
             if (scrollableArea->usesAsyncScrolling())
                 continue;
@@ -313,11 +312,10 @@ bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(const
     if (!viewportConstrainedObjects)
         return false;
 
-    for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
-        RenderObject& viewportConstrainedObject = **it;
-        if (!is<RenderBoxModelObject>(viewportConstrainedObject) || !viewportConstrainedObject.hasLayer())
+    for (auto& viewportConstrainedObject : *viewportConstrainedObjects) {
+        if (!is<RenderBoxModelObject>(*viewportConstrainedObject) || !viewportConstrainedObject->hasLayer())
             return true;
-        RenderLayer& layer = *downcast<RenderBoxModelObject>(viewportConstrainedObject).layer();
+        RenderLayer& layer = *downcast<RenderBoxModelObject>(*viewportConstrainedObject).layer();
         // Any explicit reason that a fixed position element is not composited shouldn't cause slow scrolling.
         if (!layer.isComposited() && layer.viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
             return true;