Bug 707382, merge nsIDOMDataTransfer and nsIDOMNSDataTransfer, r=jonas

This commit is contained in:
Neil Deakin 2012-02-07 13:02:32 -05:00
Родитель a1be08b67e
Коммит 92e5958c61
11 изменённых файлов: 43 добавлений и 84 удалений

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

@ -4874,11 +4874,8 @@ nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
} }
// each event should use a clone of the original dataTransfer. // each event should use a clone of the original dataTransfer.
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS = initialDataTransfer->Clone(aDragEvent->message, aDragEvent->userCancelled,
do_QueryInterface(initialDataTransfer); getter_AddRefs(aDragEvent->dataTransfer));
NS_ENSURE_TRUE(initialDataTransferNS, NS_ERROR_FAILURE);
initialDataTransferNS->Clone(aDragEvent->message, aDragEvent->userCancelled,
getter_AddRefs(aDragEvent->dataTransfer));
NS_ENSURE_TRUE(aDragEvent->dataTransfer, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(aDragEvent->dataTransfer, NS_ERROR_OUT_OF_MEMORY);
// for the dragenter and dragover events, initialize the drop effect // for the dragenter and dragover events, initialize the drop effect
@ -4886,14 +4883,10 @@ nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
// the event is fired based on the keyboard state. // the event is fired based on the keyboard state.
if (aDragEvent->message == NS_DRAGDROP_ENTER || if (aDragEvent->message == NS_DRAGDROP_ENTER ||
aDragEvent->message == NS_DRAGDROP_OVER) { aDragEvent->message == NS_DRAGDROP_OVER) {
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
do_QueryInterface(aDragEvent->dataTransfer);
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
PRUint32 action, effectAllowed; PRUint32 action, effectAllowed;
dragSession->GetDragAction(&action); dragSession->GetDragAction(&action);
newDataTransfer->GetEffectAllowedInt(&effectAllowed); aDragEvent->dataTransfer->GetEffectAllowedInt(&effectAllowed);
newDataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed)); aDragEvent->dataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed));
} }
else if (aDragEvent->message == NS_DRAGDROP_DROP || else if (aDragEvent->message == NS_DRAGDROP_DROP ||
aDragEvent->message == NS_DRAGDROP_DRAGDROP || aDragEvent->message == NS_DRAGDROP_DRAGDROP ||
@ -4902,13 +4895,9 @@ nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
// last value that the dropEffect had. This will have been set in // last value that the dropEffect had. This will have been set in
// nsEventStateManager::PostHandleEvent for the last dragenter or // nsEventStateManager::PostHandleEvent for the last dragenter or
// dragover event. // dragover event.
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
do_QueryInterface(aDragEvent->dataTransfer);
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
PRUint32 dropEffect; PRUint32 dropEffect;
initialDataTransferNS->GetDropEffectInt(&dropEffect); initialDataTransfer->GetDropEffectInt(&dropEffect);
newDataTransfer->SetDropEffectInt(dropEffect); aDragEvent->dataTransfer->SetDropEffectInt(dropEffect);
} }
return NS_OK; return NS_OK;

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

@ -67,7 +67,6 @@ DOMCI_DATA(DataTransfer, nsDOMDataTransfer)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMDataTransfer) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMDataTransfer)
NS_INTERFACE_MAP_ENTRY(nsIDOMDataTransfer) NS_INTERFACE_MAP_ENTRY(nsIDOMDataTransfer)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSDataTransfer)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDataTransfer) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDataTransfer)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataTransfer) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataTransfer)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END

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

@ -67,13 +67,11 @@ struct TransferItem {
nsCOMPtr<nsIVariant> mData; nsCOMPtr<nsIVariant> mData;
}; };
class nsDOMDataTransfer : public nsIDOMDataTransfer, class nsDOMDataTransfer : public nsIDOMDataTransfer
public nsIDOMNSDataTransfer
{ {
public: public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMDATATRANSFER NS_DECL_NSIDOMDATATRANSFER
NS_DECL_NSIDOMNSDATATRANSFER
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMDataTransfer, nsIDOMDataTransfer) NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMDataTransfer, nsIDOMDataTransfer)

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

@ -3302,13 +3302,10 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// the initial dataTransfer is the one from the dragstart event that // the initial dataTransfer is the one from the dragstart event that
// was set on the dragSession when the drag began. // was set on the dragSession when the drag began.
nsCOMPtr<nsIDOMNSDataTransfer> dataTransfer; nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer)); dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
do_QueryInterface(initialDataTransfer);
nsDragEvent *dragEvent = (nsDragEvent*)aEvent; nsDragEvent *dragEvent = (nsDragEvent*)aEvent;
// collect any changes to moz cursor settings stored in the event's // collect any changes to moz cursor settings stored in the event's
@ -3340,7 +3337,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// initialized (which is done in nsDOMDragEvent::GetDataTransfer), // initialized (which is done in nsDOMDragEvent::GetDataTransfer),
// so set it from the drag action. We'll still want to filter it // so set it from the drag action. We'll still want to filter it
// based on the effectAllowed below. // based on the effectAllowed below.
dataTransfer = initialDataTransferNS; dataTransfer = initialDataTransfer;
PRUint32 action; PRUint32 action;
dragSession->GetDragAction(&action); dragSession->GetDragAction(&action);
@ -3390,8 +3387,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// now set the drop effect in the initial dataTransfer. This ensures // now set the drop effect in the initial dataTransfer. This ensures
// that we can get the desired drop effect in the drop event. // that we can get the desired drop effect in the drop event.
if (initialDataTransferNS) if (initialDataTransfer)
initialDataTransferNS->SetDropEffectInt(dropEffect); initialDataTransfer->SetDropEffectInt(dropEffect);
} }
break; break;
@ -4184,18 +4181,11 @@ nsEventStateManager::UpdateDragDataTransfer(nsDragEvent* dragEvent)
// was set on the dragSession when the drag began. // was set on the dragSession when the drag began.
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer)); dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
if (initialDataTransfer) {
// grab the interface that has GetMozCursor.
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
do_QueryInterface(initialDataTransfer);
nsCOMPtr<nsIDOMNSDataTransfer> eventTransferNS =
do_QueryInterface(dragEvent->dataTransfer);
if (initialDataTransferNS && eventTransferNS) {
// retrieve the current moz cursor setting and save it. // retrieve the current moz cursor setting and save it.
nsAutoString mozCursor; nsAutoString mozCursor;
eventTransferNS->GetMozCursor(mozCursor); dragEvent->dataTransfer->GetMozCursor(mozCursor);
initialDataTransferNS->SetMozCursor(mozCursor); initialDataTransfer->SetMozCursor(mozCursor);
} }
} }
} }

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

@ -4118,7 +4118,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer) DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer) DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDataTransfer)
DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(NotifyPaintEvent, nsIDOMNotifyPaintEvent) DOM_CLASSINFO_MAP_BEGIN(NotifyPaintEvent, nsIDOMNotifyPaintEvent)

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

@ -40,7 +40,7 @@
interface nsIVariant; interface nsIVariant;
interface nsIDOMFileList; interface nsIDOMFileList;
[scriptable, uuid(34042440-60A8-4992-AE5C-798E69148955)] [scriptable, uuid(E929ACB6-435C-4CB8-9AD1-AE3B9353BCC5)]
interface nsIDOMDataTransfer : nsISupports interface nsIDOMDataTransfer : nsISupports
{ {
/** /**
@ -160,28 +160,6 @@ interface nsIDOMDataTransfer : nsISupports
* @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
*/ */
void addElement(in nsIDOMElement element); void addElement(in nsIDOMElement element);
};
[scriptable, uuid(AE6DF4E2-FA37-4701-A33E-A5678F826EED)]
interface nsIDOMNSDataTransfer : nsISupports
{
/*
* Integer version of dropEffect, set to one of the constants in nsIDragService.
*/
[noscript] attribute unsigned long dropEffectInt;
/*
* Integer version of effectAllowed, set to one or a combination of the
* constants in nsIDragService.
*/
[noscript] attribute unsigned long effectAllowedInt;
/**
* Creates a copy of the data transfer object, for the given event type and
* user cancelled flag.
*/
[noscript] nsIDOMDataTransfer clone(in PRUint32 aEventType,
in boolean aUserCancelled);
/** /**
* The number of items being dragged. * The number of items being dragged.
@ -272,4 +250,22 @@ interface nsIDOMNSDataTransfer : nsISupports
* drags, or if the caller cannot access this node, this will be null. * drags, or if the caller cannot access this node, this will be null.
*/ */
readonly attribute nsIDOMNode mozSourceNode; readonly attribute nsIDOMNode mozSourceNode;
/*
* Integer version of dropEffect, set to one of the constants in nsIDragService.
*/
[noscript] attribute unsigned long dropEffectInt;
/*
* Integer version of effectAllowed, set to one or a combination of the
* constants in nsIDragService.
*/
[noscript] attribute unsigned long effectAllowedInt;
/**
* Creates a copy of the data transfer object, for the given event type and
* user cancelled flag.
*/
[noscript] nsIDOMDataTransfer clone(in PRUint32 aEventType,
in boolean aUserCancelled);
}; };

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

