mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 856351 - Paris binding for DragEvent, r=peterv
--HG-- extra : rebase_source : 695b5a3bf3641f0e39d33ca8718e1bc78695b09d
This commit is contained in:
parent
1640c1840c
commit
aef2ae28d5
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
31
dom/webidl/DragEvent.webidl
Normal file
31
dom/webidl/DragEvent.webidl
Normal 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);
|
||||
};
|
@ -58,6 +58,7 @@ webidl_files = \
|
||||
DOMStringMap.webidl \
|
||||
DOMTokenList.webidl \
|
||||
DOMTransaction.webidl \
|
||||
DragEvent.webidl \
|
||||
DummyBinding.webidl \
|
||||
DynamicsCompressorNode.webidl \
|
||||
Element.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user