[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:33:16 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit d2b60b1c8621ca901925356cc6c1079ec5c2145b
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Apr 9 18:48:40 2004 +0000
WebKit:
Fixed:
<rdar://problem/3616873>: support for pasting and drag and dropping of URLS to editable WebViews
<rdar://problem/3546417>: support for pasting and drag and dropping of images to editable WebViews
Reviewed by rjw.
* DOM.subproj/WebDOMOperations.h:
* DOM.subproj/WebDOMOperations.m:
(-[DOMNode webArchive]): renamed from "archive" because "archive" collides with DOMHTMLObjectElement's method
(-[DOMRange webArchive]): ditto
* Misc.subproj/WebNSPasteboardExtras.h:
* Misc.subproj/WebNSPasteboardExtras.m:
(-[NSPasteboard _web_writeImage:URL:title:archive:]): take just an archive instead of an HTML string and file wrapper
* Misc.subproj/WebNSViewExtras.h:
* Misc.subproj/WebNSViewExtras.m:
(-[NSView _web_dragImage:archive:rect:URL:title:event:]): take just an archive instead of an HTML string and file wrapper
* WebView.subproj/WebDataProtocol.h:
* WebView.subproj/WebDataProtocol.m:
(+[NSURL _web_uniqueWebDataURL]): new
(+[NSURL _web_uniqueWebDataURLWithRelativeString:]): new
* WebView.subproj/WebDefaultContextMenuDelegate.m:
(-[WebDefaultUIDelegate copyImageToClipboard:]): call renamed _web_writeImage
* WebView.subproj/WebFrame.m:
(-[WebFrame _webDataRequestForData:MIMEType:textEncodingName:baseURL:unreachableURL:]): use _web_uniqueWebDataURL for creating a URL
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _pasteImageResource:]): new
(-[WebHTMLView _pasteFromPasteboard:]): renamed, now handles images and URLs
(-[WebHTMLView _handleMouseDragged:]): call renamed _web_dragImage
(-[WebHTMLView paste:]): call renamed _pasteFromPasteboard
(-[WebHTMLView concludeDragOperation:]): call renamed _pasteFromPasteboard
* WebView.subproj/WebHTMLViewPrivate.h:
* WebView.subproj/WebImageRepresentation.h:
* WebView.subproj/WebImageRepresentation.m:
(-[WebImageRepresentation archive]): new
* WebView.subproj/WebImageView.m:
(-[WebImageView writeImageToPasteboard:]): call renamed _web_writeImage
(-[WebImageView mouseDragged:]): call renamed _web_dragImage
WebBrowser:
Reviewed by rjw.
* BrowserDocument.m:
(-[BrowserDocument dataRepresentationOfType:]): call renamed [DOMNode webArchive]
(-[BrowserDocument mailPage:]): ditto
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6343 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index b02c5a5..cc38e6e 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,43 @@
+2004-04-08 Chris Blumenberg <cblu at apple.com>
+
+ Fixed:
+ <rdar://problem/3616873>: support for pasting and drag and dropping of URLS to editable WebViews
+ <rdar://problem/3546417>: support for pasting and drag and dropping of images to editable WebViews
+
+ Reviewed by rjw.
+
+ * DOM.subproj/WebDOMOperations.h:
+ * DOM.subproj/WebDOMOperations.m:
+ (-[DOMNode webArchive]): renamed from "archive" because "archive" collides with DOMHTMLObjectElement's method
+ (-[DOMRange webArchive]): ditto
+ * Misc.subproj/WebNSPasteboardExtras.h:
+ * Misc.subproj/WebNSPasteboardExtras.m:
+ (-[NSPasteboard _web_writeImage:URL:title:archive:]): take just an archive instead of an HTML string and file wrapper
+ * Misc.subproj/WebNSViewExtras.h:
+ * Misc.subproj/WebNSViewExtras.m:
+ (-[NSView _web_dragImage:archive:rect:URL:title:event:]): take just an archive instead of an HTML string and file wrapper
+ * WebView.subproj/WebDataProtocol.h:
+ * WebView.subproj/WebDataProtocol.m:
+ (+[NSURL _web_uniqueWebDataURL]): new
+ (+[NSURL _web_uniqueWebDataURLWithRelativeString:]): new
+ * WebView.subproj/WebDefaultContextMenuDelegate.m:
+ (-[WebDefaultUIDelegate copyImageToClipboard:]): call renamed _web_writeImage
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame _webDataRequestForData:MIMEType:textEncodingName:baseURL:unreachableURL:]): use _web_uniqueWebDataURL for creating a URL
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _pasteImageResource:]): new
+ (-[WebHTMLView _pasteFromPasteboard:]): renamed, now handles images and URLs
+ (-[WebHTMLView _handleMouseDragged:]): call renamed _web_dragImage
+ (-[WebHTMLView paste:]): call renamed _pasteFromPasteboard
+ (-[WebHTMLView concludeDragOperation:]): call renamed _pasteFromPasteboard
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ * WebView.subproj/WebImageRepresentation.h:
+ * WebView.subproj/WebImageRepresentation.m:
+ (-[WebImageRepresentation archive]): new
+ * WebView.subproj/WebImageView.m:
+ (-[WebImageView writeImageToPasteboard:]): call renamed _web_writeImage
+ (-[WebImageView mouseDragged:]): call renamed _web_dragImage
+
=== Safari-136 ===
2004-04-08 Chris Blumenberg <cblu at apple.com>
diff --git a/WebKit/DOM.subproj/WebDOMOperations.h b/WebKit/DOM.subproj/WebDOMOperations.h
index edea1e9..e9c5012 100644
--- a/WebKit/DOM.subproj/WebDOMOperations.h
+++ b/WebKit/DOM.subproj/WebDOMOperations.h
@@ -10,12 +10,12 @@
@class WebArchive;
@interface DOMNode (WebDOMNodeOperations)
-- (WebArchive *)archive;
+- (WebArchive *)webArchive;
- (NSString *)markupString;
@end
@interface DOMRange (WebDOMRangeOperations)
-- (WebArchive *)archive;
+- (WebArchive *)webArchive;
- (NSString *)markupString;
@end
diff --git a/WebKit/DOM.subproj/WebDOMOperations.m b/WebKit/DOM.subproj/WebDOMOperations.m
index 8597660..d17e537 100644
--- a/WebKit/DOM.subproj/WebDOMOperations.m
+++ b/WebKit/DOM.subproj/WebDOMOperations.m
@@ -24,7 +24,7 @@
return (WebBridge *)[WebBridge bridgeForDOMDocument:[self ownerDocument]];
}
-- (WebArchive *)archive
+- (WebArchive *)webArchive
{
WebBridge *bridge = [self _bridge];
NSArray *subresourceURLStrings;
@@ -46,7 +46,7 @@
return [[self startContainer] _bridge];
}
-- (WebArchive *)archive
+- (WebArchive *)webArchive
{
WebBridge *bridge = [self _bridge];
NSArray *subresourceURLStrings;
diff --git a/WebKit/English.lproj/StringsNotToBeLocalized.txt b/WebKit/English.lproj/StringsNotToBeLocalized.txt
index 6bc01ec..a527ea6 100644
--- a/WebKit/English.lproj/StringsNotToBeLocalized.txt
+++ b/WebKit/English.lproj/StringsNotToBeLocalized.txt
@@ -14,7 +14,7 @@
"%@/%s"
"%@/Library/Preferences/%@"
"%@:%u"
-"%@://%p"
+"%@://%@"
"%d"
","
"- %s:%d %s - "
@@ -22,6 +22,8 @@
"/<!--frame%d-->-->"
"/Library/Internet Plug-Ins"
"/favicon.ico"
+"/image.pict"
+"/image.tiff"
"/tmp/WebKitPlugInStreamXXXXXX"
"/tmp/XXXXXX.tiff"
"0x0"
@@ -41,6 +43,8 @@
":/?#"
";"
"<!--framePath "
+"<A HREF=\"%@\">%@</A>"
+"<IMG SRC=\"%@\">"
"="
"=================\nARGUMENT BAD: %s, %s (%s:%d %s)\n=================\n"
"=================\nASSERTION FAILED: "
@@ -277,6 +281,8 @@
"html"
"http"
"https"
+"image/pict"
+"image/tiff"
"javascript:"
"lastVisitedDate"
"localhost"
diff --git a/WebKit/Misc.subproj/WebNSPasteboardExtras.h b/WebKit/Misc.subproj/WebNSPasteboardExtras.h
index 91d9d38..cbe638c 100644
--- a/WebKit/Misc.subproj/WebNSPasteboardExtras.h
+++ b/WebKit/Misc.subproj/WebNSPasteboardExtras.h
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
+ at class WebArchive;
@class WebImageRenderer;
extern NSString *WebURLPboardType;
@@ -50,7 +51,6 @@ extern NSString *WebURLNamePboardType;
- (void)_web_writeImage:(WebImageRenderer *)image
URL:(NSURL *)URL
title:(NSString *)title
- fileWrapper:(NSFileWrapper *)wrapper
- HTMLString:(NSString *)HTMLString;
+ archive:(WebArchive *)archive;
@end
diff --git a/WebKit/Misc.subproj/WebNSPasteboardExtras.m b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
index b683948..c0c6137 100644
--- a/WebKit/Misc.subproj/WebNSPasteboardExtras.m
+++ b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
@@ -8,9 +8,12 @@
#import <WebKit/WebNSPasteboardExtras.h>
+#import <WebKit/WebArchive.h>
#import <WebKit/WebAssertions.h>
#import <WebKit/WebImageRenderer.h>
+#import <WebKit/WebImageRendererFactory.h>
#import <WebKit/WebNSURLExtras.h>
+#import <WebKit/WebResourcePrivate.h>
#import <WebKit/WebURLsWithTitles.h>
#import <WebKit/WebViewPrivate.h>
@@ -150,8 +153,7 @@ NSString *WebURLNamePboardType = nil;
- (void)_web_writeImage:(WebImageRenderer *)image
URL:(NSURL *)URL
title:(NSString *)title
- fileWrapper:(NSFileWrapper *)fileWrapper
- HTMLString:(NSString *)HTMLString
+ archive:(WebArchive *)archive
{
ASSERT(image);
ASSERT(URL);
@@ -161,11 +163,9 @@ NSString *WebURLNamePboardType = nil;
[types addObjectsFromArray:[NSPasteboard _web_writableDragTypesForURL]];
- if (fileWrapper) {
+ if (archive) {
[types addObject:NSRTFDPboardType];
- }
- if (HTMLString) {
- [types addObject:NSHTMLPboardType];
+ [types addObject:WebArchivePboardType];
}
if (isDrag) {
[types addObject:NSFilesPromisePboardType];
@@ -174,11 +174,16 @@ NSString *WebURLNamePboardType = nil;
[self _web_writeURL:URL andTitle:title withOwner:self types:types];
[self setData:[image TIFFRepresentation] forType:NSTIFFPboardType];
- if (fileWrapper) {
- [self _web_writeFileWrapperAsRTFDAttachment:fileWrapper];
- }
- if (HTMLString) {
- [self setString:HTMLString forType:NSHTMLPboardType];
+ if (archive) {
+ // This image data is either the only subresource of an archive (HTML image case)
+ // or the main resource (standalone image case).
+ WebResource *resource = [[archive subresources] objectAtIndex:0];
+ if (resource == nil) {
+ resource = [archive mainResource];
+ }
+ ASSERT([[[WebImageRendererFactory sharedFactory] supportedMIMETypes] containsObject:[resource MIMEType]]);
+ [self _web_writeFileWrapperAsRTFDAttachment:[resource _fileWrapperRepresentation]];
+ [self setData:[archive data] forType:WebArchivePboardType];
}
if (isDrag) {
NSString *filename = [URL _web_suggestedFilenameWithMIMEType:[image MIMEType]];
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
index 8d19b43..4cdb1f2 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.h
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -7,6 +7,7 @@
#define WebDragImageAlpha 0.75
+ at class WebArchive;
@class WebFrameView;
@class WebImageRenderer;
@@ -41,10 +42,9 @@
// Resizes and applies alpha to image, extends pboard and sets drag origins for dragging promised image files.
- (void)_web_dragImage:(WebImageRenderer *)image
- fileWrapper:(NSFileWrapper *)fileWrapper
+ archive:(WebArchive *)archive
rect:(NSRect)rect
URL:(NSURL *)URL
title:(NSString *)title
- HTMLString:(NSString *)HTMLString
event:(NSEvent *)event;
@end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
index 4dfb875..8168bc9 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.m
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -179,11 +179,10 @@
#endif
- (void)_web_dragImage:(WebImageRenderer *)image
- fileWrapper:(NSFileWrapper *)fileWrapper
+ archive:(WebArchive *)archive
rect:(NSRect)rect
URL:(NSURL *)URL
title:(NSString *)title
- HTMLString:(NSString *)HTMLString
event:(NSEvent *)event
{
NSPoint mouseDownPoint = [self convertPoint:[event locationInWindow] fromView:nil];
@@ -228,7 +227,7 @@
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- [pboard _web_writeImage:image URL:URL title:title fileWrapper:fileWrapper HTMLString:HTMLString];
+ [pboard _web_writeImage:image URL:URL title:title archive:archive];
id source = [[NSFilePromiseDragSource alloc] initWithSource:(id)self];
[source setTypes:filesTypes onPasteboard:pboard];
diff --git a/WebKit/WebView.subproj/WebDataProtocol.h b/WebKit/WebView.subproj/WebDataProtocol.h
index e0fd8c0..caf4329 100644
--- a/WebKit/WebView.subproj/WebDataProtocol.h
+++ b/WebKit/WebView.subproj/WebDataProtocol.h
@@ -17,8 +17,12 @@
+ (BOOL)_webIsDataProtocolURL:(NSURL *)URL;
@end
+ at interface NSURL (WebDataURL)
++ (NSURL *)_web_uniqueWebDataURL;
++ (NSURL *)_web_uniqueWebDataURLWithRelativeString:(NSString *)string;
+ at end
+
@interface NSURLRequest (WebDataRequest)
-+ (NSURL *)_webDataRequestURLForData:(NSData *)data;
- (NSURL *)_webDataRequestBaseURL;
- (NSURL *)_webDataRequestUnreachableURL;
- (NSURL *)_webDataRequestExternalURL;
diff --git a/WebKit/WebView.subproj/WebDataProtocol.m b/WebKit/WebView.subproj/WebDataProtocol.m
index 9829cbf..e22612d 100644
--- a/WebKit/WebView.subproj/WebDataProtocol.m
+++ b/WebKit/WebView.subproj/WebDataProtocol.m
@@ -50,9 +50,9 @@ static NSString *WebDataRequestPropertyKey = @"WebDataRequest";
@end
- at implementation NSURLRequest (WebDataRequest)
+ at implementation NSURL (WebDataURL)
-+ (NSURL *)_webDataRequestURLForData:(NSData *)data
++ (NSURL *)_web_uniqueWebDataURL
{
static BOOL registered;
@@ -60,15 +60,25 @@ static NSString *WebDataRequestPropertyKey = @"WebDataRequest";
[NSURLProtocol registerClass:[WebDataProtocol class]];
registered = YES;
}
-
- static unsigned int counter = 1;
- // The URL we generate is meaningless. The only interesting properties of the URL
- // are it's scheme and that they be unique for the lifespan of the application.
- NSURL *fakeURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%p", WebDataProtocolScheme, counter++, 0]];
- return fakeURL;
+ CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
+ NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
+ CFRelease(UUIDRef);
+ NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", WebDataProtocolScheme, UUIDString]];
+ [UUIDString release];
+ return URL;
+}
+
++ (NSURL *)_web_uniqueWebDataURLWithRelativeString:(NSString *)string
+{
+ return [NSURL URLWithString:string relativeToURL:[self _web_uniqueWebDataURL]];
}
+ at end
+
+
+ at implementation NSURLRequest (WebDataRequest)
+
- (WebDataRequestParameters *)_webDataRequestParametersForReading
{
return [NSURLProtocol propertyForKey:WebDataRequestPropertyKey inRequest:self];
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
index da94e00..f28c0bd 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
@@ -212,14 +212,10 @@
{
NSDictionary *element = [sender representedObject];
NSURL *linkURL = [element objectForKey:WebElementLinkURLKey];
- NSURL *imageURL = [element objectForKey:WebElementImageURLKey];
- NSFileWrapper *wrapper = [[[element objectForKey:WebElementFrameKey] dataSource] _fileWrapperForURL:imageURL];
- ASSERT(wrapper);
[[NSPasteboard generalPasteboard] _web_writeImage:[element objectForKey:WebElementImageKey]
- URL:linkURL ? linkURL : imageURL
+ URL:linkURL ? linkURL : [element objectForKey:WebElementImageURLKey]
title:[element objectForKey:WebElementImageAltStringKey]
- fileWrapper:wrapper
- HTMLString:[[element objectForKey:WebCoreElementDOMNodeKey] markupString]];
+ archive:[[element objectForKey:WebCoreElementDOMNodeKey] webArchive]];
}
- (void)openFrameInNewWindow:(id)sender
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 0f452f4..c0a87f6 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -267,8 +267,8 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
- (NSURLRequest *)_webDataRequestForData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName: (NSString *)encodingName baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL
{
- NSURL *fakeURL = [NSURLRequest _webDataRequestURLForData: data];
- NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL: fakeURL] autorelease];
+ NSURL *fakeURL = [NSURL _web_uniqueWebDataURL];
+ NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:fakeURL] autorelease];
[request _webDataRequestSetData:data];
[request _webDataRequestSetEncoding:encodingName];
[request _webDataRequestSetBaseURL:URL];
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 22af4c8..e57c263 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -9,6 +9,7 @@
#import <WebKit/WebArchive.h>
#import <WebKit/WebBridge.h>
#import <WebKit/WebClipView.h>
+#import <WebKit/WebDataProtocol.h>
#import <WebKit/WebDataSourcePrivate.h>
#import <WebKit/WebDocumentInternal.h>
#import <WebKit/WebDOMOperations.h>
@@ -18,6 +19,7 @@
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebHTMLRepresentationPrivate.h>
#import <WebKit/WebImageRenderer.h>
+#import <WebKit/WebImageRendererFactory.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebKitNSStringExtras.h>
#import <WebKit/WebNetscapePluginEmbeddedView.h>
@@ -577,29 +579,76 @@ static WebHTMLView *lastHitView = nil;
return [[self _bridge] isSelectionEditable];
}
-- (void)_pasteMarkupFromPasteboard:(NSPasteboard *)pasteboard
+- (void)_pasteMarkupString:(NSString *)markupString
+{
+ if ([markupString length] > 0) {
+ [[self _bridge] pasteMarkupString:markupString];
+ }
+}
+
+- (void)_pasteImageResource:(WebResource *)resource
+{
+ ASSERT(resource);
+ [[self _dataSource] addSubresource:resource];
+ [self _pasteMarkupString:[NSString stringWithFormat:@"<IMG SRC=\"%@\">", [[resource URL] _web_originalDataAsString]]];
+}
+
+- (void)_pasteFromPasteboard:(NSPasteboard *)pasteboard
{
NSArray *types = [pasteboard types];
- NSString *markupString = nil;
if ([types containsObject:WebArchivePboardType]) {
- WebArchive *archive = [[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]];
+ WebArchive *archive = [[[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]] autorelease];
WebResource *mainResource = [archive mainResource];
if (mainResource) {
- markupString = [[[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding] autorelease];
- [[self _dataSource] addSubresources:[archive subresources]];
+ NSString *MIMEType = [mainResource MIMEType];
+ if ([WebView canShowMIMETypeAsHTML:MIMEType]) {
+ NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding];
+ [[self _dataSource] addSubresources:[archive subresources]];
+ [self _pasteMarkupString:markupString];
+ [markupString release];
+ return;
+ } else if ([[[WebImageRendererFactory sharedFactory] supportedMIMETypes] containsObject:MIMEType]) {
+ [self _pasteImageResource:mainResource];
+ return;
+ }
}
- [archive release];
}
- if (!markupString && [types containsObject:NSHTMLPboardType]) {
- markupString = [pasteboard stringForType:NSHTMLPboardType];
- }
- if (!markupString && [types containsObject:NSStringPboardType]) {
- markupString = [pasteboard stringForType:NSStringPboardType];
- }
- if (markupString) {
- [[self _bridge] pasteMarkupString:markupString];
+ NSURL *URL;
+
+ if ([types containsObject:NSHTMLPboardType]) {
+ [self _pasteMarkupString:[pasteboard stringForType:NSHTMLPboardType]];
+ } else if ([types containsObject:NSTIFFPboardType]) {
+ WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSTIFFPboardType]
+ URL:[NSURL _web_uniqueWebDataURLWithRelativeString:@"/image.tiff"]
+ MIMEType:@"image/tiff"
+ textEncodingName:nil];
+ [self _pasteImageResource:resource];
+ [resource release];
+ } else if ([types containsObject:NSPICTPboardType]) {
+ WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSPICTPboardType]
+ URL:[NSURL _web_uniqueWebDataURLWithRelativeString:@"/image.pict"]
+ MIMEType:@"image/pict"
+ textEncodingName:nil];
+ [self _pasteImageResource:resource];
+ [resource release];
+ } else if ((URL = [pasteboard _web_bestURL])) {
+ NSString *URLString = [URL _web_originalDataAsString];
+ NSString *linkLabel = [pasteboard stringForType:WebURLNamePboardType];
+ linkLabel = [linkLabel length] > 0 ? linkLabel : URLString;
+ NSString *markupString = [NSString stringWithFormat:@"<A HREF=\"%@\">%@</A>", URLString, linkLabel];
+ [self _pasteMarkupString:markupString];
+ } else if ([types containsObject:NSRTFDPboardType]) {
+ // FIXME: Support RTFD to HTML (or DOM) conversion.
+ ERROR("RTFD to HTML conversion not yet supported.");
+ [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]];
+ } else if ([types containsObject:NSRTFPboardType]) {
+ // FIXME: Support RTF to HTML (or DOM) conversion.
+ ERROR("RTF to HTML conversion not yet supported.");
+ [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]];
+ } else if ([types containsObject:NSStringPboardType]) {
+ [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]];
}
}
@@ -714,11 +763,10 @@ static WebHTMLView *lastHitView = nil;
NSFileWrapper *fileWrapper = [[self _dataSource] _fileWrapperForURL:_private->draggingImageURL];
ASSERT(fileWrapper);
[self _web_dragImage:image
- fileWrapper:fileWrapper
+ archive:[[element objectForKey:WebCoreElementDOMNodeKey] webArchive]
rect:[[element objectForKey:WebElementImageRectKey] rectValue]
URL:linkURL ? linkURL : imageURL
title:[element objectForKey:WebElementImageAltStringKey]
- HTMLString:[[element objectForKey:WebCoreElementDOMNodeKey] markupString]
event:_private->mouseDownEvent];
} else if (linkURL) {
@@ -952,7 +1000,9 @@ static WebHTMLView *lastHitView = nil;
_private->pluginController = [[WebPluginController alloc] initWithHTMLView:self];
_private->needsLayout = YES;
- [self registerForDraggedTypes:[NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSStringPboardType, nil]];
+ [self registerForDraggedTypes:[NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType,
+ NSTIFFPboardType, NSPICTPboardType, NSURLPboardType,
+ NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, nil]];
return self;
}
@@ -995,7 +1045,7 @@ static WebHTMLView *lastHitView = nil;
- (void)paste:(id)sender
{
- [self _pasteMarkupFromPasteboard:[NSPasteboard generalPasteboard]];
+ [self _pasteFromPasteboard:[NSPasteboard generalPasteboard]];
}
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
@@ -1661,7 +1711,7 @@ static WebHTMLView *lastHitView = nil;
{
if ([self _dragOperationForDraggingInfo:sender] != NSDragOperationNone) {
// FIXME: We should delete the original selection if we're doing a move.
- [self _pasteMarkupFromPasteboard:[sender draggingPasteboard]];
+ [self _pasteFromPasteboard:[sender draggingPasteboard]];
} else {
// Since we're not handling the drag, forward this message to the WebView since it may want to handle it.
[[self _webView] concludeDragOperation:sender];
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index e41e5b2..e1611c3 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -77,7 +77,7 @@
- (BOOL)_canDelete;
- (BOOL)_canPaste;
- (BOOL)_haveSelection;
-- (void)_pasteMarkupFromPasteboard:(NSPasteboard *)pasteboard;
+- (void)_pasteFromPasteboard:(NSPasteboard *)pasteboard;
- (void)_frameOrBoundsChanged;
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.h b/WebKit/WebView.subproj/WebImageRepresentation.h
index 561500b..5b0721c 100644
--- a/WebKit/WebView.subproj/WebImageRepresentation.h
+++ b/WebKit/WebView.subproj/WebImageRepresentation.h
@@ -5,7 +5,9 @@
#import <Cocoa/Cocoa.h>
+ at class WebArchive;
@class WebImageRenderer;
+
@protocol WebDocumentRepresentation;
@interface WebImageRepresentation : NSObject <WebDocumentRepresentation>
@@ -17,7 +19,7 @@
}
- (WebImageRenderer *)image;
- (NSString *)filename;
-- (NSFileWrapper *)fileWrapper;
+- (WebArchive *)archive;
- (BOOL)doneLoading;
- (NSData *)data;
- (NSURL *)URL;
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.m b/WebKit/WebView.subproj/WebImageRepresentation.m
index c085e74..f53f23d 100644
--- a/WebKit/WebView.subproj/WebImageRepresentation.m
+++ b/WebKit/WebView.subproj/WebImageRepresentation.m
@@ -5,10 +5,12 @@
#import "WebImageRepresentation.h"
+#import <WebKit/WebArchive.h>
#import <WebKit/WebDataSource.h>
#import <WebKit/WebImageRenderer.h>
#import <WebKit/WebImageRendererFactory.h>
#import <WebKit/WebLocalizableStrings.h>
+#import <WebKit/WebResource.h>
#import <WebCore/WebCoreImageRenderer.h>
@@ -96,11 +98,12 @@
return filename;
}
-- (NSFileWrapper *)fileWrapper
+- (WebArchive *)archive
{
- NSFileWrapper *wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:data];
- [wrapper setPreferredFilename:filename];
- return [wrapper autorelease];
+ WebResource *resource = [[WebResource alloc] initWithData:data URL:URL MIMEType:[image MIMEType] textEncodingName:nil];
+ WebArchive *archive = [[[WebArchive alloc] initWithMainResource:resource subresources:nil] autorelease];
+ [resource release];
+ return archive;
}
@end
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
index 126a487..8b6e041 100644
--- a/WebKit/WebView.subproj/WebImageView.m
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -177,7 +177,7 @@
- (BOOL)writeImageToPasteboard:(NSPasteboard *)pasteboard
{
if ([self haveCompleteImage]) {
- [pasteboard _web_writeImage:[rep image] URL:[rep URL] title:nil fileWrapper:[rep fileWrapper] HTMLString:nil];
+ [pasteboard _web_writeImage:[rep image] URL:[rep URL] title:nil archive:[rep archive]];
return YES;
}
@@ -232,11 +232,10 @@
[self retain];
[self _web_dragImage:[rep image]
- fileWrapper:[rep fileWrapper]
+ archive:[rep archive]
rect:[self drawingRect]
URL:[rep URL]
title:nil
- HTMLString:nil
event:event];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list