WebCore:
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2008 17:11:16 +0000 (17:11 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2008 17:11:16 +0000 (17:11 +0000)
commit66d0a54d13d16722f4e06b65f00a5741f39e858b
treedbcd0724156cb14248b7f5613737e84edc1a6ad5
parentfffc2e1deaa1ff9699760b67cfc7466819c39aaf
WebCore:

2008-03-25  Brady Eidson  <beidson@apple.com>

        Reviewed by Darin

        <rdar://problem/4516169> - Support WebArchives on Windows
        And pave the way for many future WebArchive bug fixes and enhancements

        This patch accomplishes two main goals:
        1 - Consolidates much of the spread out WebKitMac archive code into one place in WebCore.  This allows for cleaner refactoring
            in the future as well as adding more archive formats with ease.
        2 - Hooks up WebArchive support on Windows.  Safari-style .webarchive files are nothing more than property lists readable by
            CoreFoundation.  While there are still some outstanding issues, including an NSKeyedArchiver chunk of data for the
            ResourceResponse for each resource, this patch manually parses through the property list on CoreFoundation platforms and
            gets many archives loading on Windows

        My goal for this first cut was zero behavior change.  As such, I went for a direct port of the WebKitMac code.  There will be
        opportunities for redesign and refactoring as followups.

        * WebCore.base.exp:

        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::setupForReplaceByMIMEType): Ported from WebKitMac, WebDataSource
        (WebCore::DocumentLoader::addAllArchiveResources):
        (WebCore::DocumentLoader::addArchiveResource):
        (WebCore::DocumentLoader::archiveResourceForURL):
        (WebCore::DocumentLoader::popArchiveForSubframe):
        (WebCore::DocumentLoader::clearArchiveResources):
        * loader/DocumentLoader.h:

        * loader/FrameLoader.cpp: Moved WebFrameLoaderClient and WebFrame code down into their more appropriate FrameLoader home
        (WebCore::FrameLoader::FrameLoader):
        (WebCore::FrameLoader::setDefersLoading):
        (WebCore::FrameLoader::deliverArchivedResourcesAfterDelay):
        (WebCore::FrameLoader::archiveResourceDeliveryTimerFired):
        (WebCore::FrameLoader::loadURLIntoChildFrame):
        (WebCore::FrameLoader::loadArchive):
        (WebCore::FrameLoader::scheduleArchiveLoad):
        (WebCore::FrameLoader::stopAllLoaders):
        (WebCore::FrameLoader::cancelPendingArchiveLoad):
        (WebCore::FrameLoader::isArchiveLoadPending):
        (WebCore::FrameLoader::finishedLoadingDocument):
        * loader/FrameLoader.h:

        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::load):

        * loader/archive/Archive.h: Generic "Archive of web resources" class that is only useful when subclassed.
            Contains a MainResource, subresources, and Archives for subframes
        (WebCore::Archive::mainResource):
        (WebCore::Archive::subresources):
        (WebCore::Archive::subframeArchives):
        (WebCore::Archive::setMainResource):
        (WebCore::Archive::addSubresource):
        (WebCore::Archive::addSubframeArchive):

        * loader/archive/ArchiveFactory.cpp: A class that will take raw archive data and the MIMEtype, and create the
            appropriate Archive class for it.  Additionally it handles registering the known MIMEtypes for all known archive formats
        (WebCore::archiveFactoryCreate):
        (WebCore::archiveMIMETypes):
        (WebCore::ArchiveFactory::isArchiveMimeType):
        (WebCore::ArchiveFactory::create):
        (WebCore::ArchiveFactory::registerKnownArchiveMIMETypes):
        * loader/archive/ArchiveFactory.h:

        * loader/archive/ArchiveResource.cpp: Analog to "WebResource" in WebKitMac.  Contains the data and other important
            attributes of an archived resource
        (WebCore::ArchiveResource::create):
        (WebCore::ArchiveResource::ArchiveResource):
        (WebCore::ArchiveResource::response):
        * loader/archive/ArchiveResource.h:
        (WebCore::ArchiveResource::data):
        (WebCore::ArchiveResource::url):
        (WebCore::ArchiveResource::mimeType):
        (WebCore::ArchiveResource::textEncoding):
        (WebCore::ArchiveResource::frameName):
        (WebCore::ArchiveResource::ignoreWhenUnarchiving):
        (WebCore::ArchiveResource::shouldIgnoreWhenUnarchiving):

        * loader/archive/ArchiveResourceCollection.cpp: Analog of "WebUnarchivingState" in WebKitMac.  Contains a hash of
            all the resources for every frame in an archive, and contains the archives for each subframe needed to load a multi-frame archive
        (WebCore::ArchiveResourceCollection::ArchiveResourceCollection):
        (WebCore::ArchiveResourceCollection::addAllResources):
        (WebCore::ArchiveResourceCollection::addResource):
        (WebCore::ArchiveResourceCollection::archiveResourceForURL):
        (WebCore::ArchiveResourceCollection::popSubframeArchive):
        * loader/archive/ArchiveResourceCollection.h:

        * loader/archive/cf/LegacyWebArchive.cpp: Subclass of Archive specifically for Webkit's Objective-C based ".webarchive" format.
            Mostly a collection of static methods involved in parsing and serializing a WebKit-style .webarchive.  Is mostly supported
            for any CF platform.
        (WebCore::createPropertyListRepresentationFromResource):
        (WebCore::createPropertyListRep):
        (WebCore::createResourceResponseFromPropertyListData):
        (WebCore::createResource):
        (WebCore::LegacyWebArchive::create):
        (WebCore::LegacyWebArchive::LegacyWebArchive):
        (WebCore::LegacyWebArchive::init):
        (WebCore::LegacyWebArchive::extract):
        (WebCore::LegacyWebArchive::rawDataRepresentation):
        (WebCore::createResourceResponseFromMacArchivedData):
        (WebCore::propertyListDataFromResourceResponse):
        * loader/archive/cf/LegacyWebArchive.h:
        * loader/archive/cf/LegacyWebArchiveMac.mm:
        (WebCore::createResourceResponseFromMacArchivedData):
        (WebCore::propertyListDataFromResourceResponse):

        * platform/network/mac/ResourceRequest.h:
        * platform/network/mac/ResourceRequestMac.mm:
        (WebCore::ResourceRequest::applyWebArchiveHackForMail): Tweak the resource request for Mac clients when loading WebArchives

