dom/events/MouseScrollEvent.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "mozilla/dom/MouseScrollEvent.h"
michael@0 7 #include "mozilla/MouseEvents.h"
michael@0 8 #include "prtime.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11 namespace dom {
michael@0 12
michael@0 13 MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
michael@0 14 nsPresContext* aPresContext,
michael@0 15 WidgetMouseScrollEvent* aEvent)
michael@0 16 : MouseEvent(aOwner, aPresContext,
michael@0 17 aEvent ? aEvent : new WidgetMouseScrollEvent(false, 0, nullptr))
michael@0 18 {
michael@0 19 if (aEvent) {
michael@0 20 mEventIsInternal = false;
michael@0 21 } else {
michael@0 22 mEventIsInternal = true;
michael@0 23 mEvent->time = PR_Now();
michael@0 24 mEvent->refPoint.x = mEvent->refPoint.y = 0;
michael@0 25 static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
michael@0 26 nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
michael@0 27 }
michael@0 28
michael@0 29 mDetail = mEvent->AsMouseScrollEvent()->delta;
michael@0 30 }
michael@0 31
michael@0 32 NS_IMPL_ADDREF_INHERITED(MouseScrollEvent, MouseEvent)
michael@0 33 NS_IMPL_RELEASE_INHERITED(MouseScrollEvent, MouseEvent)
michael@0 34
michael@0 35 NS_INTERFACE_MAP_BEGIN(MouseScrollEvent)
michael@0 36 NS_INTERFACE_MAP_ENTRY(nsIDOMMouseScrollEvent)
michael@0 37 NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
michael@0 38
michael@0 39 NS_IMETHODIMP
michael@0 40 MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
michael@0 41 bool aCanBubble,
michael@0 42 bool aCancelable,
michael@0 43 nsIDOMWindow* aView,
michael@0 44 int32_t aDetail,
michael@0 45 int32_t aScreenX,
michael@0 46 int32_t aScreenY,
michael@0 47 int32_t aClientX,
michael@0 48 int32_t aClientY,
michael@0 49 bool aCtrlKey,
michael@0 50 bool aAltKey,
michael@0 51 bool aShiftKey,
michael@0 52 bool aMetaKey,
michael@0 53 uint16_t aButton,
michael@0 54 nsIDOMEventTarget* aRelatedTarget,
michael@0 55 int32_t aAxis)
michael@0 56 {
michael@0 57 nsresult rv =
michael@0 58 MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
michael@0 59 aScreenX, aScreenY, aClientX, aClientY,
michael@0 60 aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
michael@0 61 aRelatedTarget);
michael@0 62 NS_ENSURE_SUCCESS(rv, rv);
michael@0 63 mEvent->AsMouseScrollEvent()->isHorizontal = (aAxis == HORIZONTAL_AXIS);
michael@0 64 return NS_OK;
michael@0 65 }
michael@0 66
michael@0 67
michael@0 68 NS_IMETHODIMP
michael@0 69 MouseScrollEvent::GetAxis(int32_t* aResult)
michael@0 70 {
michael@0 71 NS_ENSURE_ARG_POINTER(aResult);
michael@0 72 *aResult = Axis();
michael@0 73 return NS_OK;
michael@0 74 }
michael@0 75
michael@0 76 int32_t
michael@0 77 MouseScrollEvent::Axis()
michael@0 78 {
michael@0 79 return mEvent->AsMouseScrollEvent()->isHorizontal ?
michael@0 80 static_cast<int32_t>(HORIZONTAL_AXIS) :
michael@0 81 static_cast<int32_t>(VERTICAL_AXIS);
michael@0 82 }
michael@0 83
michael@0 84 } // namespace dom
michael@0 85 } // namespace mozilla
michael@0 86
michael@0 87 using namespace mozilla;
michael@0 88 using namespace dom;
michael@0 89
michael@0 90 nsresult
michael@0 91 NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 92 EventTarget* aOwner,
michael@0 93 nsPresContext* aPresContext,
michael@0 94 WidgetMouseScrollEvent* aEvent)
michael@0 95 {
michael@0 96 MouseScrollEvent* it = new MouseScrollEvent(aOwner, aPresContext, aEvent);
michael@0 97 NS_ADDREF(it);
michael@0 98 *aInstancePtrResult = static_cast<Event*>(it);
michael@0 99 return NS_OK;
michael@0 100 }

mercurial