diff --git a/content/events/src/nsDOMDataTransfer.cpp b/content/events/src/nsDOMDataTransfer.cpp index 8303692b998c..f7a0c793e97d 100644 --- a/content/events/src/nsDOMDataTransfer.cpp +++ b/content/events/src/nsDOMDataTransfer.cpp @@ -386,6 +386,24 @@ nsDOMDataTransfer::SetMozCursor(const nsAString& aCursorState) return NS_OK; } +NS_IMETHODIMP +nsDOMDataTransfer::GetMozSourceNode(nsIDOMNode** aSourceNode) +{ + *aSourceNode = nsnull; + + nsCOMPtr dragSession = nsContentUtils::GetDragSession(); + if (!dragSession) + return NS_OK; + + nsCOMPtr 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 dragService = - do_GetService("@mozilla.org/widget/dragservice;1"); - if (!dragService) - return; - - nsCOMPtr dragSession; - dragService->GetCurrentSession(getter_AddRefs(dragSession)); + nsCOMPtr 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 dragService = - do_GetService("@mozilla.org/widget/dragservice;1"); - if (!dragService) - return; - - nsCOMPtr dragSession; - dragService->GetCurrentSession(getter_AddRefs(dragSession)); + nsCOMPtr dragSession = nsContentUtils::GetDragSession(); if (!dragSession) return; diff --git a/dom/interfaces/events/nsIDOMDataTransfer.idl b/dom/interfaces/events/nsIDOMDataTransfer.idl index 5b27e0dfb3e6..71e1e264fea7 100644 --- a/dom/interfaces/events/nsIDOMDataTransfer.idl +++ b/dom/interfaces/events/nsIDOMDataTransfer.idl @@ -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; };