1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/MouseScrollEvent.h"
7 #include "mozilla/MouseEvents.h"
13 MouseScrollEvent::MouseScrollEvent(EventTarget
* aOwner
,
14 nsPresContext
* aPresContext
,
15 WidgetMouseScrollEvent
* aEvent
)
16 : MouseEvent(aOwner
, aPresContext
,
17 aEvent
? aEvent
: new WidgetMouseScrollEvent(false, 0, nullptr))
20 mEventIsInternal
= false;
22 mEventIsInternal
= true;
23 mEvent
->time
= PR_Now();
24 mEvent
->refPoint
.x
= mEvent
->refPoint
.y
= 0;
25 static_cast<WidgetMouseEventBase
*>(mEvent
)->inputSource
=
26 nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN
;
29 mDetail
= mEvent
->AsMouseScrollEvent()->delta
;
32 NS_IMPL_ADDREF_INHERITED(MouseScrollEvent
, MouseEvent
)
33 NS_IMPL_RELEASE_INHERITED(MouseScrollEvent
, MouseEvent
)
35 NS_INTERFACE_MAP_BEGIN(MouseScrollEvent
)
36 NS_INTERFACE_MAP_ENTRY(nsIDOMMouseScrollEvent
)
37 NS_INTERFACE_MAP_END_INHERITING(MouseEvent
)
40 MouseScrollEvent::InitMouseScrollEvent(const nsAString
& aType
,
54 nsIDOMEventTarget
* aRelatedTarget
,
58 MouseEvent::InitMouseEvent(aType
, aCanBubble
, aCancelable
, aView
, aDetail
,
59 aScreenX
, aScreenY
, aClientX
, aClientY
,
60 aCtrlKey
, aAltKey
, aShiftKey
, aMetaKey
, aButton
,
62 NS_ENSURE_SUCCESS(rv
, rv
);
63 mEvent
->AsMouseScrollEvent()->isHorizontal
= (aAxis
== HORIZONTAL_AXIS
);
69 MouseScrollEvent::GetAxis(int32_t* aResult
)
71 NS_ENSURE_ARG_POINTER(aResult
);
77 MouseScrollEvent::Axis()
79 return mEvent
->AsMouseScrollEvent()->isHorizontal
?
80 static_cast<int32_t>(HORIZONTAL_AXIS
) :
81 static_cast<int32_t>(VERTICAL_AXIS
);
85 } // namespace mozilla
87 using namespace mozilla
;
91 NS_NewDOMMouseScrollEvent(nsIDOMEvent
** aInstancePtrResult
,
93 nsPresContext
* aPresContext
,
94 WidgetMouseScrollEvent
* aEvent
)
96 MouseScrollEvent
* it
= new MouseScrollEvent(aOwner
, aPresContext
, aEvent
);
98 *aInstancePtrResult
= static_cast<Event
*>(it
);