Bug 856351 - Paris binding for DragEvent, r=peterv

--HG--
extra : rebase_source : 695b5a3bf3641f0e39d33ca8718e1bc78695b09d
This commit is contained in:
Olli Pettay 2013-04-19 02:13:35 +03:00
parent 1640c1840c
commit aef2ae28d5
5 changed files with 73 additions and 7 deletions

View File

@ -26,6 +26,7 @@ nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
mEvent->refPoint.x = mEvent->refPoint.y = 0;
static_cast<nsMouseEvent*>(mEvent)->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
}
SetIsDOMBinding();
}
nsDOMDragEvent::~nsDOMDragEvent()
@ -74,27 +75,31 @@ nsDOMDragEvent::InitDragEvent(const nsAString & aType,
NS_IMETHODIMP
nsDOMDragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
{
NS_IF_ADDREF(*aDataTransfer = GetDataTransfer());
return NS_OK;
}
nsIDOMDataTransfer*
nsDOMDragEvent::GetDataTransfer()
{
// the dataTransfer field of the event caches the DataTransfer associated
// with the drag. It is initialized when an attempt is made to retrieve it
// rather that when the event is created to avoid duplicating the data when
// no listener ever uses it.
*aDataTransfer = nullptr;
if (!mEvent || mEvent->eventStructType != NS_DRAG_EVENT) {
NS_WARNING("Tried to get dataTransfer from non-drag event!");
return NS_OK;
return nullptr;
}
nsDragEvent* dragEvent = static_cast<nsDragEvent*>(mEvent);
// for synthetic events, just use the supplied data transfer object even if null
if (!mEventIsInternal) {
nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, nullptr);
}
NS_IF_ADDREF(*aDataTransfer = dragEvent->dataTransfer);
return NS_OK;
return dragEvent->dataTransfer;
}
nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,

View File

@ -8,6 +8,7 @@
#include "nsIDOMDragEvent.h"
#include "nsDOMMouseEvent.h"
#include "mozilla/dom/DragEventBinding.h"
class nsEvent;
@ -24,6 +25,30 @@ public:
NS_DECL_NSIDOMDRAGEVENT
NS_FORWARD_TO_NSDOMMOUSEEVENT
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
{
return mozilla::dom::DragEventBinding::Wrap(aCx, aScope, this);
}
nsIDOMDataTransfer* GetDataTransfer();
void InitDragEvent(const nsAString& aType,
bool aCanBubble, bool aCancelable,
nsIDOMWindow* aView, int32_t aDetail,
int32_t aScreenX, int32_t aScreenY,
int32_t aClientX, int32_t aClientY,
bool aCtrlKey, bool aAltKey, bool aShiftKey,
bool aMetaKey, uint16_t aButton,
mozilla::dom::EventTarget* aRelatedTarget,
nsIDOMDataTransfer* aDataTransfer,
mozilla::ErrorResult& aRv)
{
aRv = InitDragEvent(aType, aCanBubble, aCancelable,
aView, aDetail, aScreenX, aScreenY, aClientX, aClientY,
aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
aRelatedTarget, aDataTransfer);
}
};
nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,

View File

@ -268,6 +268,10 @@ DOMInterfaces = {
'nativeType': 'nsDOMTokenList',
},
'DragEvent': {
'nativeType': 'nsDOMDragEvent',
},
'DummyInterface': {
'skipGen': True,
'register': False,
@ -1528,4 +1532,4 @@ addExternalIface('XPathResult', nativeType='nsISupports')
addExternalIface('XPathExpression')
addExternalIface('XPathNSResolver')
addExternalIface('XULCommandDispatcher')
addExternalIface('DataTransfer')
addExternalIface('DataTransfer', notflattened=True)

View File

@ -0,0 +1,31 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
interface WindowProxy;
interface DataTransfer;
interface DragEvent : MouseEvent
{
readonly attribute DataTransfer? dataTransfer;
[Throws]
void initDragEvent(DOMString type,
boolean canBubble,
boolean cancelable,
WindowProxy? aView,
long aDetail,
long aScreenX,
long aScreenY,
long aClientX,
long aClientY,
boolean aCtrlKey,
boolean aAltKey,
boolean aShiftKey,
boolean aMetaKey,
unsigned short aButton,
EventTarget? aRelatedTarget,
DataTransfer? aDataTransfer);
};

View File

@ -58,6 +58,7 @@ webidl_files = \
DOMStringMap.webidl \
DOMTokenList.webidl \
DOMTransaction.webidl \
DragEvent.webidl \
DummyBinding.webidl \
DynamicsCompressorNode.webidl \
Element.webidl \