зеркало из https://github.com/mozilla/gecko-dev.git
Beginnings of dnd support.
This commit is contained in:
Родитель
cd310bf362
Коммит
4c0e759087
|
@ -48,6 +48,9 @@ class nsIWebBrowser;
|
|||
class nsIDOMNode;
|
||||
class nsIDOMEvent;
|
||||
class nsIWebBrowserFind;
|
||||
class nsIEventSink;
|
||||
class nsIDragHelperService;
|
||||
|
||||
|
||||
// Protocol implemented by anyone interested in progress
|
||||
// related to a BrowserView. A listener should explicitly
|
||||
|
@ -101,6 +104,9 @@ enum {
|
|||
nsIWebBrowser* _webBrowser;
|
||||
nsCocoaBrowserListener* _listener;
|
||||
NSWindow* mWindow;
|
||||
nsIEventSink* mEventSink;
|
||||
|
||||
nsIDragHelperService* mDragHelper;
|
||||
}
|
||||
|
||||
// NSView overrides
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
// XPCOM and String includes
|
||||
#include "nsCRT.h"
|
||||
|
@ -81,6 +82,10 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIContextMenuListener.h"
|
||||
|
||||
typedef unsigned int DragReference;
|
||||
#include "nsIDragHelperService.h"
|
||||
|
||||
|
||||
// Cut/copy/paste
|
||||
#include "nsIClipboardCommands.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
|
||||
frame.size.width, frame.size.height);
|
||||
baseWin->Create();
|
||||
|
||||
nsCOMPtr<nsIWidget> topLevel;
|
||||
baseWin->GetMainWidget(getter_AddRefs(topLevel));
|
||||
nsCOMPtr<nsIEventSink> sink = do_QueryInterface(topLevel);
|
||||
mEventSink = sink.get();
|
||||
NS_IF_ADDREF(mEventSink);
|
||||
NS_ASSERTION(mEventSink, "Couldn't get event sink!");
|
||||
|
||||
// register the view as a drop site for text, files, and urls.
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:NSStringPboardType, NSURLPboardType, NSFilenamesPboardType, nil]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
|
||||
NS_RELEASE(_listener);
|
||||
NS_IF_RELEASE(_webBrowser);
|
||||
NS_IF_RELEASE(mEventSink);
|
||||
|
||||
nsCocoaBrowserService::BrowserClosed();
|
||||
|
||||
|
@ -1411,5 +1428,54 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
nsCOMPtr<nsIDragHelperService> helper(do_GetService("@mozilla.org/widget/draghelperservice;1"));
|
||||
mDragHelper = helper.get();
|
||||
NS_IF_ADDREF(mDragHelper);
|
||||
NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" );
|
||||
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Enter ( [sender draggingSequenceNumber], mEventSink );
|
||||
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ( mDragHelper ) {
|
||||
mDragHelper->Leave ( [sender draggingSequenceNumber], mEventSink );
|
||||
NS_RELEASE(mDragHelper);
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
PRBool dropAllowed = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Tracking ( [sender draggingSequenceNumber], mEventSink, &dropAllowed );
|
||||
|
||||
NSLog(@"Drop allowed is %d", dropAllowed);
|
||||
return dropAllowed ? NSDragOperationCopy : NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSLog(@"Drag DROP!");
|
||||
|
||||
PRBool dragAccepted = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Drop ( [sender draggingSequenceNumber], mEventSink, &dragAccepted );
|
||||
|
||||
return dragAccepted;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ class nsIWebBrowser;
|
|||
class nsIDOMNode;
|
||||
class nsIDOMEvent;
|
||||
class nsIWebBrowserFind;
|
||||
class nsIEventSink;
|
||||
class nsIDragHelperService;
|
||||
|
||||
|
||||
// Protocol implemented by anyone interested in progress
|
||||
// related to a BrowserView. A listener should explicitly
|
||||
|
@ -101,6 +104,9 @@ enum {
|
|||
nsIWebBrowser* _webBrowser;
|
||||
nsCocoaBrowserListener* _listener;
|
||||
NSWindow* mWindow;
|
||||
nsIEventSink* mEventSink;
|
||||
|
||||
nsIDragHelperService* mDragHelper;
|
||||
}
|
||||
|
||||
// NSView overrides
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
// XPCOM and String includes
|
||||
#include "nsCRT.h"
|
||||
|
@ -81,6 +82,10 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIContextMenuListener.h"
|
||||
|
||||
typedef unsigned int DragReference;
|
||||
#include "nsIDragHelperService.h"
|
||||
|
||||
|
||||
// Cut/copy/paste
|
||||
#include "nsIClipboardCommands.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
|
||||
frame.size.width, frame.size.height);
|
||||
baseWin->Create();
|
||||
|
||||
nsCOMPtr<nsIWidget> topLevel;
|
||||
baseWin->GetMainWidget(getter_AddRefs(topLevel));
|
||||
nsCOMPtr<nsIEventSink> sink = do_QueryInterface(topLevel);
|
||||
mEventSink = sink.get();
|
||||
NS_IF_ADDREF(mEventSink);
|
||||
NS_ASSERTION(mEventSink, "Couldn't get event sink!");
|
||||
|
||||
// register the view as a drop site for text, files, and urls.
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:NSStringPboardType, NSURLPboardType, NSFilenamesPboardType, nil]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
|
||||
NS_RELEASE(_listener);
|
||||
NS_IF_RELEASE(_webBrowser);
|
||||
NS_IF_RELEASE(mEventSink);
|
||||
|
||||
nsCocoaBrowserService::BrowserClosed();
|
||||
|
||||
|
@ -1411,5 +1428,54 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
nsCOMPtr<nsIDragHelperService> helper(do_GetService("@mozilla.org/widget/draghelperservice;1"));
|
||||
mDragHelper = helper.get();
|
||||
NS_IF_ADDREF(mDragHelper);
|
||||
NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" );
|
||||
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Enter ( [sender draggingSequenceNumber], mEventSink );
|
||||
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ( mDragHelper ) {
|
||||
mDragHelper->Leave ( [sender draggingSequenceNumber], mEventSink );
|
||||
NS_RELEASE(mDragHelper);
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
PRBool dropAllowed = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Tracking ( [sender draggingSequenceNumber], mEventSink, &dropAllowed );
|
||||
|
||||
NSLog(@"Drop allowed is %d", dropAllowed);
|
||||
return dropAllowed ? NSDragOperationCopy : NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSLog(@"Drag DROP!");
|
||||
|
||||
PRBool dragAccepted = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Drop ( [sender draggingSequenceNumber], mEventSink, &dragAccepted );
|
||||
|
||||
return dragAccepted;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ class nsIWebBrowser;
|
|||
class nsIDOMNode;
|
||||
class nsIDOMEvent;
|
||||
class nsIWebBrowserFind;
|
||||
class nsIEventSink;
|
||||
class nsIDragHelperService;
|
||||
|
||||
|
||||
// Protocol implemented by anyone interested in progress
|
||||
// related to a BrowserView. A listener should explicitly
|
||||
|
@ -101,6 +104,9 @@ enum {
|
|||
nsIWebBrowser* _webBrowser;
|
||||
nsCocoaBrowserListener* _listener;
|
||||
NSWindow* mWindow;
|
||||
nsIEventSink* mEventSink;
|
||||
|
||||
nsIDragHelperService* mDragHelper;
|
||||
}
|
||||
|
||||
// NSView overrides
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
// XPCOM and String includes
|
||||
#include "nsCRT.h"
|
||||
|
@ -81,6 +82,10 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIContextMenuListener.h"
|
||||
|
||||
typedef unsigned int DragReference;
|
||||
#include "nsIDragHelperService.h"
|
||||
|
||||
|
||||
// Cut/copy/paste
|
||||
#include "nsIClipboardCommands.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
|
||||
frame.size.width, frame.size.height);
|
||||
baseWin->Create();
|
||||
|
||||
nsCOMPtr<nsIWidget> topLevel;
|
||||
baseWin->GetMainWidget(getter_AddRefs(topLevel));
|
||||
nsCOMPtr<nsIEventSink> sink = do_QueryInterface(topLevel);
|
||||
mEventSink = sink.get();
|
||||
NS_IF_ADDREF(mEventSink);
|
||||
NS_ASSERTION(mEventSink, "Couldn't get event sink!");
|
||||
|
||||
// register the view as a drop site for text, files, and urls.
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:NSStringPboardType, NSURLPboardType, NSFilenamesPboardType, nil]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
|
||||
NS_RELEASE(_listener);
|
||||
NS_IF_RELEASE(_webBrowser);
|
||||
NS_IF_RELEASE(mEventSink);
|
||||
|
||||
nsCocoaBrowserService::BrowserClosed();
|
||||
|
||||
|
@ -1411,5 +1428,54 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
nsCOMPtr<nsIDragHelperService> helper(do_GetService("@mozilla.org/widget/draghelperservice;1"));
|
||||
mDragHelper = helper.get();
|
||||
NS_IF_ADDREF(mDragHelper);
|
||||
NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" );
|
||||
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Enter ( [sender draggingSequenceNumber], mEventSink );
|
||||
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ( mDragHelper ) {
|
||||
mDragHelper->Leave ( [sender draggingSequenceNumber], mEventSink );
|
||||
NS_RELEASE(mDragHelper);
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
PRBool dropAllowed = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Tracking ( [sender draggingSequenceNumber], mEventSink, &dropAllowed );
|
||||
|
||||
NSLog(@"Drop allowed is %d", dropAllowed);
|
||||
return dropAllowed ? NSDragOperationCopy : NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSLog(@"Drag DROP!");
|
||||
|
||||
PRBool dragAccepted = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Drop ( [sender draggingSequenceNumber], mEventSink, &dragAccepted );
|
||||
|
||||
return dragAccepted;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ class nsIWebBrowser;
|
|||
class nsIDOMNode;
|
||||
class nsIDOMEvent;
|
||||
class nsIWebBrowserFind;
|
||||
class nsIEventSink;
|
||||
class nsIDragHelperService;
|
||||
|
||||
|
||||
// Protocol implemented by anyone interested in progress
|
||||
// related to a BrowserView. A listener should explicitly
|
||||
|
@ -101,6 +104,9 @@ enum {
|
|||
nsIWebBrowser* _webBrowser;
|
||||
nsCocoaBrowserListener* _listener;
|
||||
NSWindow* mWindow;
|
||||
nsIEventSink* mEventSink;
|
||||
|
||||
nsIDragHelperService* mDragHelper;
|
||||
}
|
||||
|
||||
// NSView overrides
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
// XPCOM and String includes
|
||||
#include "nsCRT.h"
|
||||
|
@ -81,6 +82,10 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIContextMenuListener.h"
|
||||
|
||||
typedef unsigned int DragReference;
|
||||
#include "nsIDragHelperService.h"
|
||||
|
||||
|
||||
// Cut/copy/paste
|
||||
#include "nsIClipboardCommands.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
|
||||
frame.size.width, frame.size.height);
|
||||
baseWin->Create();
|
||||
|
||||
nsCOMPtr<nsIWidget> topLevel;
|
||||
baseWin->GetMainWidget(getter_AddRefs(topLevel));
|
||||
nsCOMPtr<nsIEventSink> sink = do_QueryInterface(topLevel);
|
||||
mEventSink = sink.get();
|
||||
NS_IF_ADDREF(mEventSink);
|
||||
NS_ASSERTION(mEventSink, "Couldn't get event sink!");
|
||||
|
||||
// register the view as a drop site for text, files, and urls.
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:NSStringPboardType, NSURLPboardType, NSFilenamesPboardType, nil]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
|
||||
NS_RELEASE(_listener);
|
||||
NS_IF_RELEASE(_webBrowser);
|
||||
NS_IF_RELEASE(mEventSink);
|
||||
|
||||
nsCocoaBrowserService::BrowserClosed();
|
||||
|
||||
|
@ -1411,5 +1428,54 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
nsCOMPtr<nsIDragHelperService> helper(do_GetService("@mozilla.org/widget/draghelperservice;1"));
|
||||
mDragHelper = helper.get();
|
||||
NS_IF_ADDREF(mDragHelper);
|
||||
NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" );
|
||||
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Enter ( [sender draggingSequenceNumber], mEventSink );
|
||||
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ( mDragHelper ) {
|
||||
mDragHelper->Leave ( [sender draggingSequenceNumber], mEventSink );
|
||||
NS_RELEASE(mDragHelper);
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
PRBool dropAllowed = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Tracking ( [sender draggingSequenceNumber], mEventSink, &dropAllowed );
|
||||
|
||||
NSLog(@"Drop allowed is %d", dropAllowed);
|
||||
return dropAllowed ? NSDragOperationCopy : NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSLog(@"Drag DROP!");
|
||||
|
||||
PRBool dragAccepted = PR_FALSE;
|
||||
if ( mDragHelper )
|
||||
mDragHelper->Drop ( [sender draggingSequenceNumber], mEventSink, &dragAccepted );
|
||||
|
||||
return dragAccepted;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче