2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
2018-03-20 04:16:06 +00:00
|
|
|
#include "mozilla/dom/MouseEventBinding.h"
|
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
|
2015-08-28 23:58:26 +00:00
|
|
|
: new WidgetSimpleGestureEvent(false, eVoidEvent, nullptr)) {
|
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;
|
2016-03-28 04:29:42 +00:00
|
|
|
mEvent->mTime = PR_Now();
|
2016-04-18 14:09:02 +00:00
|
|
|
mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
|
2019-04-21 18:19:43 +00:00
|
|
|
static_cast<WidgetMouseEventBase*>(mEvent)->mInputSource =
|
2018-06-25 21:20:54 +00:00
|
|
|
MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-09 16:17:10 +00:00
|
|
|
uint32_t SimpleGestureEvent::AllowedDirections() const {
|
2016-05-09 19:16:54 +00:00
|
|
|
return mEvent->AsSimpleGestureEvent()->mAllowedDirections;
|
2013-10-18 06:10:23 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
void SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections) {
|
2016-05-09 19:16:54 +00:00
|
|
|
mEvent->AsSimpleGestureEvent()->mAllowedDirections = aAllowedDirections;
|
2013-04-09 19:44:01 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 16:17:10 +00:00
|
|
|
uint32_t SimpleGestureEvent::Direction() const {
|
2016-05-09 19:16:54 +00:00
|
|
|
return mEvent->AsSimpleGestureEvent()->mDirection;
|
2013-10-18 06:10:23 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 16:17:10 +00:00
|
|
|
double SimpleGestureEvent::Delta() const {
|
2016-05-09 19:16:55 +00:00
|
|
|
return mEvent->AsSimpleGestureEvent()->mDelta;
|
2013-10-18 06:10:23 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 16:17:10 +00:00
|
|
|
uint32_t SimpleGestureEvent::ClickCount() const {
|
2016-05-09 19:16:54 +00:00
|
|
|
return mEvent->AsSimpleGestureEvent()->mClickCount;
|
2013-10-18 06:10:23 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
void SimpleGestureEvent::InitSimpleGestureEvent(
|
|
|
|
const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg,
|
2017-11-06 22:52:14 +00:00
|
|
|
nsGlobalWindowInner* aViewArg, int32_t aDetailArg, int32_t aScreenX,
|
2014-02-27 10:51:14 +00:00
|
|
|
int32_t aScreenY, int32_t aClientX, int32_t aClientY, bool aCtrlKeyArg,
|
|
|
|
bool aAltKeyArg, bool aShiftKeyArg, bool aMetaKeyArg, uint16_t aButton,
|
|
|
|
EventTarget* aRelatedTarget, uint32_t aAllowedDirectionsArg,
|
|
|
|
uint32_t aDirectionArg, double aDeltaArg, uint32_t aClickCountArg) {
|
2016-10-30 19:30:06 +00:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
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
|
|
|
|
2013-10-18 06:10:23 +00:00
|
|
|
WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
|
2016-05-09 19:16:54 +00:00
|
|
|
simpleGestureEvent->mAllowedDirections = aAllowedDirectionsArg;
|
2016-05-09 19:16:54 +00:00
|
|
|
simpleGestureEvent->mDirection = aDirectionArg;
|
2016-05-09 19:16:55 +00:00
|
|
|
simpleGestureEvent->mDelta = aDeltaArg;
|
2016-05-09 19:16:54 +00:00
|
|
|
simpleGestureEvent->mClickCount = aClickCountArg;
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 11:39:31 +00:00
|
|
|
already_AddRefed<SimpleGestureEvent> NS_NewDOMSimpleGestureEvent(
|
2014-02-27 10:51:14 +00:00
|
|
|
EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
WidgetSimpleGestureEvent* aEvent) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SimpleGestureEvent> it =
|
2015-08-12 11:39:31 +00:00
|
|
|
new SimpleGestureEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2008-10-23 20:15:20 +00:00
|
|
|
}
|