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

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:05:49 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 783d171febe63edc9f66f1c2a76206b8bd4150f6
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 27 16:28:59 2003 +0000

    	Fixed:
    	<rdar://problem/3462977>: ER: Nice if images dragged from web pages didn't redownload
    	<rdar://problem/3031582>: Dragging an image to the desktop doesn't leave the file where I dropped it
    	<rdar://problem/3061371>: "CFURLGetFSRef failed" log when dragging image to Finder
    
            Reviewed by john.
    
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]): attempt to fetch the image data from the cache, if that works, write out the file
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5275 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index e31abf2..d2d3aa3 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2003-10-24  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed:
+	<rdar://problem/3462977>: ER: Nice if images dragged from web pages didn't redownload
+	<rdar://problem/3031582>: Dragging an image to the desktop doesn't leave the file where I dropped it
+	<rdar://problem/3061371>: "CFURLGetFSRef failed" log when dragging image to Finder
+
+        Reviewed by john.
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]): attempt to fetch the image data from the cache, if that works, write out the file
+
 2003-10-26  Darin Adler  <darin at apple.com>
 
         * WebKitPrefix.h: Add a definition of NULL here so we get the stricter type checking
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 3282a0e..f8bc70c 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -38,6 +38,9 @@
 #import <WebKit/WebPreferences.h>
 #import <WebKit/WebStringTruncator.h>
 
+#import <Foundation/NSFileManager_NSURLExtras.h>
+#import <Foundation/NSURL_NSURLExtras.h>
+#import <Foundation/NSURLRequestPrivate.h>
 
 // These are a little larger than typical because dragging links is a fairly
 // advanced feature that can confuse non-power-users
@@ -1481,19 +1484,34 @@ static WebHTMLView *lastHitView = nil;
 
 - (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
 {
-    if (!_private->draggingImageURL) {
-        return nil;
+    ASSERT(_private->draggingImageURL);
+    
+    WebView *webView = [self _webView];
+    NSString *filename;
+    
+    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_private->draggingImageURL];
+    [request setHTTPUserAgent:[webView userAgentForURL:_private->draggingImageURL]];
+    NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
+    [request release];
+    
+    NSData *data = [cachedResponse data];
+    if (data) {
+        // FIXME: Report an error if we fail to create a file.
+        NSString *path = [[dropDestination path] stringByAppendingPathComponent:[[cachedResponse response] suggestedFilename]];
+        path = [[NSFileManager defaultManager] _web_pathWithUniqueFilenameForPath:path];
+        if (![data writeToFile:path atomically:NO]) {
+            ERROR("Failed to create image file via [NSData writeToFile:atomically:]");
+        }
+        filename = [path lastPathComponent];
+    } else {
+        // FIXME: The file is supposed to be created at this point so the Finder places the file
+        // where the drag ended. Since we can't create the file until the download starts,
+        // this fails.
+        [webView _downloadURL:_private->draggingImageURL toDirectory:[dropDestination path]];
+        filename = [_private->draggingImageURL _web_suggestedFilenameWithMIMEType:nil];
     }
-
-    [[self _webView] _downloadURL:_private->draggingImageURL toDirectory:[dropDestination path]];
-
-    // FIXME: The file is supposed to be created at this point so the Finder places the file
-    // where the drag ended. Since we can't create the file until the download starts,
-    // this fails. Even if we did create the file at this point, the Finder doesn't
-    // place the file in the right place anyway (2825055).
-    // FIXME: We may return a different filename than the file that we will create.
-    // Since the file isn't created at this point anwyway, it doesn't matter what we return.
-    return [NSArray arrayWithObject:[[_private->draggingImageURL path] lastPathComponent]];
+    
+    return [NSArray arrayWithObject:filename];
 }
 
 - (void)mouseUp:(NSEvent *)event

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list