-
beidson@apple.com authored
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: http://svn.webkit.org/repository/webkit/trunk@31281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
f36a4a19