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
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
#include "mozilla/dom/SimpleGestureEvent.h"
|
2013-09-25 11:21:16 +00:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2014-02-27 10:51:14 +00:00
|
|
|
#include "prtime.h"
|
2008-10-23 20:15:20 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-27 06:20:57 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetSimpleGestureEvent* aEvent)
|
2014-02-27 10:51:15 +00:00
|
|
|
: MouseEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent :
|
|
|
|
new WidgetSimpleGestureEvent(false, 0, nullptr))
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
2014-08-04 05:28:53 +00:00
|
|
|
NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
|
2014-08-04 05:28:46 +00:00
|
|
|
"event type mismatch");
|
2008-10-23 20:15:20 +00:00
|
|
|
|
|
|
|
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;
|
2013-10-02 06:38:27 +00:00
|
|
|
static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
|
|
|
|
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:15 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SimpleGestureEvent, MouseEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SimpleGestureEvent, MouseEvent)
|
2008-10-23 20:15:20 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
|
2008-10-23 20:15:20 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
|
2014-02-27 10:51:15 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
|
2008-10-23 20:15:20 +00:00
|
|
|
|
2013-04-09 19:44:01 +00:00
|
|
|
/* attribute unsigned long allowedDirections; */
|
2013-10-18 06:10:23 +00:00
|
|
|
uint32_t
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::AllowedDirections()
|
2013-10-18 06:10:23 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsSimpleGestureEvent()->allowedDirections;
|
|
|
|
}
|
|
|
|
|
2013-04-09 19:44:01 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::GetAllowedDirections(uint32_t* aAllowedDirections)
|
2013-04-09 19:44:01 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAllowedDirections);
|
2013-10-18 06:10:23 +00:00
|
|
|
*aAllowedDirections = AllowedDirections();
|
2013-04-09 19:44:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
|
2013-04-09 19:44:01 +00:00
|
|
|
{
|
2013-10-18 06:10:23 +00:00
|
|
|
mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
|
2013-04-09 19:44:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-23 20:15:20 +00:00
|
|
|
/* readonly attribute unsigned long direction; */
|
2013-10-18 06:10:23 +00:00
|
|
|
uint32_t
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::Direction()
|
2013-10-18 06:10:23 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsSimpleGestureEvent()->direction;
|
|
|
|
}
|
|
|
|
|
2008-10-23 20:15:20 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::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; */
|
2013-10-18 06:10:23 +00:00
|
|
|
double
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::Delta()
|
2013-10-18 06:10:23 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsSimpleGestureEvent()->delta;
|
|
|
|
}
|
|
|
|
|
2008-10-23 20:15:20 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::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; */
|
2013-10-18 06:10:23 +00:00
|
|
|
uint32_t
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::ClickCount()
|
2013-10-18 06:10:23 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsSimpleGestureEvent()->clickCount;
|
|
|
|
}
|
|
|
|
|
2012-06-14 17:40:12 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::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
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
|
|
|
|
bool aCanBubbleArg,
|
|
|
|
bool aCancelableArg,
|
|
|
|
nsIDOMWindow* aViewArg,
|
|
|
|
int32_t aDetailArg,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
|
|
|
int32_t aClientY,
|
|
|
|
bool aCtrlKeyArg,
|
|
|
|
bool aAltKeyArg,
|
|
|
|
bool aShiftKeyArg,
|
|
|
|
bool aMetaKeyArg,
|
|
|
|
uint16_t aButton,
|
|
|
|
nsIDOMEventTarget* aRelatedTarget,
|
|
|
|
uint32_t aAllowedDirectionsArg,
|
|
|
|
uint32_t aDirectionArg,
|
|
|
|
double aDeltaArg,
|
|
|
|
uint32_t aClickCountArg)
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
2014-02-27 10:51:15 +00:00
|
|
|
nsresult rv =
|
|
|
|
MouseEvent::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);
|
|
|
|
|
2013-10-18 06:10:23 +00:00
|
|
|
WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
|
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;
|
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetSimpleGestureEvent* aEvent)
|
2008-10-23 20:15:20 +00:00
|
|
|
{
|
2014-02-27 10:51:14 +00:00
|
|
|
SimpleGestureEvent* it = new SimpleGestureEvent(aOwner, aPresContext, aEvent);
|
2014-03-17 20:00:11 +00:00
|
|
|
NS_ADDREF(it);
|
|
|
|
*aInstancePtrResult = static_cast<Event*>(it);
|
|
|
|
return NS_OK;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|