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/. */
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
#include "mozilla/dom/MouseEvent.h"
|
|
|
|
#include "mozilla/MouseEvents.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-02-27 14:51:15 +04:00
|
|
|
#include "nsIContent.h"
|
2013-07-03 19:56:26 +04:00
|
|
|
#include "prtime.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-04-25 07:00:01 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MouseEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseEventBase* aEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
2015-08-26 15:56:59 +03:00
|
|
|
aEvent ? aEvent :
|
2015-08-29 02:58:26 +03:00
|
|
|
new WidgetMouseEvent(false, eVoidEvent, nullptr,
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetMouseEvent::eReal))
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2013-10-01 11:23:02 +04:00
|
|
|
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
|
2004-08-20 22:09:19 +04:00
|
|
|
// It's not that important, though, since a scroll event is not a real
|
|
|
|
// DOM event.
|
2013-10-22 12:55:20 +04:00
|
|
|
|
|
|
|
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
|
2004-08-20 22:09:19 +04:00
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2004-08-20 22:09:19 +04: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-22 12:55:20 +04:00
|
|
|
mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
if (mouseEvent) {
|
2016-05-12 05:36:41 +03:00
|
|
|
MOZ_ASSERT(mouseEvent->mReason != WidgetMouseEvent::eSynthesized,
|
2013-10-22 12:55:20 +04:00
|
|
|
"Don't dispatch DOM events from synthesized mouse events");
|
2016-05-10 17:29:14 +03:00
|
|
|
mDetail = mouseEvent->mClickCount;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MouseEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MouseEvent, UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(MouseEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* aView,
|
2014-02-27 14:51:15 +04:00
|
|
|
int32_t aDetail,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
2016-02-26 12:04:00 +03:00
|
|
|
int32_t aClientY,
|
2014-02-27 14:51:15 +04:00
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
uint16_t aButton,
|
2016-01-30 20:05:36 +03:00
|
|
|
EventTarget* aRelatedTarget)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
2008-12-19 17:58:47 +03:00
|
|
|
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass: {
|
2013-10-18 10:10:26 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
mouseEventBase->relatedTarget = aRelatedTarget;
|
|
|
|
mouseEventBase->button = aButton;
|
|
|
|
mouseEventBase->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
|
|
|
|
mClientPoint.x = aClientX;
|
|
|
|
mClientPoint.y = aClientY;
|
2016-04-18 17:09:02 +03:00
|
|
|
mouseEventBase->mRefPoint.x = aScreenX;
|
|
|
|
mouseEventBase->mRefPoint.y = aScreenY;
|
2013-10-18 10:10:26 +04:00
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
|
|
|
|
if (mouseEvent) {
|
2016-05-10 17:29:14 +03:00
|
|
|
mouseEvent->mClickCount = aDetail;
|
2013-10-18 10:10:26 +04:00
|
|
|
}
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-02-26 12:04:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MouseEvent::InitMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
mozIDOMWindow* aView,
|
|
|
|
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,
|
|
|
|
nsIDOMEventTarget* aRelatedTarget)
|
|
|
|
{
|
|
|
|
MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
|
|
|
|
nsGlobalWindow::Cast(aView), aDetail,
|
|
|
|
aScreenX, aScreenY,
|
|
|
|
aClientX, aClientY,
|
|
|
|
aCtrlKey, aAltKey, aShiftKey,
|
|
|
|
aMetaKey, aButton,
|
|
|
|
static_cast<EventTarget *>(aRelatedTarget));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* aView,
|
2014-02-27 14:51:15 +04:00
|
|
|
int32_t aDetail,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
|
|
|
int32_t aClientY,
|
|
|
|
int16_t aButton,
|
2016-01-30 20:05:36 +03:00
|
|
|
EventTarget* aRelatedTarget,
|
2014-02-27 14:51:15 +04:00
|
|
|
const nsAString& aModifiersList)
|
2012-04-25 07:00:01 +04:00
|
|
|
{
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2012-04-25 07:00:01 +04:00
|
|
|
Modifiers modifiers = ComputeModifierState(aModifiersList);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
|
|
|
|
aScreenX, aScreenY, aClientX, aClientY,
|
|
|
|
(modifiers & MODIFIER_CONTROL) != 0,
|
|
|
|
(modifiers & MODIFIER_ALT) != 0,
|
|
|
|
(modifiers & MODIFIER_SHIFT) != 0,
|
|
|
|
(modifiers & MODIFIER_META) != 0,
|
|
|
|
aButton, aRelatedTarget);
|
2012-04-25 07:00:01 +04:00
|
|
|
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2016-03-31 11:03:00 +03:00
|
|
|
mEvent->AsInputEvent()->mModifiers = modifiers;
|
2016-01-30 20:05:36 +03:00
|
|
|
return;
|
2012-04-25 07:00:01 +04:00
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("There is no space to store the modifiers");
|
2012-04-25 07:00:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 23:26:02 +03:00
|
|
|
void
|
|
|
|
MouseEvent::InitializeExtraMouseEventDictionaryMembers(const MouseEventInit& aParam)
|
|
|
|
{
|
|
|
|
InitModifiers(aParam);
|
|
|
|
mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
|
|
|
|
mMovementPoint.x = aParam.mMovementX;
|
|
|
|
mMovementPoint.y = aParam.mMovementY;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
already_AddRefed<MouseEvent>
|
|
|
|
MouseEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const MouseEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-02-27 14:51:15 +04:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr);
|
2013-03-14 19:30:47 +04:00
|
|
|
bool trusted = e->Init(t);
|
|
|
|
e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
|
|
|
|
aParam.mView, aParam.mDetail, aParam.mScreenX,
|
|
|
|
aParam.mScreenY, aParam.mClientX, aParam.mClientY,
|
|
|
|
aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
|
2016-01-30 20:05:36 +03:00
|
|
|
aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget);
|
2015-05-19 23:26:02 +03:00
|
|
|
e->InitializeExtraMouseEventDictionaryMembers(aParam);
|
2013-03-14 19:30:47 +04:00
|
|
|
e->SetTrusted(trusted);
|
2016-08-31 06:16:11 +03:00
|
|
|
e->SetComposed(aParam.mComposed);
|
2013-03-14 19:30:47 +04:00
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitNSMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* aView,
|
2014-02-27 14:51:15 +04: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 20:05:36 +03:00
|
|
|
EventTarget* aRelatedTarget,
|
2014-02-27 14:51:15 +04:00
|
|
|
float aPressure,
|
|
|
|
uint16_t aInputSource)
|
|
|
|
{
|
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);
|
2008-12-12 02:55:15 +03:00
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
mouseEventBase->pressure = aPressure;
|
|
|
|
mouseEventBase->inputSource = aInputSource;
|
2008-12-12 02:55:15 +03:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetButton(int16_t* aButton)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aButton);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aButton = Button();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-20 22:38:13 +04:00
|
|
|
int16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::Button()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
return mEvent->AsMouseEventBase()->button;
|
2004-08-20 22:09:19 +04:00
|
|
|
default:
|
2006-11-17 00:35:39 +03:00
|
|
|
NS_WARNING("Tried to get mouse button for non-mouse event!");
|
2013-10-02 10:38:27 +04:00
|
|
|
return WidgetMouseEvent::eLeftButton;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:01 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetButtons(uint16_t* aButtons)
|
2012-04-25 07:00:01 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aButtons);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aButtons = Buttons();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::Buttons()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
return mEvent->AsMouseEventBase()->buttons;
|
2012-04-25 07:00:01 +04:00
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
|
2012-04-25 07:00:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRelatedTarget);
|
2014-03-15 23:00:15 +04:00
|
|
|
*aRelatedTarget = GetRelatedTarget().take();
|
2013-03-14 19:30:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
already_AddRefed<EventTarget>
|
|
|
|
MouseEvent::GetRelatedTarget()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-02-27 14:51:15 +04:00
|
|
|
nsCOMPtr<EventTarget> relatedTarget;
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
relatedTarget =
|
|
|
|
do_QueryInterface(mEvent->AsMouseEventBase()->relatedTarget);
|
2006-07-13 11:51:54 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2016-12-19 14:36:48 +03:00
|
|
|
return EnsureWebAccessibleRelatedTarget(relatedTarget);
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 02:32:00 +04:00
|
|
|
void
|
|
|
|
MouseEvent::GetRegion(nsAString& aRegion)
|
|
|
|
{
|
|
|
|
SetDOMStringToNull(aRegion);
|
2014-05-20 08:54:00 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
if (mouseEventBase) {
|
|
|
|
aRegion = mouseEventBase->region;
|
|
|
|
}
|
2014-04-27 02:32:00 +04:00
|
|
|
}
|
|
|
|
|
2012-04-12 01:55:21 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozMovementX(int32_t* aMovementX)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMovementX);
|
2015-05-19 23:26:02 +03:00
|
|
|
*aMovementX = MovementX();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozMovementY(int32_t* aMovementY)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMovementY);
|
2015-05-19 23:26:02 +03:00
|
|
|
*aMovementY = MovementY();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MouseEvent::GetScreenX(int32_t* aScreenX)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aScreenX);
|
2016-11-16 22:10:22 +03:00
|
|
|
*aScreenX = ScreenX(CallerType::System);
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2016-11-16 22:10:22 +03:00
|
|
|
MouseEvent::ScreenX(CallerType aCallerType)
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-12-17 08:25:52 +03:00
|
|
|
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
|
2016-11-16 22:10:22 +03:00
|
|
|
// Sanitize to something sort of like client cooords, but not quite
|
|
|
|
// (defaulting to (0,0) instead of our pre-specified client coords).
|
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
|
|
|
CSSIntPoint(0, 0)).x;
|
|
|
|
}
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetScreenCoords(mPresContext, mEvent, mEvent->mRefPoint).x;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetScreenY(int32_t* aScreenY)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aScreenY);
|
2016-11-16 22:10:22 +03:00
|
|
|
*aScreenY = ScreenY(CallerType::System);
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2016-11-16 22:10:22 +03:00
|
|
|
MouseEvent::ScreenY(CallerType aCallerType)
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-12-17 08:25:52 +03:00
|
|
|
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
|
2016-11-16 22:10:22 +03:00
|
|
|
// Sanitize to something sort of like client cooords, but not quite
|
|
|
|
// (defaulting to (0,0) instead of our pre-specified client coords).
|
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
|
|
|
CSSIntPoint(0, 0)).y;
|
|
|
|
}
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetScreenCoords(mPresContext, mEvent, mEvent->mRefPoint).y;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MouseEvent::GetClientX(int32_t* aClientX)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aClientX);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aClientX = ClientX();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ClientX()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
2014-03-05 04:37:43 +04:00
|
|
|
mClientPoint).x;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetClientY(int32_t* aClientY)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aClientY);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aClientY = ClientY();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ClientY()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
2014-03-05 04:37:43 +04:00
|
|
|
mClientPoint).y;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2015-03-13 14:50:10 +03:00
|
|
|
int32_t
|
|
|
|
MouseEvent::OffsetX()
|
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetOffsetCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
2015-03-13 14:50:10 +03:00
|
|
|
mClientPoint).x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
MouseEvent::OffsetY()
|
|
|
|
{
|
2017-03-23 13:57:44 +03:00
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 17:09:02 +03:00
|
|
|
return Event::GetOffsetCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
2015-03-13 14:50:10 +03:00
|
|
|
mClientPoint).y;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::AltKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsAlt();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetAltKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = AltKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::CtrlKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetCtrlKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = CtrlKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ShiftKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetShiftKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = ShiftKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MetaKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMetaKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = MetaKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:02 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetModifierState(const nsAString& aKey,
|
2012-04-25 07:00:02 +04:00
|
|
|
bool* aState)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
*aState = GetModifierState(aKey);
|
2012-04-25 07:00:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
float
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MozPressure() const
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->pressure;
|
|
|
|
}
|
|
|
|
|
2008-12-12 02:55:15 +03:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozPressure(float* aPressure)
|
2008-12-12 02:55:15 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPressure);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aPressure = MozPressure();
|
2008-12-12 02:55:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:33:06 +03:00
|
|
|
bool
|
|
|
|
MouseEvent::HitCluster() const
|
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->hitCluster;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
uint16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MozInputSource() const
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->inputSource;
|
|
|
|
}
|
|
|
|
|
2010-04-06 16:59:24 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozInputSource(uint16_t* aInputSource)
|
2010-04-06 16:59:24 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aInputSource);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aInputSource = MozInputSource();
|
2010-04-06 16:59:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<MouseEvent>
|
|
|
|
NS_NewDOMMouseEvent(EventTarget* aOwner,
|
2014-02-27 14:51:15 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseEvent* aEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MouseEvent> it = new MouseEvent(aOwner, aPresContext, aEvent);
|
2015-08-12 14:39:31 +03:00
|
|
|
return it.forget();
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|