2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-07-25 08:07:43 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
#include "mozilla/dom/MouseScrollEvent.h"
|
2018-03-20 07:16:06 +03:00
|
|
|
#include "mozilla/dom/MouseEventBinding.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-02-27 14:51:14 +04:00
|
|
|
#include "prtime.h"
|
2008-07-25 08:07:43 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-10-01 11:23:02 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseScrollEvent* aEvent)
|
2014-02-27 14:51:15 +04:00
|
|
|
: MouseEvent(aOwner, aPresContext,
|
2015-08-26 15:56:59 +03:00
|
|
|
aEvent
|
|
|
|
? aEvent
|
2015-08-29 02:58:26 +03:00
|
|
|
: new WidgetMouseScrollEvent(false, eVoidEvent, nullptr)) {
|
2008-12-20 02:27:33 +03:00
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2008-12-20 02:27:33 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = true;
|
2016-03-28 07:29:42 +03:00
|
|
|
mEvent->mTime = PR_Now();
|
2016-04-18 17:09:02 +03:00
|
|
|
mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
|
2013-10-02 10:38:27 +04:00
|
|
|
static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
|
2018-06-26 00:20:54 +03:00
|
|
|
MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
|
2008-12-20 02:27:33 +03:00
|
|
|
}
|
|
|
|
|
2016-04-06 10:44:11 +03:00
|
|
|
mDetail = mEvent->AsMouseScrollEvent()->mDelta;
|
2008-07-25 08:07:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
void MouseScrollEvent::InitMouseScrollEvent(
|
|
|
|
const nsAString& aType, bool aCanBubble, bool aCancelable,
|
2017-11-07 01:52:14 +03:00
|
|
|
nsGlobalWindowInner* aView, int32_t aDetail, int32_t aScreenX,
|
2014-02-27 14:51:14 +04:00
|
|
|
int32_t aScreenY, int32_t aClientX, int32_t aClientY, bool aCtrlKey,
|
|
|
|
bool aAltKey, bool aShiftKey, bool aMetaKey, uint16_t aButton,
|
2016-01-30 20:05:36 +03:00
|
|
|
EventTarget* aRelatedTarget, int32_t aAxis) {
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
|
|
|
|
aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
|
|
|
|
aAltKey, aShiftKey, aMetaKey, aButton,
|
|
|
|
aRelatedTarget);
|
2016-04-06 10:44:11 +03:00
|
|
|
mEvent->AsMouseScrollEvent()->mIsHorizontal =
|
2018-06-26 00:20:54 +03:00
|
|
|
(aAxis == MouseScrollEvent_Binding::HORIZONTAL_AXIS);
|
2013-04-16 00:37:52 +04:00
|
|
|
}
|
2008-07-25 08:07:43 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
int32_t MouseScrollEvent::Axis() {
|
2016-04-06 10:44:11 +03:00
|
|
|
return mEvent->AsMouseScrollEvent()->mIsHorizontal
|
2018-06-26 00:20:54 +03:00
|
|
|
? MouseScrollEvent_Binding::HORIZONTAL_AXIS
|
|
|
|
: MouseScrollEvent_Binding::VERTICAL_AXIS;
|
2008-07-25 08:07:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<MouseScrollEvent> NS_NewDOMMouseScrollEvent(
|
2014-02-27 14:51:14 +04:00
|
|
|
EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
WidgetMouseScrollEvent* aEvent) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MouseScrollEvent> it =
|
2015-08-12 14:39:31 +03:00
|
|
|
new MouseScrollEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2008-07-25 08:07:43 +04:00
|
|
|
}
|