mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
4ac9bef80d
- Bug 936092, initial DnD support for e10s, r=enndeakin,karlt (3cde556cf) - Bug 1152066 - Remove ugly dynamic loading code now that we can assume this symbol exists. r=roc (04813dd18) - Bug 966395 - Correctly propagate the input language's direction on OSX. r=masayuki/mrbkap (14a21fa0c) - Bug 1158791 - Try harder to avoid Gtk-Critical errors in xpcshell tests. r=karlt (f6cec3b99) - Bug 1153922 - Add a SandboxOptions option for creating the sandbox in a fresh JS::Zone. r=mrbkap (f99b17726) - Bug 968520 - Always use fallible allocator with nsTArray_base::ShrinkCapacity. r=froydnj (b7cf63063) - Bug 1160027 - Move ResourceQueue implementation from header file - r=cpearce (5fabd8c8f) - Bug 1119277 - Remove the process CPU priority parameter and simplify all the associated code. r=khuey, r=dhylands (32d2b0df2) - Goanna -> Gecko (2b16bec4c) - Bug 892371 - Adjust oom_score_adj values for foreground processes according to an LRU policy. r=dhylands, r=khuey (61cdfc3db) - Bug 892371 - Add mochitests covering LRU priority adjustments for both foreground and background processes. r=khuey (46676e34f) - Bug 1164297 - tweaks to logging modules of MediaDecoderStateMachine to remove accessing to env vars. r=cpearce. (e9dc910da) - Bug 1150539: log getUserMedia constraints used in MediaManager:5. r=jesup (161853b66) - Bug 1139027 - Permit running of camera mochitests on B2G desktop. r=mikeh (8bb265db2) - Bug 1145403 - Don't open MediaManager on shutdown. r=jesup (9338eef82) - Bug 1046245 - enumerateDevices w/non-blocking e10s, nsICryptoHMAC, clear cookies, lambdas. r=keeler, florian, billm, jesup (ce9d684a0) - remove StopWebRtcLoc() to be readded in Bug 1219339 - Part2 (7a0c901fc) - Bug 1046245 - IO on STS thread + cleanup BackgroundChild on shutdown r=jesup (e85dd7716) - Bug 579517 follow-up: Remove NSPR types that crept in (35aee15a6) - Bug 1152443 - Fix broken validation which prevented reading of enumerate_devices.txt. r=jesup (4e135355b) - Bug 1143562 - use /data/b2g/mozilla/gmp as the gmp storage folder on B2G. r=cpearce. (ddc07f09a) - Bug 1143562. Part2 - only init |mStorageBaseDir| in the chrome process. r=cpearce (3039a4f44) - remove specific hack, this code is going away anyway (34aed4d6b) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 0 - Make mozIGeckoMediaPluginService::GetPluginVersionForAPI return whether we even have the plugin. r=cpearce. (e6ac61630) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 1 - split GeckoMediaPluginService into a part for chrome and a part for both content and chrome. r=jwwang. (09f8c4a83) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 2 - support asynchronous GMP API getters. r=jwwang,rjesup. (e33266976) - Bug 1143532 - Include pid in the log messages of GMPParent. r=edwin (8486ebc50) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 3 - split the GMP IPDL actors in 2 parts (and use opens to open the second in non-e10s). r=billm. (d17fa36ff) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 4 - make GetNodeId asynchronous. r=jwwang. (db7a21e4a) - Bug 1150049 - tidy up nsImageBoxFrame::Init a little bit; r=dholbert (41c258a71) - Bug 1150266 - fix IPDL thinko for never-inline method declarations; r=bent (445d3420b) - Bug 1150207 - Convert a focus() call to use SpecialPowers to avoid out-of-order focusing behaviour. r=mwargers (4d134848c) - Bug 1148641 - Guard against null parameters to SendSetTargetAPZCNotification. r=botond (8c5f4bb6d) - Bug 1096172 - Fix position reporting of bad charrefs in RCDATA. r=hsivonen. (77100d26d) - Bug 1149971 Part 2: Cet rid of kCurrentProcessId as it makes lots of static initializers. r=dvander (3efaefdba) - remove android widgets (0c2565418) - Bug 1129991 - Remove QuotaManager::SetCurrentWindow(); r=bent (7ccabf88c) - Bug 1133748 - Fix ipdl code for bridged protocols that are also opened. r=billm. (402751d09) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 5 - use bridging for GMP in e10s. r=billm. (e45a87c5f) - Bug 1057908 followup: Add missing 'override' annotation on GMPServiceParent::ActorDestroy method decl. rs=ehsan (48f53b28a) - Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Add nsServiceManagerUtils.h include to WMFDecoderModule.cpp. (67cddb4da) - kill android widgets better (bec243c8d)
658 lines
19 KiB
C++
658 lines
19 KiB
C++
/* -*- 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"
|
|
#include "mozilla/dom/DataTransfer.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsIDOMMouseEvent.h"
|
|
#include "nsIDOMWheelEvent.h"
|
|
|
|
/******************************************************************************
|
|
* nsDragDropEventStatus
|
|
******************************************************************************/
|
|
|
|
enum nsDragDropEventStatus
|
|
{
|
|
// The event is a enter
|
|
nsDragDropEventStatus_eDragEntered,
|
|
// The event is exit
|
|
nsDragDropEventStatus_eDragExited,
|
|
// The event is drop
|
|
nsDragDropEventStatus_eDrop
|
|
};
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
class PBrowserParent;
|
|
class PBrowserChild;
|
|
} // namespace dom
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetPointerHelper
|
|
******************************************************************************/
|
|
|
|
class WidgetPointerHelper
|
|
{
|
|
public:
|
|
bool convertToPointer;
|
|
uint32_t pointerId;
|
|
uint32_t tiltX;
|
|
uint32_t tiltY;
|
|
bool retargetedByPointerCapture;
|
|
|
|
WidgetPointerHelper() : convertToPointer(true), pointerId(0), tiltX(0), tiltY(0),
|
|
retargetedByPointerCapture(false) {}
|
|
|
|
void AssignPointerHelperData(const WidgetPointerHelper& aEvent)
|
|
{
|
|
convertToPointer = aEvent.convertToPointer;
|
|
pointerId = aEvent.pointerId;
|
|
tiltX = aEvent.tiltX;
|
|
tiltY = aEvent.tiltY;
|
|
retargetedByPointerCapture = aEvent.retargetedByPointerCapture;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetMouseEventBase
|
|
******************************************************************************/
|
|
|
|
class WidgetMouseEventBase : public WidgetInputEvent
|
|
{
|
|
private:
|
|
friend class dom::PBrowserParent;
|
|
friend class dom::PBrowserChild;
|
|
|
|
protected:
|
|
WidgetMouseEventBase()
|
|
{
|
|
}
|
|
|
|
WidgetMouseEventBase(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
|
|
EventClassID aEventClassID)
|
|
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
|
|
, button(0)
|
|
, buttons(0)
|
|
, pressure(0)
|
|
, hitCluster(false)
|
|
, inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
|
|
{
|
|
}
|
|
|
|
public:
|
|
virtual WidgetMouseEventBase* AsMouseEventBase() override { return this; }
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_CRASH("WidgetMouseEventBase must not be most-subclass");
|
|
return nullptr;
|
|
}
|
|
|
|
/// The possible related target
|
|
nsCOMPtr<nsISupports> relatedTarget;
|
|
|
|
enum buttonType
|
|
{
|
|
eLeftButton = 0,
|
|
eMiddleButton = 1,
|
|
eRightButton = 2
|
|
};
|
|
// Pressed button ID of mousedown or mouseup event.
|
|
// This is set only when pressing a button causes the event.
|
|
int16_t button;
|
|
|
|
enum buttonsFlag {
|
|
eLeftButtonFlag = 0x01,
|
|
eRightButtonFlag = 0x02,
|
|
eMiddleButtonFlag = 0x04,
|
|
// typicall, "back" button being left side of 5-button
|
|
// mice, see "buttons" attribute document of DOM3 Events.
|
|
e4thButtonFlag = 0x08,
|
|
// typicall, "forward" button being right side of 5-button
|
|
// mice, see "buttons" attribute document of DOM3 Events.
|
|
e5thButtonFlag = 0x10
|
|
};
|
|
|
|
// Flags of all pressed buttons at the event fired.
|
|
// This is set at any mouse event, don't be confused with |button|.
|
|
int16_t buttons;
|
|
|
|
// Finger or touch pressure of event. It ranges between 0.0 and 1.0.
|
|
float pressure;
|
|
// Touch near a cluster of links (true)
|
|
bool hitCluster;
|
|
|
|
// Possible values at nsIDOMMouseEvent
|
|
uint16_t inputSource;
|
|
|
|
// ID of the canvas HitRegion
|
|
nsString region;
|
|
|
|
void AssignMouseEventBaseData(const WidgetMouseEventBase& aEvent,
|
|
bool aCopyTargets)
|
|
{
|
|
AssignInputEventData(aEvent, aCopyTargets);
|
|
|
|
relatedTarget = aCopyTargets ? aEvent.relatedTarget : nullptr;
|
|
button = aEvent.button;
|
|
buttons = aEvent.buttons;
|
|
pressure = aEvent.pressure;
|
|
hitCluster = aEvent.hitCluster;
|
|
inputSource = aEvent.inputSource;
|
|
}
|
|
|
|
/**
|
|
* Returns true if left click event.
|
|
*/
|
|
bool IsLeftClickEvent() const
|
|
{
|
|
return message == NS_MOUSE_CLICK && button == eLeftButton;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetMouseEvent
|
|
******************************************************************************/
|
|
|
|
class WidgetMouseEvent : public WidgetMouseEventBase, public WidgetPointerHelper
|
|
{
|
|
private:
|
|
friend class mozilla::dom::PBrowserParent;
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
public:
|
|
enum reasonType
|
|
{
|
|
eReal,
|
|
eSynthesized
|
|
};
|
|
|
|
enum contextType
|
|
{
|
|
eNormal,
|
|
eContextMenuKey
|
|
};
|
|
|
|
enum exitType
|
|
{
|
|
eChild,
|
|
eTopLevel
|
|
};
|
|
|
|
protected:
|
|
WidgetMouseEvent()
|
|
{
|
|
}
|
|
|
|
WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
|
|
EventClassID aEventClassID, reasonType aReason)
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID)
|
|
, acceptActivation(false)
|
|
, ignoreRootScrollFrame(false)
|
|
, reason(aReason)
|
|
, context(eNormal)
|
|
, exit(eChild)
|
|
, clickCount(0)
|
|
{
|
|
switch (aMessage) {
|
|
case NS_MOUSEENTER:
|
|
case NS_MOUSELEAVE:
|
|
mFlags.mBubbles = false;
|
|
mFlags.mCancelable = false;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public:
|
|
virtual WidgetMouseEvent* AsMouseEvent() override { return this; }
|
|
|
|
WidgetMouseEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
|
|
reasonType aReason, contextType aContext = eNormal) :
|
|
WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass),
|
|
acceptActivation(false), ignoreRootScrollFrame(false),
|
|
reason(aReason), context(aContext), exit(eChild), clickCount(0)
|
|
{
|
|
switch (aMessage) {
|
|
case NS_MOUSEENTER:
|
|
case NS_MOUSELEAVE:
|
|
mFlags.mBubbles = false;
|
|
mFlags.mCancelable = false;
|
|
break;
|
|
case NS_CONTEXTMENU:
|
|
button = (context == eNormal) ? eRightButton : eLeftButton;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
virtual ~WidgetMouseEvent()
|
|
{
|
|
NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
|
|
button ==
|
|
((context == eNormal) ? eRightButton : eLeftButton),
|
|
"Wrong button set to NS_CONTEXTMENU event?");
|
|
}
|
|
#endif
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_ASSERT(mClass == eMouseEventClass,
|
|
"Duplicate() must be overridden by sub class");
|
|
// Not copying widget, it is a weak reference.
|
|
WidgetMouseEvent* result =
|
|
new WidgetMouseEvent(false, message, nullptr, reason, context);
|
|
result->AssignMouseEventData(*this, true);
|
|
result->mFlags = mFlags;
|
|
return result;
|
|
}
|
|
|
|
// Special return code for MOUSE_ACTIVATE to signal.
|
|
// If the target accepts activation (1), or denies it (0).
|
|
bool acceptActivation;
|
|
// Whether the event should ignore scroll frame bounds during dispatch.
|
|
bool ignoreRootScrollFrame;
|
|
|
|
reasonType reason : 4;
|
|
contextType context : 4;
|
|
exitType exit;
|
|
|
|
/// The number of mouse clicks.
|
|
uint32_t clickCount;
|
|
|
|
void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets)
|
|
{
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
AssignPointerHelperData(aEvent);
|
|
|
|
acceptActivation = aEvent.acceptActivation;
|
|
ignoreRootScrollFrame = aEvent.ignoreRootScrollFrame;
|
|
clickCount = aEvent.clickCount;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the event is a context menu event caused by key.
|
|
*/
|
|
bool IsContextMenuKeyEvent() const
|
|
{
|
|
return message == NS_CONTEXTMENU && context == eContextMenuKey;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the event is a real mouse event. Otherwise, i.e., it's
|
|
* a synthesized event by scroll or something, returns false.
|
|
*/
|
|
bool IsReal() const
|
|
{
|
|
return reason == eReal;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetDragEvent
|
|
******************************************************************************/
|
|
|
|
class WidgetDragEvent : public WidgetMouseEvent
|
|
{
|
|
private:
|
|
friend class mozilla::dom::PBrowserParent;
|
|
friend class mozilla::dom::PBrowserChild;
|
|
protected:
|
|
WidgetDragEvent()
|
|
{
|
|
}
|
|
public:
|
|
virtual WidgetDragEvent* AsDragEvent() override { return this; }
|
|
|
|
WidgetDragEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
|
: WidgetMouseEvent(aIsTrusted, aMessage, aWidget, eDragEventClass, eReal)
|
|
, userCancelled(false)
|
|
, mDefaultPreventedOnContent(false)
|
|
{
|
|
mFlags.mCancelable =
|
|
(aMessage != NS_DRAGDROP_EXIT_SYNTH &&
|
|
aMessage != NS_DRAGDROP_LEAVE_SYNTH &&
|
|
aMessage != NS_DRAGDROP_END);
|
|
}
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_ASSERT(mClass == eDragEventClass,
|
|
"Duplicate() must be overridden by sub class");
|
|
// Not copying widget, it is a weak reference.
|
|
WidgetDragEvent* result = new WidgetDragEvent(false, message, nullptr);
|
|
result->AssignDragEventData(*this, true);
|
|
result->mFlags = mFlags;
|
|
return result;
|
|
}
|
|
|
|
// The dragging data.
|
|
nsCOMPtr<dom::DataTransfer> dataTransfer;
|
|
|
|
// If this is true, user has cancelled the drag operation.
|
|
bool userCancelled;
|
|
// If this is true, the drag event's preventDefault() is called on content.
|
|
bool mDefaultPreventedOnContent;
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
void AssignDragEventData(const WidgetDragEvent& aEvent, bool aCopyTargets)
|
|
{
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
dataTransfer = aEvent.dataTransfer;
|
|
// XXX userCancelled isn't copied, is this instentionally?
|
|
userCancelled = false;
|
|
mDefaultPreventedOnContent = aEvent.mDefaultPreventedOnContent;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* 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()
|
|
{
|
|
}
|
|
|
|
public:
|
|
virtual WidgetMouseScrollEvent* AsMouseScrollEvent() override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
WidgetMouseScrollEvent(bool aIsTrusted, uint32_t aMessage,
|
|
nsIWidget* aWidget)
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
|
|
eMouseScrollEventClass)
|
|
, delta(0)
|
|
, isHorizontal(false)
|
|
{
|
|
}
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_ASSERT(mClass == eMouseScrollEventClass,
|
|
"Duplicate() must be overridden by sub class");
|
|
// Not copying widget, it is a weak reference.
|
|
WidgetMouseScrollEvent* result =
|
|
new WidgetMouseScrollEvent(false, message, nullptr);
|
|
result->AssignMouseScrollEventData(*this, true);
|
|
result->mFlags = mFlags;
|
|
return result;
|
|
}
|
|
|
|
// The delta value of mouse scroll event.
|
|
// If the event message is NS_MOUSE_SCROLL, the value indicates scroll amount
|
|
// in lines. However, if the value is nsIDOMUIEvent::SCROLL_PAGE_UP or
|
|
// nsIDOMUIEvent::SCROLL_PAGE_DOWN, the value inducates one page scroll.
|
|
// If the event message is NS_MOUSE_PIXEL_SCROLL, the value indicates scroll
|
|
// amount in pixels.
|
|
int32_t delta;
|
|
|
|
// If this is true, it may cause to scroll horizontally.
|
|
// Otherwise, vertically.
|
|
bool isHorizontal;
|
|
|
|
void AssignMouseScrollEventData(const WidgetMouseScrollEvent& aEvent,
|
|
bool aCopyTargets)
|
|
{
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
delta = aEvent.delta;
|
|
isHorizontal = aEvent.isHorizontal;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetWheelEvent
|
|
******************************************************************************/
|
|
|
|
class WidgetWheelEvent : public WidgetMouseEventBase
|
|
{
|
|
private:
|
|
friend class mozilla::dom::PBrowserParent;
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
WidgetWheelEvent()
|
|
{
|
|
}
|
|
|
|
public:
|
|
virtual WidgetWheelEvent* AsWheelEvent() override { return this; }
|
|
|
|
WidgetWheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
|
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eWheelEventClass)
|
|
, deltaX(0.0)
|
|
, deltaY(0.0)
|
|
, deltaZ(0.0)
|
|
, deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL)
|
|
, customizedByUserPrefs(false)
|
|
, isMomentum(false)
|
|
, mIsNoLineOrPageDelta(false)
|
|
, lineOrPageDeltaX(0)
|
|
, lineOrPageDeltaY(0)
|
|
, scrollType(SCROLL_DEFAULT)
|
|
, overflowDeltaX(0.0)
|
|
, overflowDeltaY(0.0)
|
|
, mViewPortIsOverscrolled(false)
|
|
{
|
|
}
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_ASSERT(mClass == eWheelEventClass,
|
|
"Duplicate() must be overridden by sub class");
|
|
// Not copying widget, it is a weak reference.
|
|
WidgetWheelEvent* result = new WidgetWheelEvent(false, message, nullptr);
|
|
result->AssignWheelEventData(*this, true);
|
|
result->mFlags = mFlags;
|
|
return result;
|
|
}
|
|
|
|
// NOTE: deltaX, deltaY and deltaZ may be customized by
|
|
// mousewheel.*.delta_multiplier_* prefs which are applied by
|
|
// EventStateManager. So, after widget dispatches this event,
|
|
// these delta values may have different values than before.
|
|
double deltaX;
|
|
double deltaY;
|
|
double deltaZ;
|
|
|
|
// Should be one of nsIDOMWheelEvent::DOM_DELTA_*
|
|
uint32_t deltaMode;
|
|
|
|
// Following members are for internal use only, not for DOM event.
|
|
|
|
// If the delta values are computed from prefs, this value is true.
|
|
// Otherwise, i.e., they are computed from native events, false.
|
|
bool customizedByUserPrefs;
|
|
|
|
// true if the event is caused by momentum.
|
|
bool isMomentum;
|
|
|
|
// If device event handlers don't know when they should set lineOrPageDeltaX
|
|
// and lineOrPageDeltaY, this is true. Otherwise, false.
|
|
// If mIsNoLineOrPageDelta is true, ESM will generate NS_MOUSE_SCROLL events
|
|
// when accumulated delta values reach a line height.
|
|
bool mIsNoLineOrPageDelta;
|
|
|
|
// If widget sets lineOrPageDelta, EventStateManager will dispatch
|
|
// NS_MOUSE_SCROLL event for compatibility. Note that the delta value means
|
|
// pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines.
|
|
int32_t lineOrPageDeltaX;
|
|
int32_t lineOrPageDeltaY;
|
|
|
|
// 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()
|
|
{
|
|
if (!lineOrPageDeltaX && !lineOrPageDeltaY) {
|
|
return 0;
|
|
}
|
|
if (lineOrPageDeltaY && !lineOrPageDeltaX) {
|
|
return lineOrPageDeltaY;
|
|
}
|
|
if (lineOrPageDeltaX && !lineOrPageDeltaY) {
|
|
return lineOrPageDeltaX;
|
|
}
|
|
if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
|
|
(lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
|
|
return 0; // We cannot guess the answer in this case.
|
|
}
|
|
return (Abs(lineOrPageDeltaX) > Abs(lineOrPageDeltaY)) ?
|
|
lineOrPageDeltaX : lineOrPageDeltaY;
|
|
}
|
|
|
|
// Scroll type
|
|
// The default value is SCROLL_DEFAULT, which means EventStateManager will
|
|
// select preferred scroll type automatically.
|
|
enum ScrollType
|
|
{
|
|
SCROLL_DEFAULT,
|
|
SCROLL_SYNCHRONOUSLY,
|
|
SCROLL_ASYNCHRONOUSELY,
|
|
SCROLL_SMOOTHLY
|
|
};
|
|
ScrollType scrollType;
|
|
|
|
// overflowed delta values for scroll, these values are set by
|
|
// nsEventStateManger. If the default action of the wheel event isn't scroll,
|
|
// these values always zero. Otherwise, remaning delta values which are
|
|
// not used by scroll are set.
|
|
// NOTE: deltaX, deltaY and deltaZ may be modified by EventStateManager.
|
|
// However, overflowDeltaX and overflowDeltaY 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 deltaX and deltaY.
|
|
double overflowDeltaX;
|
|
double overflowDeltaY;
|
|
|
|
// 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;
|
|
|
|
void AssignWheelEventData(const WidgetWheelEvent& aEvent, bool aCopyTargets)
|
|
{
|
|
AssignMouseEventBaseData(aEvent, aCopyTargets);
|
|
|
|
deltaX = aEvent.deltaX;
|
|
deltaY = aEvent.deltaY;
|
|
deltaZ = aEvent.deltaZ;
|
|
deltaMode = aEvent.deltaMode;
|
|
customizedByUserPrefs = aEvent.customizedByUserPrefs;
|
|
isMomentum = aEvent.isMomentum;
|
|
mIsNoLineOrPageDelta = aEvent.mIsNoLineOrPageDelta;
|
|
lineOrPageDeltaX = aEvent.lineOrPageDeltaX;
|
|
lineOrPageDeltaY = aEvent.lineOrPageDeltaY;
|
|
scrollType = aEvent.scrollType;
|
|
overflowDeltaX = aEvent.overflowDeltaX;
|
|
overflowDeltaY = aEvent.overflowDeltaY;
|
|
mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled;
|
|
}
|
|
};
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetPointerEvent
|
|
******************************************************************************/
|
|
|
|
class WidgetPointerEvent : public WidgetMouseEvent
|
|
{
|
|
friend class mozilla::dom::PBrowserParent;
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
WidgetPointerEvent()
|
|
{
|
|
}
|
|
|
|
public:
|
|
virtual WidgetPointerEvent* AsPointerEvent() override { return this; }
|
|
|
|
WidgetPointerEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget* w)
|
|
: WidgetMouseEvent(aIsTrusted, aMsg, w, ePointerEventClass, eReal)
|
|
, width(0)
|
|
, height(0)
|
|
, isPrimary(true)
|
|
{
|
|
UpdateFlags();
|
|
}
|
|
|
|
explicit WidgetPointerEvent(const WidgetMouseEvent& aEvent)
|
|
: WidgetMouseEvent(aEvent)
|
|
, width(0)
|
|
, height(0)
|
|
, isPrimary(true)
|
|
{
|
|
mClass = ePointerEventClass;
|
|
UpdateFlags();
|
|
}
|
|
|
|
void UpdateFlags()
|
|
{
|
|
switch (message) {
|
|
case NS_POINTER_ENTER:
|
|
case NS_POINTER_LEAVE:
|
|
mFlags.mBubbles = false;
|
|
mFlags.mCancelable = false;
|
|
break;
|
|
case NS_POINTER_CANCEL:
|
|
case NS_POINTER_GOT_CAPTURE:
|
|
case NS_POINTER_LOST_CAPTURE:
|
|
mFlags.mCancelable = false;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
virtual WidgetEvent* Duplicate() const override
|
|
{
|
|
MOZ_ASSERT(mClass == ePointerEventClass,
|
|
"Duplicate() must be overridden by sub class");
|
|
// Not copying widget, it is a weak reference.
|
|
WidgetPointerEvent* result =
|
|
new WidgetPointerEvent(false, message, nullptr);
|
|
result->AssignPointerEventData(*this, true);
|
|
result->mFlags = mFlags;
|
|
return result;
|
|
}
|
|
|
|
uint32_t width;
|
|
uint32_t height;
|
|
bool isPrimary;
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
void AssignPointerEventData(const WidgetPointerEvent& aEvent,
|
|
bool aCopyTargets)
|
|
{
|
|
AssignMouseEventData(aEvent, aCopyTargets);
|
|
|
|
width = aEvent.width;
|
|
height = aEvent.height;
|
|
isPrimary = aEvent.isPrimary;
|
|
}
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_MouseEvents_h__
|