https://bugs.webkit.org/show_bug.cgi?id=83055
Reviewed by Adam Barth.
No new tests, no functionality change intended.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::setupForReplaceByMIMEType):
(WebCore::DocumentLoader::maybeCreateArchive): Renamed from
FrameLoader::finishedLoadingDocument(). Returns true if an archive
was created.
(WebCore::DocumentLoader::setArchive):
(WebCore::DocumentLoader::scheduleArchiveLoad):
(WebCore::DocumentLoader::documentURL): Add a check for whether an archive url
should be returned, so that we don't need special handling in Document and
FrameLoader for overriding the document url later.
* loader/DocumentLoader.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::receivedFirstData): Remove archive special cases, since
DocumentLoader::documentURL() will return the right thing for legacy archives
and maybeCreateArchive() will override the base url for mhtml.
(WebCore::FrameLoader::loadArchive):
* loader/FrameLoader.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114016
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-12 Nate Chapin <japhet@chromium.org>
+
+ Move Archive processing to DocumentLoader, instead of FrameLoader.
+ https://bugs.webkit.org/show_bug.cgi?id=83055
+
+ Reviewed by Adam Barth.
+
+ No new tests, no functionality change intended.
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::finishedLoading):
+ (WebCore::DocumentLoader::setupForReplaceByMIMEType):
+ (WebCore::DocumentLoader::maybeCreateArchive): Renamed from
+ FrameLoader::finishedLoadingDocument(). Returns true if an archive
+ was created.
+ (WebCore::DocumentLoader::setArchive):
+ (WebCore::DocumentLoader::scheduleArchiveLoad):
+ (WebCore::DocumentLoader::documentURL): Add a check for whether an archive url
+ should be returned, so that we don't need special handling in Document and
+ FrameLoader for overriding the document url later.
+ * loader/DocumentLoader.h:
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::receivedFirstData): Remove archive special cases, since
+ DocumentLoader::documentURL() will return the right thing for legacy archives
+ and maybeCreateArchive() will override the base url for mhtml.
+ (WebCore::FrameLoader::loadArchive):
+ * loader/FrameLoader.h:
+
2012-04-12 Dmitry Lomov <dslomov@google.com>
REGRESSION (r113233): fast/canvas/webgl/array-message-passing.html crashing on Lion and Snow Leopard bots.
// Appcache uses ResourceHandle directly, DocumentLoader doesn't count these loads.
m_applicationCacheHost->stopLoadingInFrame(m_frame);
+
+#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+ clearArchiveResources();
+#endif
if (!loading) {
// If something above restarted loading we might run into mysterious crashes like
{
m_gotFirstByte = true;
commitIfReady();
- if (!frameLoader())
+ if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
return;
- frameLoader()->finishedLoadingDocument(this);
+ if (!maybeCreateArchive())
+ frameLoader()->client()->finishedLoading(this);
m_writer.end();
- if (!m_mainDocumentError.isNull() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
+ if (!m_mainDocumentError.isNull())
return;
clearMainResourceLoader();
frameLoader()->checkLoadComplete();
commitLoad(resourceData->data(), resourceData->size());
}
- frameLoader()->finishedLoadingDocument(this);
+ maybeCreateArchive();
m_writer.end();
frameLoader()->setReplacing();
return frameLoader()->subframeIsLoading();
}
+bool DocumentLoader::maybeCreateArchive()
+{
+#if !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
+ return false;
+#else
+
+ // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
+ m_archive = ArchiveFactory::create(m_response.url(), mainResourceData().get(), m_response.mimeType());
+ if (!m_archive)
+ return false;
+
+ addAllArchiveResources(m_archive.get());
+ ArchiveResource* mainResource = m_archive->mainResource();
+ m_parsedArchiveData = mainResource->data();
+ m_writer.setMIMEType(mainResource->mimeType());
+
+ ASSERT(m_frame->document());
+ String userChosenEncoding = overrideEncoding();
+ bool encodingIsUserChosen = !userChosenEncoding.isNull();
+ m_writer.setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen);
+ m_writer.addData(mainResource->data()->data(), mainResource->data()->size());
+ return true;
+#endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
+}
+
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+void DocumentLoader::setArchive(PassRefPtr<Archive> archive)
+{
+ m_archive = archive;
+ addAllArchiveResources(m_archive.get());
+}
+
void DocumentLoader::addAllArchiveResources(Archive* archive)
{
if (!m_archiveResourceCollection)
m_substituteResourceDeliveryTimer.stop();
}
-void DocumentLoader::setParsedArchiveData(PassRefPtr<SharedBuffer> data)
-{
- m_parsedArchiveData = data;
-}
-
SharedBuffer* DocumentLoader::parsedArchiveData() const
{
return m_parsedArchiveData.get();
}
}
- Archive* archive = frameLoader()->archive();
- if (!archive)
+ if (!m_archive)
return false;
- switch (archive->type()) {
+ switch (m_archive->type()) {
#if ENABLE(WEB_ARCHIVE)
case Archive::WebArchive:
// WebArchiveDebugMode means we fail loads instead of trying to fetch them from the network if they're not in the archive.
KURL DocumentLoader::documentURL() const
{
KURL url = substituteData().responseURL();
+#if ENABLE(WEB_ARCHIVE)
+ if (url.isEmpty() && m_archive && m_archive->type() == Archive::WebArchive)
+ url = m_archive->mainResource()->url();
+#endif
if (url.isEmpty())
url = requestURL();
if (url.isEmpty())
#endif
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+ Archive* archive() const { return m_archive.get(); }
+ void setArchive(PassRefPtr<Archive>);
void addAllArchiveResources(Archive*);
void addArchiveResource(PassRefPtr<ArchiveResource>);
-
PassRefPtr<Archive> popArchiveForSubframe(const String& frameName, const KURL&);
- void clearArchiveResources();
- void setParsedArchiveData(PassRefPtr<SharedBuffer>);
SharedBuffer* parsedArchiveData() const;
-
+
bool scheduleArchiveLoad(ResourceLoader*, const ResourceRequest&, const KURL&);
#endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
bool doesProgressiveLoad(const String& MIMEType) const;
void checkLoadComplete();
void clearMainResourceLoader();
+
+ bool maybeCreateArchive();
+#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+ void clearArchiveResources();
+#endif
void deliverSubstituteResourcesAfterDelay();
void substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*);
OwnPtr<ArchiveResourceCollection> m_archiveResourceCollection;
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+ RefPtr<Archive> m_archive;
RefPtr<SharedBuffer> m_parsedArchiveData;
#endif
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
#include "Archive.h"
-#include "ArchiveFactory.h"
#endif
namespace WebCore {
void FrameLoader::receivedFirstData()
{
KURL workingURL = activeDocumentLoader()->documentURL();
-#if ENABLE(WEB_ARCHIVE)
- // FIXME: The document loader, not the frame loader, should be in charge of loading web archives.
- // Once this is done, we can just make DocumentLoader::documentURL() return the right URL
- // based on whether it has a non-null archive or not.
- if (m_archive && activeDocumentLoader()->parsedArchiveData())
- workingURL = m_archive->mainResource()->url();
-#endif
-
activeDocumentLoader()->writer()->begin(workingURL, false);
activeDocumentLoader()->writer()->setDocumentWasLoadedAsPartOfNavigation();
#if ENABLE(MHTML)
- if (m_archive) {
- // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
- // relative URLs are resolved properly.
- m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url());
- }
+ // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
+ // relative URLs are resolved properly.
+ if (activeDocumentLoader()->archive() && activeDocumentLoader()->archive()->type() == Archive::MHTML)
+ m_frame->document()->setBaseURLOverride(activeDocumentLoader()->archive()->mainResource()->url());
#endif
dispatchDidCommitLoad();
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
void FrameLoader::loadArchive(PassRefPtr<Archive> archive)
{
- m_archive = archive;
-
- ArchiveResource* mainResource = m_archive->mainResource();
+ ArchiveResource* mainResource = archive->mainResource();
ASSERT(mainResource);
if (!mainResource)
return;
#endif
RefPtr<DocumentLoader> documentLoader = m_client->createDocumentLoader(request, substituteData);
- documentLoader->addAllArchiveResources(m_archive.get());
+ documentLoader->setArchive(archive.get());
load(documentLoader.get());
}
#endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
m_documentLoader->stopLoading();
setProvisionalDocumentLoader(0);
-
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
- if (m_documentLoader)
- m_documentLoader->clearArchiveResources();
-#endif
m_checkTimer.stop();
return page && m_frame == page->mainFrame();
}
-void FrameLoader::finishedLoadingDocument(DocumentLoader* loader)
-{
- if (m_stateMachine.creatingInitialEmptyDocument())
- return;
-
-#if !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
- m_client->finishedLoading(loader);
-#else
- // Give archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
- m_archive = ArchiveFactory::create(loader->response().url(), loader->mainResourceData().get(), loader->responseMIMEType());
- if (!m_archive) {
- m_client->finishedLoading(loader);
- return;
- }
-
- // FIXME: The remainder of this function should be moved to DocumentLoader.
-
- loader->addAllArchiveResources(m_archive.get());
-
- ArchiveResource* mainResource = m_archive->mainResource();
- loader->setParsedArchiveData(mainResource->data());
-
- loader->writer()->setMIMEType(mainResource->mimeType());
-
- closeURL();
- didOpenURL();
-
- ASSERT(m_frame->document());
- String userChosenEncoding = documentLoader()->overrideEncoding();
- bool encodingIsUserChosen = !userChosenEncoding.isNull();
- loader->writer()->setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen);
- loader->writer()->addData(mainResource->data()->data(), mainResource->data()->size());
-#endif // ENABLE(WEB_ARCHIVE)
-}
-
bool FrameLoader::isReplacing() const
{
return m_loadType == FrameLoadTypeReplace;
bool isHostedByObjectElement() const;
bool isLoadingMainFrame() const;
- void finishedLoadingDocument(DocumentLoader*);
bool isReplacing() const;
void setReplacing();
bool subframeIsLoading() const;
NetworkingContext* networkingContext() const;
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
- Archive* archive() const { return m_archive.get(); }
-#endif
-
private:
bool allChildrenAreComplete() const; // immediate children, not all descendants
RefPtr<FrameNetworkingContext> m_networkingContext;
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
- RefPtr<Archive> m_archive;
-#endif
-
KURL m_previousUrl;
RefPtr<HistoryItem> m_requestedHistoryItem;
};