Unreviewed, rolling out r113526.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Apr 2012 03:28:38 +0000 (03:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Apr 2012 03:28:38 +0000 (03:28 +0000)
http://trac.webkit.org/changeset/113526
https://bugs.webkit.org/show_bug.cgi?id=83417

speculative rollout for broken chrome browser_test (Requested
by simonjam on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-04-06

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::setupForReplaceByMIMEType):
(WebCore):
(WebCore::DocumentLoader::setParsedArchiveData):
(WebCore::DocumentLoader::scheduleArchiveLoad):
(WebCore::DocumentLoader::documentURL):
* loader/DocumentLoader.h:
(DocumentLoader):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::receivedFirstData):
(WebCore::FrameLoader::loadArchive):
(WebCore::FrameLoader::stopAllLoaders):
(WebCore::FrameLoader::finishedLoadingDocument):
(WebCore):
* loader/FrameLoader.h:
(FrameLoader):
(WebCore::FrameLoader::archive):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h

index df904d9..2bc092a 100644 (file)
@@ -1,3 +1,32 @@
+2012-04-06  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r113526.
+        http://trac.webkit.org/changeset/113526
+        https://bugs.webkit.org/show_bug.cgi?id=83417
+
+        speculative rollout for broken chrome browser_test (Requested
+        by simonjam on #webkit).
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::finishedLoading):
+        (WebCore::DocumentLoader::setupForReplaceByMIMEType):
+        (WebCore):
+        (WebCore::DocumentLoader::setParsedArchiveData):
+        (WebCore::DocumentLoader::scheduleArchiveLoad):
+        (WebCore::DocumentLoader::documentURL):
+        * loader/DocumentLoader.h:
+        (DocumentLoader):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::receivedFirstData):
+        (WebCore::FrameLoader::loadArchive):
+        (WebCore::FrameLoader::stopAllLoaders):
+        (WebCore::FrameLoader::finishedLoadingDocument):
+        (WebCore):
+        * loader/FrameLoader.h:
+        (FrameLoader):
+        (WebCore::FrameLoader::archive):
+
 2012-04-06  James Robinson  <jamesr@chromium.org>
 
         [chromium] Avoid deleting impl tree when becoming invisible
index 4980083..d76861c 100644 (file)
@@ -225,10 +225,6 @@ void DocumentLoader::stopLoading()
 
     // 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 
@@ -286,12 +282,11 @@ void DocumentLoader::finishedLoading()
 {
     m_gotFirstByte = true;   
     commitIfReady();
-    if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
+    if (!frameLoader())
         return;
-    if (!maybeCreateArchive())
-        frameLoader()->client()->finishedLoading(this);
+    frameLoader()->finishedLoadingDocument(this);
     m_writer.end();
-    if (!m_mainDocumentError.isNull())
+    if (!m_mainDocumentError.isNull() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
         return;
     clearMainResourceLoader();
     frameLoader()->checkLoadComplete();
@@ -355,7 +350,7 @@ void DocumentLoader::setupForReplaceByMIMEType(const String& newMIMEType)
         commitLoad(resourceData->data(), resourceData->size());
     }
     
-    maybeCreateArchive();
+    frameLoader()->finishedLoadingDocument(this);
     m_writer.end();
     
     frameLoader()->setReplacing();
@@ -444,46 +439,7 @@ bool DocumentLoader::isLoadingInAPISense() const
     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);
-
-#if ENABLE(MHTML)
-    // 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 (m_archive->type() == Archive::MHTML)
-        m_frame->document()->setBaseURLOverride(mainResource->url());
-#endif
-
-    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)
@@ -521,6 +477,11 @@ void DocumentLoader::clearArchiveResources()
     m_substituteResourceDeliveryTimer.stop();
 }
 
+void DocumentLoader::setParsedArchiveData(PassRefPtr<SharedBuffer> data)
+{
+    m_parsedArchiveData = data;
+}
+
 SharedBuffer* DocumentLoader::parsedArchiveData() const
 {
     return m_parsedArchiveData.get();
@@ -666,10 +627,11 @@ bool DocumentLoader::scheduleArchiveLoad(ResourceLoader* loader, const ResourceR
         }
     }
 
-    if (!m_archive)
+    Archive* archive = frameLoader()->archive();
+    if (!archive)
         return false;
 
-    switch (m_archive->type()) {
+    switch (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.
@@ -742,10 +704,6 @@ const KURL& DocumentLoader::responseURL() const
 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())
index b0b50ea..3b1fb12 100644 (file)
@@ -132,12 +132,14 @@ namespace WebCore {
 #endif
 
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
-        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)
 
@@ -255,11 +257,6 @@ namespace WebCore {
         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>*);
@@ -329,7 +326,6 @@ namespace WebCore {
 
         OwnPtr<ArchiveResourceCollection> m_archiveResourceCollection;
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
-        RefPtr<Archive> m_archive;
         RefPtr<SharedBuffer> m_parsedArchiveData;
 #endif
 
index 2d64671..3cc9b78 100644 (file)
 
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
 #include "Archive.h"
+#include "ArchiveFactory.h"
 #endif
 
 namespace WebCore {
@@ -564,9 +565,25 @@ void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, boo
 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());
+    }
+#endif
+
     dispatchDidCommitLoad();
     dispatchDidClearWindowObjectsInAllWorlds();
 
@@ -812,7 +829,9 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
 void FrameLoader::loadArchive(PassRefPtr<Archive> archive)
 {
-    ArchiveResource* mainResource = archive->mainResource();
+    m_archive = archive;
+    
+    ArchiveResource* mainResource = m_archive->mainResource();
     ASSERT(mainResource);
     if (!mainResource)
         return;
@@ -825,7 +844,7 @@ void FrameLoader::loadArchive(PassRefPtr<Archive> archive)
 #endif
 
     RefPtr<DocumentLoader> documentLoader = m_client->createDocumentLoader(request, substituteData);
-    documentLoader->setArchive(archive.get());
+    documentLoader->addAllArchiveResources(m_archive.get());
     load(documentLoader.get());
 }
 #endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
@@ -1526,6 +1545,11 @@ void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItem
         m_documentLoader->stopLoading();
 
     setProvisionalDocumentLoader(0);
+    
+#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+    if (m_documentLoader)
+        m_documentLoader->clearArchiveResources();
+#endif
 
     m_checkTimer.stop();
 
@@ -1977,6 +2001,41 @@ bool FrameLoader::isLoadingMainFrame() const
     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;
index ed378ae..6fbe41b 100644 (file)
@@ -160,6 +160,7 @@ public:
     bool isHostedByObjectElement() const;
     bool isLoadingMainFrame() const;
 
+    void finishedLoadingDocument(DocumentLoader*);
     bool isReplacing() const;
     void setReplacing();
     bool subframeIsLoading() const;
@@ -283,6 +284,10 @@ public:
 
     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
 
@@ -427,6 +432,10 @@ private:
 
     RefPtr<FrameNetworkingContext> m_networkingContext;
 
+#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
+    RefPtr<Archive> m_archive;
+#endif
+
     KURL m_previousUrl;
     RefPtr<HistoryItem> m_requestedHistoryItem;
 };