[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:13:00 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit caa79c0148ec36b9c567f058dd6e3e732011792a
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 9 23:14:27 2002 +0000

            Reviewed by Chris.
    
    	- fixed 3122608 -- Downloads can't be cancelled
    
    	When I fixed the leak for other categories of policy interruption, I messed
    	things up for downloads. Added new parameters to handle this right.
    
            * WebView.subproj/WebBaseResourceHandleDelegate.h: Remove isDownload flag.
            * WebView.subproj/WebBaseResourceHandleDelegate.m:
            (-[WebBaseResourceHandleDelegate isDownload]): Return NO, override in subclass.
            (-[WebBaseResourceHandleDelegate handle:didReceiveResponse:]): Call isDownload
    	method instead of looking at flag directly.
    
            * WebView.subproj/WebControllerPrivate.h: Add complete: parameter to _mainReceivedError:.
            * WebView.subproj/WebControllerPrivate.m:
            (-[WebController _mainReceivedError:fromDataSource:complete:]): If complete is NO, then
    	don't mark the primary load as complete.
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient isDownload]): Added. Returns YES if downloadHandler is non-nil.
            (-[WebMainResourceClient receivedError:complete:]): Added complete parameter. Call the
    	_setPrimaryLoadComplete: method in the download case (fixes a possible leak), and pass
    	the complete parameter through to the controller.
            (-[WebMainResourceClient cancel]): Pass complete:YES.
            (-[WebMainResourceClient interruptForPolicyChangeAndKeepLoading:]): Added the keepLoading
    	flag, and pass complete:!keepLoading.
            (-[WebMainResourceClient stopLoadingForPolicyChange]): Pass keepLoading:NO.
            (-[WebMainResourceClient continueAfterContentPolicy:response:]): Pass keepLoading:YES,
    	and remove the call to the now-obsolete setIsDownload:.
            (-[WebMainResourceClient handle:didFailLoadingWithError:]): Pass complete:YES.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2978 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6a4d3a5..cb7d73a 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,35 @@
+2002-12-09  Darin Adler  <darin at apple.com>
+
+        Reviewed by Chris.
+
+	- fixed 3122608 -- Downloads can't be cancelled
+
+	When I fixed the leak for other categories of policy interruption, I messed
+	things up for downloads. Added new parameters to handle this right.
+
+        * WebView.subproj/WebBaseResourceHandleDelegate.h: Remove isDownload flag.
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate isDownload]): Return NO, override in subclass.
+        (-[WebBaseResourceHandleDelegate handle:didReceiveResponse:]): Call isDownload
+	method instead of looking at flag directly.
+
+        * WebView.subproj/WebControllerPrivate.h: Add complete: parameter to _mainReceivedError:.
+        * WebView.subproj/WebControllerPrivate.m:
+        (-[WebController _mainReceivedError:fromDataSource:complete:]): If complete is NO, then
+	don't mark the primary load as complete.
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient isDownload]): Added. Returns YES if downloadHandler is non-nil.
+        (-[WebMainResourceClient receivedError:complete:]): Added complete parameter. Call the
+	_setPrimaryLoadComplete: method in the download case (fixes a possible leak), and pass
+	the complete parameter through to the controller.
+        (-[WebMainResourceClient cancel]): Pass complete:YES.
+        (-[WebMainResourceClient interruptForPolicyChangeAndKeepLoading:]): Added the keepLoading
+	flag, and pass complete:!keepLoading.
+        (-[WebMainResourceClient stopLoadingForPolicyChange]): Pass keepLoading:NO.
+        (-[WebMainResourceClient continueAfterContentPolicy:response:]): Pass keepLoading:YES,
+	and remove the call to the now-obsolete setIsDownload:.
+        (-[WebMainResourceClient handle:didFailLoadingWithError:]): Pass complete:YES.
+
 2002-12-08  Darin Adler  <darin at apple.com>
 
         Reviewed by Don and Dave.
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
index c27885c..ef25b8d 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
@@ -28,7 +28,6 @@
     id <WebResourceLoadDelegate>resourceLoadDelegate;
     id <WebResourceLoadDelegate>downloadDelegate;
     NSURL *currentURL;
-    BOOL isDownload;
     BOOL reachedTerminalState;
     BOOL defersCallbacks;
 }
@@ -40,7 +39,7 @@
 
 - (id <WebResourceLoadDelegate>)resourceLoadDelegate;
 - (id <WebResourceLoadDelegate>)downloadDelegate;
-- (void)setIsDownload:(BOOL)f;
+- (BOOL)isDownload;
 
 - (void)cancel;
 - (void)cancelQuietly;
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
index 9cf034a..5b18d81 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
@@ -113,14 +113,9 @@
     return downloadDelegate;
 }
 
