Commit b00be861 authored by beidson@apple.com's avatar beidson@apple.com

WebCore:

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

        Reviewed by Mark Rowe

        Part of the continued push to move WebArchive-related code down to WebCore, this
        moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource()

        * WebCore.base.exp:
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::subresource): Create an ArchiveResource from a CachedResource if it exists
          Otherwise, fallback to an ArchiveResource from the current Archive if any.  Otherwise, return null
        * loader/DocumentLoader.h:

        * loader/archive/ArchiveResource.cpp:
        (WebCore::ArchiveResource::create):
        (WebCore::ArchiveResource::ArchiveResource):
        * loader/archive/ArchiveResource.h:

WebKit/mac:

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

        Reviewed by Mark Rowe

        Part of the continued push to move WebArchive-related code down to WebCore, this
        moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource()

        * WebView/WebDataSource.mm:
        (-[WebDataSource subresourceForURL:]): Call through to the DocumentLoader 

        * WebView/WebFrame.mm: Remove [WebFrame _getData:andResponse:forURL:], as its only use
          has now been ported down to WebCore
        * WebView/WebFrameInternal.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d668403d
2008-03-26 Brady Eidson <beidson@apple.com>
Reviewed by Mark Rowe
Part of the continued push to move WebArchive-related code down to WebCore, this
moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource()
* WebCore.base.exp:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::subresource): Create an ArchiveResource from a CachedResource if it exists
Otherwise, fallback to an ArchiveResource from the current Archive if any. Otherwise, return null
* loader/DocumentLoader.h:
* loader/archive/ArchiveResource.cpp:
(WebCore::ArchiveResource::create):
(WebCore::ArchiveResource::ArchiveResource):
* loader/archive/ArchiveResource.h:
2008-03-26 Sam Weinig <sam@webkit.org>
Fix Gtk+ build.
......@@ -265,6 +265,7 @@ __ZN7WebCore13KeyboardEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowERKNS_6StringE
__ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE
__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE
__ZN7WebCore14DocumentLoader11subresourceERKNS_4KURLE
__ZN7WebCore14DocumentLoader13attachToFrameEv
__ZN7WebCore14DocumentLoader15detachFromFrameEv
__ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
......
......@@ -465,6 +465,22 @@ void DocumentLoader::addArchiveResource(PassRefPtr<ArchiveResource> resource)
m_archiveResourceCollection->addResource(resource);
}
PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url)
{
if (!isCommitted())
return 0;
Document* doc = m_frame->document();
if (!doc)
return archiveResourceForURL(url);
CachedResource* resource = doc->docLoader()->cachedResource(url);
if (!resource)
return archiveResourceForURL(url);
return ArchiveResource::create(resource->data(), url, resource->response());
}
ArchiveResource* DocumentLoader::archiveResourceForURL(const KURL& url)
{
if (!m_archiveResourceCollection)
......
......@@ -122,7 +122,13 @@ namespace WebCore {
void addAllArchiveResources(Archive*);
void addArchiveResource(PassRefPtr<ArchiveResource>);
// Return an ArchiveResource for the URL, either creating from live data or
// pulling from the ArchiveResourceCollection
PassRefPtr<ArchiveResource> subresource(const KURL&);
// Return the ArchiveResource for the URL only when loading an Archive
ArchiveResource* archiveResourceForURL(const KURL&);
PassRefPtr<Archive> popArchiveForSubframe(const String& frameName);
void clearArchiveResources();
void setParsedArchiveData(PassRefPtr<SharedBuffer>);
......
......@@ -33,6 +33,11 @@
namespace WebCore {
PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response)
{
return adoptRef(new ArchiveResource(data, url, response));
}
PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName)
{
return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName));
......@@ -43,6 +48,15 @@ PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> dat
return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, resourceResponse));
}
ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response)
: m_data(data)
, m_url(url)
, m_mimeType(response.mimeType())
, m_textEncoding(response.textEncodingName())
, m_response(response)
{
}
ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName)
: m_data(data)
, m_url(url)
......
......@@ -40,6 +40,7 @@ namespace WebCore {
class ArchiveResource : public RefCounted<ArchiveResource> {
public:
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&);
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName);
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
......@@ -55,6 +56,7 @@ public:
bool shouldIgnoreWhenUnarchiving() const { return m_shouldIgnoreWhenUnarchiving; }
private:
ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&);
ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName);
ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
......
2008-03-26 Brady Eidson <beidson@apple.com>
Reviewed by Mark Rowe
Part of the continued push to move WebArchive-related code down to WebCore, this
moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource()
* WebView/WebDataSource.mm:
(-[WebDataSource subresourceForURL:]): Call through to the DocumentLoader
* WebView/WebFrame.mm: Remove [WebFrame _getData:andResponse:forURL:], as its only use
has now been ported down to WebCore
* WebView/WebFrameInternal.h:
2008-03-26 Mark Rowe <mrowe@apple.com>
Rubber-stamped by Brady Eidson.
......
......@@ -482,18 +482,9 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (WebResource *)subresourceForURL:(NSURL *)URL
{
if (!_private->loader->isCommitted())
return nil;
NSData *data;
NSURLResponse *response;
if (![[self webFrame] _getData:&data andResponse:&response forURL:[URL _web_originalDataAsString]]) {
DocumentLoader* loader = [self _documentLoader];
ArchiveResource* coreResource = loader->archiveResourceForURL(URL);
return coreResource ? [[[WebResource alloc] _initWithCoreResource:coreResource] autorelease] : nil;
}
return [[[WebResource alloc] _initWithData:data URL:URL response:response] autorelease];
RefPtr<ArchiveResource> subresource = _private->loader->subresource(URL);
return subresource ? [[[WebResource alloc] _initWithCoreResource:subresource.get()] autorelease] : nil;
}
- (void)addSubresource:(WebResource *)subresource
......
......@@ -970,26 +970,6 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
_private->coreFrame->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation);
}
- (BOOL)_getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)url
{
Document* doc = _private->coreFrame->document();
if (!doc)
return NO;
CachedResource* resource = doc->docLoader()->cachedResource(url);
if (!resource)
return NO;
SharedBuffer* buffer = resource->data();
if (buffer)
*data = [buffer->createNSData() autorelease];
else
*data = nil;
*response = resource->response().nsURLResponse();
return YES;
}
- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses
{
Document* doc = _private->coreFrame->document();
......
......@@ -181,7 +181,6 @@ WebView *getWebView(WebFrame *webFrame);
- (void)_dragSourceMovedTo:(NSPoint)windowLoc;
- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
- (BOOL)_getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)URL;
- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses;
- (BOOL)_canProvideDocumentSource;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment