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
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
namespace mozilla::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)) {
|
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);
|
2019-04-21 21:19:43 +03:00
|
|
|
mouseEvent->mInputSource = MouseEvent_Binding::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-27 14:51:15 +04:00
|
|
|
void MouseEvent::InitMouseEvent(const nsAString& aType, bool aCanBubble,
|
2017-11-07 01:52:14 +03:00
|
|
|
bool aCancelable, nsGlobalWindowInner* 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, bool aCtrlKey, bool aAltKey,
|
2014-02-27 14:51:15 +04:00
|
|
|
bool aShiftKey, bool aMetaKey, uint16_t aButton,
|
2016-01-30 20:05:36 +03:00
|
|
|
EventTarget* aRelatedTarget) {
|
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();
|
2017-12-18 20:08:11 +03:00
|
|
|
mouseEventBase->mRelatedTarget = aRelatedTarget;
|
2019-04-21 21:17:10 +03:00
|
|
|
mouseEventBase->mButton = aButton;
|
2013-10-18 10:10:26 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
void MouseEvent::InitMouseEvent(const nsAString& aType, bool aCanBubble,
|
2017-11-07 01:52:14 +03:00
|
|
|
bool aCancelable, nsGlobalWindowInner* 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) {
|
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);
|
2019-04-21 22:42:37 +03:00
|
|
|
mEvent->AsMouseEventBase()->mButtons = aParam.mButtons;
|
2015-05-19 23:26:02 +03:00
|
|
|
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,
|
2019-09-11 17:35:28 +03:00
|
|
|
const MouseEventInit& aParam) {
|
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, aParam.mMetaKey,
|
2016-01-30 20:05:36 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
void MouseEvent::InitNSMouseEvent(const nsAString& aType, bool aCanBubble,
|
2017-11-07 01:52:14 +03:00
|
|
|
bool aCancelable, nsGlobalWindowInner* 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,
|
2016-01-30 20:05:36 +03:00
|
|
|
uint16_t aButton, 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();
|
2019-04-21 21:19:18 +03:00
|
|
|
mouseEventBase->mPressure = aPressure;
|
2019-04-21 21:19:43 +03:00
|
|
|
mouseEventBase->mInputSource = aInputSource;
|
2008-12-12 02:55:15 +03:00
|
|
|
}
|
|
|
|
|
Bug 1528289 - part 2: Dispatch same events on the web contents when autoscroll is canceled with a click r=Gijs,edgar
Chrome behaves like this:
1. When user starts autoscroll with a middle click, `mousedown` and `mouseup`
are fired, but `auxclick` nor `paste` event is not fired.
2. When user ends autoscroll with a left click, only `mouseup` event is fired.
I.e, `mousedown` nor `click` event is not fired.
3. When user ends autoscroll with a middle click, only `mouseup` event is fired.
I.e., `mousedown`, `auxclick` nor `paste` events is not fired.
4. When user ends autoscroll with a right click, `mouseup` and `contextmenu`
events are fired, but `mousedown` and `auxclick` events are not fired.
This patch emulates these Chrome's behavior as far as possible. However,
unfortunately, we cannot do exactly same behavior without some big patches
because each widget (`nsWindow` or `nsChildView`) discards a mouse event
which rolled up a widget before dispatching it into the DOM. Therefore,
for now, this patch does not fix the following issues:
1. `mousedown` event is not fired in content when clicking outside the
autoscroller to close it except when pressing the secondary button or on any
buttons on Linux.
2. `mouseup` event is not fired in content when clicking outside the
autoscroller to close it except when pressing the primary button macOS.
3. `click` event and `auxclick` events are fired when clicking outside the
autoscroller with the secondary button.
So, the middle button `click`/`auxclick` events and `paste` event which is
reported to the bug won't be fired with this patch. I'll file follow up bugs.
Differential Revision: https://phabricator.services.mozilla.com/D104652
2021-03-23 22:22:48 +03:00
|
|
|
void MouseEvent::PreventClickEvent() {
|
|
|
|
if (WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent()) {
|
|
|
|
mouseEvent->mClickEventPrevented = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 22:56:44 +03:00
|
|
|
bool MouseEvent::ClickEventPrevented() {
|
|
|
|
if (WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent()) {
|
|
|
|
return mouseEvent->mClickEventPrevented;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
int16_t MouseEvent::Button() {
|
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:
|
2019-04-21 21:17:10 +03:00
|
|
|
return mEvent->AsMouseEventBase()->mButton;
|
2004-08-20 22:09:19 +04:00
|
|
|
default:
|
2019-04-21 21:17:10 +03:00
|
|
|
NS_WARNING("Tried to get mouse mButton for non-mouse event!");
|
2020-06-19 21:02:41 +03:00
|
|
|
return MouseButton::ePrimary;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
uint16_t MouseEvent::Buttons() {
|
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:
|
2019-04-21 22:42:37 +03:00
|
|
|
return mEvent->AsMouseEventBase()->mButtons;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
already_AddRefed<EventTarget> MouseEvent::GetRelatedTarget() {
|
|
|
|
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:
|
2017-12-18 20:08:11 +03:00
|
|
|
relatedTarget = mEvent->AsMouseEventBase()->mRelatedTarget;
|
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) {
|
2019-04-21 21:20:22 +03:00
|
|
|
aRegion = mouseEventBase->mRegion;
|
2014-05-20 08:54:00 +04:00
|
|
|
}
|
2014-04-27 02:32:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:10:22 +03:00
|
|
|
int32_t MouseEvent::ScreenX(CallerType aCallerType) {
|
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
|
|
|
}
|
|
|
|
|
2016-11-16 22:10:22 +03:00
|
|
|
int32_t MouseEvent::ScreenY(CallerType aCallerType) {
|
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
|
|
|
}
|
|
|
|
|
2019-07-04 04:50:22 +03:00
|
|
|
int32_t MouseEvent::PageX() const {
|
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mPrivateDataDuplicated) {
|
|
|
|
return mPagePoint.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Event::GetPageCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
|
|
|
mClientPoint)
|
|
|
|
.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t MouseEvent::PageY() const {
|
|
|
|
if (mEvent->mFlags.mIsPositionless) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mPrivateDataDuplicated) {
|
|
|
|
return mPagePoint.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Event::GetPageCoords(mPresContext, mEvent, mEvent->mRefPoint,
|
|
|
|
mClientPoint)
|
|
|
|
.y;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
int32_t MouseEvent::ClientX() {
|
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
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
int32_t MouseEvent::ClientY() {
|
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 MouseEvent::AltKey() { return mEvent->AsInputEvent()->IsAlt(); }
|
|
|
|
|
|
|
|
bool MouseEvent::CtrlKey() { return mEvent->AsInputEvent()->IsControl(); }
|
|
|
|
|
|
|
|
bool MouseEvent::ShiftKey() { return mEvent->AsInputEvent()->IsShift(); }
|
|
|
|
|
|
|
|
bool MouseEvent::MetaKey() { return mEvent->AsInputEvent()->IsMeta(); }
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
float MouseEvent::MozPressure() const {
|
2019-04-21 21:19:18 +03:00
|
|
|
return mEvent->AsMouseEventBase()->mPressure;
|
2013-10-18 10:10:26 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
uint16_t MouseEvent::MozInputSource() const {
|
2019-04-21 21:19:43 +03:00
|
|
|
return mEvent->AsMouseEventBase()->mInputSource;
|
2013-10-18 10:10:26 +04:00
|
|
|
}
|
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
} // namespace mozilla::dom
|
2014-02-27 14:51:15 +04:00
|
|
|
|
|
|
|
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) {
|
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
|
|
|
}
|