2013-09-24 14:04:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_MouseEvents_h__
|
|
|
|
#define mozilla_MouseEvents_h__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "mozilla/BasicEvents.h"
|
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2014-02-27 07:23:31 +04:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
2019-05-06 11:12:21 +03:00
|
|
|
class PBrowserBridgeParent;
|
2013-09-24 14:04:15 +04:00
|
|
|
} // namespace dom
|
|
|
|
|
2017-09-20 08:00:57 +03:00
|
|
|
class WidgetPointerEvent;
|
2020-03-20 20:13:51 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
MOZ_DECLARE_COPY_CONSTRUCTIBLE(mozilla::WidgetPointerEvent)
|
|
|
|
|
|
|
|
namespace mozilla {
|
2017-09-20 08:00:57 +03:00
|
|
|
class WidgetPointerEventHolder final {
|
|
|
|
public:
|
|
|
|
nsTArray<WidgetPointerEvent> mEvents;
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder)
|
|
|
|
|
|
|
|
private:
|
2020-03-16 13:56:57 +03:00
|
|
|
virtual ~WidgetPointerEventHolder() = default;
|
2017-09-20 08:00:57 +03:00
|
|
|
};
|
|
|
|
|
2014-02-27 01:37:01 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetPointerHelper
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetPointerHelper {
|
|
|
|
public:
|
2014-04-04 21:09:10 +04:00
|
|
|
uint32_t pointerId;
|
2014-02-27 01:37:01 +04:00
|
|
|
uint32_t tiltX;
|
|
|
|
uint32_t tiltY;
|
2017-02-09 05:49:00 +03:00
|
|
|
uint32_t twist;
|
|
|
|
float tangentialPressure;
|
2016-11-20 04:36:39 +03:00
|
|
|
bool convertToPointer;
|
2017-09-20 08:00:57 +03:00
|
|
|
RefPtr<WidgetPointerEventHolder> mCoalescedWidgetEvents;
|
2014-02-27 01:37:01 +04:00
|
|
|
|
2016-11-20 04:36:39 +03:00
|
|
|
WidgetPointerHelper()
|
|
|
|
: pointerId(0),
|
|
|
|
tiltX(0),
|
|
|
|
tiltY(0),
|
2017-02-09 05:49:00 +03:00
|
|
|
twist(0),
|
|
|
|
tangentialPressure(0),
|
2016-11-20 04:36:39 +03:00
|
|
|
convertToPointer(true) {}
|
2014-02-27 01:37:01 +04:00
|
|
|
|
2017-02-09 05:49:00 +03:00
|
|
|
WidgetPointerHelper(uint32_t aPointerId, uint32_t aTiltX, uint32_t aTiltY,
|
|
|
|
uint32_t aTwist = 0, float aTangentialPressure = 0)
|
2016-11-20 05:24:46 +03:00
|
|
|
: pointerId(aPointerId),
|
|
|
|
tiltX(aTiltX),
|
|
|
|
tiltY(aTiltY),
|
2017-02-09 05:49:00 +03:00
|
|
|
twist(aTwist),
|
|
|
|
tangentialPressure(aTangentialPressure),
|
2016-11-20 05:24:46 +03:00
|
|
|
convertToPointer(true) {}
|
|
|
|
|
2020-03-16 13:56:57 +03:00
|
|
|
explicit WidgetPointerHelper(const WidgetPointerHelper& aHelper) = default;
|
2017-09-20 08:00:57 +03:00
|
|
|
|
|
|
|
void AssignPointerHelperData(const WidgetPointerHelper& aEvent,
|
|
|
|
bool aCopyCoalescedEvents = false) {
|
2014-04-04 21:09:10 +04:00
|
|
|
pointerId = aEvent.pointerId;
|
2014-02-27 01:37:01 +04:00
|
|
|
tiltX = aEvent.tiltX;
|
|
|
|
tiltY = aEvent.tiltY;
|
2017-02-09 05:49:00 +03:00
|
|
|
twist = aEvent.twist;
|
|
|
|
tangentialPressure = aEvent.tangentialPressure;
|
2016-11-20 04:36:39 +03:00
|
|
|
convertToPointer = aEvent.convertToPointer;
|
2017-09-20 08:00:57 +03:00
|
|
|
if (aCopyCoalescedEvents) {
|
|
|
|
mCoalescedWidgetEvents = aEvent.mCoalescedWidgetEvents;
|
|
|
|
}
|
2014-02-27 01:37:01 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseEventBase
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetMouseEventBase : public WidgetInputEvent {
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
2019-05-06 11:12:21 +03:00
|
|
|
friend class dom::PBrowserBridgeParent;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
protected:
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetMouseEventBase()
|
2019-04-21 21:20:58 +03:00
|
|
|
: mPressure(0),
|
|
|
|
mButton(0),
|
2019-04-21 22:42:37 +03:00
|
|
|
mButtons(0),
|
2020-03-03 18:27:50 +03:00
|
|
|
mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
|
2019-04-21 21:20:58 +03:00
|
|
|
// Including MouseEventBinding.h here leads to an include loop, so
|
|
|
|
// we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetMouseEventBase(bool aIsTrusted, EventMessage aMessage,
|
|
|
|
nsIWidget* aWidget, EventClassID aEventClassID)
|
2014-08-04 09:28:46 +04:00
|
|
|
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID),
|
2019-04-21 21:20:58 +03:00
|
|
|
mPressure(0),
|
2019-04-21 21:17:10 +03:00
|
|
|
mButton(0),
|
2019-04-21 22:42:37 +03:00
|
|
|
mButtons(0),
|
2020-03-03 18:27:50 +03:00
|
|
|
mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
|
2019-04-21 21:20:58 +03:00
|
|
|
// Including MouseEventBinding.h here leads to an include loop, so
|
|
|
|
// we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetMouseEventBase* AsMouseEventBase() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-01-27 10:10:44 +04:00
|
|
|
MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
|
|
|
|
}
|
|
|
|
|
2019-04-21 21:20:58 +03:00
|
|
|
// ID of the canvas HitRegion
|
|
|
|
nsString mRegion;
|
|
|
|
|
|
|
|
// Finger or touch pressure of event. It ranges between 0.0 and 1.0.
|
|
|
|
float mPressure;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// Pressed button ID of mousedown or mouseup event.
|
|
|
|
// This is set only when pressing a button causes the event.
|
2019-04-21 21:17:10 +03:00
|
|
|
int16_t mButton;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// Flags of all pressed buttons at the event fired.
|
2019-04-21 21:17:10 +03:00
|
|
|
// This is set at any mouse event, don't be confused with |mButton|.
|
2019-04-21 22:42:37 +03:00
|
|
|
int16_t mButtons;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2018-03-20 07:16:06 +03:00
|
|
|
// Possible values a in MouseEvent
|
2019-04-21 21:19:43 +03:00
|
|
|
uint16_t mInputSource;
|
2014-05-20 08:54:00 +04:00
|
|
|
|
2019-04-21 23:13:34 +03:00
|
|
|
bool IsLeftButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::eLeftFlag);
|
|
|
|
}
|
|
|
|
bool IsRightButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::eRightFlag);
|
|
|
|
}
|
2019-04-21 22:42:37 +03:00
|
|
|
bool IsMiddleButtonPressed() const {
|
2019-04-21 23:13:34 +03:00
|
|
|
return !!(mButtons & MouseButtonsFlag::eMiddleFlag);
|
|
|
|
}
|
|
|
|
bool Is4thButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::e4thFlag);
|
|
|
|
}
|
|
|
|
bool Is5thButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::e5thFlag);
|
2019-04-21 22:42:37 +03:00
|
|
|
}
|
2015-10-16 07:19:27 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignInputEventData(aEvent, aCopyTargets);
|
|
|
|
|
2019-04-21 21:17:10 +03:00
|
|
|
mButton = aEvent.mButton;
|
2019-04-21 22:42:37 +03:00
|
|
|
mButtons = aEvent.mButtons;
|
2019-04-21 21:19:18 +03:00
|
|
|
mPressure = aEvent.mPressure;
|
2019-04-21 21:19:43 +03:00
|
|
|
mInputSource = aEvent.mInputSource;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2013-10-28 13:03:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if left click event.
|
|
|
|
*/
|
|
|
|
bool IsLeftClickEvent() const {
|
2019-04-21 23:13:34 +03:00
|
|
|
return mMessage == eMouseClick && mButton == MouseButton::eLeft;
|
2013-10-28 13:03:19 +04:00
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
class WidgetMouseEvent : public WidgetMouseEventBase,
|
|
|
|
public WidgetPointerHelper {
|
2013-09-24 14:04:15 +04:00
|
|
|
private:
|
2016-05-10 15:57:16 +03:00
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
2019-05-06 11:12:21 +03:00
|
|
|
friend class dom::PBrowserBridgeParent;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
public:
|
2016-05-12 05:17:46 +03:00
|
|
|
typedef bool ReasonType;
|
|
|
|
enum Reason : ReasonType { eReal, eSynthesized };
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-05-12 05:28:14 +03:00
|
|
|
typedef bool ContextMenuTriggerType;
|
|
|
|
enum ContextMenuTrigger : ContextMenuTriggerType { eNormal, eContextMenuKey };
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-05-12 05:32:53 +03:00
|
|
|
typedef bool ExitFromType;
|
|
|
|
enum ExitFrom : ExitFromType { eChild, eTopLevel };
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
protected:
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetMouseEvent()
|
2016-05-12 05:36:41 +03:00
|
|
|
: mReason(eReal),
|
2016-05-12 05:39:05 +03:00
|
|
|
mContextMenuTrigger(eNormal),
|
2016-05-12 05:42:08 +03:00
|
|
|
mExitFrom(eChild),
|
2016-05-10 15:15:05 +03:00
|
|
|
mIgnoreRootScrollFrame(false),
|
2019-04-18 15:57:37 +03:00
|
|
|
mClickCount(0),
|
|
|
|
mUseLegacyNonPrimaryDispatch(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
|
|
|
EventClassID aEventClassID, Reason aReason)
|
2014-08-04 09:28:46 +04:00
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID),
|
2016-05-12 05:36:41 +03:00
|
|
|
mReason(aReason),
|
2016-05-12 05:39:05 +03:00
|
|
|
mContextMenuTrigger(eNormal),
|
2016-05-12 05:42:08 +03:00
|
|
|
mExitFrom(eChild),
|
2016-05-10 15:15:05 +03:00
|
|
|
mIgnoreRootScrollFrame(false),
|
2019-04-18 15:57:37 +03:00
|
|
|
mClickCount(0),
|
|
|
|
mUseLegacyNonPrimaryDispatch(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetMouseEvent* AsMouseEvent() override { return this; }
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-05-12 05:39:05 +03:00
|
|
|
WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
|
|
|
Reason aReason,
|
|
|
|
ContextMenuTrigger aContextMenuTrigger = eNormal)
|
2016-05-12 05:17:46 +03:00
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass),
|
2016-05-12 05:36:41 +03:00
|
|
|
mReason(aReason),
|
2016-05-12 05:39:05 +03:00
|
|
|
mContextMenuTrigger(aContextMenuTrigger),
|
2016-05-12 05:42:08 +03:00
|
|
|
mExitFrom(eChild),
|
2016-05-10 15:15:05 +03:00
|
|
|
mIgnoreRootScrollFrame(false),
|
2019-04-18 15:57:37 +03:00
|
|
|
mClickCount(0),
|
|
|
|
mUseLegacyNonPrimaryDispatch(false) {
|
2016-04-13 09:16:42 +03:00
|
|
|
if (aMessage == eContextMenu) {
|
2019-04-21 23:13:34 +03:00
|
|
|
mButton = (mContextMenuTrigger == eNormal) ? MouseButton::eRight
|
|
|
|
: MouseButton::eLeft;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-10-18 10:10:20 +04:00
|
|
|
virtual ~WidgetMouseEvent() {
|
2016-09-01 08:01:16 +03:00
|
|
|
NS_WARNING_ASSERTION(
|
|
|
|
mMessage != eContextMenu ||
|
2019-04-21 23:13:34 +03:00
|
|
|
mButton == ((mContextMenuTrigger == eNormal) ? MouseButton::eRight
|
|
|
|
: MouseButton::eLeft),
|
2016-09-01 08:01:16 +03:00
|
|
|
"Wrong button set to eContextMenu event?");
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:50 +04:00
|
|
|
MOZ_ASSERT(mClass == eMouseEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetMouseEvent* result = new WidgetMouseEvent(
|
2016-05-12 05:39:05 +03:00
|
|
|
false, mMessage, nullptr, mReason, mContextMenuTrigger);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignMouseEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-12 00:35:40 +03:00
|
|
|
// If during mouseup handling we detect that click event might need to be
|
|
|
|
// dispatched, this is setup to be the target of the click event.
|
|
|
|
nsCOMPtr<dom::EventTarget> mClickTarget;
|
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
// mReason indicates the reason why the event is fired:
|
|
|
|
// - Representing mouse operation.
|
|
|
|
// - Synthesized for emulating mousemove event when the content under the
|
|
|
|
// mouse cursor is scrolled.
|
2016-05-12 05:36:41 +03:00
|
|
|
Reason mReason;
|
2016-05-12 05:17:46 +03:00
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
// mContextMenuTrigger is valid only when mMessage is eContextMenu.
|
|
|
|
// This indicates if the context menu event is caused by context menu key or
|
|
|
|
// other reasons (typically, a click of right mouse button).
|
2016-05-12 05:39:05 +03:00
|
|
|
ContextMenuTrigger mContextMenuTrigger;
|
2016-05-12 05:28:14 +03:00
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
// mExitFrom is valid only when mMessage is eMouseExitFromWidget.
|
|
|
|
// This indicates if the mouse cursor exits from a top level widget or
|
|
|
|
// a child widget.
|
2016-05-12 05:42:08 +03:00
|
|
|
ExitFrom mExitFrom;
|
2016-05-12 05:32:53 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// Whether the event should ignore scroll frame bounds during dispatch.
|
2016-05-10 15:15:05 +03:00
|
|
|
bool mIgnoreRootScrollFrame;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-05-10 15:57:16 +03:00
|
|
|
// mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
|
|
|
|
// eMouseClick or eMouseDoubleClick. The number is count of mouse clicks.
|
|
|
|
// Otherwise, this must be 0.
|
2016-05-10 17:29:14 +03:00
|
|
|
uint32_t mClickCount;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2019-04-18 15:57:37 +03:00
|
|
|
// Indicates whether the event should dispatch click events for non-primary
|
|
|
|
// mouse buttons on window and document.
|
|
|
|
bool mUseLegacyNonPrimaryDispatch;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
2017-09-20 08:00:57 +03:00
|
|
|
AssignPointerHelperData(aEvent, /* aCopyCoalescedEvents */ true);
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-05-10 15:15:05 +03:00
|
|
|
mIgnoreRootScrollFrame = aEvent.mIgnoreRootScrollFrame;
|
2016-05-10 17:29:14 +03:00
|
|
|
mClickCount = aEvent.mClickCount;
|
2019-04-18 15:57:37 +03:00
|
|
|
mUseLegacyNonPrimaryDispatch = aEvent.mUseLegacyNonPrimaryDispatch;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2013-10-28 13:03:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the event is a context menu event caused by key.
|
|
|
|
*/
|
|
|
|
bool IsContextMenuKeyEvent() const {
|
2016-05-12 05:39:05 +03:00
|
|
|
return mMessage == eContextMenu && mContextMenuTrigger == eContextMenuKey;
|
2013-10-28 13:03:19 +04:00
|
|
|
}
|
2014-04-01 08:09:22 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the event is a real mouse event. Otherwise, i.e., it's
|
|
|
|
* a synthesized event by scroll or something, returns false.
|
|
|
|
*/
|
2016-05-12 05:36:41 +03:00
|
|
|
bool IsReal() const { return mReason == eReal; }
|
2018-10-10 15:04:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if middle click paste is enabled.
|
|
|
|
*/
|
|
|
|
static bool IsMiddleClickPasteEnabled();
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetDragEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetDragEvent : public WidgetMouseEvent {
|
2015-04-08 21:48:11 +03:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
protected:
|
|
|
|
WidgetDragEvent()
|
2016-01-12 21:16:59 +03:00
|
|
|
: mUserCancelled(false), mDefaultPreventedOnContent(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetDragEvent* AsDragEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetDragEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
|
2014-08-04 09:28:50 +04:00
|
|
|
: WidgetMouseEvent(aIsTrusted, aMessage, aWidget, eDragEventClass, eReal),
|
2016-03-31 13:06:05 +03:00
|
|
|
mUserCancelled(false),
|
2014-08-04 09:28:50 +04:00
|
|
|
mDefaultPreventedOnContent(false) {}
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:50 +04:00
|
|
|
MOZ_ASSERT(mClass == eDragEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2015-08-22 04:34:51 +03:00
|
|
|
WidgetDragEvent* result = new WidgetDragEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignDragEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// The dragging data.
|
2016-03-31 11:26:32 +03:00
|
|
|
nsCOMPtr<dom::DataTransfer> mDataTransfer;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// If this is true, user has cancelled the drag operation.
|
2016-03-31 13:06:05 +03:00
|
|
|
bool mUserCancelled;
|
2013-12-12 13:39:04 +04:00
|
|
|
// If this is true, the drag event's preventDefault() is called on content.
|
|
|
|
bool mDefaultPreventedOnContent;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
|
|
void AssignDragEventData(const WidgetDragEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-03-31 11:26:32 +03:00
|
|
|
mDataTransfer = aEvent.mDataTransfer;
|
2016-03-31 13:06:05 +03:00
|
|
|
// XXX mUserCancelled isn't copied, is this intentionally?
|
|
|
|
mUserCancelled = false;
|
2013-12-12 13:39:04 +04:00
|
|
|
mDefaultPreventedOnContent = aEvent.mDefaultPreventedOnContent;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2019-12-21 15:27:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should be called before dispatching the DOM tree if this event is
|
|
|
|
* synthesized for tests because drop effect is initialized before
|
|
|
|
* dispatching from widget if it's not synthesized event, but synthesized
|
|
|
|
* events are not initialized in the path.
|
|
|
|
*/
|
|
|
|
void InitDropEffectForTests();
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseScrollEvent
|
|
|
|
*
|
|
|
|
* This is used for legacy DOM mouse scroll events, i.e.,
|
|
|
|
* DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
|
|
|
|
* by ESM even if widget dispatches them. Use new WidgetWheelEvent instead.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetMouseScrollEvent : public WidgetMouseEventBase {
|
|
|
|
private:
|
|
|
|
WidgetMouseScrollEvent() : mDelta(0), mIsHorizontal(false) {}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetMouseScrollEvent* AsMouseScrollEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetMouseScrollEvent(bool aIsTrusted, EventMessage aMessage,
|
2014-08-04 09:28:51 +04:00
|
|
|
nsIWidget* aWidget)
|
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
|
|
|
|
eMouseScrollEventClass),
|
2016-04-06 10:44:11 +03:00
|
|
|
mDelta(0),
|
|
|
|
mIsHorizontal(false) {}
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:51 +04:00
|
|
|
MOZ_ASSERT(mClass == eMouseScrollEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetMouseScrollEvent* result =
|
2015-08-22 04:34:51 +03:00
|
|
|
new WidgetMouseScrollEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignMouseScrollEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// The delta value of mouse scroll event.
|
2015-09-10 04:40:04 +03:00
|
|
|
// If the event message is eLegacyMouseLineOrPageScroll, the value indicates
|
|
|
|
// scroll amount in lines. However, if the value is
|
2018-03-26 21:53:02 +03:00
|
|
|
// UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
|
2015-09-10 04:40:04 +03:00
|
|
|
// value inducates one page scroll. If the event message is
|
2015-09-10 04:40:04 +03:00
|
|
|
// eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
|
2016-04-06 10:44:11 +03:00
|
|
|
int32_t mDelta;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// If this is true, it may cause to scroll horizontally.
|
|
|
|
// Otherwise, vertically.
|
2016-04-06 10:44:11 +03:00
|
|
|
bool mIsHorizontal;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
void AssignMouseScrollEventData(const WidgetMouseScrollEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
|
2016-04-06 10:44:11 +03:00
|
|
|
mDelta = aEvent.mDelta;
|
|
|
|
mIsHorizontal = aEvent.mIsHorizontal;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetWheelEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetWheelEvent : public WidgetMouseEventBase {
|
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetWheelEvent()
|
2016-03-31 12:55:59 +03:00
|
|
|
: mDeltaX(0.0),
|
2016-03-31 12:09:47 +03:00
|
|
|
mDeltaY(0.0),
|
2016-03-31 12:18:34 +03:00
|
|
|
mDeltaZ(0.0),
|
2016-03-31 18:46:18 +03:00
|
|
|
mOverflowDeltaX(0.0),
|
|
|
|
mOverflowDeltaY(0.0)
|
2018-03-20 07:16:05 +03:00
|
|
|
// Including WheelEventBinding.h here leads to an include loop, so
|
2018-06-26 00:20:54 +03:00
|
|
|
// we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
|
|
|
|
,
|
|
|
|
mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
|
2016-03-31 18:10:46 +03:00
|
|
|
mLineOrPageDeltaX(0),
|
2016-03-31 18:10:09 +03:00
|
|
|
mLineOrPageDeltaY(0),
|
2016-03-31 17:54:42 +03:00
|
|
|
mScrollType(SCROLL_DEFAULT),
|
2016-03-31 18:46:18 +03:00
|
|
|
mCustomizedByUserPrefs(false),
|
2018-06-15 17:48:51 +03:00
|
|
|
mMayHaveMomentum(false),
|
2016-03-31 18:46:18 +03:00
|
|
|
mIsMomentum(false),
|
|
|
|
mIsNoLineOrPageDelta(false),
|
2016-01-12 21:16:59 +03:00
|
|
|
mViewPortIsOverscrolled(false),
|
|
|
|
mCanTriggerSwipe(false),
|
2016-01-27 09:09:13 +03:00
|
|
|
mAllowToOverrideSystemScrollSpeed(false),
|
2018-03-15 11:31:07 +03:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetWheelEvent* AsWheelEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetWheelEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
|
2014-08-04 09:28:51 +04:00
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eWheelEventClass),
|
2016-03-31 12:55:59 +03:00
|
|
|
mDeltaX(0.0),
|
2016-03-31 12:09:47 +03:00
|
|
|
mDeltaY(0.0),
|
2016-03-31 12:18:34 +03:00
|
|
|
mDeltaZ(0.0),
|
2016-03-31 18:46:18 +03:00
|
|
|
mOverflowDeltaX(0.0),
|
|
|
|
mOverflowDeltaY(0.0)
|
2018-03-20 07:16:05 +03:00
|
|
|
// Including WheelEventBinding.h here leads to an include loop, so
|
2018-06-26 00:20:54 +03:00
|
|
|
// we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
|
|
|
|
,
|
|
|
|
mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
|
2016-03-31 18:46:18 +03:00
|
|
|
mLineOrPageDeltaX(0),
|
|
|
|
mLineOrPageDeltaY(0),
|
|
|
|
mScrollType(SCROLL_DEFAULT),
|
2016-03-31 12:44:01 +03:00
|
|
|
mCustomizedByUserPrefs(false),
|
2016-03-31 17:36:49 +03:00
|
|
|
mMayHaveMomentum(false),
|
2016-03-31 17:45:55 +03:00
|
|
|
mIsMomentum(false),
|
2014-08-04 09:28:51 +04:00
|
|
|
mIsNoLineOrPageDelta(false),
|
|
|
|
mViewPortIsOverscrolled(false),
|
2015-08-28 06:50:31 +03:00
|
|
|
mCanTriggerSwipe(false),
|
2016-01-27 09:09:13 +03:00
|
|
|
mAllowToOverrideSystemScrollSpeed(true),
|
2018-03-15 11:31:07 +03:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:51 +04:00
|
|
|
MOZ_ASSERT(mClass == eWheelEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2015-08-22 04:34:51 +03:00
|
|
|
WidgetWheelEvent* result = new WidgetWheelEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignWheelEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-08-28 06:50:31 +03:00
|
|
|
// On OS X, scroll gestures that start at the edge of the scrollable range
|
|
|
|
// can result in a swipe gesture. For the first wheel event of such a
|
|
|
|
// gesture, call TriggersSwipe() after the event has been processed
|
|
|
|
// in order to find out whether a swipe should be started.
|
|
|
|
bool TriggersSwipe() const {
|
|
|
|
return mCanTriggerSwipe && mViewPortIsOverscrolled &&
|
2016-03-31 18:27:45 +03:00
|
|
|
this->mOverflowDeltaX != 0.0;
|
2015-08-28 06:50:31 +03:00
|
|
|
}
|
|
|
|
|
2016-03-31 12:18:34 +03:00
|
|
|
// NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
|
2013-09-24 14:04:15 +04:00
|
|
|
// mousewheel.*.delta_multiplier_* prefs which are applied by
|
2014-04-01 08:09:23 +04:00
|
|
|
// EventStateManager. So, after widget dispatches this event,
|
2013-09-24 14:04:15 +04:00
|
|
|
// these delta values may have different values than before.
|
2016-03-31 12:55:59 +03:00
|
|
|
double mDeltaX;
|
2016-03-31 12:09:47 +03:00
|
|
|
double mDeltaY;
|
2016-03-31 12:18:34 +03:00
|
|
|
double mDeltaZ;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-03-31 18:46:18 +03:00
|
|
|
// overflowed delta values for scroll, these values are set by
|
2018-03-15 11:31:07 +03:00
|
|
|
// EventStateManger. If the default action of the wheel event isn't scroll,
|
|
|
|
// these values are always zero. Otherwise, remaining delta values which are
|
2016-03-31 18:46:18 +03:00
|
|
|
// not used by scroll are set.
|
|
|
|
// NOTE: mDeltaX, mDeltaY and mDeltaZ may be modified by EventStateManager.
|
|
|
|
// However, mOverflowDeltaX and mOverflowDeltaY indicate unused original
|
|
|
|
// delta values which are not applied the delta_multiplier prefs.
|
|
|
|
// So, if widget wanted to know the actual direction to be scrolled,
|
|
|
|
// it would need to check the mDeltaX and mDeltaY.
|
|
|
|
double mOverflowDeltaX;
|
|
|
|
double mOverflowDeltaY;
|
|
|
|
|
2018-06-26 00:20:54 +03:00
|
|
|
// Should be one of WheelEvent_Binding::DOM_DELTA_*
|
2016-03-31 12:35:24 +03:00
|
|
|
uint32_t mDeltaMode;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-03-31 18:10:46 +03:00
|
|
|
// If widget sets mLineOrPageDelta, EventStateManager will dispatch
|
2015-09-10 04:40:04 +03:00
|
|
|
// eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
|
2016-03-31 12:35:24 +03:00
|
|
|
// value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
|
2016-03-31 18:10:46 +03:00
|
|
|
int32_t mLineOrPageDeltaX;
|
2016-03-31 18:10:09 +03:00
|
|
|
int32_t mLineOrPageDeltaY;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// When the default action for an wheel event is moving history or zooming,
|
|
|
|
// need to chose a delta value for doing it.
|
|
|
|
int32_t GetPreferredIntDelta() {
|
2016-03-31 18:10:09 +03:00
|
|
|
if (!mLineOrPageDeltaX && !mLineOrPageDeltaY) {
|
2013-09-24 14:04:15 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-03-31 18:10:09 +03:00
|
|
|
if (mLineOrPageDeltaY && !mLineOrPageDeltaX) {
|
|
|
|
return mLineOrPageDeltaY;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2016-03-31 18:10:09 +03:00
|
|
|
if (mLineOrPageDeltaX && !mLineOrPageDeltaY) {
|
2016-03-31 18:10:46 +03:00
|
|
|
return mLineOrPageDeltaX;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2016-03-31 18:10:09 +03:00
|
|
|
if ((mLineOrPageDeltaX < 0 && mLineOrPageDeltaY > 0) ||
|
|
|
|
(mLineOrPageDeltaX > 0 && mLineOrPageDeltaY < 0)) {
|
2013-09-24 14:04:15 +04:00
|
|
|
return 0; // We cannot guess the answer in this case.
|
|
|
|
}
|
2016-03-31 18:10:09 +03:00
|
|
|
return (Abs(mLineOrPageDeltaX) > Abs(mLineOrPageDeltaY))
|
|
|
|
? mLineOrPageDeltaX
|
|
|
|
: mLineOrPageDeltaY;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Scroll type
|
2014-04-01 08:09:23 +04:00
|
|
|
// The default value is SCROLL_DEFAULT, which means EventStateManager will
|
2013-09-24 14:04:15 +04:00
|
|
|
// select preferred scroll type automatically.
|
2016-03-31 18:46:18 +03:00
|
|
|
enum ScrollType : uint8_t {
|
2013-09-24 14:04:15 +04:00
|
|
|
SCROLL_DEFAULT,
|
|
|
|
SCROLL_SYNCHRONOUSLY,
|
|
|
|
SCROLL_ASYNCHRONOUSELY,
|
|
|
|
SCROLL_SMOOTHLY
|
|
|
|
};
|
2016-03-31 17:54:42 +03:00
|
|
|
ScrollType mScrollType;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2016-03-31 18:46:18 +03:00
|
|
|
// If the delta values are computed from prefs, this value is true.
|
|
|
|
// Otherwise, i.e., they are computed from native events, false.
|
|
|
|
bool mCustomizedByUserPrefs;
|
|
|
|
|
|
|
|
// true if the momentum events directly tied to this event may follow it.
|
|
|
|
bool mMayHaveMomentum;
|
|
|
|
// true if the event is caused by momentum.
|
|
|
|
bool mIsMomentum;
|
|
|
|
|
|
|
|
// If device event handlers don't know when they should set mLineOrPageDeltaX
|
|
|
|
// and mLineOrPageDeltaY, this is true. Otherwise, false.
|
|
|
|
// If mIsNoLineOrPageDelta is true, ESM will generate
|
|
|
|
// eLegacyMouseLineOrPageScroll events when accumulated delta values reach
|
|
|
|
// a line height.
|
|
|
|
bool mIsNoLineOrPageDelta;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2013-10-11 23:48:53 +04:00
|
|
|
// Whether or not the parent of the currently overscrolled frame is the
|
|
|
|
// ViewPort. This is false in situations when an element on the page is being
|
|
|
|
// overscrolled (such as a text field), but true when the 'page' is being
|
|
|
|
// overscrolled.
|
|
|
|
bool mViewPortIsOverscrolled;
|
|
|
|
|
2015-08-28 06:50:31 +03:00
|
|
|
// The wheel event can trigger a swipe to start if it's overscrolling the
|
|
|
|
// viewport.
|
|
|
|
bool mCanTriggerSwipe;
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
// If mAllowToOverrideSystemScrollSpeed is true, the scroll speed may be
|
|
|
|
// overridden. Otherwise, the scroll speed won't be overridden even if
|
|
|
|
// it's enabled by the pref.
|
|
|
|
bool mAllowToOverrideSystemScrollSpeed;
|
|
|
|
|
2018-03-15 11:31:07 +03:00
|
|
|
// After the event's default action handler has adjusted its delta's values
|
|
|
|
// for horizontalizing a vertical wheel scroll, this variable will be set to
|
|
|
|
// true.
|
|
|
|
bool mDeltaValuesHorizontalizedForDefaultHandler;
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignWheelEventData(const WidgetWheelEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
|
2016-03-31 12:55:59 +03:00
|
|
|
mDeltaX = aEvent.mDeltaX;
|
2016-03-31 12:09:47 +03:00
|
|
|
mDeltaY = aEvent.mDeltaY;
|
2016-03-31 12:18:34 +03:00
|
|
|
mDeltaZ = aEvent.mDeltaZ;
|
2016-03-31 12:35:24 +03:00
|
|
|
mDeltaMode = aEvent.mDeltaMode;
|
2016-03-31 12:44:01 +03:00
|
|
|
mCustomizedByUserPrefs = aEvent.mCustomizedByUserPrefs;
|
2016-03-31 17:36:49 +03:00
|
|
|
mMayHaveMomentum = aEvent.mMayHaveMomentum;
|
2016-03-31 17:45:55 +03:00
|
|
|
mIsMomentum = aEvent.mIsMomentum;
|
2014-07-07 13:54:14 +04:00
|
|
|
mIsNoLineOrPageDelta = aEvent.mIsNoLineOrPageDelta;
|
2016-03-31 18:10:46 +03:00
|
|
|
mLineOrPageDeltaX = aEvent.mLineOrPageDeltaX;
|
2016-03-31 18:10:09 +03:00
|
|
|
mLineOrPageDeltaY = aEvent.mLineOrPageDeltaY;
|
2016-03-31 17:54:42 +03:00
|
|
|
mScrollType = aEvent.mScrollType;
|
2016-03-31 18:27:45 +03:00
|
|
|
mOverflowDeltaX = aEvent.mOverflowDeltaX;
|
2016-03-31 18:36:55 +03:00
|
|
|
mOverflowDeltaY = aEvent.mOverflowDeltaY;
|
2013-10-11 23:48:53 +04:00
|
|
|
mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled;
|
2015-08-28 06:50:31 +03:00
|
|
|
mCanTriggerSwipe = aEvent.mCanTriggerSwipe;
|
2016-01-27 09:09:13 +03:00
|
|
|
mAllowToOverrideSystemScrollSpeed =
|
|
|
|
aEvent.mAllowToOverrideSystemScrollSpeed;
|
2018-03-15 11:31:07 +03:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler =
|
|
|
|
aEvent.mDeltaValuesHorizontalizedForDefaultHandler;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2016-01-27 09:09:13 +03:00
|
|
|
|
|
|
|
// System scroll speed settings may be too slow at using Gecko. In such
|
|
|
|
// case, we should override the scroll speed computed with system settings.
|
|
|
|
// Following methods return preferred delta values which are multiplied by
|
|
|
|
// factors specified by prefs. If system scroll speed shouldn't be
|
|
|
|
// overridden (e.g., this feature is disabled by pref), they return raw
|
|
|
|
// delta values.
|
|
|
|
double OverriddenDeltaX() const;
|
|
|
|
double OverriddenDeltaY() const;
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
// Compute the overridden delta value. This may be useful for suppressing
|
|
|
|
// too fast scroll by system scroll speed overriding when widget sets
|
|
|
|
// mAllowToOverrideSystemScrollSpeed.
|
|
|
|
static double ComputeOverriddenDelta(double aDelta, bool aIsForVertical);
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
private:
|
|
|
|
static bool sInitialized;
|
|
|
|
static bool sIsSystemScrollSpeedOverrideEnabled;
|
|
|
|
static int32_t sOverrideFactorX;
|
|
|
|
static int32_t sOverrideFactorY;
|
|
|
|
static void Initialize();
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
2013-11-21 09:44:22 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetPointerEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetPointerEvent : public WidgetMouseEvent {
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetPointerEvent() : mWidth(1), mHeight(1), mIsPrimary(true) {}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetPointerEvent* AsPointerEvent() override { return this; }
|
2013-11-21 09:44:22 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetPointerEvent(bool aIsTrusted, EventMessage aMsg, nsIWidget* w)
|
2014-08-04 09:28:52 +04:00
|
|
|
: WidgetMouseEvent(aIsTrusted, aMsg, w, ePointerEventClass, eReal),
|
2016-09-21 11:26:21 +03:00
|
|
|
mWidth(1),
|
|
|
|
mHeight(1),
|
2016-08-03 11:34:53 +03:00
|
|
|
mIsPrimary(true) {}
|
2013-11-21 09:44:22 +04:00
|
|
|
|
2014-08-08 03:46:08 +04:00
|
|
|
explicit WidgetPointerEvent(const WidgetMouseEvent& aEvent)
|
2013-11-21 09:44:22 +04:00
|
|
|
: WidgetMouseEvent(aEvent), mWidth(1), mHeight(1), mIsPrimary(true) {
|
2014-08-04 09:28:52 +04:00
|
|
|
mClass = ePointerEventClass;
|
2013-11-21 09:44:22 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:52 +04:00
|
|
|
MOZ_ASSERT(mClass == ePointerEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetPointerEvent* result =
|
2015-08-22 04:34:51 +03:00
|
|
|
new WidgetPointerEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignPointerEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-08-03 11:18:04 +03:00
|
|
|
uint32_t mWidth;
|
2016-08-03 11:23:56 +03:00
|
|
|
uint32_t mHeight;
|
2016-08-03 11:34:53 +03:00
|
|
|
bool mIsPrimary;
|
2014-01-27 10:10:44 +04:00
|
|
|
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
|
|
void AssignPointerEventData(const WidgetPointerEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-08-03 11:18:04 +03:00
|
|
|
mWidth = aEvent.mWidth;
|
2016-08-03 11:23:56 +03:00
|
|
|
mHeight = aEvent.mHeight;
|
2016-08-03 11:34:53 +03:00
|
|
|
mIsPrimary = aEvent.mIsPrimary;
|
2014-01-27 10:10:44 +04:00
|
|
|
}
|
2013-11-21 09:44:22 +04:00
|
|
|
};
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_MouseEvents_h__
|