WebKit:

2008-03-25  Brady Eidson  <beidson@apple.com>

        Reviewed by Darin

        <rdar://problem/4516169> - Support WebArchives on Windows

        * WebKit.xcodeproj/project.pbxproj:

WebKit/mac:

2008-03-25  Brady Eidson  <beidson@apple.com>

        Reviewed by Darin

        <rdar://problem/4516169> - Support WebArchives on Windows
        And paves the way for many future WebArchive bug fixes and enhancements

        This change moves most of the real workhorse code about WebArchives into WebCore.  It maintains
        1-to-1 relationships between a few objects in WebCore and WebKit.  Such as:
         * WebArchive <-> LegacyWebArchive
         * WebResource <-> ArchiveResource
         * WebUnarchivingState <-> ArchiveResourceCollection

        The other biggest changes involve many FrameLoaderClient methods that existed soley for WebArchives
        and now exist in WebCore

        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::clearUnarchivingState): Emptied - to be removed in a followup patch
        (WebFrameLoaderClient::finalSetupForReplace):
        (WebFrameLoaderClient::setDefersLoading):
        (WebFrameLoaderClient::willUseArchive):
        (WebFrameLoaderClient::isArchiveLoadPending):
        (WebFrameLoaderClient::cancelPendingArchiveLoad):
        (WebFrameLoaderClient::clearArchivedResources):
        (WebFrameLoaderClient::createFrame):

        * WebView/WebArchive.mm:
        (+[WebArchivePrivate initialize]):
        (-[WebArchivePrivate init]):
        (-[WebArchivePrivate initWithCoreArchive:]):
        (-[WebArchivePrivate coreArchive]):
        (-[WebArchivePrivate setCoreArchive:]):
        (-[WebArchivePrivate dealloc]):
        (-[WebArchivePrivate finalize]):
        (-[WebArchive init]):
        (-[WebArchive initWithMainResource:subresources:subframeArchives:]):
        (-[WebArchive initWithData:]):
        (-[WebArchive initWithCoder:]):
        (-[WebArchive encodeWithCoder:]):
        (-[WebArchive mainResource]):
        (-[WebArchive subresources]):
        (-[WebArchive subframeArchives]):
        (-[WebArchive data]):
        (-[WebArchive _initWithCoreLegacyWebArchive:WebCore::]):
        (-[WebArchive WebCore::]):
        * WebView/WebArchiveInternal.h: Added.

        * WebView/WebDataSource.mm:
        (-[WebDataSourcePrivate dealloc]):
        (-[WebDataSource _addSubframeArchives:]):
        (-[WebDataSource _documentFragmentWithArchive:]):
        (-[WebDataSource subresourceForURL:]):
        (-[WebDataSource addSubresource:]):
        * WebView/WebDataSourceInternal.h:

        * WebView/WebFrame.mm:
        (-[WebFrame loadArchive:]):
        * WebView/WebFrameInternal.h:

        * WebView/WebHTMLRepresentation.mm:
        (-[WebHTMLRepresentation finishedLoadingWithDataSource:]):

        * WebView/WebResource.mm:
        (+[WebResourcePrivate initialize]):
        (-[WebResourcePrivate init]):
        (-[WebResourcePrivate initWithCoreResource:]):
        (-[WebResourcePrivate dealloc]):
        (-[WebResourcePrivate finalize]):
        (-[WebResource initWithCoder:]):
        (-[WebResource encodeWithCoder:]):
        (-[WebResource data]):
        (-[WebResource URL]):
        (-[WebResource MIMEType]):
        (-[WebResource textEncodingName]):
        (-[WebResource frameName]):
        (-[WebResource _initWithCoreResource:WebCore::]):
        (-[WebResource WebCore::]):
        (-[WebResource _ignoreWhenUnarchiving]):
        (-[WebResource _initWithData:URL:MIMEType:textEncodingName:frameName:response:copyData:]):
        (-[WebResource _fileWrapperRepresentation]):
        (-[WebResource _response]):
        (-[WebResource _stringValue]):
        * WebView/WebResourceInternal.h: Added.
        * WebView/WebResourcePrivate.h:

        * WebView/WebUnarchivingState.h: Removed.
        * WebView/WebUnarchivingState.m: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/loader/DocumentLoader.cpp
