[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:45:15 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 313f1a9c0652294497a1df86f796153e6e44d5f0
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jun 12 01:04:58 2004 +0000
WebCore:
Support for WebKit drag & drop API.
Reviewed by trey.
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge _positionForPoint:]): new
(-[WebCoreBridge moveDragCaretToPoint:]): call _positionForPoint
(-[WebCoreBridge editableDOMRangeForPoint:]): new
WebKit:
Implemented the remainder of the drag & drop API.
Reviewed by trey.
* Misc.subproj/WebNSPasteboardExtras.h:
* Misc.subproj/WebNSPasteboardExtras.m:
(-[NSPasteboard _web_declareAndWriteDragImage:URL:title:archive:source:]): new
* Misc.subproj/WebNSViewExtras.h:
* Misc.subproj/WebNSViewExtras.m:
(-[NSView _web_dragImage:rect:event:pasteboard:source:]): simplified, this method now just creates a drag image and starts the drag
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge allowDHTMLDrag:UADrag:]): now calls _delegateDragSourceActionMask on WebHTMLView to interact with the delegate
* WebView.subproj/WebDefaultUIDelegate.m:
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]): call new delegate method, cleaned-up a little
(-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): call drag caret methods on WebView instead of WebBridge so WebView can make sure only 1 HTML view has a drag cursor
(-[WebHTMLView draggingCancelledWithDraggingInfo:]): ditto
(-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): ditto
(-[WebHTMLView _delegateDragSourceActionMask]): new, gets drag source action mask from delegate
* WebView.subproj/WebHTMLViewInternal.h:
* WebView.subproj/WebImageView.h:
* WebView.subproj/WebImageView.m:
(-[WebImageView mouseDown:]): get the drag source action mask from the delegate
(-[WebImageView mouseDragged:]): inform the delegate of the drag
* WebView.subproj/WebView.m:
(-[WebViewPrivate dealloc]): assert that dragCursorBridge is nil
(-[WebView _close]): release dragCursorBridge
(-[WebView _bridgeAtPoint:]): new
(-[WebView editableDOMRangeForPoint:]): new API
(-[WebView moveDragCaretToPoint:]): new API
(-[WebView removeDragCaret]): new API
(-[WebView _frameViewAtWindowPoint:]): moved so this can be called internally
* WebView.subproj/WebViewInternal.h:
* WebView.subproj/WebViewPrivate.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 4bc6759..608f2ee 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2004-06-11 Chris Blumenberg <cblu at apple.com>
+
+ Support for WebKit drag & drop API.
+
+ Reviewed by trey.
+
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge _positionForPoint:]): new
+ (-[WebCoreBridge moveDragCaretToPoint:]): call _positionForPoint
+ (-[WebCoreBridge editableDOMRangeForPoint:]): new
+
2004-06-11 Darin Adler <darin at apple.com>
Reviewed by Dave.
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 18d2462..38d5166 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -307,6 +307,7 @@ typedef enum {
- (void)moveDragCaretToPoint:(NSPoint)point;
- (void)removeDragCaret;
- (DOMRange *)dragCaretDOMRange;
+- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point;
- (void)deleteSelection;
- (void)deleteKeyPressed;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 7842d0b..2f339b3 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1462,18 +1462,22 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
cmd.apply();
}
-- (void)moveDragCaretToPoint:(NSPoint)point
+- (Position)_positionForPoint:(NSPoint)point
{
RenderObject *renderer = _part->renderer();
if (!renderer) {
- return;
+ return Position();
}
RenderObject::NodeInfo nodeInfo(true, true);
renderer->layer()->nodeAtPoint(nodeInfo, (int)point.x, (int)point.y);
NodeImpl *node = nodeInfo.innerNode();
-
- Selection dragCaret(node->positionForCoordinates((int)point.x, (int)point.y));
+ return node->positionForCoordinates((int)point.x, (int)point.y);
+}
+
+- (void)moveDragCaretToPoint:(NSPoint)point
+{
+ Selection dragCaret([self _positionForPoint:point]);
_part->setDragCaret(dragCaret);
}
@@ -1487,6 +1491,12 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
return [DOMRange _rangeWithImpl:_part->dragCaret().toRange().handle()];
}
+- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point
+{
+ Position position = [self _positionForPoint:point];
+ return position.isEmpty() ? nil : [DOMRange _rangeWithImpl:Selection(position).toRange().handle()];
+}
+
- (void)deleteSelection
{
if (!_part || !_part->xmlDocImpl())
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c74c553..366a81b 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,40 @@
+2004-06-11 Chris Blumenberg <cblu at apple.com>
+
+ Implemented the remainder of the drag & drop API.
+
+ Reviewed by trey.
+
+ * Misc.subproj/WebNSPasteboardExtras.h:
+ * Misc.subproj/WebNSPasteboardExtras.m:
+ (-[NSPasteboard _web_declareAndWriteDragImage:URL:title:archive:source:]): new
+ * Misc.subproj/WebNSViewExtras.h:
+ * Misc.subproj/WebNSViewExtras.m:
+ (-[NSView _web_dragImage:rect:event:pasteboard:source:]): simplified, this method now just creates a drag image and starts the drag
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge allowDHTMLDrag:UADrag:]): now calls _delegateDragSourceActionMask on WebHTMLView to interact with the delegate
+ * WebView.subproj/WebDefaultUIDelegate.m:
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]): call new delegate method, cleaned-up a little
+ (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): call drag caret methods on WebView instead of WebBridge so WebView can make sure only 1 HTML view has a drag cursor
+ (-[WebHTMLView draggingCancelledWithDraggingInfo:]): ditto
+ (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): ditto
+ (-[WebHTMLView _delegateDragSourceActionMask]): new, gets drag source action mask from delegate
+ * WebView.subproj/WebHTMLViewInternal.h:
+ * WebView.subproj/WebImageView.h:
+ * WebView.subproj/WebImageView.m:
+ (-[WebImageView mouseDown:]): get the drag source action mask from the delegate
+ (-[WebImageView mouseDragged:]): inform the delegate of the drag
+ * WebView.subproj/WebView.m:
+ (-[WebViewPrivate dealloc]): assert that dragCursorBridge is nil
+ (-[WebView _close]): release dragCursorBridge
+ (-[WebView _bridgeAtPoint:]): new
+ (-[WebView editableDOMRangeForPoint:]): new API
+ (-[WebView moveDragCaretToPoint:]): new API
+ (-[WebView removeDragCaret]): new API
+ (-[WebView _frameViewAtWindowPoint:]): moved so this can be called internally
+ * WebView.subproj/WebViewInternal.h:
+ * WebView.subproj/WebViewPrivate.h:
+
2004-07-10 Trey Matteson <trey at apple.com>
Prep work for latest delegate API for dragging. In addition, I also straightened out all
diff --git a/WebKit/Misc.subproj/WebNSPasteboardExtras.h b/WebKit/Misc.subproj/WebNSPasteboardExtras.h
index 3890533..c59fcbd 100644
--- a/WebKit/Misc.subproj/WebNSPasteboardExtras.h
+++ b/WebKit/Misc.subproj/WebNSPasteboardExtras.h
@@ -47,4 +47,10 @@ extern NSString *WebURLNamePboardType;
archive:(WebArchive *)archive
types:(NSArray *)types;
+- (id)_web_declareAndWriteDragImage:(WebImageRenderer *)image
+ URL:(NSURL *)URL
+ title:(NSString *)title
+ archive:(WebArchive *)archive
+ source:(id)source;
+
@end
diff --git a/WebKit/Misc.subproj/WebNSPasteboardExtras.m b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
index 0bde080..b7ec8f3 100644
--- a/WebKit/Misc.subproj/WebNSPasteboardExtras.m
+++ b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
@@ -19,12 +19,18 @@
#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURL_NSURLExtras.h>
+#import <Foundation/NSURLFileTypeMappings.h>
#import <HIServices/CoreTranslationFlavorTypeNames.h>
NSString *WebURLPboardType = nil;
NSString *WebURLNamePboardType = nil;
+ at interface NSFilePromiseDragSource : NSObject
+- initWithSource:(id)draggingSource;
+- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pboard;
+ at end
+
@implementation NSPasteboard (WebExtras)
+ (void)initialize
@@ -202,4 +208,27 @@ NSString *WebURLNamePboardType = nil;
}
}
+- (id)_web_declareAndWriteDragImage:(WebImageRenderer *)image
+ URL:(NSURL *)URL
+ title:(NSString *)title
+ archive:(WebArchive *)archive
+ source:(id)source
+{
+ ASSERT(self == [NSPasteboard pasteboardWithName:NSDragPboard]);
+ NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil];
+ [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImage]];
+ [self declareTypes:types owner:source];
+ [self _web_writeImage:image URL:URL title:title archive:archive types:types];
+ [types release];
+
+ NSString *extension = [[NSURLFileTypeMappings sharedMappings] preferredExtensionForMIMEType:[image MIMEType]];
+ if (extension == nil) {
+ extension = @"";
+ }
+ id dragSource = [[NSFilePromiseDragSource alloc] initWithSource:source];
+ [dragSource setTypes:[NSArray arrayWithObject:extension] onPasteboard:self];
+
+ return dragSource;
+}
+
@end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
index d3b36b5..feadce6 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.h
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -40,14 +40,10 @@
// Returns NSDragOperationNone otherwise.
- (NSDragOperation)_web_dragOperationForDraggingInfo:(id <NSDraggingInfo>)sender;
-// Resizes and applies alpha to image, extends pboard and sets drag origins for dragging promised image files.
+// Resizes and applies alpha to image and drags it.
- (void)_web_dragImage:(WebImageRenderer *)image
- archive:(WebArchive *)archive
rect:(NSRect)rect
- URL:(NSURL *)URL
- title:(NSString *)title
event:(NSEvent *)event
- dragImage:(NSImage *)dragImageOverride
- dragLocation:(NSPoint)dragLocOverride
- writePasteboard:(BOOL)writePB;
+ pasteboard:(NSPasteboard *)pasteboard
+ source:(id)source;
@end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
index 9c3a0d8..a398832 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.m
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -13,6 +13,7 @@
#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURL_NSURLExtras.h>
+#import <Foundation/NSURLFileTypeMappings.h>
#define WebDragStartHysteresisX 5.0
#define WebDragStartHysteresisY 5.0
@@ -29,11 +30,6 @@
@end
#endif
- at interface NSFilePromiseDragSource : NSObject
-- initWithSource:(id)draggingSource;
-- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pboard;
- at end
-
@implementation NSView (WebExtras)
- (NSView *)_web_superviewOfClass:(Class)class stoppingAtClass:(Class)limitClass
@@ -179,64 +175,40 @@
#endif
- (void)_web_dragImage:(WebImageRenderer *)image
- archive:(WebArchive *)archive
rect:(NSRect)rect
- URL:(NSURL *)URL
- title:(NSString *)title
event:(NSEvent *)event
- dragImage:(NSImage *)dragImageOverride
- dragLocation:(NSPoint)dragLocOverride
- writePasteboard:(BOOL)writePB
+ pasteboard:(NSPasteboard *)pasteboard
+ source:(id)source
{
NSPoint mouseDownPoint = [self convertPoint:[event locationInWindow] fromView:nil];
NSImage *dragImage;
NSPoint origin;
-
- NSString *filename = [URL _web_suggestedFilenameWithMIMEType:[image MIMEType]];
- NSString *fileType = [filename pathExtension];
- if (!fileType) {
- fileType = @"";
- }
- if (dragImageOverride) {
- dragImage = dragImageOverride;
- origin = dragLocOverride;
- } else {
- if ([image size].height * [image size].width <= WebMaxOriginalImageArea) {
- NSSize originalSize = rect.size;
- origin = rect.origin;
-
- dragImage = [[image copy] autorelease];
- [dragImage setScalesWhenResized:YES];
- [dragImage setSize:originalSize];
+ if ([image size].height * [image size].width <= WebMaxOriginalImageArea) {
+ NSSize originalSize = rect.size;
+ origin = rect.origin;
- [dragImage _web_scaleToMaxSize:WebMaxDragImageSize];
- NSSize newSize = [dragImage size];
+ dragImage = [[image copy] autorelease];
+ [dragImage setScalesWhenResized:YES];
+ [dragImage setSize:originalSize];
- [dragImage _web_dissolveToFraction:WebDragImageAlpha];
-
- // Properly orient the drag image and orient it differently if it's smaller than the original
- origin.x = mouseDownPoint.x - (((mouseDownPoint.x - origin.x) / originalSize.width) * newSize.width);
- origin.y = origin.y + originalSize.height;
- origin.y = mouseDownPoint.y - (((mouseDownPoint.y - origin.y) / originalSize.height) * newSize.height);
- } else {
- dragImage = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
- NSSize offset = NSMakeSize([dragImage size].width - WebDragIconRightInset, -WebDragIconBottomInset);
- origin = NSMakePoint(mouseDownPoint.x - offset.width, mouseDownPoint.y - offset.height);
+ [dragImage _web_scaleToMaxSize:WebMaxDragImageSize];
+ NSSize newSize = [dragImage size];
+
+ [dragImage _web_dissolveToFraction:WebDragImageAlpha];
+
+ // Properly orient the drag image and orient it differently if it's smaller than the original
+ origin.x = mouseDownPoint.x - (((mouseDownPoint.x - origin.x) / originalSize.width) * newSize.width);
+ origin.y = origin.y + originalSize.height;
+ origin.y = mouseDownPoint.y - (((mouseDownPoint.y - origin.y) / originalSize.height) * newSize.height);
+ } else {
+ NSString *extension = [[NSURLFileTypeMappings sharedMappings] preferredExtensionForMIMEType:[image MIMEType]];
+ if (extension == nil) {
+ extension = @"";
}
- }
-
- NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- id source = nil;
- if (writePB) {
- NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil];
- [types addObjectsFromArray:[NSPasteboard _web_writableTypesForImage]];
- [pasteboard declareTypes:types owner:self];
- [pasteboard _web_writeImage:image URL:URL title:title archive:archive types:types];
- [types release];
-
- source = [[NSFilePromiseDragSource alloc] initWithSource:(id)self];
- [source setTypes:[NSArray arrayWithObject:fileType] onPasteboard:pasteboard];
+ dragImage = [[NSWorkspace sharedWorkspace] iconForFileType:extension];
+ NSSize offset = NSMakeSize([dragImage size].width - WebDragIconRightInset, -WebDragIconBottomInset);
+ origin = NSMakePoint(mouseDownPoint.x - offset.width, mouseDownPoint.y - offset.height);
}
// Per kwebster, offset arg is ignored
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 3e010a6..e83d46f 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -989,9 +989,11 @@ static BOOL loggedObjectCacheSize = NO;
- (void)allowDHTMLDrag:(BOOL *)flagDHTML UADrag:(BOOL *)flagUA
{
- // FIXME: call up to the WebView, then out to the delegate for the drag action
- *flagDHTML = YES;
- *flagUA = YES;
+ WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
+ ASSERT([docView isKindOfClass:[WebHTMLView class]]);
+ unsigned int mask = [docView _delegateDragSourceActionMask];
+ *flagDHTML = (mask & WebDragSourceActionDHTML) != 0;
+ *flagUA = ((mask & WebDragSourceActionImage) || (mask & WebDragSourceActionLink) || (mask & WebDragSourceActionSelection));
}
- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData
diff --git a/WebKit/WebView.subproj/WebDefaultUIDelegate.m b/WebKit/WebView.subproj/WebDefaultUIDelegate.m
index aecc46b..c864ec1 100644
--- a/WebKit/WebView.subproj/WebDefaultUIDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultUIDelegate.m
@@ -182,4 +182,13 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
{
}
+- (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
+{
+ return WebDragSourceActionAny;
+}
+
+- (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard;
+{
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 1390a7e..f16a7a7 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -816,61 +816,50 @@ static WebHTMLView *lastHitView = nil;
} else {
dragLoc = NSMakePoint(mouseDownPoint.x - wcDragLoc.x, mouseDownPoint.y + wcDragLoc.y);
}
- } else if (imageURL) {
- // This image is only for the benefit of the delegate!? _web_dragImage figures out its own version
- dragImage = [[[element objectForKey:WebElementImageKey] copy] autorelease];
- [dragImage _web_dissolveToFraction:WebDragImageAlpha];
- dragLoc = NSZeroPoint; // unused below, _web_dragImage figures out the location
- } else if (linkURL) {
- dragImage = [self _dragImageForLinkElement:element];
- NSSize offset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
- dragLoc = NSMakePoint(mouseDraggedPoint.x - offset.width, mouseDraggedPoint.y - offset.height);
- } else if (isSelected) {
- dragImage = [[self _bridge] selectionImage];
- [dragImage _web_dissolveToFraction:WebDragImageAlpha];
- NSRect visibleSelectionRect = [[self _bridge] visibleSelectionRect];
- dragLoc = NSMakePoint(NSMinX(visibleSelectionRect), NSMaxY(visibleSelectionRect));
- } else {
- ASSERT(srcIsDHTML);
- // WebCore should have given us an image, but we'll make one up
- NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"missing_image" ofType:@"tiff"];
- dragImage = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
- NSSize imageSize = [dragImage size];
- dragLoc = NSMakePoint(mouseDownPoint.x - imageSize.width/2, mouseDownPoint.y + imageSize.height/2);
}
- ASSERT(dragImage != nil);
WebView *webView = [self _webView];
- //??? use srcIsDHTML to determine DragDestAction
- if (![[webView _UIDelegateForwarder] webView:webView
- shouldBeginDragForElement:element
- dragImage:dragImage
- mouseDownEvent:_private->mouseDownEvent
- mouseDraggedEvent:mouseDraggedEvent]) {
- return YES;
- }
-
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+
// note per kwebster, the offset arg below is always ignored in positioning the image
- if (imageURL) {
- _private->draggingImageURL = [imageURL retain];
- WebImageRenderer *image = [element objectForKey:WebElementImageKey];
- ASSERT([image isKindOfClass:[WebImageRenderer class]]);
- [self _web_dragImage:image
- archive:[[element objectForKey:WebElementDOMNodeKey] webArchive]
- rect:[[element objectForKey:WebElementImageRectKey] rectValue]
- URL:linkURL ? linkURL : imageURL
- title:[element objectForKey:WebElementImageAltStringKey]
- event:_private->mouseDownEvent
- dragImage:wcDragImage
- dragLocation:wcDragLoc
- writePasteboard:!dhtmlWroteData];
- } else if (linkURL) {
+ if (imageURL && (_private->dragSourceActionMask & WebDragSourceActionImage)) {
+ id source = self;
+ if (!dhtmlWroteData) {
+ _private->draggingImageURL = [imageURL retain];
+ source = [pasteboard _web_declareAndWriteDragImage:[element objectForKey:WebElementImageKey]
+ URL:linkURL ? linkURL : imageURL
+ title:[element objectForKey:WebElementImageAltStringKey]
+ archive:[[element objectForKey:WebElementDOMNodeKey] webArchive]
+ source:self];
+ }
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionImage fromPoint:mouseDownPoint withPasteboard:pasteboard];
+ if (dragImage == nil) {
+ [self _web_dragImage:[element objectForKey:WebElementImageKey]
+ rect:[[element objectForKey:WebElementImageRectKey] rectValue]
+ event:_private->mouseDownEvent
+ pasteboard:pasteboard
+ source:source];
+ } else {
+ [self dragImage:dragImage
+ at:dragLoc
+ offset:NSZeroSize
+ event:_private->mouseDownEvent
+ pasteboard:pasteboard
+ source:source
+ slideBack:YES];
+ }
+ } else if (linkURL && (_private->dragSourceActionMask & WebDragSourceActionLink)) {
if (!dhtmlWroteData) {
NSArray *types = [NSPasteboard _web_writableTypesForURL];
[pasteboard declareTypes:types owner:self];
[pasteboard _web_writeURL:linkURL andTitle:[element objectForKey:WebElementLinkLabelKey] types:types];
}
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionLink fromPoint:mouseDownPoint withPasteboard:pasteboard];
+ if (dragImage == nil) {
+ dragImage = [self _dragImageForLinkElement:element];
+ NSSize offset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
+ dragLoc = NSMakePoint(mouseDraggedPoint.x - offset.width, mouseDraggedPoint.y - offset.height);
+ }
// HACK: We should pass the mouseDown event instead of the mouseDragged! This hack gets rid of
// a flash of the image at the mouseDown location when the drag starts.
[self dragImage:dragImage
@@ -880,10 +869,17 @@ static WebHTMLView *lastHitView = nil;
pasteboard:pasteboard
source:self
slideBack:NO];
- } else if (isSelected) {
+ } else if (isSelected && (_private->dragSourceActionMask & WebDragSourceActionSelection)) {
if (!dhtmlWroteData) {
[self _writeSelectionToPasteboard:pasteboard];
}
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionSelection fromPoint:mouseDownPoint withPasteboard:pasteboard];
+ if (dragImage == nil) {
+ dragImage = [[self _bridge] selectionImage];
+ [dragImage _web_dissolveToFraction:WebDragImageAlpha];
+ NSRect visibleSelectionRect = [[self _bridge] visibleSelectionRect];
+ dragLoc = NSMakePoint(NSMinX(visibleSelectionRect), NSMaxY(visibleSelectionRect));
+ }
[self dragImage:dragImage
at:dragLoc
offset:NSZeroSize
@@ -892,7 +888,16 @@ static WebHTMLView *lastHitView = nil;
source:self
slideBack:YES];
} else {
- // FIXME - need slideback control for WC
+ ASSERT(srcIsDHTML);
+ ASSERT(_private->dragSourceActionMask & WebDragSourceActionDHTML);
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionDHTML fromPoint:mouseDownPoint withPasteboard:pasteboard];
+ if (dragImage == nil) {
+ // WebCore should have given us an image, but we'll make one up
+ NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"missing_image" ofType:@"tiff"];
+ dragImage = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
+ NSSize imageSize = [dragImage size];
+ dragLoc = NSMakePoint(mouseDownPoint.x - imageSize.width/2, mouseDownPoint.y + imageSize.height/2);
+ }
[self dragImage:dragImage
at:dragLoc
offset:NSZeroSize
@@ -1006,10 +1011,10 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
NSURL *imageURL = [mouseDownElement objectForKey: WebElementImageURLKey];
- if ((imageURL && [[WebPreferences standardPreferences] loadsImagesAutomatically]) ||
- (!imageURL && [mouseDownElement objectForKey: WebElementLinkURLKey]) ||
- ([[mouseDownElement objectForKey:WebElementIsSelectedKey] boolValue] &&
- ([mouseDraggedEvent timestamp] - [_private->mouseDownEvent timestamp]) > TextDragDelay)) {
+ if (((imageURL && [[WebPreferences standardPreferences] loadsImagesAutomatically] && (_private->dragSourceActionMask & WebDragSourceActionImage)) ||
+ (!imageURL && [mouseDownElement objectForKey: WebElementLinkURLKey] && (_private->dragSourceActionMask & WebDragSourceActionLink)) ||
+ ([[mouseDownElement objectForKey:WebElementIsSelectedKey] boolValue] && (_private->dragSourceActionMask & WebDragSourceActionSelection))) &&
+ (([mouseDraggedEvent timestamp] - [_private->mouseDownEvent timestamp]) > TextDragDelay)) {
return YES;
}
@@ -1962,10 +1967,11 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
!_private->webCoreHandlingDrag
&& [self _canProcessDragWithDraggingInfo:draggingInfo])
{
- [[self _bridge] moveDragCaretToPoint:[self convertPoint:[draggingInfo draggingLocation] fromView:nil]];
+ WebView *webView = [self _webView];
+ [webView moveDragCaretToPoint:[webView convertPoint:[draggingInfo draggingLocation] fromView:nil]];
operation = (_private->initiatedDrag && [[self _bridge] isSelectionEditable]) ? NSDragOperationMove : NSDragOperationCopy;
} else {
- [[self _bridge] removeDragCaret];
+ [[self _webView] removeDragCaret];
}
return operation;
@@ -1974,7 +1980,7 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
- (void)draggingCancelledWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo
{
[[self _bridge] dragExitedWithDraggingInfo:draggingInfo];
- [[self _bridge] removeDragCaret];
+ [[self _webView] removeDragCaret];
}
- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)draggingInfo actionMask:(unsigned int)actionMask
@@ -2001,7 +2007,7 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
didInsert = YES;
}
}
- [bridge removeDragCaret];
+ [webView removeDragCaret];
return didInsert;
}
return NO;
@@ -3189,4 +3195,12 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
// not reflected in the font panel. Maybe someday this will change.
}
+- (unsigned int)_delegateDragSourceActionMask
+{
+ WebView *webView = [self _webView];
+ NSPoint point = [webView convertPoint:[_private->mouseDownEvent locationInWindow] fromView:nil];
+ _private->dragSourceActionMask = [[webView _UIDelegateForwarder] webView:webView dragSourceActionMaskForPoint:point];
+ return _private->dragSourceActionMask;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebHTMLViewInternal.h b/WebKit/WebView.subproj/WebHTMLViewInternal.h
index e7b4316..3acf835 100644
--- a/WebKit/WebView.subproj/WebHTMLViewInternal.h
+++ b/WebKit/WebView.subproj/WebHTMLViewInternal.h
@@ -23,6 +23,7 @@
NSEvent *firstMouseDownEvent;
NSURL *draggingImageURL;
+ unsigned int dragSourceActionMask;
NSSize lastLayoutSize;
NSSize lastLayoutFrameSize;
@@ -47,4 +48,5 @@
@interface WebHTMLView (WebInternal)
- (void)_updateFontPanel;
+- (unsigned int)_delegateDragSourceActionMask;
@end
diff --git a/WebKit/WebView.subproj/WebImageView.h b/WebKit/WebView.subproj/WebImageView.h
index 802b9ed..bdc545f 100644
--- a/WebKit/WebView.subproj/WebImageView.h
+++ b/WebKit/WebView.subproj/WebImageView.h
@@ -13,6 +13,7 @@
BOOL needsLayout;
BOOL ignoringMouseDraggedEvents;
NSEvent *mouseDownEvent;
+ unsigned int dragSourceActionMask;
}
+ (NSArray *)supportedImageMIMETypes;
@end
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
index 99c34ef..56f9fcd 100644
--- a/WebKit/WebView.subproj/WebImageView.m
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -220,38 +220,41 @@
ignoringMouseDraggedEvents = NO;
[mouseDownEvent release];
mouseDownEvent = [event retain];
+
+ WebView *webView = [[self _web_parentWebFrameView] _webView];
+ NSPoint point = [webView convertPoint:[mouseDownEvent locationInWindow] fromView:nil];
+ dragSourceActionMask = [[webView _UIDelegateForwarder] webView:webView dragSourceActionMaskForPoint:point];
+
[super mouseDown:event];
}
- (void)mouseDragged:(NSEvent *)mouseDraggedEvent
{
- if (ignoringMouseDraggedEvents || ![self haveCompleteImage]) {
+ if (ignoringMouseDraggedEvents || ![self haveCompleteImage] || !(dragSourceActionMask & WebDragSourceActionImage)) {
return;
}
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ id source = [pasteboard _web_declareAndWriteDragImage:[rep image]
+ URL:[rep URL]
+ title:nil
+ archive:[rep archive]
+ source:self];
+
WebView *webView = [[self _web_parentWebFrameView] _webView];
- if (![[webView _UIDelegateForwarder] webView:webView
- shouldBeginDragForElement:[self elementAtPoint:NSZeroPoint]
- dragImage:[rep image]
- mouseDownEvent:mouseDownEvent
- mouseDraggedEvent:mouseDraggedEvent]) {
- return;
- }
+ NSPoint point = [webView convertPoint:[mouseDownEvent locationInWindow] fromView:nil];
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionImage fromPoint:point withPasteboard:pasteboard];
[[[self _web_parentWebFrameView] _webView] _setInitiatedDrag:YES];
-
+
// Retain this view during the drag because it may be released before the drag ends.
[self retain];
-
+
[self _web_dragImage:[rep image]
- archive:[rep archive]
rect:[self drawingRect]
- URL:[rep URL]
- title:nil
event:mouseDraggedEvent
- dragImage:nil
- dragLocation:NSZeroPoint
- writePasteboard:YES];
+ pasteboard:pasteboard
+ source:source];
}
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 0cba5d9..4fb3527 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -145,6 +145,7 @@ NSString *_WebMainFrameURLKey = @"mainFrameURL";
{
ASSERT(mainFrame == nil);
ASSERT(draggingDocumentView == nil);
+ ASSERT(dragCaretBridge == nil);
[backForwardList release];
[applicationNameForUserAgent release];
@@ -266,6 +267,9 @@ NSString *_WebMainFrameURLKey = @"mainFrameURL";
_private->setName = nil;
}
+ // To avoid leaks, call removeDragCaret in case it wasn't called after moveDragCaretToPoint.
+ [self removeDragCaret];
+
[_private->mainFrame _detachFromParent];
[_private->mainFrame release];
_private->mainFrame = nil;
@@ -1664,12 +1668,6 @@ NS_ENDHANDLER
return _private->hostWindow;
}
-- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point
-{
- NSView *view = [self hitTest:[[self superview] convertPoint:point toView:nil]];
- return (WebFrameView *)[view _web_superviewOfClass:[WebFrameView class] stoppingAtClass:[self class]];
-}
-
- (NSView <WebDocumentDragging> *)_draggingDocumentViewAtWindowPoint:(NSPoint)point
{
NSView <WebDocumentView> *documentView = [[self _frameViewAtWindowPoint:point] documentView];
@@ -2172,6 +2170,33 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
}
}
+- (WebBridge *)_bridgeAtPoint:(NSPoint)point
+{
+ return [[[self _frameViewAtWindowPoint:[self convertPoint:point toView:nil]] webFrame] _bridge];
+}
+
+- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point
+{
+ return [[self _bridgeAtPoint:point] editableDOMRangeForPoint:point];
+}
+
+- (void)moveDragCaretToPoint:(NSPoint)point
+{
+ WebBridge *bridge = [self _bridgeAtPoint:point];
+ if (bridge != _private->dragCaretBridge) {
+ [_private->dragCaretBridge removeDragCaret];
+ _private->dragCaretBridge = [bridge retain];
+ }
+ [_private->dragCaretBridge moveDragCaretToPoint:[self convertPoint:point toView:[[[_private->dragCaretBridge webFrame] frameView] documentView]]];
+}
+
+- (void)removeDragCaret
+{
+ [_private->dragCaretBridge removeDragCaret];
+ [_private->dragCaretBridge release];
+ _private->dragCaretBridge = nil;
+}
+
@end
@implementation WebView (WebViewPrintingPrivate)
@@ -2328,6 +2353,12 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
|| [[mainFrame provisionalDataSource] isLoading];
}
+- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point
+{
+ NSView *view = [self hitTest:[[self superview] convertPoint:point toView:nil]];
+ return (WebFrameView *)[view _web_superviewOfClass:[WebFrameView class] stoppingAtClass:[self class]];
+}
+
@end
@implementation WebView (WebViewEditing)
diff --git a/WebKit/WebView.subproj/WebViewInternal.h b/WebKit/WebView.subproj/WebViewInternal.h
index 55edaba..b70ec99 100644
--- a/WebKit/WebView.subproj/WebViewInternal.h
+++ b/WebKit/WebView.subproj/WebViewInternal.h
@@ -72,6 +72,7 @@
NSView <WebDocumentDragging> *draggingDocumentView;
unsigned int dragDestinationActionMask;
+ WebBridge *dragCaretBridge;
DOMCSSStyleDeclaration *typingStyle;
@@ -88,6 +89,8 @@
- (WebFrame *)_frameForCurrentSelection;
- (WebBridge *)_bridgeForCurrentSelection;
- (BOOL)_isLoading;
+
+- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point;
@end;
@interface WebView (WebViewEditingExtras)
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 4f86d4c..37081fc 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -50,6 +50,27 @@ extern NSString *_WebMainFrameURLKey;
- (void)toggleSmartInsertDelete:(id)sender;
+/*!
+ @method editableDOMRangeForPoint:
+ @param point A point in the coordinates of the WebView
+ @result A range expressing an editable position. Nil is returned if an editable position can't be found.
+*/
+- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point;
+
+/*!
+ @method moveDragCaretToPoint:
+ @param point A point in the coordinates of the WebView
+ @discussion This method moves the caret that shows where something being dragged will be dropped. It may cause the WebView to scroll
+ to make the new position of the drag caret visible.
+*/
+- (void)moveDragCaretToPoint:(NSPoint)point;
+
+/*!
+ @method removeDragCaret
+ @abstract Removes the drag caret from the WebView
+*/
+- (void)removeDragCaret;
+
@end
@interface WebView (WebPrivate)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list