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/MouseScrollEvent.h"
8 #include "mozilla/dom/MouseEventBinding.h"
9 #include "mozilla/MouseEvents.h"
12 namespace mozilla::dom
{
14 MouseScrollEvent::MouseScrollEvent(EventTarget
* aOwner
,
15 nsPresContext
* aPresContext
,
16 WidgetMouseScrollEvent
* aEvent
)
17 : MouseEvent(aOwner
, aPresContext
,
20 : new WidgetMouseScrollEvent(false, eVoidEvent
, nullptr)) {
22 mEventIsInternal
= false;
24 mEventIsInternal
= true;
25 mEvent
->mRefPoint
= LayoutDeviceIntPoint(0, 0);
26 static_cast<WidgetMouseEventBase
*>(mEvent
)->mInputSource
=
27 MouseEvent_Binding::MOZ_SOURCE_UNKNOWN
;
30 mDetail
= mEvent
->AsMouseScrollEvent()->mDelta
;
33 void MouseScrollEvent::InitMouseScrollEvent(
34 const nsAString
& aType
, bool aCanBubble
, bool aCancelable
,
35 nsGlobalWindowInner
* aView
, int32_t aDetail
, int32_t aScreenX
,
36 int32_t aScreenY
, int32_t aClientX
, int32_t aClientY
, bool aCtrlKey
,
37 bool aAltKey
, bool aShiftKey
, bool aMetaKey
, uint16_t aButton
,
38 EventTarget
* aRelatedTarget
, int32_t aAxis
) {
39 NS_ENSURE_TRUE_VOID(!mEvent
->mFlags
.mIsBeingDispatched
);
41 MouseEvent::InitMouseEvent(aType
, aCanBubble
, aCancelable
, aView
, aDetail
,
42 aScreenX
, aScreenY
, aClientX
, aClientY
, aCtrlKey
,
43 aAltKey
, aShiftKey
, aMetaKey
, aButton
,
45 mEvent
->AsMouseScrollEvent()->mIsHorizontal
=
46 (aAxis
== MouseScrollEvent_Binding::HORIZONTAL_AXIS
);
49 int32_t MouseScrollEvent::Axis() {
50 return mEvent
->AsMouseScrollEvent()->mIsHorizontal
51 ? MouseScrollEvent_Binding::HORIZONTAL_AXIS
52 : MouseScrollEvent_Binding::VERTICAL_AXIS
;
55 } // namespace mozilla::dom
57 using namespace mozilla
;
60 already_AddRefed
<MouseScrollEvent
> NS_NewDOMMouseScrollEvent(
61 EventTarget
* aOwner
, nsPresContext
* aPresContext
,
62 WidgetMouseScrollEvent
* aEvent
) {
63 RefPtr
<MouseScrollEvent
> it
=
64 new MouseScrollEvent(aOwner
, aPresContext
, aEvent
);