Make the document where the drag originated available from the drag session. bug 39326

This commit is contained in:
pinkerton%netscape.com 2000-07-31 20:51:42 +00:00
Родитель d84b17c9f2
Коммит 98c2e53a99
8 изменённых файлов: 67 добавлений и 6 удалений

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

@ -33,6 +33,9 @@
native nsSize (nsSize);
interface nsIDOMDocument;
[scriptable, uuid(CBA22C53-FCCE-11d2-96D4-0060B0FB9956)]
interface nsIDragSession : nsISupports
{
@ -58,6 +61,13 @@ interface nsIDragSession : nsISupports
*/
readonly attribute unsigned long numDropItems;
/**
* The document where the drag was started, which will be null if the
* drag originated outside the application. Useful for determining if a drop
* originated in the same document.
*/
readonly attribute nsIDOMDocument sourceDocument;
/**
* Get data from a Drag&Drop. Can be called while the drag is in process
* or after the drop has completed.

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

@ -87,6 +87,8 @@ NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
nsIScriptableRegion * aRegion,
PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession ( aDOMNode, anArrayTransferables, aRegion, aActionType );
#ifdef DEBUG_DD
g_print("InvokeDragSession\n");
#endif

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

@ -56,6 +56,9 @@
#include "nsPoint.h"
#include "nsIWidget.h"
#include "nsIXULContent.h"
#include "nsIDOMElement.h"
#if !TARGET_CARBON
DragSendDataUPP nsDragService::sDragSendDataUPP = NewDragSendDataProc(DragSendDataProc);
@ -96,6 +99,23 @@ nsDragService :: ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outSc
{
NS_ASSERTION ( aDOMNode, "Oopps, no DOM node" );
// until bug 41237 is fixed, only do translucent dragging if the drag is in
// the chrome or it's a link.
nsCOMPtr<nsIXULContent> xulContent ( do_QueryInterface(aDOMNode) );
if ( !xulContent ) {
// the link node is the parent of the node we have (which is probably text or image).
nsCOMPtr<nsIDOMNode> parent;
aDOMNode->GetParentNode ( getter_AddRefs(parent) );
if ( parent ) {
nsAutoString localName;
parent->GetLocalName ( localName );
if ( ! localName.Equals(NS_LITERAL_STRING("A")) )
return PR_FALSE;
}
else
return FALSE;
}
PRBool haveRectFlag = PR_FALSE;
outScreenRect.left = outScreenRect.right = outScreenRect.top = outScreenRect.bottom = 0;
@ -179,6 +199,8 @@ nsDragService :: ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outSc
NS_IMETHODIMP
nsDragService :: InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * aTransferableArray, nsIScriptableRegion * aDragRgn, PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession ( aDOMNode, aTransferableArray, aDragRgn, aActionType );
Rect frameRect = { 0, 0, 0, 0 };
PRBool useRectFromFrame = PR_FALSE;
if ( aDOMNode )

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

@ -111,6 +111,8 @@ nsresult nsDragService::InvokeDragSession( nsIDOMNode *aDOMNode,
nsIRegion *aRegion,
PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession ( aDOMNode, aTransArray, aRegion, aActionType );
// This is horribly multidimensional -- we have an array of dragitems, fine.
// But -- each dragitem may be a file list, which itself is several dragitems.
PDRAGITEM pDragItems = 0;

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

@ -102,6 +102,8 @@ NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
nsIScriptableRegion *aRegion,
PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession ( aDOMNode, aTransferableArray, aRegion, aActionType );
PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::InvokeDragSession this=<%p> aActionType=<%d>\n", this, aActionType));
//mWidget = gtk_invisible_new();
//gtk_widget_show(mWidget);

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

@ -64,6 +64,8 @@ nsDragService::~nsDragService()
//-------------------------------------------------------------------------
NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables, nsIScriptableRegion * aRegion, PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession ( aDOMNode, anArrayTransferables, aRegion, aActionType );
nsresult rv;
PRUint32 numItemsToDrag = 0;
rv = anArrayTransferables->Count(&numItemsToDrag);

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

@ -108,21 +108,31 @@ NS_IMETHODIMP nsBaseDragService::GetTargetSize (nsSize * aDragTargetSize)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseDragService::GetNumDropItems (PRUint32 * aNumItems)
{
*aNumItems = 0;
return NS_ERROR_FAILURE;
}
//
// GetSourceDocument
//
// Returns the DOM document where the drag was initiated. This will be
// nsnull if the drag began outside of our application.
//
NS_IMETHODIMP
nsBaseDragService :: GetSourceDocument ( nsIDOMDocument** aSourceDocument )
{
*aSourceDocument = mSourceDocument.get();
NS_IF_ADDREF ( *aSourceDocument );
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseDragService::GetData (nsITransferable * aTransferable, PRUint32 aItemIndex)
{
return NS_ERROR_FAILURE;
}
@ -133,10 +143,16 @@ NS_IMETHODIMP nsBaseDragService::IsDataFlavorSupported(const char *aDataFlavor,
return NS_ERROR_FAILURE;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseDragService::InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables, nsIScriptableRegion * aRegion, PRUint32 aActionType)
{
return NS_ERROR_FAILURE;
// stash the document of the dom node. if one isn't provided, warn.
NS_WARN_IF_FALSE ( aDOMNode, "No node provided to InvokeDragSession, you should provide one" );
if ( aDOMNode )
aDOMNode->GetOwnerDocument ( getter_AddRefs(mSourceDocument) );
return NS_OK;
}
@ -175,6 +191,8 @@ NS_IMETHODIMP nsBaseDragService::EndDragSession ()
return NS_ERROR_FAILURE;
}
mDoingDrag = PR_FALSE;
mSourceDocument = nsnull; // release the source document we've been holding
return NS_OK;
}

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

@ -27,6 +27,7 @@
#include "nsIDragSession.h"
#include "nsITransferable.h"
#include "nsISupportsArray.h"
#include "nsIDOMDocument.h"
#include "nsCOMPtr.h"
/**
@ -55,6 +56,8 @@ protected:
nsSize mTargetSize;
PRUint32 mDragAction;
nsCOMPtr<nsIDragTracker> mCurrentlyTracking;
nsCOMPtr<nsIDOMDocument> mSourceDocument; // the document at the drag source. will be null
// if it came from outside the app.
};