WebCore/loader/DocumentLoader.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/ResourceLoader.cpp
WebCore/loader/archive/Archive.h
WebCore/loader/archive/ArchiveFactory.cpp
WebCore/loader/archive/ArchiveFactory.h
WebCore/loader/archive/ArchiveResource.cpp
WebCore/loader/archive/ArchiveResource.h
WebCore/loader/archive/ArchiveResourceCollection.cpp
WebCore/loader/archive/ArchiveResourceCollection.h
WebCore/loader/archive/cf/LegacyWebArchive.cpp
WebCore/loader/archive/cf/LegacyWebArchive.h
WebCore/loader/archive/cf/LegacyWebArchiveMac.mm
WebCore/platform/network/mac/ResourceRequest.h
WebCore/platform/network/mac/ResourceRequestMac.mm
WebKit/ChangeLog
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
WebKit/mac/WebView/WebArchive.mm
WebKit/mac/WebView/WebArchiveInternal.h [moved from WebKit/mac/WebView/WebUnarchivingState.h with 74% similarity]
WebKit/mac/WebView/WebDataSource.mm
WebKit/mac/WebView/WebDataSourceInternal.h
WebKit/mac/WebView/WebFrame.mm
WebKit/mac/WebView/WebFrameInternal.h
WebKit/mac/WebView/WebHTMLRepresentation.mm
WebKit/mac/WebView/WebResource.mm
WebKit/mac/WebView/WebResourceInternal.h [new file with mode: 0644]
WebKit/mac/WebView/WebResourcePrivate.h
WebKit/mac/WebView/WebUnarchivingState.m [deleted file]