-- (void)setIsDownload:(BOOL)f
-{
-    isDownload = f;
-}
-
 - (BOOL)isDownload
 {
-    return isDownload;
+    return NO;
 }
 
 -(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
@@ -163,7 +158,7 @@
     [response release];
     response = r;
 
-    if (isDownload)
+    if ([self isDownload])
         [downloadDelegate resource:identifier didReceiveResponse:r fromDataSource:dataSource];
     else
         [resourceLoadDelegate resource:identifier didReceiveResponse:r fromDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index 855e204..8d4caf7 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -49,7 +49,7 @@
 - (void)_finishedLoadingResourceFromDataSource:(WebDataSource *)dataSource;
 - (void)_receivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
 - (void)_mainReceivedBytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
-- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
 + (NSString *)_MIMETypeForFile:(NSString *)path;
 + (NSArray *)_supportedImageMIMETypes;
 - (void)_downloadURL:(NSURL *)URL;
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index 4348015..170e7f2 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -150,18 +150,18 @@
 }
 
 
-- (void)_mainReceivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete
 {
     ASSERT(error);
     ASSERT(dataSource);
-    
-    WebFrame *frame = [dataSource webFrame];
-    ASSERT(frame);
-    
+    ASSERT([dataSource webFrame]);
+
     [dataSource _setMainDocumentError: error];
-    [dataSource _setPrimaryLoadComplete: YES];
 
-    [frame _checkLoadComplete];
+    if (isComplete) {
+        [dataSource _setPrimaryLoadComplete:YES];
+        [[dataSource webFrame] _checkLoadComplete];
+    }
 }
 
 + (NSString *)_MIMETypeForFile: (NSString *)path
diff --git a/WebKit/WebView.subproj/WebLoader.h b/WebKit/WebView.subproj/WebLoader.h
index c27885c..ef25b8d 100644
--- a/WebKit/WebView.subproj/WebLoader.h
+++ b/WebKit/WebView.subproj/WebLoader.h
@@ -28,7 +28,6 @@
     id <WebResourceLoadDelegate>resourceLoadDelegate;
     id <WebResourceLoadDelegate>downloadDelegate;
     NSURL *currentURL;
-    BOOL isDownload;
     BOOL reachedTerminalState;
     BOOL defersCallbacks;
 }
@@ -40,7 +39,7 @@
 
 - (id <WebResourceLoadDelegate>)resourceLoadDelegate;
 - (id <WebResourceLoadDelegate>)downloadDelegate;
-- (void)setIsDownload:(BOOL)f;
+- (BOOL)isDownload;
 
 - (void)cancel;
 - (void)cancelQuietly;
diff --git a/WebKit/WebView.subproj/WebLoader.m b/WebKit/WebView.subproj/WebLoader.m
index 9cf034a..5b18d81 100644
--- a/WebKit/WebView.subproj/WebLoader.m
+++ b/WebKit/WebView.subproj/WebLoader.m
@@ -113,14 +113,9 @@
     return downloadDelegate;
 }
 
-- (void)setIsDownload:(BOOL)f
-{
-    isDownload = f;
-}
-
 - (BOOL)isDownload
 {
-    return isDownload;
+    return NO;
 }
 
 -(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
@@ -163,7 +158,7 @@
     [response release];
     response = r;
 
-    if (isDownload)
+    if ([self isDownload])
         [downloadDelegate resource:identifier didReceiveResponse:r fromDataSource:dataSource];
     else
         [resourceLoadDelegate resource:identifier didReceiveResponse:r fromDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index a99fbe4..936dab1 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -64,15 +64,23 @@
     return downloadHandler;
 }
 
-- (void)receivedError:(WebError *)error
+- (BOOL)isDownload
+{
+    return downloadHandler != nil;
+}
+
+- (void)receivedError:(WebError *)error complete:(BOOL)isComplete
 {
     if (downloadHandler) {
+        ASSERT(isComplete);
         [downloadHandler cancel];
         [downloadHandler release];
         downloadHandler = nil;
+        [dataSource _setPrimaryLoadComplete:YES];
     } else {
         [[dataSource controller] _mainReceivedError:error
-                                     fromDataSource:dataSource];
+                                     fromDataSource:dataSource
+                                           complete:isComplete];
     }
 }
 
@@ -83,21 +91,20 @@
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:[self cancelledError]];
-        
+    [self receivedError:[self cancelledError] complete:YES];
     [super cancel];
 
     [self release];
 }
 
