diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/loader/archive/ArchiveResourceCollection.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/loader/archive/ArchiveResourceCollection.cpp')
-rw-r--r-- | Source/WebCore/loader/archive/ArchiveResourceCollection.cpp | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp b/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp index ac9e377b5..a3705ec77 100644 --- a/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp +++ b/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -29,64 +29,43 @@ #include "config.h" #include "ArchiveResourceCollection.h" -namespace WebCore { +#include "Archive.h" -ArchiveResourceCollection::ArchiveResourceCollection() -{ -} +namespace WebCore { -void ArchiveResourceCollection::addAllResources(Archive* archive) +void ArchiveResourceCollection::addAllResources(Archive& archive) { - ASSERT(archive); - if (!archive) - return; + for (auto& subresource : archive.subresources()) + m_subresources.set(subresource->url(), subresource.ptr()); - const Vector<RefPtr<ArchiveResource>>& subresources = archive->subresources(); - for (Vector<RefPtr<ArchiveResource>>::const_iterator iterator = subresources.begin(); iterator != subresources.end(); ++iterator) - m_subresources.set((*iterator)->url(), iterator->get()); - - const Vector<RefPtr<Archive>>& subframes = archive->subframeArchives(); - for (Vector<RefPtr<Archive>>::const_iterator iterator = subframes.begin(); iterator != subframes.end(); ++iterator) { - RefPtr<Archive> archive = *iterator; - ASSERT(archive->mainResource()); - - const String& frameName = archive->mainResource()->frameName(); - if (!frameName.isNull()) - m_subframes.set(frameName, archive.get()); - else { - // In the MHTML case, frames don't have a name so we use the URL instead. - m_subframes.set(archive->mainResource()->url().string(), archive.get()); + for (auto& subframeArchive : archive.subframeArchives()) { + ASSERT(subframeArchive->mainResource()); + auto frameName = subframeArchive->mainResource()->frameName(); + if (frameName.isNull()) { + // In the MHTML case, frames don't have a name, so we use the URL instead. + frameName = subframeArchive->mainResource()->url().string(); } + m_subframes.set(frameName, subframeArchive.ptr()); } } // FIXME: Adding a resource directly to a DocumentLoader/ArchiveResourceCollection seems like bad design, but is API some apps rely on. // Can we change the design in a manner that will let us deprecate that API without reducing functionality of those apps? -void ArchiveResourceCollection::addResource(PassRefPtr<ArchiveResource> resource) +void ArchiveResourceCollection::addResource(Ref<ArchiveResource>&& resource) { - ASSERT(resource); - if (!resource) - return; - - const URL& url = resource->url(); // get before passing PassRefPtr (which sets it to 0) - m_subresources.set(url, resource); + auto& url = resource->url(); + m_subresources.set(url, WTFMove(resource)); } ArchiveResource* ArchiveResourceCollection::archiveResourceForURL(const URL& url) { - ArchiveResource* resource = m_subresources.get(url); - if (!resource) - return 0; - - return resource; + return m_subresources.get(url); } -PassRefPtr<Archive> ArchiveResourceCollection::popSubframeArchive(const String& frameName, const URL& url) +RefPtr<Archive> ArchiveResourceCollection::popSubframeArchive(const String& frameName, const URL& url) { - RefPtr<Archive> archive = m_subframes.take(frameName); - if (archive) - return archive.release(); - + if (auto archive = m_subframes.take(frameName)) + return archive; return m_subframes.take(url.string()); } |