Changeset 31355

Show
Ignore:
Timestamp:
03/26/08 20:58:19 (8 months ago)
Author:
beidson@apple.com
Message:

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 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 subresourceForURL: down to DocumentLoader->subresource()

  • WebView/WebDataSource.mm: (-subresourceForURL:): Call through to the DocumentLoader
  • WebView/WebFrame.mm: Remove _getData:andResponse:forURL:, as its only use has now been ported down to WebCore
  • WebView/WebFrameInternal.h:
Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31354 r31355  
     12008-03-26  Brady Eidson  <beidson@apple.com> 
     2 
     3        Reviewed by Mark Rowe 
     4 
     5        Part of the continued push to move WebArchive-related code down to WebCore, this 
     6        moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource() 
     7 
     8        * WebCore.base.exp: 
     9        * loader/DocumentLoader.cpp: 
     10        (WebCore::DocumentLoader::subresource): Create an ArchiveResource from a CachedResource if it exists 
     11          Otherwise, fallback to an ArchiveResource from the current Archive if any.  Otherwise, return null 
     12        * loader/DocumentLoader.h: 
     13 
     14        * loader/archive/ArchiveResource.cpp: 
     15        (WebCore::ArchiveResource::create): 
     16        (WebCore::ArchiveResource::ArchiveResource): 
     17        * loader/archive/ArchiveResource.h: 
     18 
    1192008-03-26  Sam Weinig  <sam@webkit.org> 
    220 
  • trunk/WebCore/WebCore.base.exp

    r31316 r31355  
    266266__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow 
    267267__ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE 
     268__ZN7WebCore14DocumentLoader11subresourceERKNS_4KURLE 
    268269__ZN7WebCore14DocumentLoader13attachToFrameEv 
    269270__ZN7WebCore14DocumentLoader15detachFromFrameEv 
  • trunk/WebCore/loader/DocumentLoader.cpp

    r31293 r31355  
    466466} 
    467467 
     468PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) 
     469{ 
     470    if (!isCommitted()) 
     471        return 0; 
     472     
     473    Document* doc = m_frame->document(); 
     474    if (!doc) 
     475        return archiveResourceForURL(url); 
     476         
     477    CachedResource* resource = doc->docLoader()->cachedResource(url); 
     478    if (!resource) 
     479        return archiveResourceForURL(url); 
     480         
     481    return ArchiveResource::create(resource->data(), url, resource->response()); 
     482} 
     483 
    468484ArchiveResource* DocumentLoader::archiveResourceForURL(const KURL& url) 
    469485{ 
  • trunk/WebCore/loader/DocumentLoader.h

    r31293 r31355  
    123123        void addAllArchiveResources(Archive*); 
    124124        void addArchiveResource(PassRefPtr<ArchiveResource>); 
     125         
     126        // Return an ArchiveResource for the URL, either creating from live data or 
     127        // pulling from the ArchiveResourceCollection 
     128        PassRefPtr<ArchiveResource> subresource(const KURL&); 
     129        // Return the ArchiveResource for the URL only when loading an Archive 
    125130        ArchiveResource* archiveResourceForURL(const KURL&); 
     131         
    126132        PassRefPtr<Archive> popArchiveForSubframe(const String& frameName); 
    127133        void clearArchiveResources(); 
  • trunk/WebCore/loader/archive/ArchiveResource.cpp

    r31281 r31355  
    3434namespace WebCore { 
    3535 
     36PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response) 
     37{ 
     38    return adoptRef(new ArchiveResource(data, url, response)); 
     39} 
     40 
    3641PassRefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const KURL& url, const String& mimeType, const String& textEncoding, const String& frameName) 
    3742{ 
     
    4247{ 
    4348    return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, resourceResponse)); 
     49} 
     50 
     51ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const KURL& url, const ResourceResponse& response) 
     52    : m_data(data) 
     53    , m_url(url) 
     54    , m_mimeType(response.mimeType()) 
     55    , m_textEncoding(response.textEncodingName()) 
     56    , m_response(response) 
     57{ 
    4458} 
    4559 
  • trunk/WebCore/loader/archive/ArchiveResource.h

    r31281 r31355  
    4141class ArchiveResource : public RefCounted<ArchiveResource> { 
    4242public: 
     43    static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&); 
    4344    static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName); 
    4445    static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&); 
     
    5657 
    5758private: 
     59    ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&); 
    5860    ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName); 
    5961    ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&); 
  • trunk/WebKit/mac/ChangeLog

    r31353 r31355  
     12008-03-26  Brady Eidson  <beidson@apple.com> 
     2 
     3        Reviewed by Mark Rowe 
     4 
     5        Part of the continued push to move WebArchive-related code down to WebCore, this 
     6        moves [WebDataSource subresourceForURL:] down to DocumentLoader->subresource() 
     7 
     8        * WebView/WebDataSource.mm: 
     9        (-[WebDataSource subresourceForURL:]): Call through to the DocumentLoader  
     10 
     11        * WebView/WebFrame.mm: Remove [WebFrame _getData:andResponse:forURL:], as its only use 
     12          has now been ported down to WebCore 
     13        * WebView/WebFrameInternal.h: 
     14 
    1152008-03-26  Mark Rowe  <mrowe@apple.com> 
    216 
  • trunk/WebKit/mac/WebView/WebDataSource.mm

    r31281 r31355  
    483483- (WebResource *)subresourceForURL:(NSURL *)URL 
    484484{ 
    485     if (!_private->loader->isCommitted()) 
    486         return nil; 
    487  
    488     NSData *data; 
    489     NSURLResponse *response; 
    490     if (![[self webFrame] _getData:&data andResponse:&response forURL:[URL _web_originalDataAsString]]) { 
    491         DocumentLoader* loader = [self _documentLoader]; 
    492         ArchiveResource* coreResource = loader->archiveResourceForURL(URL); 
    493         return coreResource ? [[[WebResource alloc] _initWithCoreResource:coreResource] autorelease] : nil; 
    494     } 
    495  
    496     return [[[WebResource alloc] _initWithData:data URL:URL response:response] autorelease]; 
     485    RefPtr<ArchiveResource> subresource = _private->loader->subresource(URL); 
     486     
     487    return subresource ? [[[WebResource alloc] _initWithCoreResource:subresource.get()] autorelease] : nil; 
    497488} 
    498489 
  • trunk/WebKit/mac/WebView/WebFrame.mm

    r31281 r31355  
    971971} 
    972972 
    973 - (BOOL)_getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)url 
    974 { 
    975     Document* doc = _private->coreFrame->document(); 
    976     if (!doc) 
    977         return NO; 
    978  
    979     CachedResource* resource = doc->docLoader()->cachedResource(url); 
    980     if (!resource) 
    981         return NO; 
    982  
    983     SharedBuffer* buffer = resource->data(); 
    984     if (buffer) 
    985         *data = [buffer->createNSData() autorelease]; 
    986     else 
    987         *data = nil; 
    988  
    989     *response = resource->response().nsURLResponse(); 
    990     return YES; 
    991 } 
    992  
    993973- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses 
    994974{ 
  • trunk/WebKit/mac/WebView/WebFrameInternal.h

    r31281 r31355  
    182182- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation; 
    183183 
    184 - (BOOL)_getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)URL; 
    185184- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses; 
    186185