-- (void)interruptForPolicyChange
+- (void)interruptForPolicyChangeAndKeepLoading:(BOOL)keepLoading
 {
     // Terminate the locationChangeDelegate correctly.
     WebError *interruptError = [WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
 
     // Must call receivedError before _clearProvisionalDataSource because
     // if we remove the data source from the frame, we can't get back to the frame any more.
-    [self receivedError:interruptError];
+    [self receivedError:interruptError complete:!keepLoading];
     [[dataSource webFrame] _clearProvisionalDataSource];
     
     [self notifyDelegatesOfInterruptionByPolicyChange];
@@ -105,7 +112,7 @@
 
 -(void)stopLoadingForPolicyChange
 {
-    [self interruptForPolicyChange];
+    [self interruptForPolicyChangeAndKeepLoading:NO];
     [self cancelQuietly];
 }
 
@@ -182,12 +189,11 @@
 	    [dataSource _setDownloadPath:saveFilename];
 	}
 
-        [self interruptForPolicyChange];
+        [self interruptForPolicyChangeAndKeepLoading:YES];
 	
 	// Hand off the dataSource to the download handler.  This will cause the remaining
 	// handle delegate callbacks to go to the controller's download delegate.
 	downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
-	[self setIsDownload:YES];
         break;
 
     case WebPolicyOpenURL:
@@ -328,8 +334,7 @@
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:error];
-    
+    [self receivedError:error complete:YES];
     [super handle:h didFailLoadingWithError:error];
 
     [self release];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index a99fbe4..936dab1 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -64,15 +64,23 @@
     return downloadHandler;
 }
 
-- (void)receivedError:(WebError *)error
+- (BOOL)isDownload
+{
+    return downloadHandler != nil;
+}
+
+- (void)receivedError:(WebError *)error complete:(BOOL)isComplete
 {
     if (downloadHandler) {
+        ASSERT(isComplete);
         [downloadHandler cancel];
         [downloadHandler release];
         downloadHandler = nil;
+        [dataSource _setPrimaryLoadComplete:YES];
     } else {
         [[dataSource controller] _mainReceivedError:error
-                                     fromDataSource:dataSource];
+                                     fromDataSource:dataSource
+                                           complete:isComplete];
     }
 }
 
@@ -83,21 +91,20 @@
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:[self cancelledError]];
-        
+    [self receivedError:[self cancelledError] complete:YES];
     [super cancel];
 
     [self release];
 }
 
-- (void)interruptForPolicyChange
+- (void)interruptForPolicyChangeAndKeepLoading:(BOOL)keepLoading
 {
     // Terminate the locationChangeDelegate correctly.
     WebError *interruptError = [WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
 
     // Must call receivedError before _clearProvisionalDataSource because
     // if we remove the data source from the frame, we can't get back to the frame any more.
-    [self receivedError:interruptError];
+    [self receivedError:interruptError complete:!keepLoading];
     [[dataSource webFrame] _clearProvisionalDataSource];
     
     [self notifyDelegatesOfInterruptionByPolicyChange];
@@ -105,7 +112,7 @@
 
 -(void)stopLoadingForPolicyChange
 {
-    [self interruptForPolicyChange];
+    [self interruptForPolicyChangeAndKeepLoading:NO];
     [self cancelQuietly];
 }
 
@@ -182,12 +189,11 @@
 	    [dataSource _setDownloadPath:saveFilename];
 	}
 
-        [self interruptForPolicyChange];
+        [self interruptForPolicyChangeAndKeepLoading:YES];
 	
 	// Hand off the dataSource to the download handler.  This will cause the remaining
 	// handle delegate callbacks to go to the controller's download delegate.
 	downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
-	[self setIsDownload:YES];
         break;
 
     case WebPolicyOpenURL:
@@ -328,8 +334,7 @@
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:error];
-    
+    [self receivedError:error complete:YES];
     [super handle:h didFailLoadingWithError:error];
 
     [self release];
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 855e204..8d4caf7 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -49,7 +49,7 @@
 - (void)_finishedLoadingResourceFromDataSource:(WebDataSource *)dataSource;
 - (void)_receivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
 - (void)_mainReceivedBytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
-- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
 + (NSString *)_MIMETypeForFile:(NSString *)path;
 + (NSArray *)_supportedImageMIMETypes;
 - (void)_downloadURL:(NSURL *)URL;
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index 4348015..170e7f2 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -150,18 +150,18 @@
 }
 
 
-- (void)_mainReceivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete
 {
     ASSERT(error);
     ASSERT(dataSource);
-    
-    WebFrame *frame = [dataSource webFrame];
-    ASSERT(frame);
-    
+    ASSERT([dataSource webFrame]);
+
     [dataSource _setMainDocumentError: error];
-    [dataSource _setPrimaryLoadComplete: YES];
 
-    [frame _checkLoadComplete];
+    if (isComplete) {
+        [dataSource _setPrimaryLoadComplete:YES];
+        [[dataSource webFrame] _checkLoadComplete];
+    }
 }
 
 + (NSString *)_MIMETypeForFile: (NSString *)path

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list