Bug 546425, add mozSourceNode to access the source node of the drag, r=jonas,sr=roc

This commit is contained in:
Neil Deakin 2010-03-02 06:21:20 -08:00
Родитель 893da6398e
Коммит ee39f914f4
2 изменённых файлов: 27 добавлений и 15 удалений

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

@ -386,6 +386,24 @@ nsDOMDataTransfer::SetMozCursor(const nsAString& aCursorState)
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataTransfer::GetMozSourceNode(nsIDOMNode** aSourceNode)
{
*aSourceNode = nsnull;
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (!dragSession)
return NS_OK;
nsCOMPtr<nsIDOMNode> sourceNode;
dragSession->GetSourceNode(getter_AddRefs(sourceNode));
if (sourceNode && !nsContentUtils::CanCallerAccess(sourceNode))
return NS_OK;
sourceNode.swap(*aSourceNode);
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataTransfer::MozTypesAt(PRUint32 aIndex, nsIDOMDOMStringList** aTypes)
{
@ -789,13 +807,7 @@ nsDOMDataTransfer::CacheExternalFormats()
// asked for, as it may be time consuming for the source application to
// generate it.
nsCOMPtr<nsIDragService> dragService =
do_GetService("@mozilla.org/widget/dragservice;1");
if (!dragService)
return;
nsCOMPtr<nsIDragSession> dragSession;
dragService->GetCurrentSession(getter_AddRefs(dragSession));
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (!dragSession)
return;
@ -853,13 +865,7 @@ nsDOMDataTransfer::FillInExternalDragData(TransferItem& aItem, PRUint32 aIndex)
else if (strcmp(format, "text/uri-list") == 0)
format = kURLDataMime;
nsCOMPtr<nsIDragService> dragService =
do_GetService("@mozilla.org/widget/dragservice;1");
if (!dragService)
return;
nsCOMPtr<nsIDragSession> dragSession;
dragService->GetCurrentSession(getter_AddRefs(dragSession));
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (!dragSession)
return;

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

@ -162,7 +162,7 @@ interface nsIDOMDataTransfer : nsISupports
void addElement(in nsIDOMElement element);
};
[scriptable, uuid(990758e9-fd38-4444-a1e8-395195802bda)]
[scriptable, uuid(AE6DF4E2-FA37-4701-A33E-A5678F826EED)]
interface nsIDOMNSDataTransfer : nsISupports
{
/*
@ -266,4 +266,10 @@ interface nsIDOMNSDataTransfer : nsISupports
* This property is only relevant for the dragend event.
*/
readonly attribute boolean mozUserCancelled;
/**
* The node that the mouse was pressed over to begin the drag. For external
* drags, or if the caller cannot access this node, this will be null.
*/
readonly attribute nsIDOMNode mozSourceNode;
};