/src/mozilla-central/dom/events/MouseScrollEvent.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "mozilla/dom/MouseScrollEvent.h" |
8 | | #include "mozilla/dom/MouseEventBinding.h" |
9 | | #include "mozilla/MouseEvents.h" |
10 | | #include "prtime.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace dom { |
14 | | |
15 | | MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner, |
16 | | nsPresContext* aPresContext, |
17 | | WidgetMouseScrollEvent* aEvent) |
18 | | : MouseEvent(aOwner, aPresContext, |
19 | | aEvent ? aEvent : |
20 | | new WidgetMouseScrollEvent(false, eVoidEvent, nullptr)) |
21 | 0 | { |
22 | 0 | if (aEvent) { |
23 | 0 | mEventIsInternal = false; |
24 | 0 | } else { |
25 | 0 | mEventIsInternal = true; |
26 | 0 | mEvent->mTime = PR_Now(); |
27 | 0 | mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); |
28 | 0 | static_cast<WidgetMouseEventBase*>(mEvent)->inputSource = |
29 | 0 | MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; |
30 | 0 | } |
31 | 0 |
|
32 | 0 | mDetail = mEvent->AsMouseScrollEvent()->mDelta; |
33 | 0 | } |
34 | | |
35 | | void |
36 | | MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType, |
37 | | bool aCanBubble, |
38 | | bool aCancelable, |
39 | | nsGlobalWindowInner* aView, |
40 | | int32_t aDetail, |
41 | | int32_t aScreenX, |
42 | | int32_t aScreenY, |
43 | | int32_t aClientX, |
44 | | int32_t aClientY, |
45 | | bool aCtrlKey, |
46 | | bool aAltKey, |
47 | | bool aShiftKey, |
48 | | bool aMetaKey, |
49 | | uint16_t aButton, |
50 | | EventTarget* aRelatedTarget, |
51 | | int32_t aAxis) |
52 | 0 | { |
53 | 0 | NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched); |
54 | 0 |
|
55 | 0 | MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail, |
56 | 0 | aScreenX, aScreenY, aClientX, aClientY, |
57 | 0 | aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton, |
58 | 0 | aRelatedTarget); |
59 | 0 | mEvent->AsMouseScrollEvent()->mIsHorizontal = |
60 | 0 | (aAxis == MouseScrollEvent_Binding::HORIZONTAL_AXIS); |
61 | 0 | } |
62 | | |
63 | | int32_t |
64 | | MouseScrollEvent::Axis() |
65 | 0 | { |
66 | 0 | return mEvent->AsMouseScrollEvent()->mIsHorizontal ? |
67 | 0 | MouseScrollEvent_Binding::HORIZONTAL_AXIS : |
68 | 0 | MouseScrollEvent_Binding::VERTICAL_AXIS; |
69 | 0 | } |
70 | | |
71 | | } // namespace dom |
72 | | } // namespace mozilla |
73 | | |
74 | | using namespace mozilla; |
75 | | using namespace dom; |
76 | | |
77 | | already_AddRefed<MouseScrollEvent> |
78 | | NS_NewDOMMouseScrollEvent(EventTarget* aOwner, |
79 | | nsPresContext* aPresContext, |
80 | | WidgetMouseScrollEvent* aEvent) |
81 | 0 | { |
82 | 0 | RefPtr<MouseScrollEvent> it = |
83 | 0 | new MouseScrollEvent(aOwner, aPresContext, aEvent); |
84 | 0 | return it.forget(); |
85 | 0 | } |