[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:44:49 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 20238fbd3b61828e765016b7822e1aef6935c4f1
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jun 9 23:50:26 2004 +0000
Implemented drag destination portion of the new drag & drop API.
Reviewed by trey.
* WebView.subproj/WebDefaultUIDelegate.m:
(-[WebDefaultUIDelegate webView:dragDestinationActionMaskForDraggingInfo:]): new delegate implementation
(-[WebDefaultUIDelegate webView:willPerformDragDestinationAction:forDraggingInfo:]): ditto
* WebView.subproj/WebDocumentInternal.h:
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): handle the action mask
(-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): ditto
* WebView.subproj/WebUIDelegate.h:
* WebView.subproj/WebUIDelegatePrivate.h:
* WebView.subproj/WebView.m:
(-[WebView _dragOperationForDraggingInfo:]): call new delegate methods
(-[WebView performDragOperation:]): ditto
* WebView.subproj/WebViewInternal.h:
* WebView.subproj/WebViewPrivate.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6804 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7dc50a5..3ca8451 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,24 @@
+2004-06-09 Chris Blumenberg <cblu at apple.com>
+
+ Implemented drag destination portion of the new drag & drop API.
+
+ Reviewed by trey.
+
+ * WebView.subproj/WebDefaultUIDelegate.m:
+ (-[WebDefaultUIDelegate webView:dragDestinationActionMaskForDraggingInfo:]): new delegate implementation
+ (-[WebDefaultUIDelegate webView:willPerformDragDestinationAction:forDraggingInfo:]): ditto
+ * WebView.subproj/WebDocumentInternal.h:
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): handle the action mask
+ (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): ditto
+ * WebView.subproj/WebUIDelegate.h:
+ * WebView.subproj/WebUIDelegatePrivate.h:
+ * WebView.subproj/WebView.m:
+ (-[WebView _dragOperationForDraggingInfo:]): call new delegate methods
+ (-[WebView performDragOperation:]): ditto
+ * WebView.subproj/WebViewInternal.h:
+ * WebView.subproj/WebViewPrivate.h:
+
2004-06-09 Richard Williamson <rjw at apple.com>
Implemented PDF rendering for the drawImage() function
diff --git a/WebKit/WebView.subproj/WebDefaultUIDelegate.m b/WebKit/WebView.subproj/WebDefaultUIDelegate.m
index d908328..aecc46b 100644
--- a/WebKit/WebView.subproj/WebDefaultUIDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultUIDelegate.m
@@ -173,14 +173,13 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
return YES;
}
-- (BOOL)webView:(WebView *)webView shouldDetermineDragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo dragOperation:(NSDragOperation *)dragOperation
+- (unsigned)webView:(WebView *)webView dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
{
- return YES;
+ return WebDragDestinationActionAny;
}
-- (BOOL)webView:(WebView *)webView shouldProcessDragWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo
+- (void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo
{
- return YES;
}
@end
diff --git a/WebKit/WebView.subproj/WebDocumentInternal.h b/WebKit/WebView.subproj/WebDocumentInternal.h
index 14e8a5d..1c7ae04 100644
--- a/WebKit/WebView.subproj/WebDocumentInternal.h
+++ b/WebKit/WebView.subproj/WebDocumentInternal.h
@@ -19,9 +19,9 @@
@end
@protocol WebDocumentDragging <NSObject>
-- (NSDragOperation)draggingUpdatedWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
+- (NSDragOperation)draggingUpdatedWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo actionMask:(unsigned int)actionMask;
+- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)draggingInfo actionMask:(unsigned int)actionMask;
- (void)draggingCancelledWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
-- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
@end
@protocol WebDocumentElement <NSObject>
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 6a64fee..133a4ec 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -1907,19 +1907,25 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
return NO;
}
-- (NSDragOperation)draggingUpdatedWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo
+- (NSDragOperation)draggingUpdatedWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo actionMask:(unsigned int)actionMask
{
- NSDragOperation operation = [[self _bridge] dragOperationForDraggingInfo:draggingInfo];
+ NSDragOperation operation = NSDragOperationNone;
+
+ if (actionMask & WebDragDestinationActionDHTML) {
+ operation = [[self _bridge] dragOperationForDraggingInfo:draggingInfo];
+ }
_private->webCoreHandlingDrag = (operation != NSDragOperationNone);
- if (!_private->webCoreHandlingDrag
- && [self _canProcessDragWithDraggingInfo:draggingInfo]
- && [[self _webView] _webKitDragRespondsToDragging])
+
+ if ((actionMask & WebDragDestinationActionEdit) &&
+ !_private->webCoreHandlingDrag
+ && [self _canProcessDragWithDraggingInfo:draggingInfo])
{
[[self _bridge] moveDragCaretToPoint:[self convertPoint:[draggingInfo draggingLocation] fromView:nil]];
operation = (_private->initiatedDrag && [[self _bridge] isSelectionEditable]) ? NSDragOperationMove : NSDragOperationCopy;
} else {
[[self _bridge] removeDragCaret];
}
+
return operation;
}
@@ -1929,16 +1935,21 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
[[self _bridge] removeDragCaret];
}
-- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)draggingInfo
+- (BOOL)concludeDragForDraggingInfo:(id <NSDraggingInfo>)draggingInfo actionMask:(unsigned int)actionMask
{
+ WebView *webView = [self _webView];
WebBridge *bridge = [self _bridge];
if (_private->webCoreHandlingDrag) {
- return [[self _bridge] concludeDragForDraggingInfo:draggingInfo];
- } else {
+ ASSERT(actionMask & WebDragDestinationActionDHTML);
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionDHTML forDraggingInfo:draggingInfo];
+ [[self _bridge] concludeDragForDraggingInfo:draggingInfo];
+ return YES;
+ } else if (actionMask & WebDragDestinationActionEdit) {
BOOL didInsert = NO;
- if ([self _canProcessDragWithDraggingInfo:draggingInfo] && [[self _webView] _webKitDragRespondsToDragging]) {
+ if ([self _canProcessDragWithDraggingInfo:draggingInfo]) {
DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:[draggingInfo draggingPasteboard] allowPlainText:YES];
if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[bridge dragCaretDOMRange] givenAction:WebViewInsertActionDropped]) {
+ [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo];
if (_private->initiatedDrag && [bridge isSelectionEditable]) {
[bridge moveSelectionToDragCaret:fragment];
} else {
@@ -1951,6 +1962,7 @@ static void FlipImageSpec(CoreDragImageSpec* imageSpec) {
[bridge removeDragCaret];
return didInsert;
}
+ return NO;
}
- (NSDictionary *)elementAtPoint:(NSPoint)point
diff --git a/WebKit/WebView.subproj/WebUIDelegate.h b/WebKit/WebView.subproj/WebUIDelegate.h
index 3d31901..2c7ac2b 100644
--- a/WebKit/WebView.subproj/WebUIDelegate.h
+++ b/WebKit/WebView.subproj/WebUIDelegate.h
@@ -24,10 +24,10 @@ enum {
WebMenuItemTagCopyImageToClipboard,
WebMenuItemTagOpenFrameInNewWindow,
WebMenuItemTagCopy,
- WebMenuItemTagGoBack,
- WebMenuItemTagGoForward,
- WebMenuItemTagStop,
- WebMenuItemTagReload
+ WebMenuItemTagGoBack,
+ WebMenuItemTagGoForward,
+ WebMenuItemTagStop,
+ WebMenuItemTagReload
};
/*!
diff --git a/WebKit/WebView.subproj/WebUIDelegatePrivate.h b/WebKit/WebView.subproj/WebUIDelegatePrivate.h
index b29226d..bd24b94 100644
--- a/WebKit/WebView.subproj/WebUIDelegatePrivate.h
+++ b/WebKit/WebView.subproj/WebUIDelegatePrivate.h
@@ -5,6 +5,42 @@
#import <WebKit/WebUIDelegate.h>
+/*!
+ @enum WebDragDestinationAction
+ @abstract Actions that the destination of a drag can perform.
+ @constant WebDragDestinationActionNone No action
+ @constant WebDragDestinationActionDHTML Allows DHTML (such as JavaScript) to handle the drag
+ @constant WebDragDestinationActionEdit Allows editable documents to be edited from the drag
+ @constant WebDragDestinationActionLoad Allows a location change from the drag
+ @constant WebDragDestinationActionAny Allows any of the above to occur
+*/
+typedef enum {
+ WebDragDestinationActionNone = 0,
+ WebDragDestinationActionDHTML = 1,
+ WebDragDestinationActionEdit = 2,
+ WebDragDestinationActionLoad = 4,
+ WebDragDestinationActionAny = UINT_MAX
+} WebDragDestinationAction;
+
+/*!
+ @enum WebDragSourceAction
+ @abstract Actions that the source of a drag can perform.
+ @constant WebDragSourceActionNone No action
+ @constant WebDragSourceActionDHTML Allows DHTML (such as JavaScript) to start a drag
+ @constant WebDragSourceActionImage Allows an image drag to occur
+ @constant WebDragSourceActionLink Allows a link drag to occur
+ @constant WebDragSourceActionSelection Allows a selection drag to occur
+ @constant WebDragSourceActionAny Allows any of the above to occur
+*/
+typedef enum {
+ WebDragSourceActionNone = 0,
+ WebDragSourceActionDHTML = 1,
+ WebDragSourceActionImage = 2,
+ WebDragSourceActionLink = 4,
+ WebDragSourceActionSelection = 8,
+ WebDragSourceActionAny = UINT_MAX
+} WebDragSourceAction;
+
@interface NSObject (WebUIDelegatePrivate)
- (void)webViewPrint:(WebView *)sender;
@@ -14,8 +50,50 @@
- (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect;
- (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect;
- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message;
-- (BOOL)webView:(WebView *)webView shouldBeginDragForElement:(NSDictionary *)element pasteboard:(NSPasteboard *)pasteboard mouseDownEvent:(NSEvent *)mouseDownEvent mouseDraggedEvent:(NSEvent *)mouseDraggedEvent;
-- (BOOL)webView:(WebView *)webView shouldDetermineDragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo dragOperation:(NSDragOperation *)dragOperation;
-- (BOOL)webView:(WebView *)webView shouldProcessDragWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
+
+/*!
+ @method webView:dragDestinationActionMaskForDraggingInfo:
+ @abstract Controls behavior when dragging to a WebView
+ @param webView The WebView sending the delegate method
+ @param draggingInfo The dragging info of the drag
+ @discussion This method is called periodically as something is dragged over a WebView. The UI delegate can return a mask
+ indicating which drag destination actions can occur, WebDragDestinationActionAny to allow any kind of action or
+ WebDragDestinationActionNone to not accept the drag.
+*/
+- (unsigned)webView:(WebView *)webView dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
+
+/*!
+ @method webView:willPerformDragDestinationAction:forDraggingInfo:
+ @abstract Informs that WebView will perform a drag destination action
+ @param webView The WebView sending the delegate method
+ @param action The drag destination action
+ @param draggingInfo The dragging info of the drag
+ @discussion This method is called after the last call to webView:dragDestinationActionMaskForDraggingInfo: after something is dropped on a WebView.
+ This method informs the UI delegate of the drag destination that WebView will perform.
+*/
+- (void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
+
+/*!
+ @method webView:dragSourceActionMaskForPoint:
+ @abstract Controls behavior when dragging from a WebView
+ @param webView The WebView sending the delegate method
+ @param point The point where the drag started in the coordinates of the WebView
+ @discussion This method is called after the user has begun a drag from a WebView. The UI delegate can return a mask indicating
+ which drag source actions can occur, WebDragSourceActionAny to allow any kind of action or WebDragSourceActionNone to not begin a drag.
+*/
+- (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
+
+/*!
+ @method webView:willPerformDragSourceAction:fromPoint:withPasteboard:
+ @abstract Informs that a drag a has begun from a WebView
+ @param webView The WebView sending the delegate method
+ @param action The drag source action
+ @param point The point where the drag started in the coordinates of the WebView
+ @param pasteboard The drag pasteboard
+ @discussion This method is called after webView:dragSourceActionMaskForPoint: is called after the user has begun a drag from a WebView.
+ This method informs the UI delegate of the drag source action that will be performed and gives the delegate an opportunity to modify
+ the contents of the dragging pasteboard.
+*/
+- (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard;
@end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index f83c772..0cba5d9 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -1116,16 +1116,6 @@ NSString *_WebMainFrameURLKey = @"mainFrameURL";
_private->initiatedDrag = initiatedDrag;
}
-- (void)_setWebKitDragRespondsToDragging:(BOOL)flag
-{
- _private->doWebKitDragReponse = flag;
-}
-
-- (BOOL)_webKitDragRespondsToDragging
-{
- return _private->doWebKitDragReponse;
-}
-
@end
@@ -1250,7 +1240,6 @@ NSMutableDictionary *countInvocations;
- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName
{
_private->drawsBackground = YES;
- _private->doWebKitDragReponse = YES;
NSRect f = [self frame];
WebFrameView *wv = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
@@ -1722,7 +1711,21 @@ NS_ENDHANDLER
}
}
-- (NSDragOperation)_dragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo
+- (NSDragOperation)_loadingDragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo
+{
+ if (_private->dragDestinationActionMask & WebDragDestinationActionLoad) {
+ NSPoint windowPoint = [draggingInfo draggingLocation];
+ NSView *view = [self hitTest:[[self superview] convertPoint:windowPoint toView:nil]];
+ // Don't accept the drag over a plug-in since plug-ins may want to handle it.
+ if (![view isKindOfClass:[WebBaseNetscapePluginView class]] && !_private->editable && !_private->initiatedDrag) {
+ // If not editing or dragging, use _web_dragOperationForDraggingInfo to find a URL to load on the pasteboard.
+ return [self _web_dragOperationForDraggingInfo:draggingInfo];
+ }
+ }
+ return NSDragOperationNone;
+}
+
+- (NSDragOperation)_delegateDragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo
{
NSPoint windowPoint = [draggingInfo draggingLocation];
NSView <WebDocumentDragging> *newDraggingView = [self _draggingDocumentViewAtWindowPoint:windowPoint];
@@ -1731,21 +1734,16 @@ NS_ENDHANDLER
[self _setDraggingDocumentView:newDraggingView];
}
+ _private->dragDestinationActionMask = [[self _UIDelegateForwarder] webView:self dragDestinationActionMaskForDraggingInfo:draggingInfo];
NSDragOperation operation = NSDragOperationNone;
- if ([[self _UIDelegateForwarder] webView:self shouldDetermineDragOperationForDraggingInfo:draggingInfo dragOperation:&operation]) {
- operation = [_private->draggingDocumentView draggingUpdatedWithDraggingInfo:draggingInfo];
+
+ if (_private->dragDestinationActionMask == WebDragDestinationActionNone) {
+ [_private->draggingDocumentView draggingCancelledWithDraggingInfo:draggingInfo];
+ } else {
+ operation = [_private->draggingDocumentView draggingUpdatedWithDraggingInfo:draggingInfo actionMask:_private->dragDestinationActionMask];
if (operation == NSDragOperationNone) {
- NSView *view = [self hitTest:[[self superview] convertPoint:windowPoint toView:nil]];
- // Don't accept the drag over a plug-in since plug-ins may want to handle it.
- if (![view isKindOfClass:[WebBaseNetscapePluginView class]]
- && !_private->editable && !_private->initiatedDrag)
- {
- // If not editing or dragging, use _web_dragOperationForDraggingInfo to find a URL to load on the pasteboard.
- operation = [self _web_dragOperationForDraggingInfo:draggingInfo];
- }
+ return [self _loadingDragOperationForDraggingInfo:draggingInfo];
}
- } else {
- [_private->draggingDocumentView draggingCancelledWithDraggingInfo:draggingInfo];
}
return operation;
@@ -1753,12 +1751,12 @@ NS_ENDHANDLER
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
{
- return [self _dragOperationForDraggingInfo:draggingInfo];
+ return [self _delegateDragOperationForDraggingInfo:draggingInfo];
}
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
{
- return [self _dragOperationForDraggingInfo:draggingInfo];
+ return [self _delegateDragOperationForDraggingInfo:draggingInfo];
}
- (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
@@ -1774,33 +1772,27 @@ NS_ENDHANDLER
- (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo
{
- return YES;
-}
-
-- (void)concludeDragOperation:(id <NSDraggingInfo>)draggingInfo
-{
ASSERT(_private->draggingDocumentView == [self _draggingDocumentViewAtWindowPoint:[draggingInfo draggingLocation]]);
- if (![[self _UIDelegateForwarder] webView:self shouldProcessDragWithDraggingInfo:draggingInfo]) {
- [self _setDraggingDocumentView:nil];
- return;
- }
-
- if ([_private->draggingDocumentView concludeDragForDraggingInfo:draggingInfo]) {
+ if ([_private->draggingDocumentView concludeDragForDraggingInfo:draggingInfo actionMask:_private->dragDestinationActionMask]) {
[self _setDraggingDocumentView:nil];
- return;
+ return YES;
}
[self _setDraggingDocumentView:nil];
-
- if (!_private->editable && !_private->initiatedDrag) {
+
+ if ([self _loadingDragOperationForDraggingInfo:draggingInfo] != NSDragOperationNone) {
NSURL *URL = [[self class] URLFromPasteboard:[draggingInfo draggingPasteboard]];
- if (URL) {
+ if (URL != nil) {
+ [[self _UIDelegateForwarder] webView:self willPerformDragDestinationAction:WebDragDestinationActionLoad forDraggingInfo:draggingInfo];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:URL];
[[self mainFrame] loadRequest:request];
[request release];
+ return YES;
}
}
+
+ return NO;
}
- (NSView *)_hitTest:(NSPoint *)aPoint dragTypes:(NSSet *)types
diff --git a/WebKit/WebView.subproj/WebViewInternal.h b/WebKit/WebView.subproj/WebViewInternal.h
index f5414f2..55edaba 100644
--- a/WebKit/WebView.subproj/WebViewInternal.h
+++ b/WebKit/WebView.subproj/WebViewInternal.h
@@ -67,11 +67,11 @@
BOOL drawsBackground;
BOOL editable;
BOOL initiatedDrag;
- BOOL doWebKitDragReponse; // should we do the built-in WebKit handling of incoming drags?
NSString *mediaStyle;
NSView <WebDocumentDragging> *draggingDocumentView;
+ unsigned int dragDestinationActionMask;
DOMCSSStyleDeclaration *typingStyle;
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index c245743..4f86d4c 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -214,9 +214,6 @@ Could be worth adding to the API.
- (void)_writeImageElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
- (void)_writeLinkElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard;
-- (void)_setWebKitDragRespondsToDragging:(BOOL)flag;
-- (BOOL)_webKitDragRespondsToDragging;
-
@end
@interface WebView (WebViewPrintingPrivate)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list