+2007-07-13 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Maciej.
+
+ <rdar://problem/5290103> Assert failure when loading page with multipart resource
+
+ Don't try to call the delegate method if the resource object doesn't exist in the
+ identifier map. When a multipart resource has finished loading one part, it is removed from the
+ web view identifier map.
+
+ This is not an ideal fix, a better fix would be to special-case multipart resources and not remove
+ them when the first part has finished loading. I've filed <rdar://problem/5335034> to track doing that.
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
+ (WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge):
+ (WebFrameLoaderClient::dispatchDidReceiveResponse):
+ (WebFrameLoaderClient::willCacheResponse):
+ (WebFrameLoaderClient::dispatchDidReceiveContentLength):
+ (WebFrameLoaderClient::dispatchDidFinishLoading):
+ (WebFrameLoaderClient::dispatchDidFailLoading):
+
2007-07-13 Timothy Hatcher <timothy@apple.com>
Reviewed by Oliver Hunt.
NSURLAuthenticationChallenge *webChallenge = mac(challenge);
if (implementations.delegateImplementsDidReceiveAuthenticationChallenge) {
- [resourceLoadDelegate webView:webView resource:[webView _objectForIdentifier:identifier] didReceiveAuthenticationChallenge:webChallenge fromDataSource:dataSource(loader)];
- return;
+ if (id resource = [webView _objectForIdentifier:identifier]) {
+ [resourceLoadDelegate webView:webView resource:resource didReceiveAuthenticationChallenge:webChallenge fromDataSource:dataSource(loader)];
+ return;
+ }
}
NSWindow *window = [webView hostWindow] ? [webView hostWindow] : [webView window];
NSURLAuthenticationChallenge *webChallenge = mac(challenge);
if (implementations.delegateImplementsDidCancelAuthenticationChallenge) {
- [resourceLoadDelegate webView:webView resource:[webView _objectForIdentifier:identifier] didCancelAuthenticationChallenge:webChallenge fromDataSource:dataSource(loader)];
- return;
+ if (id resource = [webView _objectForIdentifier:identifier]) {
+ [resourceLoadDelegate webView:webView resource:resource didCancelAuthenticationChallenge:webChallenge fromDataSource:dataSource(loader)];
+ return;
+ }
}
[(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:webChallenge];
id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
- if (implementations.delegateImplementsDidReceiveResponse)
- implementations.didReceiveResponseFunc(resourceLoadDelegate, @selector(webView:resource:didReceiveResponse:fromDataSource:), webView, [webView _objectForIdentifier:identifier], response.nsURLResponse(), dataSource(loader));
+ if (implementations.delegateImplementsDidReceiveResponse) {
+ if (id resource = [webView _objectForIdentifier:identifier])
+ implementations.didReceiveResponseFunc(resourceLoadDelegate, @selector(webView:resource:didReceiveResponse:fromDataSource:), webView, resource, response.nsURLResponse(), dataSource(loader));
+ }
}
NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader* loader, unsigned long identifier, NSCachedURLResponse* response) const
WebView *webView = getWebView(m_webFrame.get());
id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
- if (implementations.delegateImplementsWillCacheResponse)
- return implementations.willCacheResponseFunc(resourceLoadDelegate, @selector(webView:resource:willCacheResponse:fromDataSource:), webView, [webView _objectForIdentifier:identifier], response, dataSource(loader));
+ if (implementations.delegateImplementsWillCacheResponse) {
+ if (id resource = [webView _objectForIdentifier:identifier])
+ return implementations.willCacheResponseFunc(resourceLoadDelegate, @selector(webView:resource:willCacheResponse:fromDataSource:), webView, resource, response, dataSource(loader));
+ }
return response;
}
id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
- if (implementations.delegateImplementsDidReceiveContentLength)
- implementations.didReceiveContentLengthFunc(resourceLoadDelegate, @selector(webView:resource:didReceiveContentLength:fromDataSource:), webView, [webView _objectForIdentifier:identifier], (WebNSUInteger)lengthReceived, dataSource(loader));
+ if (implementations.delegateImplementsDidReceiveContentLength) {
+ if (id resource = [webView _objectForIdentifier:identifier])
+ implementations.didReceiveContentLengthFunc(resourceLoadDelegate, @selector(webView:resource:didReceiveContentLength:fromDataSource:), webView, resource, (WebNSUInteger)lengthReceived, dataSource(loader));
+ }
}
void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
- if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
- implementations.didFinishLoadingFromDataSourceFunc(resourceLoadDelegate, @selector(webView:resource:didFinishLoadingFromDataSource:), webView, [webView _objectForIdentifier:identifier], dataSource(loader));
+ if (implementations.delegateImplementsDidFinishLoadingFromDataSource) {
+ if (id resource = [webView _objectForIdentifier:identifier])
+ implementations.didFinishLoadingFromDataSourceFunc(resourceLoadDelegate, @selector(webView:resource:didFinishLoadingFromDataSource:), webView, resource, dataSource(loader));
+ }
[webView _removeObjectForIdentifier:identifier];
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount(identifier);
id resourceLoadDelegate = WebViewGetResourceLoadDelegate(webView);
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
- if (implementations.delegateImplementsDidFailLoadingWithErrorFromDataSource)
- implementations.didFailLoadingWithErrorFromDataSourceFunc(resourceLoadDelegate, @selector(webView:resource:didFailLoadingWithError:fromDataSource:), webView, [webView _objectForIdentifier:identifier], error, dataSource(loader));
+ if (implementations.delegateImplementsDidFailLoadingWithErrorFromDataSource) {
+ if (id resource = [webView _objectForIdentifier:identifier])
+ implementations.didFailLoadingWithErrorFromDataSourceFunc(resourceLoadDelegate, @selector(webView:resource:didFailLoadingWithError:fromDataSource:), webView, resource, error, dataSource(loader));
+ }
[webView _removeObjectForIdentifier:identifier];
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount(identifier);