2013-09-24 10:04:15 +00: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>
|
2024-08-17 07:43:46 +00:00
|
|
|
#include <math.h>
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
#include "mozilla/BasicEvents.h"
|
Bug 1844723 - Make `CreateMouseOrPointerWidgetEvent()` set `mButton` to "not pressed" value and compute `mButtons` if the source event has not been dispatched yet r=edgar,dom-core
`CreateMouseOrPointerWidgetEvent()` is designed to create `mouseenter`,
`mouseover`, `mouseout`, `mouseleave`, `pointerenter`, `pointerover`,
`pointerout` and `pointerleave` from a source event.
They are not button state change events, but the source event may be so.
According to the WPTs ([1], [2]) and the fact that the other browsers pass the
tests, the button state of pointer events of synthesizing events should be
synchronized with what the web apps notified (i.e., previous state of the
source event) if and only if the input source supports hover state and the
source event which changes a button state has not been dispatched into the DOM
yet.
1. https://searchfox.org/mozilla-central/rev/08d53deb2cf587e68d1825082c955e8a1926be73/testing/web-platform/tests/pointerevents/pointerevent_attributes_hoverable_pointers.html#44,51,60,63
2. https://searchfox.org/mozilla-central/rev/08d53deb2cf587e68d1825082c955e8a1926be73/testing/web-platform/tests/pointerevents/pointerevent_attributes_nohover_pointers.html#17,45,47,51
Differential Revision: https://phabricator.services.mozilla.com/D187644
2023-10-10 07:33:05 +00:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-09-24 10:04:15 +00:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2014-02-27 03:23:31 +00:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
2023-02-04 11:12:36 +00:00
|
|
|
#include "mozilla/ipc/IPCForwards.h"
|
2013-09-24 10:04:15 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
2019-05-06 08:12:21 +00:00
|
|
|
class PBrowserBridgeParent;
|
2013-09-24 10:04:15 +00:00
|
|
|
} // namespace dom
|
|
|
|
|
2017-09-20 05:00:57 +00:00
|
|
|
class WidgetPointerEvent;
|
2020-03-20 17:13:51 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
namespace mozilla {
|
2017-09-20 05:00:57 +00:00
|
|
|
class WidgetPointerEventHolder final {
|
|
|
|
public:
|
|
|
|
nsTArray<WidgetPointerEvent> mEvents;
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(WidgetPointerEventHolder)
|
|
|
|
|
|
|
|
private:
|
2020-03-16 10:56:57 +00:00
|
|
|
virtual ~WidgetPointerEventHolder() = default;
|
2017-09-20 05:00:57 +00:00
|
|
|
};
|
|
|
|
|
2014-02-26 21:37:01 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetPointerHelper
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetPointerHelper {
|
|
|
|
public:
|
2014-04-04 17:09:10 +00:00
|
|
|
uint32_t pointerId;
|
2023-01-13 08:35:44 +00:00
|
|
|
int32_t tiltX;
|
|
|
|
int32_t tiltY;
|
2023-01-13 08:35:44 +00:00
|
|
|
int32_t twist;
|
2017-02-09 02:49:00 +00:00
|
|
|
float tangentialPressure;
|
2016-11-20 01:36:39 +00:00
|
|
|
bool convertToPointer;
|
2017-09-20 05:00:57 +00:00
|
|
|
RefPtr<WidgetPointerEventHolder> mCoalescedWidgetEvents;
|
2014-02-26 21:37:01 +00:00
|
|
|
|
2016-11-20 01:36:39 +00:00
|
|
|
WidgetPointerHelper()
|
|
|
|
: pointerId(0),
|
|
|
|
tiltX(0),
|
|
|
|
tiltY(0),
|
2017-02-09 02:49:00 +00:00
|
|
|
twist(0),
|
|
|
|
tangentialPressure(0),
|
2016-11-20 01:36:39 +00:00
|
|
|
convertToPointer(true) {}
|
2014-02-26 21:37:01 +00:00
|
|
|
|
2017-02-09 02:49:00 +00:00
|
|
|
WidgetPointerHelper(uint32_t aPointerId, uint32_t aTiltX, uint32_t aTiltY,
|
|
|
|
uint32_t aTwist = 0, float aTangentialPressure = 0)
|
2016-11-20 02:24:46 +00:00
|
|
|
: pointerId(aPointerId),
|
|
|
|
tiltX(aTiltX),
|
|
|
|
tiltY(aTiltY),
|
2017-02-09 02:49:00 +00:00
|
|
|
twist(aTwist),
|
|
|
|
tangentialPressure(aTangentialPressure),
|
2016-11-20 02:24:46 +00:00
|
|
|
convertToPointer(true) {}
|
|
|
|
|
2020-03-16 10:56:57 +00:00
|
|
|
explicit WidgetPointerHelper(const WidgetPointerHelper& aHelper) = default;
|
2017-09-20 05:00:57 +00:00
|
|
|
|
2024-08-17 07:43:46 +00:00
|
|
|
constexpr static double kPi =
|
|
|
|
#ifdef M_PI
|
|
|
|
M_PI;
|
|
|
|
#else
|
|
|
|
3.14159265358979323846;
|
|
|
|
#endif
|
|
|
|
constexpr static double kHalfPi =
|
|
|
|
#ifdef M_PI_2
|
|
|
|
M_PI_2;
|
|
|
|
#else
|
|
|
|
1.57079632679489661923;
|
|
|
|
#endif
|
|
|
|
constexpr static double kDoublePi = kPi * 2;
|
|
|
|
|
|
|
|
constexpr static double GetDefaultAltitudeAngle() { return kHalfPi; }
|
|
|
|
constexpr static double GetDefaultAzimuthAngle() { return 0.0; }
|
|
|
|
|
|
|
|
double ComputeAltitudeAngle() const {
|
|
|
|
return ComputeAltitudeAngle(tiltX, tiltY);
|
|
|
|
}
|
|
|
|
double ComputeAzimuthAngle() const {
|
|
|
|
return ComputeAzimuthAngle(tiltX, tiltY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static double ComputeAltitudeAngle(int32_t aTiltX, int32_t aTiltY);
|
|
|
|
static double ComputeAzimuthAngle(int32_t aTiltX, int32_t aTiltY);
|
|
|
|
|
|
|
|
static double ComputeTiltX(double aAltitudeAngle, double aAzimuthAngle);
|
|
|
|
static double ComputeTiltY(double aAltitudeAngle, double aAzimuthAngle);
|
|
|
|
|
2017-09-20 05:00:57 +00:00
|
|
|
void AssignPointerHelperData(const WidgetPointerHelper& aEvent,
|
|
|
|
bool aCopyCoalescedEvents = false) {
|
2014-04-04 17:09:10 +00:00
|
|
|
pointerId = aEvent.pointerId;
|
2014-02-26 21:37:01 +00:00
|
|
|
tiltX = aEvent.tiltX;
|
|
|
|
tiltY = aEvent.tiltY;
|
2017-02-09 02:49:00 +00:00
|
|
|
twist = aEvent.twist;
|
|
|
|
tangentialPressure = aEvent.tangentialPressure;
|
2016-11-20 01:36:39 +00:00
|
|
|
convertToPointer = aEvent.convertToPointer;
|
2017-09-20 05:00:57 +00:00
|
|
|
if (aCopyCoalescedEvents) {
|
|
|
|
mCoalescedWidgetEvents = aEvent.mCoalescedWidgetEvents;
|
|
|
|
}
|
2014-02-26 21:37:01 +00:00
|
|
|
}
|
2024-08-17 07:43:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static int32_t GetValidTiltValue(int32_t aTilt);
|
|
|
|
static double GetValidAltitudeAngle(double aAltitudeAngle);
|
|
|
|
static double GetValidAzimuthAngle(double aAzimuthAngle);
|
2014-02-26 21:37:01 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseEventBase
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetMouseEventBase : public WidgetInputEvent {
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
2019-05-06 08:12:21 +00:00
|
|
|
friend class dom::PBrowserBridgeParent;
|
2023-02-04 11:12:36 +00:00
|
|
|
ALLOW_DEPRECATED_READPARAM
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2013-10-18 06:10:20 +00:00
|
|
|
protected:
|
2013-09-24 10:04:15 +00:00
|
|
|
WidgetMouseEventBase()
|
2019-04-21 18:20:58 +00:00
|
|
|
: mPressure(0),
|
|
|
|
mButton(0),
|
2019-04-21 19:42:37 +00:00
|
|
|
mButtons(0),
|
2020-03-03 15:27:50 +00:00
|
|
|
mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
|
2019-04-21 18:20:58 +00:00
|
|
|
// Including MouseEventBinding.h here leads to an include loop, so
|
|
|
|
// we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2015-08-26 12:56:59 +00:00
|
|
|
WidgetMouseEventBase(bool aIsTrusted, EventMessage aMessage,
|
2023-08-09 10:29:39 +00:00
|
|
|
nsIWidget* aWidget, EventClassID aEventClassID,
|
|
|
|
const WidgetEventTime* aTime = nullptr)
|
|
|
|
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID, aTime),
|
2019-04-21 18:20:58 +00:00
|
|
|
mPressure(0),
|
2019-04-21 18:17:10 +00:00
|
|
|
mButton(0),
|
2019-04-21 19:42:37 +00:00
|
|
|
mButtons(0),
|
2020-03-03 15:27:50 +00:00
|
|
|
mInputSource(/* MouseEvent_Binding::MOZ_SOURCE_MOUSE = */ 1) {}
|
2019-04-21 18:20:58 +00:00
|
|
|
// Including MouseEventBinding.h here leads to an include loop, so
|
|
|
|
// we have to hardcode MouseEvent_Binding::MOZ_SOURCE_MOUSE.
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-10-18 06:10:20 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetMouseEventBase* AsMouseEventBase() override { return this; }
|
2013-10-18 06:10:20 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-01-27 06:10:44 +00:00
|
|
|
MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
|
|
|
|
}
|
|
|
|
|
2019-04-21 18:20:58 +00:00
|
|
|
// Finger or touch pressure of event. It ranges between 0.0 and 1.0.
|
|
|
|
float mPressure;
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
// Pressed button ID of mousedown or mouseup event.
|
|
|
|
// This is set only when pressing a button causes the event.
|
2019-04-21 18:17:10 +00:00
|
|
|
int16_t mButton;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
// Flags of all pressed buttons at the event fired.
|
2019-04-21 18:17:10 +00:00
|
|
|
// This is set at any mouse event, don't be confused with |mButton|.
|
2019-04-21 19:42:37 +00:00
|
|
|
int16_t mButtons;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2018-03-20 04:16:06 +00:00
|
|
|
// Possible values a in MouseEvent
|
2019-04-21 18:19:43 +00:00
|
|
|
uint16_t mInputSource;
|
2014-05-20 04:54:00 +00:00
|
|
|
|
2019-04-21 20:13:34 +00:00
|
|
|
bool IsLeftButtonPressed() const {
|
2020-06-22 22:54:07 +00:00
|
|
|
return !!(mButtons & MouseButtonsFlag::ePrimaryFlag);
|
2019-04-21 20:13:34 +00:00
|
|
|
}
|
|
|
|
bool IsRightButtonPressed() const {
|
2020-06-22 22:54:07 +00:00
|
|
|
return !!(mButtons & MouseButtonsFlag::eSecondaryFlag);
|
2019-04-21 20:13:34 +00:00
|
|
|
}
|
2019-04-21 19:42:37 +00:00
|
|
|
bool IsMiddleButtonPressed() const {
|
2019-04-21 20:13:34 +00:00
|
|
|
return !!(mButtons & MouseButtonsFlag::eMiddleFlag);
|
|
|
|
}
|
|
|
|
bool Is4thButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::e4thFlag);
|
|
|
|
}
|
|
|
|
bool Is5thButtonPressed() const {
|
|
|
|
return !!(mButtons & MouseButtonsFlag::e5thFlag);
|
2019-04-21 19:42:37 +00:00
|
|
|
}
|
2015-10-16 04:19:27 +00:00
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignInputEventData(aEvent, aCopyTargets);
|
|
|
|
|
2019-04-21 18:17:10 +00:00
|
|
|
mButton = aEvent.mButton;
|
2019-04-21 19:42:37 +00:00
|
|
|
mButtons = aEvent.mButtons;
|
2019-04-21 18:19:18 +00:00
|
|
|
mPressure = aEvent.mPressure;
|
2019-04-21 18:19:43 +00:00
|
|
|
mInputSource = aEvent.mInputSource;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2013-10-28 09:03:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if left click event.
|
|
|
|
*/
|
|
|
|
bool IsLeftClickEvent() const {
|
2024-06-14 00:18:46 +00:00
|
|
|
return mMessage == ePointerClick && mButton == MouseButton::ePrimary;
|
2013-10-28 09:03:19 +00:00
|
|
|
}
|
Bug 1844723 - Make `CreateMouseOrPointerWidgetEvent()` set `mButton` to "not pressed" value and compute `mButtons` if the source event has not been dispatched yet r=edgar,dom-core
`CreateMouseOrPointerWidgetEvent()` is designed to create `mouseenter`,
`mouseover`, `mouseout`, `mouseleave`, `pointerenter`, `pointerover`,
`pointerout` and `pointerleave` from a source event.
They are not button state change events, but the source event may be so.
According to the WPTs ([1], [2]) and the fact that the other browsers pass the
tests, the button state of pointer events of synthesizing events should be
synchronized with what the web apps notified (i.e., previous state of the
source event) if and only if the input source supports hover state and the
source event which changes a button state has not been dispatched into the DOM
yet.
1. https://searchfox.org/mozilla-central/rev/08d53deb2cf587e68d1825082c955e8a1926be73/testing/web-platform/tests/pointerevents/pointerevent_attributes_hoverable_pointers.html#44,51,60,63
2. https://searchfox.org/mozilla-central/rev/08d53deb2cf587e68d1825082c955e8a1926be73/testing/web-platform/tests/pointerevents/pointerevent_attributes_nohover_pointers.html#17,45,47,51
Differential Revision: https://phabricator.services.mozilla.com/D187644
2023-10-10 07:33:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this event changes a button state to "pressed".
|
|
|
|
*/
|
|
|
|
[[nodiscard]] bool IsPressingButton() const {
|
|
|
|
MOZ_ASSERT(IsTrusted());
|
|
|
|
if (mClass == eMouseEventClass) {
|
|
|
|
return mMessage == eMouseDown;
|
|
|
|
}
|
|
|
|
if (mButton == MouseButton::eNotPressed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// If this is an ePointerDown event whose mButton is not "not pressed", this
|
|
|
|
// is a button pressing event.
|
|
|
|
if (mMessage == ePointerDown) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If 2 or more buttons are pressed at same time, they are sent with
|
|
|
|
// pointermove rather than pointerdown. Therefore, let's check whether
|
|
|
|
// mButtons contains the proper flag for the pressing button.
|
|
|
|
const bool buttonsContainButton = !!(
|
|
|
|
mButtons & MouseButtonsFlagToChange(static_cast<MouseButton>(mButton)));
|
|
|
|
return mMessage == ePointerMove && buttonsContainButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this event changes a button state to "released".
|
|
|
|
*/
|
|
|
|
[[nodiscard]] bool IsReleasingButton() const {
|
|
|
|
MOZ_ASSERT(IsTrusted());
|
|
|
|
if (mClass == eMouseEventClass) {
|
|
|
|
return mMessage == eMouseUp;
|
|
|
|
}
|
|
|
|
if (mButton == MouseButton::eNotPressed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// If this is an ePointerUp event whose mButton is not "not pressed", this
|
|
|
|
// is a button release event.
|
|
|
|
if (mMessage == ePointerUp) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If the releasing button is not the last button of pressing buttons, web
|
|
|
|
// apps notified by pointermove rather than pointerup. Therefore, let's
|
|
|
|
// check whether mButtons loses the proper flag for the releasing button.
|
|
|
|
const bool buttonsLoseTheButton = !(
|
|
|
|
mButtons & MouseButtonsFlagToChange(static_cast<MouseButton>(mButton)));
|
|
|
|
return mMessage == ePointerMove && buttonsLoseTheButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the input source supports hover state like a mouse.
|
|
|
|
*/
|
|
|
|
[[nodiscard]] bool InputSourceSupportsHover() const;
|
2013-09-24 10:04:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2016-05-10 12:57:16 +00:00
|
|
|
class WidgetMouseEvent : public WidgetMouseEventBase,
|
|
|
|
public WidgetPointerHelper {
|
2013-09-24 10:04:15 +00:00
|
|
|
private:
|
2016-05-10 12:57:16 +00:00
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
2019-05-06 08:12:21 +00:00
|
|
|
friend class dom::PBrowserBridgeParent;
|
2023-02-04 11:12:36 +00:00
|
|
|
ALLOW_DEPRECATED_READPARAM
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
public:
|
2016-05-12 02:17:46 +00:00
|
|
|
typedef bool ReasonType;
|
|
|
|
enum Reason : ReasonType { eReal, eSynthesized };
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2020-05-26 13:11:45 +00:00
|
|
|
typedef uint8_t ContextMenuTriggerType;
|
|
|
|
enum ContextMenuTrigger : ContextMenuTriggerType {
|
|
|
|
eNormal,
|
|
|
|
eContextMenuKey,
|
|
|
|
eControlClick
|
|
|
|
};
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2020-08-27 17:19:14 +00:00
|
|
|
typedef uint8_t ExitFromType;
|
2020-08-29 21:11:41 +00:00
|
|
|
enum ExitFrom : ExitFromType {
|
2021-01-05 09:48:24 +00:00
|
|
|
ePlatformChild,
|
|
|
|
ePlatformTopLevel,
|
2020-08-29 21:11:41 +00:00
|
|
|
ePuppet,
|
|
|
|
ePuppetParentToPuppetChild
|
|
|
|
};
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2013-10-18 06:10:20 +00:00
|
|
|
protected:
|
2024-06-14 00:18:48 +00:00
|
|
|
WidgetMouseEvent() = default;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-05-10 12:57:16 +00:00
|
|
|
WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
2023-08-09 10:29:39 +00:00
|
|
|
EventClassID aEventClassID, Reason aReason,
|
2024-06-14 00:18:48 +00:00
|
|
|
ContextMenuTrigger aContextMenuTrigger,
|
2023-08-09 10:29:39 +00:00
|
|
|
const WidgetEventTime* aTime = nullptr)
|
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID,
|
|
|
|
aTime),
|
2016-05-12 02:36:41 +00:00
|
|
|
mReason(aReason),
|
2024-06-14 00:18:48 +00:00
|
|
|
mContextMenuTrigger(aContextMenuTrigger) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2021-03-26 02:06:53 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void AssertContextMenuEventButtonConsistency() const;
|
|
|
|
#endif
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetMouseEvent* AsMouseEvent() override { return this; }
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2016-05-12 02:39:05 +00:00
|
|
|
WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
2024-06-14 00:18:48 +00:00
|
|
|
Reason aReason = eReal,
|
2023-08-09 10:29:39 +00:00
|
|
|
ContextMenuTrigger aContextMenuTrigger = eNormal,
|
|
|
|
const WidgetEventTime* aTime = nullptr)
|
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass,
|
|
|
|
aTime),
|
2016-05-12 02:36:41 +00:00
|
|
|
mReason(aReason),
|
2024-06-14 00:18:48 +00:00
|
|
|
mContextMenuTrigger(aContextMenuTrigger) {
|
Bug 1675847 - part 3: Make `ePointerClick` event dispatchers and handlers use `WidgetPointerEvent` r=smaug,search-reviewers,devtools-reviewers,nchevobbe,jteow
This patch makes the all `ePointerClick` event dispatcher in C++ code use
`WidgetPointerEvent` instead of `WidgetMouseEvent`.
Then, this patch also makes the all `click` event dispatcher in chrome code use
`PointerEvent` instead of `MouseEvent`. For detecting wrong trusted event
dispatching of `click` event, this patch adds assertion into `MouseEvent`.
Therefore, all chrome test dispatchers also changed to use `PointerEvent`.
Finally, this patch includes a change of a WPT. That checks the `pointerId`
caused by executing an access key. In this case, the value should be `-1`
rather than the default value `0` because Pointer Event spec defines so for
synthetic pointer events caused by non-pointing devices [1]. Chrome also
sets it to `-1` and fails [2]. Therefore, the new assertion will pass on both
Firefox and Chrome.
1. https://w3c.github.io/pointerevents/#dom-pointerevent-pointerid
2. https://wpt.fyi/results/uievents/interface/keyboard-accesskey-click-event.html?run_id=5087897523060736&run_id=5136270464647168&run_id=5163620816388096&run_id=5201281304231936
Differential Revision: https://phabricator.services.mozilla.com/D213001
2024-06-14 00:18:47 +00:00
|
|
|
MOZ_ASSERT_IF(aIsTrusted, !IsPointerEventMessage(mMessage));
|
2016-04-13 06:16:42 +00:00
|
|
|
if (aMessage == eContextMenu) {
|
2020-06-19 18:02:41 +00:00
|
|
|
mButton = (mContextMenuTrigger == eNormal) ? MouseButton::eSecondary
|
|
|
|
: MouseButton::ePrimary;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2021-03-26 02:06:53 +00:00
|
|
|
virtual ~WidgetMouseEvent() { AssertContextMenuEventButtonConsistency(); }
|
2013-09-24 10:04:15 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 05:28:50 +00:00
|
|
|
MOZ_ASSERT(mClass == eMouseEventClass,
|
2014-01-27 06:10:44 +00:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetMouseEvent* result = new WidgetMouseEvent(
|
2023-08-09 10:29:39 +00:00
|
|
|
false, mMessage, nullptr, mReason, mContextMenuTrigger, this);
|
2014-01-27 06:10:44 +00:00
|
|
|
result->AssignMouseEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-12-11 21:35:40 +00: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 12:57:16 +00: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.
|
2024-06-14 00:18:48 +00:00
|
|
|
Reason mReason = eReal;
|
2016-05-12 02:17:46 +00:00
|
|
|
|
2016-05-10 12:57:16 +00: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).
|
2024-06-14 00:18:48 +00:00
|
|
|
ContextMenuTrigger mContextMenuTrigger = eNormal;
|
2016-05-12 02:28:14 +00:00
|
|
|
|
2020-08-27 17:19:03 +00:00
|
|
|
// mExitFrom contains a value only when mMessage is eMouseExitFromWidget.
|
2020-08-27 17:19:14 +00:00
|
|
|
// This indicates if the mouse cursor exits from a top level platform widget,
|
|
|
|
// a child widget or a puppet widget.
|
2020-08-27 17:19:03 +00:00
|
|
|
Maybe<ExitFrom> mExitFrom;
|
2016-05-12 02:32:53 +00:00
|
|
|
|
2016-05-10 12:57:16 +00:00
|
|
|
// mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp,
|
2024-06-14 00:18:46 +00:00
|
|
|
// ePointerClick or eMouseDoubleClick. The number is count of mouse clicks.
|
2016-05-10 12:57:16 +00:00
|
|
|
// Otherwise, this must be 0.
|
2024-06-14 00:18:48 +00:00
|
|
|
uint32_t mClickCount = 0;
|
2013-09-24 10:04:15 +00: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 19:22:48 +00:00
|
|
|
// Whether the event should ignore scroll frame bounds during dispatch.
|
2024-06-14 00:18:48 +00:00
|
|
|
bool mIgnoreRootScrollFrame = false;
|
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 19:22:48 +00:00
|
|
|
|
Bug 1793267 - Make `PostEventHandler::CheckPointerCaptureState` synthesize `ePointerMove` and `eMouseMove` if nobody captures the pointer anymore r=smaug
When an element starts capturing a pointer, pointer/mouse boundary events are
dispatched by `EventStateManager::PreHandleEvent` [1]. However, when the
capturing element loses the capture, they are not dispatched.
When the pointer capture is implicitly released, the pointer may be over another
document. Therefore, this patch synthesizes an internal `ePointerMove` and
`eMouseMove` on the widget to make `PresShell::HandleEvent` redirects the event
to proper document under the pointer.
Unfortunately, I add 2 manual tests into WPT. The reason is, a drag operation
across document boundary with test driver does not work even if I specify the
pointer position within the parent document coordinates. This is same both on
Firefox and Chrome. Additionally, writing the new tests as a mochitest won't
work too. If I use synthesized mouse events, I see similar failure.
Additionally, when I use native events, it works, but unstable to run on CI.
1. https://searchfox.org/mozilla-central/rev/669fac9888b173c02baa4c036e980c0c204dfe02/dom/events/EventStateManager.cpp#1139-1140
Differential Revision: https://phabricator.services.mozilla.com/D218896
2024-08-20 03:42:26 +00:00
|
|
|
// Whether the event should be dispatched on a target limited in capturing
|
|
|
|
// content.
|
|
|
|
bool mIgnoreCapturingContent = false;
|
|
|
|
|
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 19:22:48 +00:00
|
|
|
// Whether the event shouldn't cause click event.
|
2024-06-14 00:18:48 +00:00
|
|
|
bool mClickEventPrevented = false;
|
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 19:22:48 +00:00
|
|
|
|
Bug 1793267 - Make `PostEventHandler::CheckPointerCaptureState` synthesize `ePointerMove` and `eMouseMove` if nobody captures the pointer anymore r=smaug
When an element starts capturing a pointer, pointer/mouse boundary events are
dispatched by `EventStateManager::PreHandleEvent` [1]. However, when the
capturing element loses the capture, they are not dispatched.
When the pointer capture is implicitly released, the pointer may be over another
document. Therefore, this patch synthesizes an internal `ePointerMove` and
`eMouseMove` on the widget to make `PresShell::HandleEvent` redirects the event
to proper document under the pointer.
Unfortunately, I add 2 manual tests into WPT. The reason is, a drag operation
across document boundary with test driver does not work even if I specify the
pointer position within the parent document coordinates. This is same both on
Firefox and Chrome. Additionally, writing the new tests as a mochitest won't
work too. If I use synthesized mouse events, I see similar failure.
Additionally, when I use native events, it works, but unstable to run on CI.
1. https://searchfox.org/mozilla-central/rev/669fac9888b173c02baa4c036e980c0c204dfe02/dom/events/EventStateManager.cpp#1139-1140
Differential Revision: https://phabricator.services.mozilla.com/D218896
2024-08-20 03:42:26 +00:00
|
|
|
// If this is set to true while the event is being dispatched,
|
|
|
|
// PresShell::EventHandler::FinalizeHandlingEvent will dispatch a synthesized
|
|
|
|
// eMouseMove or ePointerMove.
|
|
|
|
bool mSynthesizeMoveAfterDispatch = false;
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
2017-09-20 05:00:57 +00:00
|
|
|
AssignPointerHelperData(aEvent, /* aCopyCoalescedEvents */ true);
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2024-06-14 00:18:48 +00:00
|
|
|
mReason = aEvent.mReason;
|
|
|
|
mContextMenuTrigger = aEvent.mContextMenuTrigger;
|
2020-08-27 17:19:07 +00:00
|
|
|
mExitFrom = aEvent.mExitFrom;
|
2021-03-03 13:29:12 +00:00
|
|
|
mClickCount = aEvent.mClickCount;
|
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 19:22:48 +00:00
|
|
|
mIgnoreRootScrollFrame = aEvent.mIgnoreRootScrollFrame;
|
Bug 1793267 - Make `PostEventHandler::CheckPointerCaptureState` synthesize `ePointerMove` and `eMouseMove` if nobody captures the pointer anymore r=smaug
When an element starts capturing a pointer, pointer/mouse boundary events are
dispatched by `EventStateManager::PreHandleEvent` [1]. However, when the
capturing element loses the capture, they are not dispatched.
When the pointer capture is implicitly released, the pointer may be over another
document. Therefore, this patch synthesizes an internal `ePointerMove` and
`eMouseMove` on the widget to make `PresShell::HandleEvent` redirects the event
to proper document under the pointer.
Unfortunately, I add 2 manual tests into WPT. The reason is, a drag operation
across document boundary with test driver does not work even if I specify the
pointer position within the parent document coordinates. This is same both on
Firefox and Chrome. Additionally, writing the new tests as a mochitest won't
work too. If I use synthesized mouse events, I see similar failure.
Additionally, when I use native events, it works, but unstable to run on CI.
1. https://searchfox.org/mozilla-central/rev/669fac9888b173c02baa4c036e980c0c204dfe02/dom/events/EventStateManager.cpp#1139-1140
Differential Revision: https://phabricator.services.mozilla.com/D218896
2024-08-20 03:42:26 +00:00
|
|
|
mIgnoreCapturingContent = aEvent.mIgnoreCapturingContent;
|
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 19:22:48 +00:00
|
|
|
mClickEventPrevented = aEvent.mClickEventPrevented;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2013-10-28 09:03:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the event is a context menu event caused by key.
|
|
|
|
*/
|
|
|
|
bool IsContextMenuKeyEvent() const {
|
2016-05-12 02:39:05 +00:00
|
|
|
return mMessage == eContextMenu && mContextMenuTrigger == eContextMenuKey;
|
2013-10-28 09:03:19 +00:00
|
|
|
}
|
2014-04-01 04:09:22 +00: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 02:36:41 +00:00
|
|
|
bool IsReal() const { return mReason == eReal; }
|
2018-10-10 12:04:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if middle click paste is enabled.
|
|
|
|
*/
|
|
|
|
static bool IsMiddleClickPasteEnabled();
|
2013-09-24 10:04:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetDragEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetDragEvent : public WidgetMouseEvent {
|
2015-04-08 18:48:11 +00:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
2023-02-04 11:12:36 +00:00
|
|
|
ALLOW_DEPRECATED_READPARAM
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-04-08 18:48:11 +00:00
|
|
|
protected:
|
|
|
|
WidgetDragEvent()
|
2023-12-18 05:46:13 +00:00
|
|
|
: mUserCancelled(false),
|
|
|
|
mDefaultPreventedOnContent(false),
|
|
|
|
mInHTMLEditorEventListener(false) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetDragEvent* AsDragEvent() override { return this; }
|
2013-10-18 06:10:20 +00:00
|
|
|
|
2023-08-09 10:29:39 +00:00
|
|
|
WidgetDragEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
|
|
|
const WidgetEventTime* aTime = nullptr)
|
|
|
|
: WidgetMouseEvent(aIsTrusted, aMessage, aWidget, eDragEventClass, eReal,
|
2024-06-14 00:18:48 +00:00
|
|
|
eNormal, aTime),
|
2016-03-31 10:06:05 +00:00
|
|
|
mUserCancelled(false),
|
2023-08-15 13:46:42 +00:00
|
|
|
mDefaultPreventedOnContent(false),
|
|
|
|
mInHTMLEditorEventListener(false) {}
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 05:28:50 +00:00
|
|
|
MOZ_ASSERT(mClass == eDragEventClass,
|
2014-01-27 06:10:44 +00:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2023-08-09 10:29:39 +00:00
|
|
|
WidgetDragEvent* result =
|
|
|
|
new WidgetDragEvent(false, mMessage, nullptr, this);
|
2014-01-27 06:10:44 +00:00
|
|
|
result->AssignDragEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
// The dragging data.
|
2016-03-31 08:26:32 +00:00
|
|
|
nsCOMPtr<dom::DataTransfer> mDataTransfer;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
// If this is true, user has cancelled the drag operation.
|
2016-03-31 10:06:05 +00:00
|
|
|
bool mUserCancelled;
|
2013-12-12 09:39:04 +00:00
|
|
|
// If this is true, the drag event's preventDefault() is called on content.
|
|
|
|
bool mDefaultPreventedOnContent;
|
2023-08-15 13:46:42 +00:00
|
|
|
// If this event is currently being handled by HTMLEditorEventListener.
|
|
|
|
bool mInHTMLEditorEventListener;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
|
|
void AssignDragEventData(const WidgetDragEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-03-31 08:26:32 +00:00
|
|
|
mDataTransfer = aEvent.mDataTransfer;
|
2016-03-31 10:06:05 +00:00
|
|
|
// XXX mUserCancelled isn't copied, is this intentionally?
|
|
|
|
mUserCancelled = false;
|
2013-12-12 09:39:04 +00:00
|
|
|
mDefaultPreventedOnContent = aEvent.mDefaultPreventedOnContent;
|
2023-12-18 05:46:13 +00:00
|
|
|
// XXX mInHTMLEditorEventListener isn't copied, is this intentionally?
|
|
|
|
mInHTMLEditorEventListener = false;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2019-12-21 12:27:06 +00:00
|
|
|
|
2024-01-28 07:49:53 +00:00
|
|
|
bool CanConvertToInputData() const {
|
2024-10-01 05:29:15 +00:00
|
|
|
return mMessage == eDragStart || mMessage == eDragEnd ||
|
|
|
|
mMessage == eDragEnter || mMessage == eDragOver ||
|
|
|
|
mMessage == eDragExit || mMessage == eDrop;
|
2024-01-28 07:49:53 +00:00
|
|
|
}
|
|
|
|
|
2019-12-21 12:27:06 +00: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 10:04:15 +00: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 16:28:04 +00:00
|
|
|
virtual WidgetMouseScrollEvent* AsMouseScrollEvent() override { return this; }
|
2013-10-18 06:10:20 +00:00
|
|
|
|
2015-08-26 12:56:59 +00:00
|
|
|
WidgetMouseScrollEvent(bool aIsTrusted, EventMessage aMessage,
|
2023-08-09 10:29:39 +00:00
|
|
|
nsIWidget* aWidget,
|
|
|
|
const WidgetEventTime* aTime = nullptr)
|
2014-08-04 05:28:51 +00:00
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
|
2023-08-09 10:29:39 +00:00
|
|
|
eMouseScrollEventClass, aTime),
|
2016-04-06 07:44:11 +00:00
|
|
|
mDelta(0),
|
|
|
|
mIsHorizontal(false) {}
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 05:28:51 +00:00
|
|
|
MOZ_ASSERT(mClass == eMouseScrollEventClass,
|
2014-01-27 06:10:44 +00:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetMouseScrollEvent* result =
|
2023-08-09 10:29:39 +00:00
|
|
|
new WidgetMouseScrollEvent(false, mMessage, nullptr, this);
|
2014-01-27 06:10:44 +00:00
|
|
|
result->AssignMouseScrollEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
// The delta value of mouse scroll event.
|
2015-09-10 01:40:04 +00:00
|
|
|
// If the event message is eLegacyMouseLineOrPageScroll, the value indicates
|
|
|
|
// scroll amount in lines. However, if the value is
|
2018-03-26 18:53:02 +00:00
|
|
|
// UIEvent::SCROLL_PAGE_UP or UIEvent::SCROLL_PAGE_DOWN, the
|
2015-09-10 01:40:04 +00:00
|
|
|
// value inducates one page scroll. If the event message is
|
2015-09-10 01:40:04 +00:00
|
|
|
// eLegacyMousePixelScroll, the value indicates scroll amount in pixels.
|
2016-04-06 07:44:11 +00:00
|
|
|
int32_t mDelta;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
// If this is true, it may cause to scroll horizontally.
|
|
|
|
// Otherwise, vertically.
|
2016-04-06 07:44:11 +00:00
|
|
|
bool mIsHorizontal;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
void AssignMouseScrollEventData(const WidgetMouseScrollEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
|
2016-04-06 07:44:11 +00:00
|
|
|
mDelta = aEvent.mDelta;
|
|
|
|
mIsHorizontal = aEvent.mIsHorizontal;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetWheelEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetWheelEvent : public WidgetMouseEventBase {
|
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
2023-02-04 11:12:36 +00:00
|
|
|
ALLOW_DEPRECATED_READPARAM
|
2013-09-24 10:04:15 +00:00
|
|
|
|
|
|
|
WidgetWheelEvent()
|
2016-03-31 09:55:59 +00:00
|
|
|
: mDeltaX(0.0),
|
2016-03-31 09:09:47 +00:00
|
|
|
mDeltaY(0.0),
|
2016-03-31 09:18:34 +00:00
|
|
|
mDeltaZ(0.0),
|
2016-03-31 15:46:18 +00:00
|
|
|
mOverflowDeltaX(0.0),
|
|
|
|
mOverflowDeltaY(0.0)
|
2018-03-20 04:16:05 +00:00
|
|
|
// Including WheelEventBinding.h here leads to an include loop, so
|
2018-06-25 21:20:54 +00:00
|
|
|
// we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
|
|
|
|
,
|
|
|
|
mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
|
2016-03-31 15:10:46 +00:00
|
|
|
mLineOrPageDeltaX(0),
|
2016-03-31 15:10:09 +00:00
|
|
|
mLineOrPageDeltaY(0),
|
2016-03-31 14:54:42 +00:00
|
|
|
mScrollType(SCROLL_DEFAULT),
|
2016-03-31 15:46:18 +00:00
|
|
|
mCustomizedByUserPrefs(false),
|
2018-06-15 14:48:51 +00:00
|
|
|
mMayHaveMomentum(false),
|
2016-03-31 15:46:18 +00:00
|
|
|
mIsMomentum(false),
|
|
|
|
mIsNoLineOrPageDelta(false),
|
2016-01-12 18:16:59 +00:00
|
|
|
mViewPortIsOverscrolled(false),
|
|
|
|
mCanTriggerSwipe(false),
|
2016-01-27 06:09:13 +00:00
|
|
|
mAllowToOverrideSystemScrollSpeed(false),
|
2018-03-15 08:31:07 +00:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler(false) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetWheelEvent* AsWheelEvent() override { return this; }
|
2013-10-18 06:10:20 +00:00
|
|
|
|
2023-08-09 10:29:39 +00:00
|
|
|
WidgetWheelEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
|
|
|
|
const WidgetEventTime* aTime = nullptr)
|
|
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eWheelEventClass,
|
|
|
|
aTime),
|
2016-03-31 09:55:59 +00:00
|
|
|
mDeltaX(0.0),
|
2016-03-31 09:09:47 +00:00
|
|
|
mDeltaY(0.0),
|
2016-03-31 09:18:34 +00:00
|
|
|
mDeltaZ(0.0),
|
2016-03-31 15:46:18 +00:00
|
|
|
mOverflowDeltaX(0.0),
|
|
|
|
mOverflowDeltaY(0.0)
|
2018-03-20 04:16:05 +00:00
|
|
|
// Including WheelEventBinding.h here leads to an include loop, so
|
2018-06-25 21:20:54 +00:00
|
|
|
// we have to hardcode WheelEvent_Binding::DOM_DELTA_PIXEL.
|
|
|
|
,
|
|
|
|
mDeltaMode(/* WheelEvent_Binding::DOM_DELTA_PIXEL = */ 0),
|
2016-03-31 15:46:18 +00:00
|
|
|
mLineOrPageDeltaX(0),
|
|
|
|
mLineOrPageDeltaY(0),
|
|
|
|
mScrollType(SCROLL_DEFAULT),
|
2016-03-31 09:44:01 +00:00
|
|
|
mCustomizedByUserPrefs(false),
|
2016-03-31 14:36:49 +00:00
|
|
|
mMayHaveMomentum(false),
|
2016-03-31 14:45:55 +00:00
|
|
|
mIsMomentum(false),
|
2014-08-04 05:28:51 +00:00
|
|
|
mIsNoLineOrPageDelta(false),
|
|
|
|
mViewPortIsOverscrolled(false),
|
2015-08-28 03:50:31 +00:00
|
|
|
mCanTriggerSwipe(false),
|
2016-01-27 06:09:13 +00:00
|
|
|
mAllowToOverrideSystemScrollSpeed(true),
|
2018-03-15 08:31:07 +00:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler(false) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 05:28:51 +00:00
|
|
|
MOZ_ASSERT(mClass == eWheelEventClass,
|
2014-01-27 06:10:44 +00:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2023-08-09 10:29:39 +00:00
|
|
|
WidgetWheelEvent* result =
|
|
|
|
new WidgetWheelEvent(false, mMessage, nullptr, this);
|
2014-01-27 06:10:44 +00:00
|
|
|
result->AssignWheelEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-11-22 06:52:48 +00:00
|
|
|
// 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.
|
2015-08-28 03:50:31 +00:00
|
|
|
bool TriggersSwipe() const {
|
|
|
|
return mCanTriggerSwipe && mViewPortIsOverscrolled &&
|
2016-03-31 15:27:45 +00:00
|
|
|
this->mOverflowDeltaX != 0.0;
|
2015-08-28 03:50:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-31 09:18:34 +00:00
|
|
|
// NOTE: mDeltaX, mDeltaY and mDeltaZ may be customized by
|
2013-09-24 10:04:15 +00:00
|
|
|
// mousewheel.*.delta_multiplier_* prefs which are applied by
|
2014-04-01 04:09:23 +00:00
|
|
|
// EventStateManager. So, after widget dispatches this event,
|
2013-09-24 10:04:15 +00:00
|
|
|
// these delta values may have different values than before.
|
2016-03-31 09:55:59 +00:00
|
|
|
double mDeltaX;
|
2016-03-31 09:09:47 +00:00
|
|
|
double mDeltaY;
|
2016-03-31 09:18:34 +00:00
|
|
|
double mDeltaZ;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2021-05-14 15:17:33 +00:00
|
|
|
// The mousewheel tick counts.
|
|
|
|
double mWheelTicksX = 0.0;
|
|
|
|
double mWheelTicksY = 0.0;
|
|
|
|
|
2021-03-09 01:59:43 +00:00
|
|
|
enum class DeltaModeCheckingState : uint8_t {
|
|
|
|
// Neither deltaMode nor the delta values have been accessed.
|
|
|
|
Unknown,
|
|
|
|
// The delta values have been accessed, without checking deltaMode first.
|
|
|
|
Unchecked,
|
|
|
|
// The deltaMode has been checked.
|
|
|
|
Checked,
|
|
|
|
};
|
|
|
|
|
|
|
|
// For compat reasons, we might expose a DOM_DELTA_LINE event as
|
|
|
|
// DOM_DELTA_PIXEL instead. Whether we do that depends on whether the event
|
|
|
|
// has been asked for the deltaMode before the deltas. If it has, we assume
|
|
|
|
// that the page will correctly handle DOM_DELTA_LINE. This variable tracks
|
|
|
|
// that state. See bug 1392460.
|
|
|
|
DeltaModeCheckingState mDeltaModeCheckingState =
|
|
|
|
DeltaModeCheckingState::Unknown;
|
|
|
|
|
2021-03-08 00:24:04 +00:00
|
|
|
// The amount of scrolling per line or page, without accounting for mouse
|
|
|
|
// wheel transactions etc.
|
|
|
|
//
|
|
|
|
// Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
|
|
|
|
nsSize mScrollAmount;
|
|
|
|
|
2016-03-31 15:46:18 +00:00
|
|
|
// overflowed delta values for scroll, these values are set by
|
2018-03-15 08:31:07 +00: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 15:46:18 +00: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-25 21:20:54 +00:00
|
|
|
// Should be one of WheelEvent_Binding::DOM_DELTA_*
|
2016-03-31 09:35:24 +00:00
|
|
|
uint32_t mDeltaMode;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2016-03-31 15:10:46 +00:00
|
|
|
// If widget sets mLineOrPageDelta, EventStateManager will dispatch
|
2015-09-10 01:40:04 +00:00
|
|
|
// eLegacyMouseLineOrPageScroll event for compatibility. Note that the delta
|
2016-03-31 09:35:24 +00:00
|
|
|
// value means pages if the mDeltaMode is DOM_DELTA_PAGE, otherwise, lines.
|
2016-03-31 15:10:46 +00:00
|
|
|
int32_t mLineOrPageDeltaX;
|
2016-03-31 15:10:09 +00:00
|
|
|
int32_t mLineOrPageDeltaY;
|
2013-09-24 10:04:15 +00: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 15:10:09 +00:00
|
|
|
if (!mLineOrPageDeltaX && !mLineOrPageDeltaY) {
|
2013-09-24 10:04:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2016-03-31 15:10:09 +00:00
|
|
|
if (mLineOrPageDeltaY && !mLineOrPageDeltaX) {
|
|
|
|
return mLineOrPageDeltaY;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2016-03-31 15:10:09 +00:00
|
|
|
if (mLineOrPageDeltaX && !mLineOrPageDeltaY) {
|
2016-03-31 15:10:46 +00:00
|
|
|
return mLineOrPageDeltaX;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2016-03-31 15:10:09 +00:00
|
|
|
if ((mLineOrPageDeltaX < 0 && mLineOrPageDeltaY > 0) ||
|
|
|
|
(mLineOrPageDeltaX > 0 && mLineOrPageDeltaY < 0)) {
|
2013-09-24 10:04:15 +00:00
|
|
|
return 0; // We cannot guess the answer in this case.
|
|
|
|
}
|
2016-03-31 15:10:09 +00:00
|
|
|
return (Abs(mLineOrPageDeltaX) > Abs(mLineOrPageDeltaY))
|
|
|
|
? mLineOrPageDeltaX
|
|
|
|
: mLineOrPageDeltaY;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Scroll type
|
2014-04-01 04:09:23 +00:00
|
|
|
// The default value is SCROLL_DEFAULT, which means EventStateManager will
|
2013-09-24 10:04:15 +00:00
|
|
|
// select preferred scroll type automatically.
|
2016-03-31 15:46:18 +00:00
|
|
|
enum ScrollType : uint8_t {
|
2013-09-24 10:04:15 +00:00
|
|
|
SCROLL_DEFAULT,
|
|
|
|
SCROLL_SYNCHRONOUSLY,
|
2022-01-10 21:57:20 +00:00
|
|
|
SCROLL_ASYNCHRONOUSLY,
|
2013-09-24 10:04:15 +00:00
|
|
|
SCROLL_SMOOTHLY
|
|
|
|
};
|
2016-03-31 14:54:42 +00:00
|
|
|
ScrollType mScrollType;
|
2013-09-24 10:04:15 +00:00
|
|
|
|
2016-03-31 15:46:18 +00: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 10:04:15 +00:00
|
|
|
|
2013-10-11 19:48:53 +00: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 03:50:31 +00:00
|
|
|
// The wheel event can trigger a swipe to start if it's overscrolling the
|
|
|
|
// viewport.
|
|
|
|
bool mCanTriggerSwipe;
|
|
|
|
|
2016-01-27 06:09:13 +00: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 08:31:07 +00: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 16:12:35 +00:00
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
void AssignWheelEventData(const WidgetWheelEvent& aEvent, bool aCopyTargets) {
|
|
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
|
2016-03-31 09:55:59 +00:00
|
|
|
mDeltaX = aEvent.mDeltaX;
|
2016-03-31 09:09:47 +00:00
|
|
|
mDeltaY = aEvent.mDeltaY;
|
2016-03-31 09:18:34 +00:00
|
|
|
mDeltaZ = aEvent.mDeltaZ;
|
2016-03-31 09:35:24 +00:00
|
|
|
mDeltaMode = aEvent.mDeltaMode;
|
2021-03-08 00:24:04 +00:00
|
|
|
mScrollAmount = aEvent.mScrollAmount;
|
2016-03-31 09:44:01 +00:00
|
|
|
mCustomizedByUserPrefs = aEvent.mCustomizedByUserPrefs;
|
2016-03-31 14:36:49 +00:00
|
|
|
mMayHaveMomentum = aEvent.mMayHaveMomentum;
|
2016-03-31 14:45:55 +00:00
|
|
|
mIsMomentum = aEvent.mIsMomentum;
|
2014-07-07 09:54:14 +00:00
|
|
|
mIsNoLineOrPageDelta = aEvent.mIsNoLineOrPageDelta;
|
2016-03-31 15:10:46 +00:00
|
|
|
mLineOrPageDeltaX = aEvent.mLineOrPageDeltaX;
|
2016-03-31 15:10:09 +00:00
|
|
|
mLineOrPageDeltaY = aEvent.mLineOrPageDeltaY;
|
2016-03-31 14:54:42 +00:00
|
|
|
mScrollType = aEvent.mScrollType;
|
2016-03-31 15:27:45 +00:00
|
|
|
mOverflowDeltaX = aEvent.mOverflowDeltaX;
|
2016-03-31 15:36:55 +00:00
|
|
|
mOverflowDeltaY = aEvent.mOverflowDeltaY;
|
2013-10-11 19:48:53 +00:00
|
|
|
mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled;
|
2015-08-28 03:50:31 +00:00
|
|
|
mCanTriggerSwipe = aEvent.mCanTriggerSwipe;
|
2016-01-27 06:09:13 +00:00
|
|
|
mAllowToOverrideSystemScrollSpeed =
|
|
|
|
aEvent.mAllowToOverrideSystemScrollSpeed;
|
2018-03-15 08:31:07 +00:00
|
|
|
mDeltaValuesHorizontalizedForDefaultHandler =
|
|
|
|
aEvent.mDeltaValuesHorizontalizedForDefaultHandler;
|
2013-09-24 10:04:15 +00:00
|
|
|
}
|
2016-01-27 06:09:13 +00: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 06:09:13 +00: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 06:09:13 +00:00
|
|
|
private:
|
|
|
|
static bool sInitialized;
|
|
|
|
static bool sIsSystemScrollSpeedOverrideEnabled;
|
|
|
|
static int32_t sOverrideFactorX;
|
|
|
|
static int32_t sOverrideFactorY;
|
|
|
|
static void Initialize();
|
2013-09-24 10:04:15 +00:00
|
|
|
};
|
|
|
|
|
2013-11-21 05:44:22 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetPointerEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetPointerEvent : public WidgetMouseEvent {
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
2023-02-04 11:12:36 +00:00
|
|
|
ALLOW_DEPRECATED_READPARAM
|
2013-11-21 05:44:22 +00:00
|
|
|
|
2024-06-14 00:18:48 +00:00
|
|
|
WidgetPointerEvent() = default;
|
|
|
|
|
2013-11-21 05:44:22 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetPointerEvent* AsPointerEvent() override { return this; }
|
2013-11-21 05:44:22 +00:00
|
|
|
|
2023-08-09 10:29:39 +00:00
|
|
|
WidgetPointerEvent(bool aIsTrusted, EventMessage aMsg, nsIWidget* w,
|
2024-06-14 00:18:48 +00:00
|
|
|
const WidgetEventTime* aTime)
|
|
|
|
: WidgetMouseEvent(aIsTrusted, aMsg, w, ePointerEventClass, eReal,
|
|
|
|
eNormal, aTime) {
|
|
|
|
if (aMsg == eContextMenu) {
|
|
|
|
mButton = (mContextMenuTrigger == eNormal) ? MouseButton::eSecondary
|
|
|
|
: MouseButton::ePrimary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetPointerEvent(bool aIsTrusted, EventMessage aMsg, nsIWidget* w,
|
|
|
|
ContextMenuTrigger aContextMenuTrigger = eNormal,
|
2023-08-09 10:29:39 +00:00
|
|
|
const WidgetEventTime* aTime = nullptr)
|
2024-06-14 00:18:48 +00:00
|
|
|
: WidgetMouseEvent(aIsTrusted, aMsg, w, ePointerEventClass, eReal,
|
|
|
|
aContextMenuTrigger, aTime) {
|
|
|
|
if (aMsg == eContextMenu) {
|
|
|
|
mButton = (mContextMenuTrigger == eNormal) ? MouseButton::eSecondary
|
|
|
|
: MouseButton::ePrimary;
|
|
|
|
}
|
|
|
|
}
|
2013-11-21 05:44:22 +00:00
|
|
|
|
2014-08-07 23:46:08 +00:00
|
|
|
explicit WidgetPointerEvent(const WidgetMouseEvent& aEvent)
|
2024-06-14 00:18:48 +00:00
|
|
|
: WidgetMouseEvent(aEvent) {
|
2014-08-04 05:28:52 +00:00
|
|
|
mClass = ePointerEventClass;
|
2013-11-21 05:44:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 05:28:52 +00:00
|
|
|
MOZ_ASSERT(mClass == ePointerEventClass,
|
2014-01-27 06:10:44 +00:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2024-06-14 00:18:48 +00:00
|
|
|
WidgetPointerEvent* result = new WidgetPointerEvent(
|
|
|
|
false, mMessage, nullptr, mContextMenuTrigger, this);
|
2014-01-27 06:10:44 +00:00
|
|
|
result->AssignPointerEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-06-14 00:18:48 +00:00
|
|
|
int32_t mWidth = 1;
|
|
|
|
int32_t mHeight = 1;
|
|
|
|
bool mIsPrimary = true;
|
|
|
|
bool mFromTouchEvent = false;
|
2014-01-27 06:10:44 +00:00
|
|
|
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
|
|
void AssignPointerEventData(const WidgetPointerEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-08-03 08:18:04 +00:00
|
|
|
mWidth = aEvent.mWidth;
|
2016-08-03 08:23:56 +00:00
|
|
|
mHeight = aEvent.mHeight;
|
2016-08-03 08:34:53 +00:00
|
|
|
mIsPrimary = aEvent.mIsPrimary;
|
2021-04-13 13:14:12 +00:00
|
|
|
mFromTouchEvent = aEvent.mFromTouchEvent;
|
2014-01-27 06:10:44 +00:00
|
|
|
}
|
2013-11-21 05:44:22 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 10:04:15 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_MouseEvents_h__
|