2008-10-23 20:15:20 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2008-10-23 20:15:20 +00:00
|
|
|
|
|
|
|
#include "nsDOMSimpleGestureEvent.h"
|
|
|
|
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsSimpleGestureEvent* aEvent)
|
|
|
|
: nsDOMMouseEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent : new nsSimpleGestureEvent(false, 0, nullptr, 0, 0.0))
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
|
|
|
|
|
|
|
|
if (aEvent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = false;
|
2008-10-23 20:15:20 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = true;
|
2008-10-23 20:15:20 +00:00
|
|
|
mEvent->time = PR_Now();
|
2009-04-02 19:34:31 +00:00
|
|
|
mEvent->refPoint.x = mEvent->refPoint.y = 0;
|
2011-08-26 07:43:56 +00:00
|
|
|
static_cast<nsMouseEvent*>(mEvent)->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMSimpleGestureEvent::~nsDOMSimpleGestureEvent()
|
|
|
|
{
|
|
|
|
if (mEventIsInternal) {
|
|
|
|
delete static_cast<nsSimpleGestureEvent*>(mEvent);
|
2012-07-30 14:20:58 +00:00
|
|
|
mEvent = nullptr;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
|
2009-02-17 11:49:03 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
|
2008-10-23 20:15:20 +00:00
|
|
|
|
2013-04-09 19:44:01 +00:00
|
|
|
/* attribute unsigned long allowedDirections; */
|
|
|
|
NS_IMETHODIMP
|
2013-06-13 01:26:59 +00:00
|
|
|
nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
|
2013-04-09 19:44:01 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAllowedDirections);
|
|
|
|
*aAllowedDirections =
|
|
|
|
static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-06-13 01:26:59 +00:00
|
|
|
nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
|
2013-04-09 19:44:01 +00:00
|
|
|
{
|
|
|
|
static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections =
|
|
|
|
aAllowedDirections;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-23 20:15:20 +00:00
|
|
|
/* readonly attribute unsigned long direction; */
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDirection);
|
2013-03-28 14:24:28 +00:00
|
|
|
*aDirection = Direction();
|
2008-10-23 20:15:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute float delta; */
|
|
|
|
NS_IMETHODIMP
|
2012-08-09 07:09:42 +00:00
|
|
|
nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDelta);
|
2013-03-28 14:24:28 +00:00
|
|
|
*aDelta = Delta();
|
2008-10-23 20:15:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-14 17:40:12 +00:00
|
|
|
/* readonly attribute unsigned long clickCount; */
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount)
|
2012-06-14 17:40:12 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aClickCount);
|
2013-03-28 14:24:28 +00:00
|
|
|
*aClickCount = ClickCount();
|
2012-06-14 17:40:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-23 20:15:20 +00:00
|
|
|
NS_IMETHODIMP
|
2009-02-17 11:49:03 +00:00
|
|
|
nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aCanBubbleArg,
|
|
|
|
bool aCancelableArg,
|
2011-04-24 06:54:25 +00:00
|
|
|
nsIDOMWindow* aViewArg,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aDetailArg,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
|
|
|
int32_t aClientY,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aCtrlKeyArg,
|
|
|
|
bool aAltKeyArg,
|
|
|
|
bool aShiftKeyArg,
|
|
|
|
bool aMetaKeyArg,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t aButton,
|
2009-02-17 11:49:03 +00:00
|
|
|
nsIDOMEventTarget* aRelatedTarget,
|
2013-04-09 19:44:01 +00:00
|
|
|
uint32_t aAllowedDirectionsArg,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aDirectionArg,
|
2012-08-09 07:09:42 +00:00
|
|
|
double aDeltaArg,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aClickCountArg)
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
2009-02-17 11:49:03 +00:00
|
|
|
nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,
|
|
|
|
aCanBubbleArg,
|
|
|
|
aCancelableArg,
|
|
|
|
aViewArg,
|
|
|
|
aDetailArg,
|
|
|
|
aScreenX,
|
|
|
|
aScreenY,
|
|
|
|
aClientX,
|
|
|
|
aClientY,
|
|
|
|
aCtrlKeyArg,
|
|
|
|
aAltKeyArg,
|
|
|
|
aShiftKeyArg,
|
|
|
|
aMetaKeyArg,
|
|
|
|
aButton,
|
|
|
|
aRelatedTarget);
|
2008-10-23 20:15:20 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsSimpleGestureEvent* simpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);
|
2013-04-09 19:44:01 +00:00
|
|
|
simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
|
2009-02-17 11:49:03 +00:00
|
|
|
simpleGestureEvent->direction = aDirectionArg;
|
|
|
|
simpleGestureEvent->delta = aDeltaArg;
|
2012-06-14 17:40:12 +00:00
|
|
|
simpleGestureEvent->clickCount = aClickCountArg;
|
2008-10-23 20:15:20 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
|
2013-03-09 11:34:29 +00:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2008-10-23 20:15:20 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsSimpleGestureEvent *aEvent)
|
|
|
|
{
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMSimpleGestureEvent* it =
|
|
|
|
new nsDOMSimpleGestureEvent(aOwner, aPresContext, aEvent);
|
2008-10-23 20:15:20 +00:00
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|