This commit is contained in:
pinkerton%netscape.com 2002-04-23 03:57:09 +00:00
Родитель 2aff66e04f
Коммит 3b4eff0837
8 изменённых файлов: 288 добавлений и 0 удалений

Просмотреть файл

@ -48,6 +48,9 @@ class nsIWebBrowser;
class nsIDOMNode; class nsIDOMNode;
class nsIDOMEvent; class nsIDOMEvent;
class nsIWebBrowserFind; class nsIWebBrowserFind;
class nsIEventSink;
class nsIDragHelperService;
// Protocol implemented by anyone interested in progress // Protocol implemented by anyone interested in progress
// related to a BrowserView. A listener should explicitly // related to a BrowserView. A listener should explicitly
@ -101,6 +104,9 @@ enum {
nsIWebBrowser* _webBrowser; nsIWebBrowser* _webBrowser;
nsCocoaBrowserListener* _listener; nsCocoaBrowserListener* _listener;
NSWindow* mWindow; NSWindow* mWindow;
nsIEventSink* mEventSink;
nsIDragHelperService* mDragHelper;
} }
// NSView overrides // NSView overrides

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIWidget.h"
// XPCOM and String includes // XPCOM and String includes
#include "nsCRT.h" #include "nsCRT.h"
@ -81,6 +82,10 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIContextMenuListener.h" #include "nsIContextMenuListener.h"
typedef unsigned int DragReference;
#include "nsIDragHelperService.h"
// Cut/copy/paste // Cut/copy/paste
#include "nsIClipboardCommands.h" #include "nsIClipboardCommands.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
baseWin->InitWindow((NSView*)self, nsnull, 0, 0, baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
frame.size.width, frame.size.height); frame.size.width, frame.size.height);
baseWin->Create(); 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; return self;
} }
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_RELEASE(_listener); NS_RELEASE(_listener);
NS_IF_RELEASE(_webBrowser); NS_IF_RELEASE(_webBrowser);
NS_IF_RELEASE(mEventSink);
nsCocoaBrowserService::BrowserClosed(); 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 @end

Просмотреть файл

@ -48,6 +48,9 @@ class nsIWebBrowser;
class nsIDOMNode; class nsIDOMNode;
class nsIDOMEvent; class nsIDOMEvent;
class nsIWebBrowserFind; class nsIWebBrowserFind;
class nsIEventSink;
class nsIDragHelperService;
// Protocol implemented by anyone interested in progress // Protocol implemented by anyone interested in progress
// related to a BrowserView. A listener should explicitly // related to a BrowserView. A listener should explicitly
@ -101,6 +104,9 @@ enum {
nsIWebBrowser* _webBrowser; nsIWebBrowser* _webBrowser;
nsCocoaBrowserListener* _listener; nsCocoaBrowserListener* _listener;
NSWindow* mWindow; NSWindow* mWindow;
nsIEventSink* mEventSink;
nsIDragHelperService* mDragHelper;
} }
// NSView overrides // NSView overrides

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIWidget.h"
// XPCOM and String includes // XPCOM and String includes
#include "nsCRT.h" #include "nsCRT.h"
@ -81,6 +82,10 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIContextMenuListener.h" #include "nsIContextMenuListener.h"
typedef unsigned int DragReference;
#include "nsIDragHelperService.h"
// Cut/copy/paste // Cut/copy/paste
#include "nsIClipboardCommands.h" #include "nsIClipboardCommands.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
baseWin->InitWindow((NSView*)self, nsnull, 0, 0, baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
frame.size.width, frame.size.height); frame.size.width, frame.size.height);
baseWin->Create(); 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; return self;
} }
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_RELEASE(_listener); NS_RELEASE(_listener);
NS_IF_RELEASE(_webBrowser); NS_IF_RELEASE(_webBrowser);
NS_IF_RELEASE(mEventSink);
nsCocoaBrowserService::BrowserClosed(); 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 @end

Просмотреть файл

@ -48,6 +48,9 @@ class nsIWebBrowser;
class nsIDOMNode; class nsIDOMNode;
class nsIDOMEvent; class nsIDOMEvent;
class nsIWebBrowserFind; class nsIWebBrowserFind;
class nsIEventSink;
class nsIDragHelperService;
// Protocol implemented by anyone interested in progress // Protocol implemented by anyone interested in progress
// related to a BrowserView. A listener should explicitly // related to a BrowserView. A listener should explicitly
@ -101,6 +104,9 @@ enum {
nsIWebBrowser* _webBrowser; nsIWebBrowser* _webBrowser;
nsCocoaBrowserListener* _listener; nsCocoaBrowserListener* _listener;
NSWindow* mWindow; NSWindow* mWindow;
nsIEventSink* mEventSink;
nsIDragHelperService* mDragHelper;
} }
// NSView overrides // NSView overrides

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIWidget.h"
// XPCOM and String includes // XPCOM and String includes
#include "nsCRT.h" #include "nsCRT.h"
@ -81,6 +82,10 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIContextMenuListener.h" #include "nsIContextMenuListener.h"
typedef unsigned int DragReference;
#include "nsIDragHelperService.h"
// Cut/copy/paste // Cut/copy/paste
#include "nsIClipboardCommands.h" #include "nsIClipboardCommands.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
baseWin->InitWindow((NSView*)self, nsnull, 0, 0, baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
frame.size.width, frame.size.height); frame.size.width, frame.size.height);
baseWin->Create(); 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; return self;
} }
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_RELEASE(_listener); NS_RELEASE(_listener);
NS_IF_RELEASE(_webBrowser); NS_IF_RELEASE(_webBrowser);
NS_IF_RELEASE(mEventSink);
nsCocoaBrowserService::BrowserClosed(); 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 @end

Просмотреть файл

@ -48,6 +48,9 @@ class nsIWebBrowser;
class nsIDOMNode; class nsIDOMNode;
class nsIDOMEvent; class nsIDOMEvent;
class nsIWebBrowserFind; class nsIWebBrowserFind;
class nsIEventSink;
class nsIDragHelperService;
// Protocol implemented by anyone interested in progress // Protocol implemented by anyone interested in progress
// related to a BrowserView. A listener should explicitly // related to a BrowserView. A listener should explicitly
@ -101,6 +104,9 @@ enum {
nsIWebBrowser* _webBrowser; nsIWebBrowser* _webBrowser;
nsCocoaBrowserListener* _listener; nsCocoaBrowserListener* _listener;
NSWindow* mWindow; NSWindow* mWindow;
nsIEventSink* mEventSink;
nsIDragHelperService* mDragHelper;
} }
// NSView overrides // NSView overrides

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIWidget.h"
// XPCOM and String includes // XPCOM and String includes
#include "nsCRT.h" #include "nsCRT.h"
@ -81,6 +82,10 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIContextMenuListener.h" #include "nsIContextMenuListener.h"
typedef unsigned int DragReference;
#include "nsIDragHelperService.h"
// Cut/copy/paste // Cut/copy/paste
#include "nsIClipboardCommands.h" #include "nsIClipboardCommands.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
@ -959,6 +964,17 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
baseWin->InitWindow((NSView*)self, nsnull, 0, 0, baseWin->InitWindow((NSView*)self, nsnull, 0, 0,
frame.size.width, frame.size.height); frame.size.width, frame.size.height);
baseWin->Create(); 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; return self;
} }
@ -975,6 +991,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_RELEASE(_listener); NS_RELEASE(_listener);
NS_IF_RELEASE(_webBrowser); NS_IF_RELEASE(_webBrowser);
NS_IF_RELEASE(mEventSink);
nsCocoaBrowserService::BrowserClosed(); 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 @end