Changeset 190338 in webkit


Ignore:
Timestamp:
Sep 29, 2015 10:53:51 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Use modern for-loops in WebCore/loader.
https://bugs.webkit.org/show_bug.cgi?id=149397

Patch by Hunseop Jeong <Hunseop Jeong> on 2015-09-29
Reviewed by Darin Adler.

No new tests because there is no behavior change.

  • loader/CrossOriginAccessControl.cpp:

(WebCore::parseAccessControlExposeHeadersAllowList):

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):

  • loader/FormSubmission.cpp:

(WebCore::FormSubmission::create):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::~FrameLoader):
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::detachChildren):
(WebCore::FrameLoader::shouldClose):
(WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads):

  • loader/HistoryController.cpp:

(WebCore::HistoryController::currentFramesMatchItem):

  • loader/SubframeLoader.cpp:

(WebCore::findPluginMIMETypeFromURL):
(WebCore::SubframeLoader::createJavaAppletWidget):

  • loader/appcache/ApplicationCache.cpp:

(WebCore::ApplicationCache::isURLInOnlineWhitelist):
(WebCore::ApplicationCache::urlMatchesFallbackNamespace):

  • loader/appcache/ApplicationCacheGroup.cpp:

(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
(WebCore::ApplicationCacheGroup::postListenerTask):

  • loader/appcache/ApplicationCacheHost.cpp:

(WebCore::ApplicationCacheHost::stopDeferringEvents):

  • loader/appcache/ApplicationCacheStorage.cpp:

(WebCore::StorageIDJournal::~StorageIDJournal):
(WebCore::ApplicationCacheStorage::store):
(WebCore::ApplicationCacheStorage::getOriginsWithCache):

  • loader/archive/Archive.cpp:

(WebCore::Archive::clearAllSubframeArchivesImpl):

  • loader/archive/ArchiveResourceCollection.cpp:

(WebCore::ArchiveResourceCollection::addAllResources):

  • loader/archive/cf/LegacyWebArchive.cpp:

(WebCore::LegacyWebArchive::createPropertyListRepresentation):
(WebCore::LegacyWebArchive::create):

  • loader/archive/mhtml/MHTMLArchive.cpp:

(WebCore::MHTMLArchive::generateMHTMLData):

  • loader/cache/CachedImage.cpp:

(WebCore::CachedImage::switchClientsToRevalidatedResource):
(WebCore::CachedImage::createImage):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::switchClientsToRevalidatedResource):

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::~CachedResourceLoader):
(WebCore::CachedResourceLoader::reloadImagesIfNotDeferred):
(WebCore::CachedResourceLoader::garbageCollectDocumentResources):
(WebCore::CachedResourceLoader::isPreloaded):
(WebCore::CachedResourceLoader::printPreloadStats):

  • loader/icon/IconDatabase.cpp:

(WebCore::IconDatabase::removeAllIcons):
(WebCore::IconDatabase::setIconDataForIconURL):
(WebCore::IconDatabase::iconRecordCountWithData):
(WebCore::IconDatabase::notifyPendingLoadDecisions):
(WebCore::IconDatabase::performURLImport):
(WebCore::IconDatabase::performPendingRetainAndReleaseOperations):
(WebCore::IconDatabase::readFromDatabase):
(WebCore::IconDatabase::writeToDatabase):

Location:
trunk/Source/WebCore
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r190337 r190338  
     12015-09-29  Hunseop Jeong  <hs85.jeong@samsung.com>
     2
     3        Use modern for-loops in WebCore/loader.
     4        https://bugs.webkit.org/show_bug.cgi?id=149397
     5
     6        Reviewed by Darin Adler.
     7
     8        No new tests because there is no behavior change.
     9
     10        * loader/CrossOriginAccessControl.cpp:
     11        (WebCore::parseAccessControlExposeHeadersAllowList):
     12        * loader/DocumentLoader.cpp:
     13        (WebCore::DocumentLoader::substituteResourceDeliveryTimerFired):
     14        * loader/FormSubmission.cpp:
     15        (WebCore::FormSubmission::create):
     16        * loader/FrameLoader.cpp:
     17        (WebCore::FrameLoader::~FrameLoader):
     18        (WebCore::FrameLoader::commitProvisionalLoad):
     19        (WebCore::FrameLoader::detachChildren):
     20        (WebCore::FrameLoader::shouldClose):
     21        (WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads):
     22        * loader/HistoryController.cpp:
     23        (WebCore::HistoryController::currentFramesMatchItem):
     24        * loader/SubframeLoader.cpp:
     25        (WebCore::findPluginMIMETypeFromURL):
     26        (WebCore::SubframeLoader::createJavaAppletWidget):
     27        * loader/appcache/ApplicationCache.cpp:
     28        (WebCore::ApplicationCache::isURLInOnlineWhitelist):
     29        (WebCore::ApplicationCache::urlMatchesFallbackNamespace):
     30        * loader/appcache/ApplicationCacheGroup.cpp:
     31        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
     32        (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
     33        (WebCore::ApplicationCacheGroup::postListenerTask):
     34        * loader/appcache/ApplicationCacheHost.cpp:
     35        (WebCore::ApplicationCacheHost::stopDeferringEvents):
     36        * loader/appcache/ApplicationCacheStorage.cpp:
     37        (WebCore::StorageIDJournal::~StorageIDJournal):
     38        (WebCore::ApplicationCacheStorage::store):
     39        (WebCore::ApplicationCacheStorage::getOriginsWithCache):
     40        * loader/archive/Archive.cpp:
     41        (WebCore::Archive::clearAllSubframeArchivesImpl):
     42        * loader/archive/ArchiveResourceCollection.cpp:
     43        (WebCore::ArchiveResourceCollection::addAllResources):
     44        * loader/archive/cf/LegacyWebArchive.cpp:
     45        (WebCore::LegacyWebArchive::createPropertyListRepresentation):
     46        (WebCore::LegacyWebArchive::create):
     47        * loader/archive/mhtml/MHTMLArchive.cpp:
     48        (WebCore::MHTMLArchive::generateMHTMLData):
     49        * loader/cache/CachedImage.cpp:
     50        (WebCore::CachedImage::switchClientsToRevalidatedResource):
     51        (WebCore::CachedImage::createImage):
     52        * loader/cache/CachedResource.cpp:
     53        (WebCore::CachedResource::switchClientsToRevalidatedResource):
     54        * loader/cache/CachedResourceLoader.cpp:
     55        (WebCore::CachedResourceLoader::~CachedResourceLoader):
     56        (WebCore::CachedResourceLoader::reloadImagesIfNotDeferred):
     57        (WebCore::CachedResourceLoader::garbageCollectDocumentResources):
     58        (WebCore::CachedResourceLoader::isPreloaded):
     59        (WebCore::CachedResourceLoader::printPreloadStats):
     60        * loader/icon/IconDatabase.cpp:
     61        (WebCore::IconDatabase::removeAllIcons):
     62        (WebCore::IconDatabase::setIconDataForIconURL):
     63        (WebCore::IconDatabase::iconRecordCountWithData):
     64        (WebCore::IconDatabase::notifyPendingLoadDecisions):
     65        (WebCore::IconDatabase::performURLImport):
     66        (WebCore::IconDatabase::performPendingRetainAndReleaseOperations):
     67        (WebCore::IconDatabase::readFromDatabase):
     68        (WebCore::IconDatabase::writeToDatabase):
     69
    1702015-09-29  Chris Dumez  <cdumez@apple.com>
    271
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp

    r175231 r190338  
    171171    Vector<String> headers;
    172172    headerValue.split(',', false, headers);
    173     for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) {
    174         String strippedHeader = headers[headerCount].stripWhiteSpace();
     173    for (auto& header : headers) {
     174        String strippedHeader = header.stripWhiteSpace();
    175175        if (!strippedHeader.isEmpty())
    176176            headerSet.add(strippedHeader);
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r190169 r190338  
    11491149    copy.swap(m_pendingSubstituteResources);
    11501150
    1151     SubstituteResourceMap::const_iterator end = copy.end();
    1152     for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++it) {
    1153         RefPtr<ResourceLoader> loader = it->key;
    1154         SubstituteResource* resource = it->value.get();
    1155        
     1151    for (auto& entry : copy) {
     1152        auto& loader = entry.key;
     1153        SubstituteResource* resource = entry.value.get();
     1154
    11561155        if (resource)
    11571156            resource->deliver(*loader);
  • trunk/Source/WebCore/loader/FormSubmission.cpp

    r189771 r190338  
    202202
    203203    bool containsPasswordData = false;
    204     for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
    205         FormAssociatedElement& control = *form->associatedElements()[i];
    206         HTMLElement& element = control.asHTMLElement();
     204    for (auto& control : form->associatedElements()) {
     205        HTMLElement& element = control->asHTMLElement();
    207206        if (!element.isDisabledFormControl())
    208             control.appendFormData(*domFormData, isMultiPartForm);
     207            control->appendFormData(*domFormData, isMultiPartForm);
    209208        if (is<HTMLInputElement>(element)) {
    210209            HTMLInputElement& input = downcast<HTMLInputElement>(element);
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r189834 r190338  
    245245    setOpener(nullptr);
    246246
    247     HashSet<Frame*>::iterator end = m_openedFrames.end();
    248     for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it)
    249         (*it)->loader().m_opener = 0;
     247    for (auto& frame : m_openedFrames)
     248        frame->loader().m_opener = nullptr;
    250249
    251250    m_client.frameLoaderDestroyed();
     
    18591858#endif
    18601859
    1861         const ResponseVector& responses = m_documentLoader->responses();
    1862         size_t count = responses.size();
    1863         for (size_t i = 0; i < count; i++) {
    1864             const ResourceResponse& response = responses[i];
     1860        for (auto& response : m_documentLoader->responses()) {
    18651861            // FIXME: If the WebKit client changes or cancels the request, this is not respected.
    18661862            ResourceError error;
     
    24292425    for (Frame* child = m_frame.tree().lastChild(); child; child = child->tree().previousSibling())
    24302426        childrenToDetach.uncheckedAppend(*child);
    2431     for (unsigned i = 0; i < childrenToDetach.size(); ++i)
    2432         childrenToDetach[i]->loader().detachFromParent();
     2427    for (auto& child : childrenToDetach)
     2428        child->loader().detachFromParent();
    24332429}
    24342430
     
    34333429    m_documentLoader->takeMemoryCacheLoadsForClientNotification(pastLoads);
    34343430
    3435     size_t size = pastLoads.size();
    3436     for (size_t i = 0; i < size; ++i) {
    3437         CachedResource* resource = MemoryCache::singleton().resourceForRequest(pastLoads[i], m_frame.page()->sessionID());
     3431    for (auto& pastLoad : pastLoads) {
     3432        CachedResource* resource = MemoryCache::singleton().resourceForRequest(pastLoad, m_frame.page()->sessionID());
    34383433
    34393434        // FIXME: These loads, loaded from cache, but now gone from the cache by the time
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r187962 r190338  
    780780        return false;
    781781   
    782     unsigned size = childItems.size();
    783     for (unsigned i = 0; i < size; ++i) {
    784         if (!m_frame.tree().child(childItems[i]->target()))
     782    for (auto& item : childItems) {
     783        if (!m_frame.tree().child(item->target()))
    785784            return false;
    786785    }
  • trunk/Source/WebCore/loader/SubframeLoader.cpp

    r189164 r190338  
    172172    Vector<size_t> mimePluginIndices;
    173173    pluginData.getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
    174     for (size_t i = 0; i < mimes.size(); ++i) {
    175         const MimeClassInfo& mimeClassInfo = mimes[i];
    176         for (size_t j = 0; j < mimeClassInfo.extensions.size(); ++j) {
    177             if (equalIgnoringCase(extension, mimeClassInfo.extensions[j]))
    178                 return mimeClassInfo.type;
     174    for (auto& mime : mimes) {
     175        for (auto& mimeExtension : mime.extensions) {
     176            if (equalIgnoringCase(extension, mimeExtension))
     177                return mime.type;
    179178        }
    180179    }
  • trunk/Source/WebCore/loader/appcache/ApplicationCache.cpp

    r182570 r190338  
    154154bool ApplicationCache::isURLInOnlineWhitelist(const URL& url)
    155155{
    156     size_t whitelistSize = m_onlineWhitelist.size();
    157     for (size_t i = 0; i < whitelistSize; ++i) {
    158         if (protocolHostAndPortAreEqual(url, m_onlineWhitelist[i]) && url.string().startsWith(m_onlineWhitelist[i].string()))
     156    for (auto& whitelistURL : m_onlineWhitelist) {
     157        if (protocolHostAndPortAreEqual(url, whitelistURL) && url.string().startsWith(whitelistURL.string()))
    159158            return true;
    160159    }
     
    172171bool ApplicationCache::urlMatchesFallbackNamespace(const URL& url, URL* fallbackURL)
    173172{
    174     size_t fallbackCount = m_fallbackURLs.size();
    175     for (size_t i = 0; i < fallbackCount; ++i) {
    176         if (protocolHostAndPortAreEqual(url, m_fallbackURLs[i].first) && url.string().startsWith(m_fallbackURLs[i].first.string())) {
     173    for (auto& fallback : m_fallbackURLs) {
     174        if (protocolHostAndPortAreEqual(url, fallback.first) && url.string().startsWith(fallback.first.string())) {
    177175            if (fallbackURL)
    178                 *fallbackURL = m_fallbackURLs[i].second;
     176                *fallbackURL = fallback.second;
    179177            return true;
    180178        }
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r187533 r190338  
    730730    m_cacheBeingUpdated->setGroup(this);
    731731
    732     HashSet<DocumentLoader*>::const_iterator masterEnd = m_pendingMasterResourceLoaders.end();
    733     for (HashSet<DocumentLoader*>::const_iterator iter = m_pendingMasterResourceLoaders.begin(); iter != masterEnd; ++iter)
    734         associateDocumentLoaderWithCache(*iter, m_cacheBeingUpdated.get());
     732    for (auto& loader : m_pendingMasterResourceLoaders)
     733        associateDocumentLoaderWithCache(loader, m_cacheBeingUpdated.get());
    735734
    736735    // We have the manifest, now download the resources.
     
    752751        addEntry(explicitURL, ApplicationCacheResource::Explicit);
    753752
    754     size_t fallbackCount = manifest.fallbackURLs.size();
    755     for (size_t i = 0; i  < fallbackCount; ++i)
    756         addEntry(manifest.fallbackURLs[i].second, ApplicationCacheResource::Fallback);
     753    for (auto& fallbackURL : manifest.fallbackURLs)
     754        addEntry(fallbackURL.second, ApplicationCacheResource::Fallback);
    757755   
    758756    m_cacheBeingUpdated->setOnlineWhitelist(manifest.onlineWhitelistedURLs);
     
    942940            Vector<DocumentLoader*> loaders;
    943941            copyToVector(m_pendingMasterResourceLoaders, loaders);
    944             size_t count = loaders.size();
    945             for (size_t i = 0; i != count; ++i)
    946                 disassociateDocumentLoader(loaders[i]); // This can delete this group.
     942            for (auto& loader : loaders)
     943                disassociateDocumentLoader(loader); // This can delete this group.
    947944
    948945            // Reinstate the oldNewestCache, if there was one.
     
    10801077void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone, const HashSet<DocumentLoader*>& loaderSet)
    10811078{
    1082     HashSet<DocumentLoader*>::const_iterator loaderSetEnd = loaderSet.end();
    1083     for (HashSet<DocumentLoader*>::const_iterator iter = loaderSet.begin(); iter != loaderSetEnd; ++iter)
    1084         postListenerTask(eventID, progressTotal, progressDone, *iter);
     1079    for (auto& loader : loaderSet)
     1080        postListenerTask(eventID, progressTotal, progressDone, loader);
    10851081}
    10861082
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp

    r188486 r190338  
    306306{
    307307    Ref<DocumentLoader> protect(m_documentLoader);
    308     for (unsigned i = 0; i < m_deferredEvents.size(); ++i) {
    309         const DeferredEvent& deferred = m_deferredEvents[i];
    310         dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.progressDone);
    311     }
     308    for (auto& event : m_deferredEvents)
     309        dispatchDOMEvent(event.eventID, event.progressTotal, event.progressDone);
    312310    m_deferredEvents.clear();
    313311    m_defersEvents = false;
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp

    r182612 r190338  
    5151    ~StorageIDJournal()
    5252    {
    53         size_t size = m_records.size();
    54         for (size_t i = 0; i < size; ++i)
    55             m_records[i].restore();
     53        for (auto& record : m_records)
     54            record.restore();
    5655    }
    5756
     
    752751    const Vector<URL>& onlineWhitelist = cache->onlineWhitelist();
    753752    {
    754         size_t whitelistSize = onlineWhitelist.size();
    755         for (size_t i = 0; i < whitelistSize; ++i) {
     753        for (auto& whitelistURL : onlineWhitelist) {
    756754            SQLiteStatement statement(m_database, "INSERT INTO CacheWhitelistURLs (url, cache) VALUES (?, ?)");
    757755            statement.prepare();
    758756
    759             statement.bindText(1, onlineWhitelist[i]);
     757            statement.bindText(1, whitelistURL);
    760758            statement.bindInt64(2, cacheStorageID);
    761759
     
    780778    const FallbackURLVector& fallbackURLs = cache->fallbackURLs();
    781779    {
    782         size_t fallbackCount = fallbackURLs.size();
    783         for (size_t i = 0; i < fallbackCount; ++i) {
     780        for (auto& fallbackURL : fallbackURLs) {
    784781            SQLiteStatement statement(m_database, "INSERT INTO FallbackURLs (namespace, fallbackURL, cache) VALUES (?, ?, ?)");
    785782            statement.prepare();
    786783
    787             statement.bindText(1, fallbackURLs[i].first);
    788             statement.bindText(2, fallbackURLs[i].second);
     784            statement.bindText(1, fallbackURL.first);
     785            statement.bindText(2, fallbackURL.second);
    789786            statement.bindInt64(3, cacheStorageID);
    790787
     
    15301527    // Multiple manifest URLs might share the same SecurityOrigin, so we might be creating extra, wasted origins here.
    15311528    // The current schema doesn't allow for a more efficient way of building this list.
    1532     size_t count = urls.size();
    1533     for (size_t i = 0; i < count; ++i)
    1534         origins.add(SecurityOrigin::create(urls[i]));
     1529    for (auto& url : urls)
     1530        origins.add(SecurityOrigin::create(url));
    15351531}
    15361532
  • trunk/Source/WebCore/loader/archive/Archive.cpp

    r165676 r190338  
    4444void Archive::clearAllSubframeArchivesImpl(Vector<RefPtr<Archive>>* clearedArchives)
    4545{
    46     for (Vector<RefPtr<Archive>>::iterator it = m_subframeArchives.begin(); it != m_subframeArchives.end(); ++it) {
    47         if (!clearedArchives->contains(*it)) {
    48             clearedArchives->append(*it);
    49             (*it)->clearAllSubframeArchivesImpl(clearedArchives);
     46    for (auto& archive : m_subframeArchives) {
     47        if (!clearedArchives->contains(archive)) {
     48            clearedArchives->append(archive);
     49            archive->clearAllSubframeArchivesImpl(clearedArchives);
    5050        }
    5151    }
  • trunk/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp

    r165676 r190338  
    4242        return;
    4343
    44     const Vector<RefPtr<ArchiveResource>>& subresources = archive->subresources();
    45     for (Vector<RefPtr<ArchiveResource>>::const_iterator iterator = subresources.begin(); iterator != subresources.end(); ++iterator)
    46         m_subresources.set((*iterator)->url(), iterator->get());
     44    for (auto& subresource : archive->subresources())
     45        m_subresources.set(subresource->url(), subresource.get());
    4746
    48     const Vector<RefPtr<Archive>>& subframes = archive->subframeArchives();
    49     for (Vector<RefPtr<Archive>>::const_iterator iterator = subframes.begin(); iterator != subframes.end(); ++iterator) {
    50         RefPtr<Archive> archive = *iterator;
    51         ASSERT(archive->mainResource());
     47    for (auto& subframeArchive : archive->subframeArchives()) {
     48        ASSERT(subframeArchive->mainResource());
    5249
    53         const String& frameName = archive->mainResource()->frameName();
     50        const String& frameName = subframeArchive->mainResource()->frameName();
    5451        if (!frameName.isNull())
    55             m_subframes.set(frameName, archive.get());
     52            m_subframes.set(frameName, subframeArchive.get());
    5653        else {
    5754            // In the MHTML case, frames don't have a name so we use the URL instead.
    58             m_subframes.set(archive->mainResource()->url().string(), archive.get());
     55            m_subframes.set(subframeArchive->mainResource()->url().string(), subframeArchive.get());
    5956        }
    6057    }
  • trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp

    r189182 r190338  
    134134
    135135    RetainPtr<CFMutableArrayRef> subresourcesArray = adoptCF(CFArrayCreateMutable(0, archive->subresources().size(), &kCFTypeArrayCallBacks));
    136     const Vector<RefPtr<ArchiveResource>>& subresources(archive->subresources());
    137     for (unsigned i = 0; i < subresources.size(); ++i) {
    138         RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentation(subresources[i].get(), Subresource);
    139         if (subresource)
     136    for (auto& resource : archive->subresources()) {
     137        if (RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentation(resource.get(), Subresource))
    140138            CFArrayAppendValue(subresourcesArray.get(), subresource.get());
    141139        else
     
    146144
    147145    RetainPtr<CFMutableArrayRef> subframesArray = adoptCF(CFArrayCreateMutable(0, archive->subframeArchives().size(), &kCFTypeArrayCallBacks));
    148     const Vector<RefPtr<Archive>>& subframeArchives(archive->subframeArchives());
    149     for (unsigned i = 0; i < subframeArchives.size(); ++i) {
    150         RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresentation(subframeArchives[i].get());
    151         if (subframeArchive)
     146    for (auto& subframe : archive->subframeArchives()) {
     147        if (RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresentation(subframe.get()))
    152148            CFArrayAppendValue(subframesArray.get(), subframeArchive.get());
    153149        else
     
    247243    archive->setMainResource(mainResource);
    248244   
    249     for (unsigned i = 0; i < subresources.size(); ++i)
    250         archive->addSubresource(WTF::move(subresources[i]));
    251    
    252     for (unsigned i = 0; i < subframeArchives.size(); ++i)
    253         archive->addSubframeArchive(WTF::move(subframeArchives[i]));
    254        
     245    for (auto& subresource : subresources)
     246        archive->addSubresource(WTF::move(subresource));
     247
     248    for (auto& subframeArchive : subframeArchives)
     249        archive->addSubframeArchive(WTF::move(subframeArchive));
     250
    255251    return archive.release();
    256252}
  • trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp

    r156550 r190338  
    177177    mhtmlData->append(asciiString.data(), asciiString.length());
    178178
    179     for (size_t i = 0; i < resources.size(); ++i) {
    180         const PageSerializer::Resource& resource = resources[i];
    181 
     179    for (auto& resource : resources) {
    182180        stringBuilder.clear();
    183181        stringBuilder.append(endOfResourceBoundary);
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r188839 r190338  
    150150        // A copy of pending size requests is needed as they are deleted during CachedResource::switchClientsToRevalidateResouce().
    151151        ContainerSizeRequests switchContainerSizeRequests;
    152         for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests.begin(); it != m_pendingContainerSizeRequests.end(); ++it)
    153             switchContainerSizeRequests.set(it->key, it->value);
     152        for (auto& request : m_pendingContainerSizeRequests)
     153            switchContainerSizeRequests.set(request.key, request.value);
    154154        CachedResource::switchClientsToRevalidatedResource();
    155155        CachedImage& revalidatedCachedImage = downcast<CachedImage>(*resourceToRevalidate());
    156         for (ContainerSizeRequests::iterator it = switchContainerSizeRequests.begin(); it != switchContainerSizeRequests.end(); ++it)
    157             revalidatedCachedImage.setContainerSizeForRenderer(it->key, it->value.first, it->value.second);
     156        for (auto& request : switchContainerSizeRequests)
     157            revalidatedCachedImage.setContainerSizeForRenderer(request.key, request.value.first, request.value.second);
    158158        return;
    159159    }
     
    354354        // Send queued container size requests.
    355355        if (m_image->usesContainerSize()) {
    356             for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests.begin(); it != m_pendingContainerSizeRequests.end(); ++it)
    357                 setContainerSizeForRenderer(it->key, it->value.first, it->value.second);
     356            for (auto& request : m_pendingContainerSizeRequests)
     357                setContainerSizeForRenderer(request.key, request.value.first, request.value.second);
    358358        }
    359359        m_pendingContainerSizeRequests.clear();
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r188358 r190338  
    626626
    627627    m_switchingClientsToRevalidatedResource = true;
    628     HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end();
    629     for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) {
    630         CachedResourceHandleBase* handle = *it;
     628    for (auto& handle : m_handlesToRevalidate) {
    631629        handle->m_resource = m_resourceToRevalidate;
    632630        m_resourceToRevalidate->registerHandle(handle);
     
    637635
    638636    Vector<CachedResourceClient*> clientsToMove;
    639     HashCountedSet<CachedResourceClient*>::iterator end2 = m_clients.end();
    640     for (HashCountedSet<CachedResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) {
    641         CachedResourceClient* client = it->key;
    642         unsigned count = it->value;
     637    for (auto& entry : m_clients) {
     638        CachedResourceClient* client = entry.key;
     639        unsigned count = entry.value;
    643640        while (count) {
    644641            clientsToMove.append(client);
     
    647644    }
    648645
    649     unsigned moveCount = clientsToMove.size();
    650     for (unsigned n = 0; n < moveCount; ++n)
    651         removeClient(clientsToMove[n]);
     646    for (auto& client : clientsToMove)
     647        removeClient(client);
    652648    ASSERT(m_clients.isEmpty());
    653649
    654     for (unsigned n = 0; n < moveCount; ++n)
    655         m_resourceToRevalidate->addClientToSet(clientsToMove[n]);
    656     for (unsigned n = 0; n < moveCount; ++n) {
     650    for (auto& client : clientsToMove)
     651        m_resourceToRevalidate->addClientToSet(client);
     652    for (auto& client : clientsToMove) {
    657653        // Calling didAddClient may do anything, including trying to cancel revalidation.
    658654        // Assert that it didn't succeed.
    659655        ASSERT(m_resourceToRevalidate);
    660656        // Calling didAddClient for a client may end up removing another client. In that case it won't be in the set anymore.
    661         if (m_resourceToRevalidate->m_clients.contains(clientsToMove[n]))
    662             m_resourceToRevalidate->didAddClient(clientsToMove[n]);
     657        if (m_resourceToRevalidate->m_clients.contains(client))
     658            m_resourceToRevalidate->didAddClient(client);
    663659    }
    664660    m_switchingClientsToRevalidatedResource = false;
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r189432 r190338  
    139139
    140140    clearPreloads();
    141     DocumentResourceMap::iterator end = m_documentResources.end();
    142     for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it)
    143         it->value->setOwningCachedResourceLoader(0);
     141    for (auto& resource : m_documentResources.values())
     142        resource->setOwningCachedResourceLoader(nullptr);
    144143
    145144    // Make sure no requests still point to this CachedResourceLoader
     
    862861void CachedResourceLoader::reloadImagesIfNotDeferred()
    863862{
    864     DocumentResourceMap::iterator end = m_documentResources.end();
    865     for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) {
    866         CachedResource* resource = it->value.get();
     863    for (auto& resource : m_documentResources.values()) {
    867864        if (is<CachedImage>(*resource) && resource->stillNeedsLoad() && !clientDefersImage(resource->url()))
    868865            downcast<CachedImage>(*resource).load(*this, defaultCachedResourceOptions());
     
    946943    StringVector resourcesToDelete;
    947944
    948     for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m_documentResources.end(); ++it) {
    949         if (it->value->hasOneHandle()) {
    950             resourcesToDelete.append(it->key);
    951             it->value->setOwningCachedResourceLoader(0);
     945    for (auto& resource : m_documentResources) {
     946        if (resource.value->hasOneHandle()) {
     947            resourcesToDelete.append(resource.key);
     948            resource.value->setOwningCachedResourceLoader(nullptr);
    952949        }
    953950    }
    954951
    955     for (StringVector::const_iterator it = resourcesToDelete.begin(); it != resourcesToDelete.end(); ++it)
    956         m_documentResources.remove(*it);
     952    for (auto& resource : resourcesToDelete)
     953        m_documentResources.remove(resource);
    957954}
    958955
     
    10501047
    10511048    if (m_preloads) {
    1052         ListHashSet<CachedResource*>::iterator end = m_preloads->end();
    1053         for (ListHashSet<CachedResource*>::iterator it = m_preloads->begin(); it != end; ++it) {
    1054             CachedResource* resource = *it;
     1049        for (auto& resource : *m_preloads) {
    10551050            if (resource->url() == url)
    10561051                return true;
     
    10581053    }
    10591054
    1060     Deque<PendingPreload>::const_iterator dequeEnd = m_pendingPreloads.end();
    1061     for (Deque<PendingPreload>::const_iterator it = m_pendingPreloads.begin(); it != dequeEnd; ++it) {
    1062         PendingPreload pendingPreload = *it;
     1055    for (auto& pendingPreload : m_pendingPreloads) {
    10631056        if (pendingPreload.m_request.resourceRequest().url() == url)
    10641057            return true;
     
    10981091    unsigned images = 0;
    10991092    unsigned imageMisses = 0;
    1100     ListHashSet<CachedResource*>::iterator end = m_preloads.end();
    1101     for (ListHashSet<CachedResource*>::iterator it = m_preloads.begin(); it != end; ++it) {
    1102         CachedResource* res = *it;
    1103         if (res->preloadResult() == CachedResource::PreloadNotReferenced)
    1104             printf("!! UNREFERENCED PRELOAD %s\n", res->url().latin1().data());
    1105         else if (res->preloadResult() == CachedResource::PreloadReferencedWhileComplete)
    1106             printf("HIT COMPLETE PRELOAD %s\n", res->url().latin1().data());
    1107         else if (res->preloadResult() == CachedResource::PreloadReferencedWhileLoading)
    1108             printf("HIT LOADING PRELOAD %s\n", res->url().latin1().data());
     1093    for (auto& resource : m_preloads) {
     1094        if (resource->preloadResult() == CachedResource::PreloadNotReferenced)
     1095            printf("!! UNREFERENCED PRELOAD %s\n", resource->url().latin1().data());
     1096        else if (resource->preloadResult() == CachedResource::PreloadReferencedWhileComplete)
     1097            printf("HIT COMPLETE PRELOAD %s\n", resource->url().latin1().data());
     1098        else if (resource->preloadResult() == CachedResource::PreloadReferencedWhileLoading)
     1099            printf("HIT LOADING PRELOAD %s\n", resource->url().latin1().data());
    11091100       
    1110         if (res->type() == CachedResource::Script) {
     1101        if (resource->type() == CachedResource::Script) {
    11111102            scripts++;
    1112             if (res->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
     1103            if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
    11131104                scriptMisses++;
    1114         } else if (res->type() == CachedResource::CSSStyleSheet) {
     1105        } else if (resource->type() == CachedResource::CSSStyleSheet) {
    11151106            stylesheets++;
    1116             if (res->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
     1107            if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
    11171108                stylesheetMisses++;
    11181109        } else {
    11191110            images++;
    1120             if (res->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
     1111            if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading)
    11211112                imageMisses++;
    11221113        }
    11231114       
    1124         if (res->errorOccurred())
    1125             MemoryCache::singleton().remove(res);
     1115        if (resource->errorOccurred())
     1116            MemoryCache::singleton().remove(resource);
    11261117       
    1127         res->decreasePreloadCount();
     1118        resource->decreasePreloadCount();
    11281119    }
    11291120    m_preloads = nullptr;
  • trunk/Source/WebCore/loader/icon/IconDatabase.cpp

    r188931 r190338  
    191191        // Clear the IconRecords for every page URL - RefCounting will cause the IconRecords themselves to be deleted
    192192        // We don't delete the actual PageRecords because we have the "retain icon for url" count to keep track of
    193         HashMap<String, PageURLRecord*>::iterator iter = m_pageURLToRecordMap.begin();
    194         HashMap<String, PageURLRecord*>::iterator end = m_pageURLToRecordMap.end();
    195         for (; iter != end; ++iter)
    196             (*iter).value->setIconRecord(0);
    197            
     193        for (auto& pageURL : m_pageURLToRecordMap.values())
     194            pageURL->setIconRecord(nullptr);
     195
    198196        // Clear the iconURL -> IconRecord map
    199197        m_iconURLToRecordMap.clear();
     
    586584        scheduleOrDeferSyncTimer();
    587585
    588         for (unsigned i = 0; i < pageURLs.size(); ++i) {
     586        for (auto& pageURL : pageURLs) {
    589587            AutodrainedPool pool;
    590588
    591             LOG(IconDatabase, "Dispatching notification that retaining pageURL %s has a new icon", urlForLogging(pageURLs[i]).ascii().data());
    592             m_client->didChangeIconForPageURL(pageURLs[i]);
     589            LOG(IconDatabase, "Dispatching notification that retaining pageURL %s has a new icon", urlForLogging(pageURL).ascii().data());
     590            m_client->didChangeIconForPageURL(pageURL);
    593591        }
    594592    }
     
    776774    LockHolder locker(m_urlAndIconLock);
    777775    size_t result = 0;
    778    
    779     HashMap<String, IconRecord*>::iterator i = m_iconURLToRecordMap.begin();
    780     HashMap<String, IconRecord*>::iterator end = m_iconURLToRecordMap.end();
    781    
    782     for (; i != end; ++i)
    783         result += ((*i).value->imageDataStatus() == ImageDataStatusPresent);
    784            
     776
     777    for (auto& iconRecord : m_iconURLToRecordMap.values())
     778        result += (iconRecord->imageDataStatus() == ImageDataStatusPresent);
     779
    785780    return result;
    786781}
     
    817812    ASSERT(m_iconURLImportComplete);
    818813    LOG(IconDatabase, "Notifying all DocumentLoaders that were waiting on a load decision for their icons");
    819    
    820     HashSet<RefPtr<DocumentLoader>>::iterator i = m_loadersPendingDecision.begin();
    821     HashSet<RefPtr<DocumentLoader>>::iterator end = m_loadersPendingDecision.end();
    822    
    823     for (; i != end; ++i)
    824         if ((*i)->refCount() > 1)
    825             (*i)->iconLoadDecisionAvailable();
    826            
     814       
     815    for (auto& loader : m_loadersPendingDecision) {
     816        if (loader->refCount() > 1)
     817            loader->iconLoadDecisionAvailable();
     818    }
     819
    827820    m_loadersPendingDecision.clear();
    828821}
     
    12891282        performPendingRetainAndReleaseOperations();
    12901283
    1291         for (unsigned i = 0; i < urls.size(); ++i) {
    1292             if (!m_retainedPageURLs.contains(urls[i])) {
    1293                 PageURLRecord* record = m_pageURLToRecordMap.get(urls[i]);
     1284        for (auto& url : urls) {
     1285            if (!m_retainedPageURLs.contains(url)) {
     1286                PageURLRecord* record = m_pageURLToRecordMap.get(url);
    12941287                if (record && !databaseCleanupCounter) {
    1295                     m_pageURLToRecordMap.remove(urls[i]);
     1288                    m_pageURLToRecordMap.remove(url);
    12961289                    IconRecord* iconRecord = record->iconRecord();
    12971290                   
     
    13031296                        {
    13041297                            LockHolder locker(m_pendingReadingLock);
    1305                             m_pageURLsInterestedInIcons.remove(urls[i]);
     1298                            m_pageURLsInterestedInIcons.remove(url);
    13061299                            m_iconsPendingReading.remove(iconRecord);
    13071300                        }
     
    13151308                }
    13161309            } else {
    1317                 urlsToNotify.append(urls[i]);
     1310                urlsToNotify.append(url);
    13181311            }
    13191312        }
     
    13221315    LOG(IconDatabase, "Notifying %lu interested page URLs that their icon URL is known due to the import", static_cast<unsigned long>(urlsToNotify.size()));
    13231316    // Now that we don't hold any locks, perform the actual notifications
    1324     for (unsigned i = 0; i < urlsToNotify.size(); ++i) {
     1317    for (auto& url : urlsToNotify) {
    13251318        AutodrainedPool pool;
    13261319
    1327         LOG(IconDatabase, "Notifying icon info known for pageURL %s", urlsToNotify[i].ascii().data());
    1328         dispatchDidImportIconURLForPageURLOnMainThread(urlsToNotify[i]);
     1320        LOG(IconDatabase, "Notifying icon info known for pageURL %s", url.ascii().data());
     1321        dispatchDidImportIconURLForPageURLOnMainThread(url);
    13291322        if (shouldStopThreadActivity())
    13301323            return;
     
    14661459    }
    14671460
    1468     for (HashCountedSet<String>::const_iterator it = toRetain.begin(), end = toRetain.end(); it != end; ++it) {
    1469         ASSERT(!it->key.impl() || it->key.impl()->hasOneRef());
    1470         performRetainIconForPageURL(it->key, it->value);
    1471     }
    1472 
    1473     for (HashCountedSet<String>::const_iterator it = toRelease.begin(), end = toRelease.end(); it != end; ++it) {
    1474         ASSERT(!it->key.impl() || it->key.impl()->hasOneRef());
    1475         performReleaseIconForPageURL(it->key, it->value);
     1461    for (auto& entry : toRetain) {
     1462        ASSERT(!entry.key.impl() || entry.key.impl()->hasOneRef());
     1463        performRetainIconForPageURL(entry.key, entry.value);
     1464    }
     1465
     1466    for (auto& entry : toRelease) {
     1467        ASSERT(!entry.key.impl() || entry.key.impl()->hasOneRef());
     1468        performReleaseIconForPageURL(entry.key, entry.value);
    14761469    }
    14771470}
     
    15291522                    }
    15301523                   
    1531                     HashSet<String>::const_iterator iter = outerHash->begin();
    1532                     HashSet<String>::const_iterator end = outerHash->end();
    1533                     for (; iter != end; ++iter) {
    1534                         if (innerHash->contains(*iter)) {
    1535                             LOG(IconDatabase, "%s is interested in the icon we just read. Adding it to the notification list and removing it from the interested set", urlForLogging(*iter).ascii().data());
    1536                             urlsToNotify.add(*iter);
     1524                    for (auto& outer : *outerHash) {
     1525                        if (innerHash->contains(outer)) {
     1526                            LOG(IconDatabase, "%s is interested in the icon we just read. Adding it to the notification list and removing it from the interested set", urlForLogging(outer).ascii().data());
     1527                            urlsToNotify.add(outer);
    15371528                        }
    15381529                       
     
    15461537                        m_pageURLsInterestedInIcons.clear();
    15471538                    else {
    1548                         iter = urlsToNotify.begin();
    1549                         end = urlsToNotify.end();
    1550                         for (; iter != end; ++iter)
    1551                             m_pageURLsInterestedInIcons.remove(*iter);
     1539                        for (auto& url : urlsToNotify)
     1540                            m_pageURLsInterestedInIcons.remove(url);
    15521541                    }
    15531542                }
     
    16131602        syncTransaction.begin();
    16141603
    1615         for (unsigned i = 0; i < iconSnapshots.size(); ++i) {
    1616             writeIconSnapshotToSQLDatabase(iconSnapshots[i]);
    1617             LOG(IconDatabase, "Wrote IconRecord for IconURL %s with timeStamp of %i to the DB", urlForLogging(iconSnapshots[i].iconURL()).ascii().data(), iconSnapshots[i].timestamp());
    1618         }
    1619 
    1620         for (unsigned i = 0; i < pageSnapshots.size(); ++i) {
     1604        for (auto& snapshot : iconSnapshots) {
     1605            writeIconSnapshotToSQLDatabase(snapshot);
     1606            LOG(IconDatabase, "Wrote IconRecord for IconURL %s with timeStamp of %i to the DB", urlForLogging(snapshot.iconURL()).ascii().data(), snapshot.timestamp());
     1607        }
     1608
     1609        for (auto& snapshot : pageSnapshots) {
    16211610            // If the icon URL is empty, this page is meant to be deleted
    16221611            // ASSERTs are sanity checks to make sure the mappings exist if they should and don't if they shouldn't
    1623             if (pageSnapshots[i].iconURL().isEmpty())
    1624                 removePageURLFromSQLDatabase(pageSnapshots[i].pageURL());
     1612            if (snapshot.iconURL().isEmpty())
     1613                removePageURLFromSQLDatabase(snapshot.pageURL());
    16251614            else
    1626                 setIconURLForPageURLInSQLDatabase(pageSnapshots[i].iconURL(), pageSnapshots[i].pageURL());
    1627             LOG(IconDatabase, "Committed IconURL for PageURL %s to database", urlForLogging(pageSnapshots[i].pageURL()).ascii().data());
     1615                setIconURLForPageURLInSQLDatabase(snapshot.iconURL(), snapshot.pageURL());
     1616            LOG(IconDatabase, "Committed IconURL for PageURL %s to database", urlForLogging(snapshot.pageURL()).ascii().data());
    16281617        }
    16291618
Note: See TracChangeset for help on using the changeset viewer.