Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / dom / events / SimpleGestureEvent.cpp
blob402b1f669128b3beae0f438f4955e9c567f44b70
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/MouseEventBinding.h"
8 #include "mozilla/dom/SimpleGestureEvent.h"
9 #include "mozilla/TouchEvents.h"
10 #include "prtime.h"
12 namespace mozilla::dom {
14 SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
15 nsPresContext* aPresContext,
16 WidgetSimpleGestureEvent* aEvent)
17 : MouseEvent(
18 aOwner, aPresContext,
19 aEvent ? aEvent
20 : new WidgetSimpleGestureEvent(false, eVoidEvent, nullptr)) {
21 NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
22 "event type mismatch");
24 if (aEvent) {
25 mEventIsInternal = false;
26 } else {
27 mEventIsInternal = true;
28 mEvent->mTime = PR_Now();
29 mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
30 static_cast<WidgetMouseEventBase*>(mEvent)->mInputSource =
31 MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
35 uint32_t SimpleGestureEvent::AllowedDirections() const {
36 return mEvent->AsSimpleGestureEvent()->mAllowedDirections;
39 void SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections) {
40 mEvent->AsSimpleGestureEvent()->mAllowedDirections = aAllowedDirections;
43 uint32_t SimpleGestureEvent::Direction() const {
44 return mEvent->AsSimpleGestureEvent()->mDirection;
47 double SimpleGestureEvent::Delta() const {
48 return mEvent->AsSimpleGestureEvent()->mDelta;
51 uint32_t SimpleGestureEvent::ClickCount() const {
52 return mEvent->AsSimpleGestureEvent()->mClickCount;
55 void SimpleGestureEvent::InitSimpleGestureEvent(
56 const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg,
57 nsGlobalWindowInner* aViewArg, int32_t aDetailArg, int32_t aScreenX,
58 int32_t aScreenY, int32_t aClientX, int32_t aClientY, bool aCtrlKeyArg,
59 bool aAltKeyArg, bool aShiftKeyArg, bool aMetaKeyArg, uint16_t aButton,
60 EventTarget* aRelatedTarget, uint32_t aAllowedDirectionsArg,
61 uint32_t aDirectionArg, double aDeltaArg, uint32_t aClickCountArg) {
62 NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
64 MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg, aViewArg,
65 aDetailArg, aScreenX, aScreenY, aClientX, aClientY,
66 aCtrlKeyArg, aAltKeyArg, aShiftKeyArg, aMetaKeyArg,
67 aButton, aRelatedTarget);
69 WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
70 simpleGestureEvent->mAllowedDirections = aAllowedDirectionsArg;
71 simpleGestureEvent->mDirection = aDirectionArg;
72 simpleGestureEvent->mDelta = aDeltaArg;
73 simpleGestureEvent->mClickCount = aClickCountArg;
76 } // namespace mozilla::dom
78 using namespace mozilla;
79 using namespace mozilla::dom;
81 already_AddRefed<SimpleGestureEvent> NS_NewDOMSimpleGestureEvent(
82 EventTarget* aOwner, nsPresContext* aPresContext,
83 WidgetSimpleGestureEvent* aEvent) {
84 RefPtr<SimpleGestureEvent> it =
85 new SimpleGestureEvent(aOwner, aPresContext, aEvent);
86 return it.forget();