Reviewed by Darin.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Oct 2006 05:42:55 +0000 (05:42 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Oct 2006 05:42:55 +0000 (05:42 +0000)
        - pass all WebResourceLoadDelegate methods across client, removing need to include related headers

        * Loader/WebFrameLoader.m:
        (-[WebFrameLoader _willSendRequest:forResource:redirectResponse:]):
        (-[WebFrameLoader _didReceiveAuthenticationChallenge:forResource:]):
        (-[WebFrameLoader _didCancelAuthenticationChallenge:forResource:]):
        (-[WebFrameLoader _didReceiveResponse:forResource:]):
        (-[WebFrameLoader _didReceiveData:contentLength:forResource:]):
        (-[WebFrameLoader _didFinishLoadingForResource:]):
        (-[WebFrameLoader _didFailLoadingWithError:forResource:]):
        (-[WebFrameLoader sendRemainingDelegateMessagesWithIdentifier:response:length:error:]):
        (-[WebFrameLoader requestFromDelegateForRequest:identifier:error:]):
        * Loader/WebFrameLoaderClient.h:
        * WebView/WebFrame.m:
        (-[WebFrame _dispatchDidHandleOnloadEventsForFrame]):
        (-[WebFrame _dispatchDidReceiveServerRedirectForProvisionalLoadForFrame]):
        (-[WebFrame _dispatchIdentifierForInitialRequest:fromDocumentLoader:]):
        (-[WebFrame _dispatchResource:willSendRequest:redirectResponse:fromDocumentLoader:]):
        (-[WebFrame _dispatchDidReceiveAuthenticationChallenge:forResource:fromDocumentLoader:]):
        (-[WebFrame _dispatchDidCancelAuthenticationChallenge:forResource:fromDocumentLoader:]):
        (-[WebFrame _dispatchResource:didReceiveResponse:fromDocumentLoader:]):
        (-[WebFrame _dispatchResource:didReceiveContentLength:fromDocumentLoader:]):
        (-[WebFrame _dispatchResource:didFinishLoadingFromDocumentLoader:]):
        (-[WebFrame _dispatchResource:didFailLoadingWithError:fromDocumentLoader:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16910 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/Loader/WebFrameLoader.m
WebKit/Loader/WebFrameLoaderClient.h
WebKit/WebView/WebFrame.m

index ad5216e5ec0428434513f1a4c5dde6e5d6565d9f..cfc7cf615fb0a9775e5365f27db1979c2d4feeee 100644 (file)
@@ -1,3 +1,32 @@
+2006-10-08  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - pass all WebResourceLoadDelegate methods across client, removing need to include related headers
+
+        * Loader/WebFrameLoader.m:
+        (-[WebFrameLoader _willSendRequest:forResource:redirectResponse:]):
+        (-[WebFrameLoader _didReceiveAuthenticationChallenge:forResource:]):
+        (-[WebFrameLoader _didCancelAuthenticationChallenge:forResource:]):
+        (-[WebFrameLoader _didReceiveResponse:forResource:]):
+        (-[WebFrameLoader _didReceiveData:contentLength:forResource:]):
+        (-[WebFrameLoader _didFinishLoadingForResource:]):
+        (-[WebFrameLoader _didFailLoadingWithError:forResource:]):
+        (-[WebFrameLoader sendRemainingDelegateMessagesWithIdentifier:response:length:error:]):
+        (-[WebFrameLoader requestFromDelegateForRequest:identifier:error:]):
+        * Loader/WebFrameLoaderClient.h:
+        * WebView/WebFrame.m:
+        (-[WebFrame _dispatchDidHandleOnloadEventsForFrame]):
+        (-[WebFrame _dispatchDidReceiveServerRedirectForProvisionalLoadForFrame]):
+        (-[WebFrame _dispatchIdentifierForInitialRequest:fromDocumentLoader:]):
+        (-[WebFrame _dispatchResource:willSendRequest:redirectResponse:fromDocumentLoader:]):
+        (-[WebFrame _dispatchDidReceiveAuthenticationChallenge:forResource:fromDocumentLoader:]):
+        (-[WebFrame _dispatchDidCancelAuthenticationChallenge:forResource:fromDocumentLoader:]):
+        (-[WebFrame _dispatchResource:didReceiveResponse:fromDocumentLoader:]):
+        (-[WebFrame _dispatchResource:didReceiveContentLength:fromDocumentLoader:]):
+        (-[WebFrame _dispatchResource:didFinishLoadingFromDocumentLoader:]):
+        (-[WebFrame _dispatchResource:didFailLoadingWithError:fromDocumentLoader:]):
+
 2006-10-08  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin.
index 2523ad57502ec1ed54412b9ba6eeb62418bb8e0e..77a8aa3c9d0f36c0f16906aec1e93ebb0beab0d0 100644 (file)
@@ -38,7 +38,6 @@
 #import <WebKitSystemInterface.h>
 
 #import "WebDataSourceInternal.h"
-#import "WebDefaultResourceLoadDelegate.h"
 #import "WebDefaultUIDelegate.h"
 #import "WebDocumentLoaderMac.h"
 #import "WebDownloadInternal.h"
@@ -54,7 +53,6 @@
 #import "WebKitNSStringExtras.h"
 #import "WebNSURLExtras.h"
 #import "WebNSURLRequestExtras.h"
-#import "WebResourceLoadDelegate.h"
 #import "WebResourcePrivate.h"
 #import "WebScriptDebugServerPrivate.h"
 #import "WebUIDelegate.h"
@@ -436,72 +434,41 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
 - (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse
 {
     WebView *webView = [client webView];
-    
     [clientRequest setValue:[webView userAgentForURL:[clientRequest URL]] forHTTPHeaderField:@"User-Agent"];
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
-        return [[webView resourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:[self activeDataSource]];
-    else
-        return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:[self activeDataSource]];
+    return [client _dispatchResource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier
 {
-    WebView *webView = [client webView];
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)
-        [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
-    else
-        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
+    [client _dispatchDidReceiveAuthenticationChallenge:currentWebChallenge forResource:identifier fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier
 {
-    WebView *webView = [client webView];
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)
-        [[webView resourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
-    else
-        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
-    
+    [client _dispatchDidCancelAuthenticationChallenge:currentWebChallenge forResource:identifier fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier
 {
-    WebView *webView = [client webView];
-    
     [[self activeDocumentLoader] addResponse:r];
     
-    [webView _incrementProgressForIdentifier:identifier response:r];
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
-        [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:[self activeDataSource]];
-    else
-        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:[self activeDataSource]];
+    [[client webView] _incrementProgressForIdentifier:identifier response:r];
+    [client _dispatchResource:identifier didReceiveResponse:r fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier
 {
     WebView *webView = [client webView];
-    
     [webView _incrementProgressForIdentifier:identifier data:data];
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
-        [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:[self activeDataSource]];
-    else
-        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:[self activeDataSource]];
+
+    [client _dispatchResource:identifier didReceiveContentLength:lengthReceived fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didFinishLoadingForResource:(id)identifier
 {    
     WebView *webView = [client webView];
-    
-    [webView _completeProgressForIdentifier:identifier];    
-    
-    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
-        [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:[self activeDataSource]];
-    else
-        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:[self activeDataSource]];
+    [webView _completeProgressForIdentifier:identifier];
+    [client _dispatchResource:identifier didFinishLoadingFromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier
@@ -511,7 +478,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
     [webView _completeProgressForIdentifier:identifier];
         
     if (error)
-        [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:[self activeDataSource]];
+        [client _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:[self activeDocumentLoader]];
 }
 
 - (BOOL)_privateBrowsingEnabled
@@ -1974,57 +1941,24 @@ exit:
 
 - (void)sendRemainingDelegateMessagesWithIdentifier:(id)identifier response:(NSURLResponse *)response length:(unsigned)length error:(NSError *)error 
 {    
-    WebView *wv = [client webView];
-    id delegate = [wv resourceLoadDelegate];
-    id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
-    WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
-    WebDataSource *dataSource = [self dataSource];
-        
-    if (response != nil) {
-        if (implementations.delegateImplementsDidReceiveResponse)
-            [delegate webView:wv resource:identifier didReceiveResponse:response fromDataSource:dataSource];
-        else
-            [sharedDelegate webView:wv resource:identifier didReceiveResponse:response fromDataSource:dataSource];
-    }
+    if (response != nil)
+        [client _dispatchResource:identifier didReceiveResponse:response fromDocumentLoader:documentLoader];
     
-    if (length > 0) {
-        if (implementations.delegateImplementsDidReceiveContentLength)
-            [delegate webView:wv resource:identifier didReceiveContentLength:(WebNSUInteger)length fromDataSource:dataSource];
-        else
-            [sharedDelegate webView:wv resource:identifier didReceiveContentLength:(WebNSUInteger)length fromDataSource:dataSource];
-    }
+    if (length > 0)
+        [client _dispatchResource:identifier didReceiveContentLength:(WebNSUInteger)length fromDocumentLoader:documentLoader];
     
-    if (error == nil) {
-        if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
-            [delegate webView:wv resource:identifier didFinishLoadingFromDataSource:dataSource];
-        else
-            [sharedDelegate webView:wv resource:identifier didFinishLoadingFromDataSource:dataSource];
-        [self checkLoadComplete];
-    } else {
-        [[wv _resourceLoadDelegateForwarder] webView:wv resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
-    }
+    if (error == nil)
+        [client _dispatchResource:identifier didFinishLoadingFromDocumentLoader:documentLoader];
+    else
+        [client _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:documentLoader];
 }
 
 - (NSURLRequest *)requestFromDelegateForRequest:(NSURLRequest *)request identifier:(id *)identifier error:(NSError **)error
 {
     ASSERT(request != nil);
     
-    WebView *wv = [client webView];
-    id delegate = [wv resourceLoadDelegate];
-    id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
-    WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
-    WebDataSource *dataSource = [self dataSource];
-    
-    if (implementations.delegateImplementsIdentifierForRequest)
-        *identifier = [delegate webView:wv identifierForInitialRequest:request fromDataSource:dataSource];
-    else
-        *identifier = [sharedDelegate webView:wv identifierForInitialRequest:request fromDataSource:dataSource];
-
-    NSURLRequest *newRequest;
-    if (implementations.delegateImplementsWillSendRequest)
-        newRequest = [delegate webView:wv resource:*identifier willSendRequest:request redirectResponse:nil fromDataSource:dataSource];
-    else
-        newRequest = [sharedDelegate webView:wv resource:*identifier willSendRequest:request redirectResponse:nil fromDataSource:dataSource];
+    *identifier = [client _dispatchIdentifierForInitialRequest:request fromDocumentLoader:documentLoader]; 
+    NSURLRequest *newRequest = [client _dispatchResource:*identifier willSendRequest:request redirectResponse:nil fromDocumentLoader:documentLoader];
     
     if (newRequest == nil)
         *error = [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
index fa92efb8988ca2f4e640b35bc25817e2c0fc30ba..84894622e59717c22eedabb1a924bcb278de35f9 100644 (file)
@@ -66,5 +66,12 @@ typedef struct LoadErrorResetToken LoadErrorResetToken;
 - (void)_dispatchDidHandleOnloadEventsForFrame;
 - (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame;
 - (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)request fromDocumentLoader:(WebDocumentLoader *)loader;
+- (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(WebDocumentLoader *)loader;
+- (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(WebDocumentLoader *)loader;
 
 @end
index 66141b9a0673a4c1fcef78019e370172c93ffed9..15e17fe9e34905ff8dd7134925138f0d8dc58a34 100644 (file)
@@ -1597,24 +1597,96 @@ static inline WebDataSource *dataSource(WebDocumentLoader *loader)
 
 - (void)_dispatchDidHandleOnloadEventsForFrame
 {
-    [[[self webView] _frameLoadDelegateForwarder] webView:[self webView] didHandleOnloadEventsForFrame:self];
+    WebView *webView = [self webView];
+    [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:self];
 }
 
 - (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame
 {
-    [[[self webView] _frameLoadDelegateForwarder] webView:[self webView]
+    WebView *webView = [self webView];
+    [[webView _frameLoadDelegateForwarder] webView:webView
        didReceiveServerRedirectForProvisionalLoadForFrame:self];
 }
 
-- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)request fromDocumentLoader:(WebDocumentLoader *)loader
+- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(WebDocumentLoader *)loader
 {
     WebView *webView = [self webView];
     id resourceLoadDelegate = [webView resourceLoadDelegate];
     
     if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest)
-        return [resourceLoadDelegate webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)];
+        return [resourceLoadDelegate webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
+
+    return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
+}
+
+- (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+    id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
+        return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
+    else
+        return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+    id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)
+        [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+    else
+        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+    id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)
+        [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+    else
+        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
+        [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
+    else
+        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
 
-    return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)];
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
+        [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
+    else
+        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+    
+    if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
+        [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
+    else
+        [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
+}
+
+
+- (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(WebDocumentLoader *)loader
+{
+    WebView *webView = [self webView];
+    [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)];
 }
     
 - (void)_detachedFromParent1