2015-05-03 19:32:37 +00: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 11:12:37 +00: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 04:07:43 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
#include "mozilla/dom/MouseScrollEvent.h"
|
2013-09-25 11:21:18 +00:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-02-27 10:51:14 +00:00
|
|
|
#include "prtime.h"
|
2016-01-30 17:05:36 +00:00
|
|
|
#include "nsIDOMMouseScrollEvent.h"
|
2008-07-25 04:07:43 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-10-01 07:23:02 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseScrollEvent* aEvent)
|
2014-02-27 10:51:15 +00:00
|
|
|
: MouseEvent(aOwner, aPresContext,
|
2015-08-26 12:56:59 +00:00
|
|
|
aEvent ? aEvent :
|
2015-08-28 23:58:26 +00:00
|
|
|
new WidgetMouseScrollEvent(false, eVoidEvent, nullptr))
|
2008-07-25 04:07:43 +00:00
|
|
|
{
|
2008-12-19 23:27:33 +00:00
|
|
|
if (aEvent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = false;
|
2008-12-19 23:27:33 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = true;
|
2016-03-28 04:29:42 +00:00
|
|
|
mEvent->mTime = PR_Now();
|
2016-04-18 14:09:02 +00:00
|
|
|
mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
|
2013-10-02 06:38:27 +00:00
|
|
|
static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
|
|
|
|
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
2008-12-19 23:27:33 +00:00
|
|
|
}
|
|
|
|
|
2016-04-06 07:44:11 +00:00
|
|
|
mDetail = mEvent->AsMouseScrollEvent()->mDelta;
|
2008-07-25 04:07:43 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:15 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MouseScrollEvent, MouseEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MouseScrollEvent, MouseEvent)
|
2008-07-25 04:07:43 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(MouseScrollEvent)
|
2014-02-27 10:51:15 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
|
2008-07-25 04:07:43 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
void
|
2014-02-27 10:51:14 +00:00
|
|
|
MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 17:05:36 +00:00
|
|
|
nsGlobalWindow* aView,
|
2014-02-27 10:51:14 +00:00
|
|
|
int32_t aDetail,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
|
|
|
int32_t aClientY,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
uint16_t aButton,
|
2016-01-30 17:05:36 +00:00
|
|
|
EventTarget* aRelatedTarget,
|
2014-02-27 10:51:14 +00:00
|
|
|
int32_t aAxis)
|
2008-07-25 04:07:43 +00:00
|
|
|
{
|
2016-10-30 19:30:06 +00:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
|
|
|
|
aScreenX, aScreenY, aClientX, aClientY,
|
|
|
|
aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
|
|
|
|
aRelatedTarget);
|
2016-04-06 07:44:11 +00:00
|
|
|
mEvent->AsMouseScrollEvent()->mIsHorizontal =
|
2016-01-30 17:05:36 +00:00
|
|
|
(aAxis == nsIDOMMouseScrollEvent::HORIZONTAL_AXIS);
|
2013-04-15 20:37:52 +00:00
|
|
|
}
|
2008-07-25 04:07:43 +00:00
|
|
|
|
2013-04-15 20:37:52 +00:00
|
|
|
int32_t
|
2014-02-27 10:51:14 +00:00
|
|
|
MouseScrollEvent::Axis()
|
2013-04-15 20:37:52 +00:00
|
|
|
{
|
2016-04-06 07:44:11 +00:00
|
|
|
return mEvent->AsMouseScrollEvent()->mIsHorizontal ?
|
2016-01-30 17:05:36 +00:00
|
|
|
static_cast<int32_t>(nsIDOMMouseScrollEvent::HORIZONTAL_AXIS) :
|
|
|
|
static_cast<int32_t>(nsIDOMMouseScrollEvent::VERTICAL_AXIS);
|
2008-07-25 04:07:43 +00:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace dom;
|
|
|
|
|
2015-08-12 11:39:31 +00:00
|
|
|
already_AddRefed<MouseScrollEvent>
|
|
|
|
NS_NewDOMMouseScrollEvent(EventTarget* aOwner,
|
2014-02-27 10:51:14 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseScrollEvent* aEvent)
|
2008-07-25 04:07:43 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<MouseScrollEvent> it =
|
2015-08-12 11:39:31 +00:00
|
|
|
new MouseScrollEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2008-07-25 04:07:43 +00:00
|
|
|
}
|