@ -831,14 +831,11 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
NS_ENSURE_TRUE(typeSupported, false); NS_ENSURE_TRUE(typeSupported, false);
nsCOMPtr<nsIDOMNSDataTransfer> dataTransferNS(do_QueryInterface(dataTransfer));
NS_ENSURE_TRUE(dataTransferNS, false);
// If there is no source node, this is probably an external drag and the // If there is no source node, this is probably an external drag and the
// drop is allowed. The later checks rely on checking if the drag target // drop is allowed. The later checks rely on checking if the drag target
// is the same as the drag source. // is the same as the drag source.
nsCOMPtr<nsIDOMNode> sourceNode; nsCOMPtr<nsIDOMNode> sourceNode;
dataTransferNS->GetMozSourceNode(getter_AddRefs(sourceNode)); dataTransfer->GetMozSourceNode(getter_AddRefs(sourceNode));
if (!sourceNode) if (!sourceNode)
return true; return true;

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

@ -4597,11 +4597,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (operation == NSDragOperationNone) { if (operation == NSDragOperationNone) {
nsCOMPtr<nsIDOMDataTransfer> dataTransfer; nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
dragService->GetDataTransfer(getter_AddRefs(dataTransfer)); dragService->GetDataTransfer(getter_AddRefs(dataTransfer));
nsCOMPtr<nsIDOMNSDataTransfer> dataTransferNS = if (dataTransfer)
do_QueryInterface(dataTransfer); dataTransfer->SetDropEffectInt(nsIDragService::DRAGDROP_ACTION_NONE);
if (dataTransferNS)
dataTransferNS->SetDropEffectInt(nsIDragService::DRAGDROP_ACTION_NONE);
} }
mDragService->EndDragSession(true); mDragService->EndDragSession(true);

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

@ -1372,11 +1372,8 @@ nsDragService::SourceEndDragSession(GdkDragContext *aContext,
} }
} }
nsCOMPtr<nsIDOMNSDataTransfer> dataTransfer = if (mDataTransfer) {
do_QueryInterface(mDataTransfer); mDataTransfer->SetDropEffectInt(dropEffect);
if (dataTransfer) {
dataTransfer->SetDropEffectInt(dropEffect);
} }
// Inform the drag session that we're ending the drag. // Inform the drag session that we're ending the drag.

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

@ -317,7 +317,7 @@ nsDragService::StartInvokingDragSession(IDataObject * aDataObj,
HRESULT res = ::DoDragDrop(aDataObj, mNativeDragSrc, effects, &winDropRes); HRESULT res = ::DoDragDrop(aDataObj, mNativeDragSrc, effects, &winDropRes);
// In cases where the drop operation completed outside the application, update // In cases where the drop operation completed outside the application, update
// the source node's nsIDOMNSDataTransfer dropEffect value so it is up to date. // the source node's nsIDOMDataTransfer dropEffect value so it is up to date.
if (!mSentLocalDropEvent) { if (!mSentLocalDropEvent) {
PRUint32 dropResult; PRUint32 dropResult;
// Order is important, since multiple flags can be returned. // Order is important, since multiple flags can be returned.
@ -330,14 +330,11 @@ nsDragService::StartInvokingDragSession(IDataObject * aDataObj,
else else
dropResult = DRAGDROP_ACTION_NONE; dropResult = DRAGDROP_ACTION_NONE;
nsCOMPtr<nsIDOMNSDataTransfer> dataTransfer = if (mDataTransfer) {
do_QueryInterface(mDataTransfer);
if (dataTransfer) {
if (res == DRAGDROP_S_DROP) // Success if (res == DRAGDROP_S_DROP) // Success
dataTransfer->SetDropEffectInt(dropResult); mDataTransfer->SetDropEffectInt(dropResult);
else else
dataTransfer->SetDropEffectInt(DRAGDROP_ACTION_NONE); mDataTransfer->SetDropEffectInt(DRAGDROP_ACTION_NONE);
} }
} }

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

@ -84,7 +84,7 @@ protected:
ULONG m_cRef; ULONG m_cRef;
// Data object, hold information about cursor state // Data object, hold information about cursor state
nsCOMPtr<nsIDOMNSDataTransfer> mDataTransfer; nsCOMPtr<nsIDOMDataTransfer> mDataTransfer;
// Custom drag cursor // Custom drag cursor
HCURSOR m_hCursor; HCURSOR m_hCursor;