Commit 59712ce1 authored by beidson@apple.com's avatar beidson@apple.com

WebCore:

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

        Reviewed by Adam Roben

        Move [WebDataSource mainResource] and [WebDataSource subresources] down into WebCore
        as the push to core-ify WebArchives continues.

        This patch also introduces a behavior change.  WebCore allows ArchiveResources with null or empty data.  
        WebKit has had the inexplicable distinction of allowing empty Data in a WebResource, but not null.  
        Since WebResource is API, I decided to leave it be to avoid a behavior change.  But internally created resources 
        (as in "while archiving a page") are accepting of null or empty data.

        This actually fixes a bug where not all subframes are archived, and resulted in a layout test change.

        * WebCore.base.exp:
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::archiveResourceForURL): Make this const
        (WebCore::DocumentLoader::mainResource):
        (WebCore::DocumentLoader::subresource): Make this const and relocate
        (WebCore::DocumentLoader::getSubresources):
        * loader/DocumentLoader.h:

WebKit/mac:

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

        Reviewed by Adam Roben

        Move [WebDataSource mainResource] and [WebDataSource subresources] down into WebCore
        as the push to core-ify WebArchives continues.

        This patch also introduces a behavior change.  WebCore allows ArchiveResources with null or empty data.  
        WebKit has had the inexplicable distinction of allowing empty Data in a WebResource, but not null.  
        Since WebResource is API, I decided to leave it be to avoid a behavior change.  But internally created resources 
        (as in "while archiving a page") are accepting of null or empty data.

        This actually fixes a bug where not all subframes are archived, and resulted in a layout test change. 

        * WebView/WebDataSource.mm:
        (-[WebDataSource mainResource]): Call DocumentLoader implementation
        (-[WebDataSource subresources]): Ditto
        * WebView/WebFrame.mm: Remove [WebFrame _getAllResourceDatas:andResponses:] as its only caller is obsolete
        * WebView/WebFrameInternal.h:

LayoutTests:

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

        Reviewed by Adam Roben

        Updated results, as we now more consistently archive empty frames/empty resources

        * webarchive/archive-empty-frame-source-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31384 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7f759692
2008-03-27 Brady Eidson <beidson@apple.com>
Reviewed by Adam Roben
Updated results, as we now more consistently archive empty frames/empty resources
* webarchive/archive-empty-frame-source-expected.txt:
2008-03-26 Sam Weinig <sam@webkit.org>
Rubber-stamped by Adam Roben.
......@@ -34,5 +34,21 @@ Here lies an `iframe` with no content/src:
<key>WebResourceURL</key>
<string>file:///LayoutTests/webarchive/archive-empty-frame-source.html</string>
</dict>
<key>WebSubframeArchives</key>
<array>
<dict>
<key>WebMainResource</key>
<dict>
<key>WebResourceData</key>
<string></string>
<key>WebResourceFrameName</key>
<string>emptyFrame</string>
<key>WebResourceMIMEType</key>
<string>text/html</string>
<key>WebResourceURL</key>
<string>about:blank</string>
</dict>
</dict>
</array>
</dict>
</plist>
2008-03-27 Brady Eidson <beidson@apple.com>
Reviewed by Adam Roben
Move [WebDataSource mainResource] and [WebDataSource subresources] down into WebCore
as the push to core-ify WebArchives continues.
This patch also introduces a behavior change. WebCore allows ArchiveResources with null or empty data.
WebKit has had the inexplicable distinction of allowing empty Data in a WebResource, but not null.
Since WebResource is API, I decided to leave it be to avoid a behavior change. But internally created resources
(as in "while archiving a page") are accepting of null or empty data.
This actually fixes a bug where not all subframes are archived, and resulted in a layout test change.
* WebCore.base.exp:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::archiveResourceForURL): Make this const
(WebCore::DocumentLoader::mainResource):
(WebCore::DocumentLoader::subresource): Make this const and relocate
(WebCore::DocumentLoader::getSubresources):
* loader/DocumentLoader.h:
2008-03-27 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
......@@ -265,13 +265,11 @@ __ZN7WebCore13KeyboardEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowERKNS_6StringE
__ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE
__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE
__ZN7WebCore14DocumentLoader11subresourceERKNS_4KURLE
__ZN7WebCore14DocumentLoader13attachToFrameEv
__ZN7WebCore14DocumentLoader15detachFromFrameEv
__ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
__ZN7WebCore14DocumentLoader19prepareForLoadStartEv
__ZN7WebCore14DocumentLoader21addPlugInStreamLoaderEPNS_14ResourceLoaderE
__ZN7WebCore14DocumentLoader21archiveResourceForURLERKNS_4KURLE
__ZN7WebCore14DocumentLoader22addAllArchiveResourcesEPNS_7ArchiveE
__ZN7WebCore14DocumentLoader22cancelMainResourceLoadERKNS_13ResourceErrorE
__ZN7WebCore14DocumentLoader24removePlugInStreamLoaderEPNS_14ResourceLoaderE
......@@ -676,7 +674,10 @@ __ZNK7WebCore13HitTestResult9imageRectEv
__ZNK7WebCore13ResourceErrorcvP7NSErrorEv
__ZNK7WebCore14DocumentLoader10requestURLEv
__ZNK7WebCore14DocumentLoader11frameLoaderEv
__ZNK7WebCore14DocumentLoader11subresourceERKNS_4KURLE
__ZNK7WebCore14DocumentLoader12mainResourceEv
__ZNK7WebCore14DocumentLoader14unreachableURLEv
__ZNK7WebCore14DocumentLoader15getSubresourcesERN3WTF6VectorINS1_10PassRefPtrINS_15ArchiveResourceEEELm0EEE
__ZNK7WebCore14DocumentLoader15originalRequestEv
__ZNK7WebCore14DocumentLoader16mainResourceDataEv
__ZNK7WebCore14DocumentLoader17parsedArchiveDataEv
......
......@@ -36,6 +36,7 @@
#include "Event.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameTree.h"
#include "HistoryItem.h"
#include "Logging.h"
#include "MainResourceLoader.h"
......@@ -465,23 +466,7 @@ 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)
ArchiveResource* DocumentLoader::archiveResourceForURL(const KURL& url) const
{
if (!m_archiveResourceCollection)
return 0;
......@@ -511,6 +496,48 @@ SharedBuffer* DocumentLoader::parsedArchiveData() const
return m_parsedArchiveData.get();
}
PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const
{
const ResourceResponse& r(response());
return ArchiveResource::create(mainResourceData(), r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->name());
}
PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) const
{
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());
}
void DocumentLoader::getSubresources(Vector<PassRefPtr<ArchiveResource> >& subresources) const
{
if (!isCommitted())
return;
Document* document = m_frame->document();
if (!document)
return;
const HashMap<String, CachedResource*>& allResources = document->docLoader()->allCachedResources();
HashMap<String, CachedResource*>::const_iterator end = allResources.end();
for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
RefPtr<ArchiveResource> subresource = this->subresource(KURL(it->second->url()));
if (subresource)
subresources.append(subresource.release());
}
return;
}
void DocumentLoader::addResponse(const ResourceResponse& r)
{
if (!m_stopRecordingResponses)
......
......@@ -125,15 +125,18 @@ namespace WebCore {
// Return an ArchiveResource for the URL, either creating from live data or
// pulling from the ArchiveResourceCollection
PassRefPtr<ArchiveResource> subresource(const KURL&);
PassRefPtr<ArchiveResource> subresource(const KURL&) const;
// Return the ArchiveResource for the URL only when loading an Archive
ArchiveResource* archiveResourceForURL(const KURL&);
ArchiveResource* archiveResourceForURL(const KURL&) const;
PassRefPtr<Archive> popArchiveForSubframe(const String& frameName);
void clearArchiveResources();
void setParsedArchiveData(PassRefPtr<SharedBuffer>);
SharedBuffer* parsedArchiveData() const;
PassRefPtr<ArchiveResource> mainResource() const;
void getSubresources(Vector<PassRefPtr<ArchiveResource> >&) const;
void addResponse(const ResourceResponse&);
const ResponseVector& responses() const { return m_responses; }
......
2008-03-27 Brady Eidson <beidson@apple.com>
Reviewed by Adam Roben
Move [WebDataSource mainResource] and [WebDataSource subresources] down into WebCore
as the push to core-ify WebArchives continues.
This patch also introduces a behavior change. WebCore allows ArchiveResources with null or empty data.
WebKit has had the inexplicable distinction of allowing empty Data in a WebResource, but not null.
Since WebResource is API, I decided to leave it be to avoid a behavior change. But internally created resources
(as in "while archiving a page") are accepting of null or empty data.
This actually fixes a bug where not all subframes are archived, and resulted in a layout test change.
* WebView/WebDataSource.mm:
(-[WebDataSource mainResource]): Call DocumentLoader implementation
(-[WebDataSource subresources]): Ditto
* WebView/WebFrame.mm: Remove [WebFrame _getAllResourceDatas:andResponses:] as its only caller is obsolete
* WebView/WebFrameInternal.h:
2008-03-27 Brady Eidson <beidson@apple.com>
Reviewed by Adam
......
......@@ -453,30 +453,19 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (WebResource *)mainResource
{
NSURLResponse *response = [self response];
return [[[WebResource alloc] initWithData:[self data]
URL:[response URL]
MIMEType:[self _responseMIMEType]
textEncodingName:[response textEncodingName]
frameName:[[self webFrame] name]] autorelease];
RefPtr<ArchiveResource> coreResource = _private->loader->mainResource();
return [[[WebResource alloc] _initWithCoreResource:coreResource.release()] autorelease];
}
- (NSArray *)subresources
{
if (!_private->loader->isCommitted())
return [NSMutableArray array];
NSArray *datas;
NSArray *responses;
[[self webFrame] _getAllResourceDatas:&datas andResponses:&responses];
ASSERT([datas count] == [responses count]);
NSMutableArray *subresources = [[NSMutableArray alloc] initWithCapacity:[datas count]];
for (unsigned i = 0; i < [datas count]; ++i) {
NSURLResponse *response = [responses objectAtIndex:i];
[subresources addObject:[[[WebResource alloc] _initWithData:[datas objectAtIndex:i] URL:[response URL] response:response] autorelease]];
}
Vector<PassRefPtr<ArchiveResource> > coreSubresources;
_private->loader->getSubresources(coreSubresources);
NSMutableArray *subresources = [[NSMutableArray alloc] initWithCapacity:coreSubresources.size()];
for (unsigned i = 0; i < coreSubresources.size(); ++i)
[subresources addObject:[[[WebResource alloc] _initWithCoreResource:coreSubresources[i]] autorelease]];
return [subresources autorelease];
}
......
......@@ -970,38 +970,6 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
_private->coreFrame->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation);
}
- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses
{
Document* doc = _private->coreFrame->document();
if (!doc) {
NSArray* emptyArray = [NSArray array];
*datas = emptyArray;
*responses = emptyArray;
return;
}
const HashMap<String, CachedResource*>& allResources = doc->docLoader()->allCachedResources();
NSMutableArray *d = [[NSMutableArray alloc] initWithCapacity:allResources.size()];
NSMutableArray *r = [[NSMutableArray alloc] initWithCapacity:allResources.size()];
HashMap<String, CachedResource*>::const_iterator end = allResources.end();
for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
SharedBuffer* buffer = it->second->data();
NSData *data;
if (buffer)
data = buffer->createNSData();
else
data = [[NSData alloc] init];
[d addObject:data];
[data release];
[r addObject:it->second->response().nsURLResponse()];
}
*datas = [d autorelease];
*responses = [r autorelease];
}
- (BOOL)_canProvideDocumentSource
{
String mimeType = _private->coreFrame->loader()->responseMIMEType();
......
......@@ -181,8 +181,6 @@ WebView *getWebView(WebFrame *webFrame);
- (void)_dragSourceMovedTo:(NSPoint)windowLoc;
- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
- (void)_getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses;
- (BOOL)_canProvideDocumentSource;
- (BOOL)_canSaveAsWebArchive;
......
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