2013-01-24 03:30:48 +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/. */
|
|
|
|
|
|
|
|
#include "InputData.h"
|
|
|
|
|
2018-03-20 07:16:06 +03:00
|
|
|
#include "mozilla/dom/MouseEventBinding.h"
|
2013-04-05 12:49:00 +04:00
|
|
|
#include "mozilla/dom/Touch.h"
|
2018-03-20 07:16:05 +03:00
|
|
|
#include "mozilla/dom/WheelEventBinding.h"
|
2017-10-12 19:03:35 +03:00
|
|
|
#include "mozilla/TextEvents.h"
|
2017-07-31 12:30:38 +03:00
|
|
|
#include "nsContentUtils.h"
|
2013-01-24 03:30:48 +04:00
|
|
|
#include "nsDebug.h"
|
2013-05-18 00:17:53 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2015-01-09 21:39:08 +03:00
|
|
|
#include "UnitTransforms.h"
|
2013-01-24 03:30:48 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-04-05 12:49:00 +04:00
|
|
|
using namespace dom;
|
|
|
|
|
2016-09-14 14:54:36 +03:00
|
|
|
InputData::~InputData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
InputData::InputData(InputType aInputType)
|
|
|
|
: mInputType(aInputType)
|
|
|
|
, mTime(0)
|
2017-06-06 03:45:31 +03:00
|
|
|
, mFocusSequenceNumber(0)
|
2016-09-12 16:47:01 +03:00
|
|
|
, modifiers(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
InputData::InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: mInputType(aInputType)
|
|
|
|
, mTime(aTime)
|
|
|
|
, mTimeStamp(aTimeStamp)
|
2017-06-06 03:45:31 +03:00
|
|
|
, mFocusSequenceNumber(0)
|
2016-09-12 16:47:01 +03:00
|
|
|
, modifiers(aModifiers)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SingleTouchData::SingleTouchData(int32_t aIdentifier, ScreenIntPoint aScreenPoint,
|
|
|
|
ScreenSize aRadius, float aRotationAngle,
|
|
|
|
float aForce)
|
|
|
|
: mIdentifier(aIdentifier)
|
|
|
|
, mScreenPoint(aScreenPoint)
|
|
|
|
, mRadius(aRadius)
|
|
|
|
, mRotationAngle(aRotationAngle)
|
|
|
|
, mForce(aForce)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SingleTouchData::SingleTouchData(int32_t aIdentifier,
|
|
|
|
ParentLayerPoint aLocalScreenPoint,
|
|
|
|
ScreenSize aRadius, float aRotationAngle,
|
|
|
|
float aForce)
|
|
|
|
: mIdentifier(aIdentifier)
|
|
|
|
, mLocalScreenPoint(aLocalScreenPoint)
|
|
|
|
, mRadius(aRadius)
|
|
|
|
, mRotationAngle(aRotationAngle)
|
|
|
|
, mForce(aForce)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SingleTouchData::SingleTouchData()
|
2018-06-15 17:48:51 +03:00
|
|
|
: mIdentifier(0)
|
|
|
|
, mRotationAngle(0.0)
|
|
|
|
, mForce(0.0)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-09 02:15:37 +04:00
|
|
|
already_AddRefed<Touch> SingleTouchData::ToNewDOMTouch() const
|
2014-06-26 04:11:20 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only create dom::Touch instances on main thread");
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Touch> touch = new Touch(mIdentifier,
|
2016-07-26 17:48:30 +03:00
|
|
|
LayoutDeviceIntPoint::Truncate(mScreenPoint.x, mScreenPoint.y),
|
|
|
|
LayoutDeviceIntPoint::Truncate(mRadius.width, mRadius.height),
|
2015-11-10 08:37:31 +03:00
|
|
|
mRotationAngle,
|
|
|
|
mForce);
|
2014-06-26 04:11:20 +04:00
|
|
|
return touch.forget();
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
MultiTouchInput::MultiTouchInput(MultiTouchType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp, Modifiers aModifiers)
|
|
|
|
: InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mHandledByAPZ(false)
|
2015-09-28 17:32:05 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
MultiTouchInput::MultiTouchInput()
|
|
|
|
: InputData(MULTITOUCH_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mType(MULTITOUCH_START)
|
2016-09-12 16:47:01 +03:00
|
|
|
, mHandledByAPZ(false)
|
2015-09-28 21:44:37 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
MultiTouchInput::MultiTouchInput(const MultiTouchInput& aOther)
|
|
|
|
: InputData(MULTITOUCH_INPUT, aOther.mTime, aOther.mTimeStamp, aOther.modifiers)
|
|
|
|
, mType(aOther.mType)
|
|
|
|
, mHandledByAPZ(aOther.mHandledByAPZ)
|
2016-02-18 00:56:28 +03:00
|
|
|
{
|
2016-09-12 16:47:01 +03:00
|
|
|
mTouches.AppendElements(aOther.mTouches);
|
2016-02-18 00:56:28 +03:00
|
|
|
}
|
|
|
|
|
2013-09-27 10:20:57 +04:00
|
|
|
MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
|
2018-04-13 16:01:28 +03:00
|
|
|
: InputData(MULTITOUCH_INPUT, aTouchEvent.mTime, aTouchEvent.mTimeStamp,
|
2016-03-31 11:03:00 +03:00
|
|
|
aTouchEvent.mModifiers)
|
2015-10-28 19:53:34 +03:00
|
|
|
, mHandledByAPZ(aTouchEvent.mFlags.mHandledByAPZ)
|
2013-01-24 03:30:48 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only copy from WidgetTouchEvent on main thread");
|
2013-01-24 03:30:48 +04:00
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aTouchEvent.mMessage) {
|
2015-09-14 18:14:34 +03:00
|
|
|
case eTouchStart:
|
2013-01-24 03:30:48 +04:00
|
|
|
mType = MULTITOUCH_START;
|
|
|
|
break;
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchMove:
|
2013-01-24 03:30:48 +04:00
|
|
|
mType = MULTITOUCH_MOVE;
|
|
|
|
break;
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchEnd:
|
2013-01-24 03:30:48 +04:00
|
|
|
mType = MULTITOUCH_END;
|
|
|
|
break;
|
2015-09-14 18:14:35 +03:00
|
|
|
case eTouchCancel:
|
2013-01-24 03:30:48 +04:00
|
|
|
mType = MULTITOUCH_CANCEL;
|
|
|
|
break;
|
|
|
|
default:
|
2014-08-09 02:15:37 +04:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Did not assign a type to a MultiTouchInput");
|
2013-01-24 03:30:48 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-30 12:44:28 +03:00
|
|
|
for (size_t i = 0; i < aTouchEvent.mTouches.Length(); i++) {
|
|
|
|
const Touch* domTouch = aTouchEvent.mTouches[i];
|
2013-01-24 03:30:48 +04:00
|
|
|
|
|
|
|
// Extract data from weird interfaces.
|
2013-08-02 11:06:35 +04:00
|
|
|
int32_t identifier = domTouch->Identifier();
|
2017-07-31 12:30:38 +03:00
|
|
|
int32_t radiusX = domTouch->RadiusX(CallerType::System);
|
|
|
|
int32_t radiusY = domTouch->RadiusY(CallerType::System);
|
|
|
|
float rotationAngle = domTouch->RotationAngle(CallerType::System);
|
|
|
|
float force = domTouch->Force(CallerType::System);
|
2013-01-24 03:30:48 +04:00
|
|
|
|
|
|
|
SingleTouchData data(identifier,
|
2015-11-19 03:32:37 +03:00
|
|
|
ViewAs<ScreenPixel>(domTouch->mRefPoint,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent),
|
2013-06-12 02:13:11 +04:00
|
|
|
ScreenSize(radiusX, radiusY),
|
2013-01-24 03:30:48 +04:00
|
|
|
rotationAngle,
|
|
|
|
force);
|
|
|
|
|
|
|
|
mTouches.AppendElement(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
MultiTouchInput::MultiTouchInput(const WidgetMouseEvent& aMouseEvent)
|
|
|
|
: InputData(MULTITOUCH_INPUT, aMouseEvent.mTime, aMouseEvent.mTimeStamp,
|
|
|
|
aMouseEvent.mModifiers)
|
|
|
|
, mHandledByAPZ(aMouseEvent.mFlags.mHandledByAPZ)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only copy from WidgetMouseEvent on main thread");
|
|
|
|
switch (aMouseEvent.mMessage) {
|
|
|
|
case eMouseDown:
|
|
|
|
mType = MULTITOUCH_START;
|
|
|
|
break;
|
|
|
|
case eMouseMove:
|
|
|
|
mType = MULTITOUCH_MOVE;
|
|
|
|
break;
|
|
|
|
case eMouseUp:
|
|
|
|
mType = MULTITOUCH_END;
|
|
|
|
break;
|
|
|
|
// The mouse pointer has been interrupted in an implementation-specific
|
|
|
|
// manner, such as a synchronous event or action cancelling the touch, or a
|
|
|
|
// touch point leaving the document window and going into a non-document
|
|
|
|
// area capable of handling user interactions.
|
|
|
|
case eMouseExitFromWidget:
|
|
|
|
mType = MULTITOUCH_CANCEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_WARNING("Did not assign a type to a MultiTouchInput");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mTouches.AppendElement(SingleTouchData(0,
|
|
|
|
ViewAs<ScreenPixel>(aMouseEvent.mRefPoint,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent),
|
|
|
|
ScreenSize(1, 1),
|
|
|
|
180.0f,
|
|
|
|
1.0f));
|
|
|
|
}
|
|
|
|
|
2017-04-06 01:42:50 +03:00
|
|
|
void
|
|
|
|
MultiTouchInput::Translate(const ScreenPoint& aTranslation)
|
|
|
|
{
|
|
|
|
const int32_t xTranslation = (int32_t)(aTranslation.x + 0.5f);
|
|
|
|
const int32_t yTranslation = (int32_t)(aTranslation.y + 0.5f);
|
|
|
|
|
|
|
|
for (auto iter = mTouches.begin(); iter != mTouches.end(); iter++) {
|
|
|
|
iter->mScreenPoint.MoveBy(xTranslation, yTranslation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 02:15:37 +04:00
|
|
|
WidgetTouchEvent
|
|
|
|
MultiTouchInput::ToWidgetTouchEvent(nsIWidget* aWidget) const
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only convert To WidgetTouchEvent on main thread");
|
2014-08-09 02:15:37 +04:00
|
|
|
|
2015-08-29 02:58:26 +03:00
|
|
|
EventMessage touchEventMessage = eVoidEvent;
|
2014-08-09 02:15:37 +04:00
|
|
|
switch (mType) {
|
|
|
|
case MULTITOUCH_START:
|
2015-09-14 18:14:34 +03:00
|
|
|
touchEventMessage = eTouchStart;
|
2014-08-09 02:15:37 +04:00
|
|
|
break;
|
|
|
|
case MULTITOUCH_MOVE:
|
2015-09-14 18:14:35 +03:00
|
|
|
touchEventMessage = eTouchMove;
|
2014-08-09 02:15:37 +04:00
|
|
|
break;
|
|
|
|
case MULTITOUCH_END:
|
2015-09-14 18:14:35 +03:00
|
|
|
touchEventMessage = eTouchEnd;
|
2014-08-09 02:15:37 +04:00
|
|
|
break;
|
|
|
|
case MULTITOUCH_CANCEL:
|
2015-09-14 18:14:35 +03:00
|
|
|
touchEventMessage = eTouchCancel;
|
2014-08-09 02:15:37 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Did not assign a type to WidgetTouchEvent in MultiTouchInput");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetTouchEvent event(true, touchEventMessage, aWidget);
|
2015-08-29 02:58:26 +03:00
|
|
|
if (touchEventMessage == eVoidEvent) {
|
2014-08-09 02:15:37 +04:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2016-03-31 11:03:00 +03:00
|
|
|
event.mModifiers = this->modifiers;
|
2016-03-28 07:29:42 +03:00
|
|
|
event.mTime = this->mTime;
|
2016-03-28 07:49:02 +03:00
|
|
|
event.mTimeStamp = this->mTimeStamp;
|
2015-10-28 19:53:34 +03:00
|
|
|
event.mFlags.mHandledByAPZ = mHandledByAPZ;
|
2017-06-06 03:45:31 +03:00
|
|
|
event.mFocusSequenceNumber = mFocusSequenceNumber;
|
2014-08-09 02:15:37 +04:00
|
|
|
|
|
|
|
for (size_t i = 0; i < mTouches.Length(); i++) {
|
2016-03-30 12:44:28 +03:00
|
|
|
*event.mTouches.AppendElement() = mTouches[i].ToNewDOMTouch();
|
2014-08-09 02:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2015-01-10 21:54:24 +03:00
|
|
|
WidgetMouseEvent
|
|
|
|
MultiTouchInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only convert To WidgetMouseEvent on main thread");
|
2015-01-10 21:54:24 +03:00
|
|
|
|
2015-08-29 02:58:26 +03:00
|
|
|
EventMessage mouseEventMessage = eVoidEvent;
|
2015-01-10 21:54:24 +03:00
|
|
|
switch (mType) {
|
|
|
|
case MultiTouchInput::MULTITOUCH_START:
|
2015-08-29 02:58:30 +03:00
|
|
|
mouseEventMessage = eMouseDown;
|
2015-01-10 21:54:24 +03:00
|
|
|
break;
|
|
|
|
case MultiTouchInput::MULTITOUCH_MOVE:
|
2015-08-29 02:58:29 +03:00
|
|
|
mouseEventMessage = eMouseMove;
|
2015-01-10 21:54:24 +03:00
|
|
|
break;
|
|
|
|
case MultiTouchInput::MULTITOUCH_CANCEL:
|
|
|
|
case MultiTouchInput::MULTITOUCH_END:
|
2015-08-29 02:58:30 +03:00
|
|
|
mouseEventMessage = eMouseUp;
|
2015-01-10 21:54:24 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Did not assign a type to WidgetMouseEvent");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetMouseEvent event(true, mouseEventMessage, aWidget,
|
2015-01-10 21:54:24 +03:00
|
|
|
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
|
|
|
|
|
|
|
|
const SingleTouchData& firstTouch = mTouches[0];
|
2016-04-18 17:09:02 +03:00
|
|
|
event.mRefPoint.x = firstTouch.mScreenPoint.x;
|
|
|
|
event.mRefPoint.y = firstTouch.mScreenPoint.y;
|
2015-01-10 21:54:24 +03:00
|
|
|
|
2016-03-28 07:29:42 +03:00
|
|
|
event.mTime = mTime;
|
2015-01-10 21:54:24 +03:00
|
|
|
event.button = WidgetMouseEvent::eLeftButton;
|
2018-06-26 00:20:54 +03:00
|
|
|
event.inputSource = MouseEvent_Binding::MOZ_SOURCE_TOUCH;
|
2016-03-31 11:03:00 +03:00
|
|
|
event.mModifiers = modifiers;
|
2015-10-28 19:53:34 +03:00
|
|
|
event.mFlags.mHandledByAPZ = mHandledByAPZ;
|
2017-06-06 03:45:31 +03:00
|
|
|
event.mFocusSequenceNumber = mFocusSequenceNumber;
|
2015-01-10 21:54:24 +03:00
|
|
|
|
2015-08-29 02:58:29 +03:00
|
|
|
if (mouseEventMessage != eMouseMove) {
|
2016-05-10 17:29:14 +03:00
|
|
|
event.mClickCount = 1;
|
2015-01-10 21:54:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2015-01-20 02:38:00 +03:00
|
|
|
int32_t
|
|
|
|
MultiTouchInput::IndexOfTouch(int32_t aTouchIdentifier)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < mTouches.Length(); i++) {
|
|
|
|
if (mTouches[i].mIdentifier == aTouchIdentifier) {
|
|
|
|
return (int32_t)i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
bool
|
|
|
|
MultiTouchInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < mTouches.Length(); i++) {
|
|
|
|
Maybe<ParentLayerIntPoint> point = UntransformBy(aTransform, mTouches[i].mScreenPoint);
|
2018-04-13 16:01:28 +03:00
|
|
|
if (!point) {
|
2016-09-12 16:47:01 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mTouches[i].mLocalScreenPoint = *point;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseInput::MouseInput()
|
|
|
|
: InputData(MOUSE_INPUT)
|
|
|
|
, mType(MOUSE_NONE)
|
|
|
|
, mButtonType(NONE)
|
|
|
|
, mInputSource(0)
|
|
|
|
, mButtons(0)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseInput::MouseInput(MouseType aType, ButtonType aButtonType,
|
|
|
|
uint16_t aInputSource, int16_t aButtons,
|
|
|
|
const ScreenPoint& aPoint, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp, Modifiers aModifiers)
|
|
|
|
: InputData(MOUSE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mButtonType(aButtonType)
|
|
|
|
, mInputSource(aInputSource)
|
|
|
|
, mButtons(aButtons)
|
|
|
|
, mOrigin(aPoint)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseInput::MouseInput(const WidgetMouseEventBase& aMouseEvent)
|
|
|
|
: InputData(MOUSE_INPUT, aMouseEvent.mTime, aMouseEvent.mTimeStamp,
|
2016-03-31 11:03:00 +03:00
|
|
|
aMouseEvent.mModifiers)
|
2016-09-12 16:47:01 +03:00
|
|
|
, mType(MOUSE_NONE)
|
|
|
|
, mButtonType(NONE)
|
|
|
|
, mInputSource(aMouseEvent.inputSource)
|
|
|
|
, mButtons(aMouseEvent.buttons)
|
2015-10-28 19:53:34 +03:00
|
|
|
, mHandledByAPZ(aMouseEvent.mFlags.mHandledByAPZ)
|
2013-01-24 03:30:48 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
2016-09-12 16:47:01 +03:00
|
|
|
"Can only copy from WidgetTouchEvent on main thread");
|
|
|
|
|
|
|
|
mButtonType = NONE;
|
|
|
|
|
|
|
|
switch (aMouseEvent.button) {
|
|
|
|
case WidgetMouseEventBase::eLeftButton:
|
|
|
|
mButtonType = MouseInput::LEFT_BUTTON;
|
|
|
|
break;
|
|
|
|
case WidgetMouseEventBase::eMiddleButton:
|
|
|
|
mButtonType = MouseInput::MIDDLE_BUTTON;
|
|
|
|
break;
|
|
|
|
case WidgetMouseEventBase::eRightButton:
|
|
|
|
mButtonType = MouseInput::RIGHT_BUTTON;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aMouseEvent.mMessage) {
|
2016-09-12 16:47:01 +03:00
|
|
|
case eMouseMove:
|
|
|
|
mType = MOUSE_MOVE;
|
|
|
|
break;
|
|
|
|
case eMouseUp:
|
|
|
|
mType = MOUSE_UP;
|
|
|
|
break;
|
|
|
|
case eMouseDown:
|
|
|
|
mType = MOUSE_DOWN;
|
|
|
|
break;
|
|
|
|
case eDragStart:
|
|
|
|
mType = MOUSE_DRAG_START;
|
|
|
|
break;
|
|
|
|
case eDragEnd:
|
|
|
|
mType = MOUSE_DRAG_END;
|
|
|
|
break;
|
|
|
|
case eMouseEnterIntoWidget:
|
|
|
|
mType = MOUSE_WIDGET_ENTER;
|
|
|
|
break;
|
|
|
|
case eMouseExitFromWidget:
|
|
|
|
mType = MOUSE_WIDGET_EXIT;
|
|
|
|
break;
|
2017-11-30 07:16:26 +03:00
|
|
|
case eMouseHitTest:
|
|
|
|
mType = MOUSE_HITTEST;
|
|
|
|
break;
|
2016-09-12 16:47:01 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Mouse event type not supported");
|
|
|
|
break;
|
2013-01-24 03:30:48 +04:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
mOrigin =
|
|
|
|
ScreenPoint(ViewAs<ScreenPixel>(aMouseEvent.mRefPoint,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
|
2013-01-24 03:30:48 +04:00
|
|
|
}
|
2015-01-09 21:39:08 +03:00
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
bool
|
2016-09-12 16:47:01 +03:00
|
|
|
MouseInput::IsLeftButton() const
|
2015-01-09 21:39:08 +03:00
|
|
|
{
|
2016-09-12 16:47:01 +03:00
|
|
|
return mButtonType == LEFT_BUTTON;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MouseInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
|
|
|
{
|
|
|
|
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mOrigin);
|
|
|
|
if (!point) {
|
|
|
|
return false;
|
2015-01-09 21:39:08 +03:00
|
|
|
}
|
2016-09-12 16:47:01 +03:00
|
|
|
mLocalOrigin = *point;
|
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
return true;
|
2013-01-24 03:30:48 +04:00
|
|
|
}
|
2015-01-09 21:39:08 +03:00
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
WidgetMouseEvent
|
|
|
|
MouseInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(),
|
|
|
|
"Can only convert To WidgetTouchEvent on main thread");
|
|
|
|
|
|
|
|
EventMessage msg = eVoidEvent;
|
|
|
|
uint32_t clickCount = 0;
|
|
|
|
switch (mType) {
|
|
|
|
case MOUSE_MOVE:
|
|
|
|
msg = eMouseMove;
|
|
|
|
break;
|
|
|
|
case MOUSE_UP:
|
|
|
|
msg = eMouseUp;
|
|
|
|
clickCount = 1;
|
|
|
|
break;
|
|
|
|
case MOUSE_DOWN:
|
|
|
|
msg = eMouseDown;
|
|
|
|
clickCount = 1;
|
|
|
|
break;
|
|
|
|
case MOUSE_DRAG_START:
|
|
|
|
msg = eDragStart;
|
|
|
|
break;
|
|
|
|
case MOUSE_DRAG_END:
|
|
|
|
msg = eDragEnd;
|
|
|
|
break;
|
|
|
|
case MOUSE_WIDGET_ENTER:
|
|
|
|
msg = eMouseEnterIntoWidget;
|
|
|
|
break;
|
|
|
|
case MOUSE_WIDGET_EXIT:
|
|
|
|
msg = eMouseExitFromWidget;
|
|
|
|
break;
|
2017-11-30 07:16:26 +03:00
|
|
|
case MOUSE_HITTEST:
|
|
|
|
msg = eMouseHitTest;
|
|
|
|
break;
|
2016-09-12 16:47:01 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Did not assign a type to WidgetMouseEvent in MouseInput");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetMouseEvent event(true, msg, aWidget, WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
|
|
|
|
|
|
|
|
if (msg == eVoidEvent) {
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mButtonType) {
|
|
|
|
case MouseInput::LEFT_BUTTON:
|
|
|
|
event.button = WidgetMouseEventBase::eLeftButton;
|
|
|
|
break;
|
|
|
|
case MouseInput::MIDDLE_BUTTON:
|
|
|
|
event.button = WidgetMouseEventBase::eMiddleButton;
|
|
|
|
break;
|
|
|
|
case MouseInput::RIGHT_BUTTON:
|
|
|
|
event.button = WidgetMouseEventBase::eRightButton;
|
|
|
|
break;
|
|
|
|
case MouseInput::NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.buttons = mButtons;
|
|
|
|
event.mModifiers = modifiers;
|
|
|
|
event.mTime = mTime;
|
|
|
|
event.mTimeStamp = mTimeStamp;
|
|
|
|
event.mFlags.mHandledByAPZ = mHandledByAPZ;
|
|
|
|
event.mRefPoint =
|
|
|
|
RoundedToInt(ViewAs<LayoutDevicePixel>(mOrigin,
|
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
|
|
|
|
event.mClickCount = clickCount;
|
|
|
|
event.inputSource = mInputSource;
|
|
|
|
event.mIgnoreRootScrollFrame = true;
|
2017-06-06 03:45:31 +03:00
|
|
|
event.mFocusSequenceNumber = mFocusSequenceNumber;
|
2016-09-12 16:47:01 +03:00
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
PanGestureInput::PanGestureInput()
|
|
|
|
: InputData(PANGESTURE_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mType(PANGESTURE_MAYSTART)
|
2016-09-12 16:47:01 +03:00
|
|
|
, mLineOrPageDeltaX(0)
|
|
|
|
, mLineOrPageDeltaY(0)
|
|
|
|
, mUserDeltaMultiplierX(1.0)
|
|
|
|
, mUserDeltaMultiplierY(1.0)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
, mFollowedByMomentum(false)
|
|
|
|
, mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false)
|
2017-10-24 01:27:24 +03:00
|
|
|
, mOverscrollBehaviorAllowsSwipe(false)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ScreenPoint& aPanStartPoint,
|
|
|
|
const ScreenPoint& aPanDisplacement,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(PANGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mPanStartPoint(aPanStartPoint)
|
|
|
|
, mPanDisplacement(aPanDisplacement)
|
|
|
|
, mLineOrPageDeltaX(0)
|
|
|
|
, mLineOrPageDeltaY(0)
|
|
|
|
, mUserDeltaMultiplierX(1.0)
|
|
|
|
, mUserDeltaMultiplierY(1.0)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
, mFollowedByMomentum(false)
|
|
|
|
, mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false)
|
2017-10-24 01:27:24 +03:00
|
|
|
, mOverscrollBehaviorAllowsSwipe(false)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-26 06:21:41 +03:00
|
|
|
bool
|
|
|
|
PanGestureInput::IsMomentum() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case PanGestureInput::PANGESTURE_MOMENTUMSTART:
|
|
|
|
case PanGestureInput::PANGESTURE_MOMENTUMPAN:
|
|
|
|
case PanGestureInput::PANGESTURE_MOMENTUMEND:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetWheelEvent
|
|
|
|
PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
|
|
|
|
{
|
2015-09-10 19:59:54 +03:00
|
|
|
WidgetWheelEvent wheelEvent(true, eWheel, aWidget);
|
2016-03-31 11:03:00 +03:00
|
|
|
wheelEvent.mModifiers = this->modifiers;
|
2016-03-28 07:29:42 +03:00
|
|
|
wheelEvent.mTime = mTime;
|
2016-03-28 07:49:02 +03:00
|
|
|
wheelEvent.mTimeStamp = mTimeStamp;
|
2016-04-18 17:09:02 +03:00
|
|
|
wheelEvent.mRefPoint =
|
2015-08-26 06:21:41 +03:00
|
|
|
RoundedToInt(ViewAs<LayoutDevicePixel>(mPanStartPoint,
|
2015-11-19 03:32:37 +03:00
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
|
2015-08-26 06:21:41 +03:00
|
|
|
wheelEvent.buttons = 0;
|
2018-06-26 00:20:54 +03:00
|
|
|
wheelEvent.mDeltaMode = WheelEvent_Binding::DOM_DELTA_PIXEL;
|
2016-03-31 17:36:49 +03:00
|
|
|
wheelEvent.mMayHaveMomentum = true; // pan inputs may have momentum
|
2016-03-31 17:45:55 +03:00
|
|
|
wheelEvent.mIsMomentum = IsMomentum();
|
2016-03-31 18:10:46 +03:00
|
|
|
wheelEvent.mLineOrPageDeltaX = mLineOrPageDeltaX;
|
2016-03-31 18:10:09 +03:00
|
|
|
wheelEvent.mLineOrPageDeltaY = mLineOrPageDeltaY;
|
2016-03-31 12:55:59 +03:00
|
|
|
wheelEvent.mDeltaX = mPanDisplacement.x;
|
2016-03-31 12:09:47 +03:00
|
|
|
wheelEvent.mDeltaY = mPanDisplacement.y;
|
2015-08-12 01:04:55 +03:00
|
|
|
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
|
2017-06-06 03:45:31 +03:00
|
|
|
wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber;
|
2015-08-26 06:21:41 +03:00
|
|
|
return wheelEvent;
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
bool
|
2015-12-01 04:14:31 +03:00
|
|
|
PanGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
2018-04-13 16:01:28 +03:00
|
|
|
{
|
2015-12-01 04:06:45 +03:00
|
|
|
Maybe<ParentLayerPoint> panStartPoint = UntransformBy(aTransform, mPanStartPoint);
|
2015-07-03 22:06:26 +03:00
|
|
|
if (!panStartPoint) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLocalPanStartPoint = *panStartPoint;
|
2018-04-13 16:01:28 +03:00
|
|
|
|
2015-12-01 04:06:45 +03:00
|
|
|
Maybe<ParentLayerPoint> panDisplacement = UntransformVector(aTransform, mPanDisplacement, mPanStartPoint);
|
2015-07-03 22:06:26 +03:00
|
|
|
if (!panDisplacement) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLocalPanDisplacement = *panDisplacement;
|
|
|
|
return true;
|
2015-01-09 21:39:08 +03:00
|
|
|
}
|
|
|
|
|
2016-05-03 16:09:10 +03:00
|
|
|
ScreenPoint
|
|
|
|
PanGestureInput::UserMultipliedPanDisplacement() const
|
|
|
|
{
|
|
|
|
return ScreenPoint(mPanDisplacement.x * mUserDeltaMultiplierX,
|
|
|
|
mPanDisplacement.y * mUserDeltaMultiplierY);
|
|
|
|
}
|
|
|
|
|
|
|
|
ParentLayerPoint
|
|
|
|
PanGestureInput::UserMultipliedLocalPanDisplacement() const
|
|
|
|
{
|
|
|
|
return ParentLayerPoint(mLocalPanDisplacement.x * mUserDeltaMultiplierX,
|
|
|
|
mLocalPanDisplacement.y * mUserDeltaMultiplierY);
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
PinchGestureInput::PinchGestureInput()
|
|
|
|
: InputData(PINCHGESTURE_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mType(PINCHGESTURE_START)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-05-02 23:41:47 +03:00
|
|
|
PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ScreenPoint& aFocusPoint,
|
|
|
|
ParentLayerCoord aCurrentSpan,
|
|
|
|
ParentLayerCoord aPreviousSpan,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mFocusPoint(aFocusPoint)
|
|
|
|
, mCurrentSpan(aCurrentSpan)
|
|
|
|
, mPreviousSpan(aPreviousSpan)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ParentLayerPoint& aLocalFocusPoint,
|
2016-09-24 16:46:01 +03:00
|
|
|
ParentLayerCoord aCurrentSpan,
|
|
|
|
ParentLayerCoord aPreviousSpan,
|
2016-09-12 16:47:01 +03:00
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mLocalFocusPoint(aLocalFocusPoint)
|
|
|
|
, mCurrentSpan(aCurrentSpan)
|
|
|
|
, mPreviousSpan(aPreviousSpan)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
bool
|
2015-12-01 04:14:31 +03:00
|
|
|
PinchGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
2018-05-02 23:41:47 +03:00
|
|
|
{
|
|
|
|
if (mFocusPoint == BothFingersLifted<ScreenPixel>()) {
|
|
|
|
// Special value, no transform required.
|
|
|
|
mLocalFocusPoint = BothFingersLifted();
|
|
|
|
return true;
|
|
|
|
}
|
2015-12-01 04:06:45 +03:00
|
|
|
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mFocusPoint);
|
2015-07-03 22:06:26 +03:00
|
|
|
if (!point) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLocalFocusPoint = *point;
|
|
|
|
return true;
|
2015-01-09 21:39:08 +03:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
TapGestureInput::TapGestureInput()
|
|
|
|
: InputData(TAPGESTURE_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mType(TAPGESTURE_LONG)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TapGestureInput::TapGestureInput(TapGestureType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ScreenIntPoint& aPoint,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mPoint(aPoint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TapGestureInput::TapGestureInput(TapGestureType aType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ParentLayerPoint& aLocalPoint,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mLocalPoint(aLocalPoint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
bool
|
2015-12-01 04:14:31 +03:00
|
|
|
TapGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
2015-01-09 21:39:08 +03:00
|
|
|
{
|
2015-12-01 04:06:45 +03:00
|
|
|
Maybe<ParentLayerIntPoint> point = UntransformBy(aTransform, mPoint);
|
2015-07-03 22:06:26 +03:00
|
|
|
if (!point) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLocalPoint = *point;
|
|
|
|
return true;
|
2015-01-09 21:39:08 +03:00
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
ScrollWheelInput::ScrollWheelInput()
|
|
|
|
: InputData(SCROLLWHEEL_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mDeltaType(SCROLLDELTA_LINE)
|
|
|
|
, mScrollMode(SCROLLMODE_INSTANT)
|
2016-09-12 16:47:01 +03:00
|
|
|
, mHandledByAPZ(false)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mDeltaX(0.0)
|
|
|
|
, mDeltaY(0.0)
|
2016-09-12 16:47:01 +03:00
|
|
|
, mLineOrPageDeltaX(0)
|
|
|
|
, mLineOrPageDeltaY(0)
|
|
|
|
, mScrollSeriesNumber(0)
|
|
|
|
, mUserDeltaMultiplierX(1.0)
|
|
|
|
, mUserDeltaMultiplierY(1.0)
|
|
|
|
, mMayHaveMomentum(false)
|
|
|
|
, mIsMomentum(false)
|
2018-05-02 19:57:23 +03:00
|
|
|
, mAPZAction(APZWheelAction::Scroll)
|
2016-09-12 16:47:01 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollWheelInput::ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp,
|
|
|
|
Modifiers aModifiers, ScrollMode aScrollMode,
|
|
|
|
ScrollDeltaType aDeltaType,
|
|
|
|
const ScreenPoint& aOrigin, double aDeltaX,
|
|
|
|
double aDeltaY,
|
2018-03-16 14:23:53 +03:00
|
|
|
bool aAllowToOverrideSystemScrollSpeed,
|
|
|
|
WheelDeltaAdjustmentStrategy
|
|
|
|
aWheelDeltaAdjustmentStrategy)
|
2016-09-12 16:47:01 +03:00
|
|
|
: InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mDeltaType(aDeltaType)
|
|
|
|
, mScrollMode(aScrollMode)
|
|
|
|
, mOrigin(aOrigin)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
, mDeltaX(aDeltaX)
|
|
|
|
, mDeltaY(aDeltaY)
|
|
|
|
, mLineOrPageDeltaX(0)
|
|
|
|
, mLineOrPageDeltaY(0)
|
|
|
|
, mScrollSeriesNumber(0)
|
|
|
|
, mUserDeltaMultiplierX(1.0)
|
|
|
|
, mUserDeltaMultiplierY(1.0)
|
|
|
|
, mMayHaveMomentum(false)
|
|
|
|
, mIsMomentum(false)
|
|
|
|
, mAllowToOverrideSystemScrollSpeed(aAllowToOverrideSystemScrollSpeed)
|
2018-03-16 14:23:53 +03:00
|
|
|
, mWheelDeltaAdjustmentStrategy(aWheelDeltaAdjustmentStrategy)
|
2018-05-02 19:57:23 +03:00
|
|
|
, mAPZAction(APZWheelAction::Scroll)
|
2015-08-26 06:21:41 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent)
|
2016-09-12 16:47:01 +03:00
|
|
|
: InputData(SCROLLWHEEL_INPUT, aWheelEvent.mTime, aWheelEvent.mTimeStamp,
|
2016-03-31 11:03:00 +03:00
|
|
|
aWheelEvent.mModifiers)
|
2016-03-31 12:35:24 +03:00
|
|
|
, mDeltaType(DeltaTypeForDeltaMode(aWheelEvent.mDeltaMode))
|
2016-01-27 09:09:13 +03:00
|
|
|
, mScrollMode(SCROLLMODE_INSTANT)
|
|
|
|
, mHandledByAPZ(aWheelEvent.mFlags.mHandledByAPZ)
|
2016-03-31 12:55:59 +03:00
|
|
|
, mDeltaX(aWheelEvent.mDeltaX)
|
2016-03-31 12:09:47 +03:00
|
|
|
, mDeltaY(aWheelEvent.mDeltaY)
|
2016-03-31 18:10:46 +03:00
|
|
|
, mLineOrPageDeltaX(aWheelEvent.mLineOrPageDeltaX)
|
2016-03-31 18:10:09 +03:00
|
|
|
, mLineOrPageDeltaY(aWheelEvent.mLineOrPageDeltaY)
|
2016-01-28 16:47:28 +03:00
|
|
|
, mScrollSeriesNumber(0)
|
2016-01-27 09:09:13 +03:00
|
|
|
, mUserDeltaMultiplierX(1.0)
|
|
|
|
, mUserDeltaMultiplierY(1.0)
|
2016-03-31 17:36:49 +03:00
|
|
|
, mMayHaveMomentum(aWheelEvent.mMayHaveMomentum)
|
2016-03-31 17:45:55 +03:00
|
|
|
, mIsMomentum(aWheelEvent.mIsMomentum)
|
2016-01-27 09:09:13 +03:00
|
|
|
, mAllowToOverrideSystemScrollSpeed(
|
|
|
|
aWheelEvent.mAllowToOverrideSystemScrollSpeed)
|
2018-03-16 14:23:53 +03:00
|
|
|
, mWheelDeltaAdjustmentStrategy(WheelDeltaAdjustmentStrategy::eNone)
|
2018-05-02 19:57:23 +03:00
|
|
|
, mAPZAction(APZWheelAction::Scroll)
|
2015-11-19 03:32:37 +03:00
|
|
|
{
|
|
|
|
mOrigin =
|
2016-04-18 17:09:02 +03:00
|
|
|
ScreenPoint(ViewAs<ScreenPixel>(aWheelEvent.mRefPoint,
|
2015-11-19 03:32:37 +03:00
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
|
|
|
|
}
|
|
|
|
|
2016-09-12 16:47:01 +03:00
|
|
|
ScrollWheelInput::ScrollDeltaType
|
|
|
|
ScrollWheelInput::DeltaTypeForDeltaMode(uint32_t aDeltaMode)
|
|
|
|
{
|
|
|
|
switch (aDeltaMode) {
|
2018-06-26 00:20:54 +03:00
|
|
|
case WheelEvent_Binding::DOM_DELTA_LINE:
|
2016-09-12 16:47:01 +03:00
|
|
|
return SCROLLDELTA_LINE;
|
2018-06-26 00:20:54 +03:00
|
|
|
case WheelEvent_Binding::DOM_DELTA_PAGE:
|
2016-09-12 16:47:01 +03:00
|
|
|
return SCROLLDELTA_PAGE;
|
2018-06-26 00:20:54 +03:00
|
|
|
case WheelEvent_Binding::DOM_DELTA_PIXEL:
|
2016-09-12 16:47:01 +03:00
|
|
|
return SCROLLDELTA_PIXEL;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
return SCROLLDELTA_LINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ScrollWheelInput::DeltaModeForDeltaType(ScrollDeltaType aDeltaType)
|
|
|
|
{
|
|
|
|
switch (aDeltaType) {
|
|
|
|
case ScrollWheelInput::SCROLLDELTA_LINE:
|
2018-06-26 00:20:54 +03:00
|
|
|
return WheelEvent_Binding::DOM_DELTA_LINE;
|
2016-09-12 16:47:01 +03:00
|
|
|
case ScrollWheelInput::SCROLLDELTA_PAGE:
|
2018-06-26 00:20:54 +03:00
|
|
|
return WheelEvent_Binding::DOM_DELTA_PAGE;
|
2016-09-12 16:47:01 +03:00
|
|
|
case ScrollWheelInput::SCROLLDELTA_PIXEL:
|
|
|
|
default:
|
2018-06-26 00:20:54 +03:00
|
|
|
return WheelEvent_Binding::DOM_DELTA_PIXEL;
|
2016-09-12 16:47:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIScrollableFrame::ScrollUnit
|
|
|
|
ScrollWheelInput::ScrollUnitForDeltaType(ScrollDeltaType aDeltaType)
|
|
|
|
{
|
|
|
|
switch (aDeltaType) {
|
|
|
|
case SCROLLDELTA_LINE:
|
|
|
|
return nsIScrollableFrame::LINES;
|
|
|
|
case SCROLLDELTA_PAGE:
|
|
|
|
return nsIScrollableFrame::PAGES;
|
|
|
|
case SCROLLDELTA_PIXEL:
|
|
|
|
return nsIScrollableFrame::DEVICE_PIXELS;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
return nsIScrollableFrame::LINES;
|
|
|
|
}
|
|
|
|
|
2015-08-26 06:21:41 +03:00
|
|
|
WidgetWheelEvent
|
|
|
|
ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
|
|
|
|
{
|
2015-09-10 19:59:54 +03:00
|
|
|
WidgetWheelEvent wheelEvent(true, eWheel, aWidget);
|
2016-03-31 11:03:00 +03:00
|
|
|
wheelEvent.mModifiers = this->modifiers;
|
2016-03-28 07:29:42 +03:00
|
|
|
wheelEvent.mTime = mTime;
|
2016-03-28 07:49:02 +03:00
|
|
|
wheelEvent.mTimeStamp = mTimeStamp;
|
2016-04-18 17:09:02 +03:00
|
|
|
wheelEvent.mRefPoint =
|
2015-08-26 06:21:41 +03:00
|
|
|
RoundedToInt(ViewAs<LayoutDevicePixel>(mOrigin,
|
2015-11-19 03:32:37 +03:00
|
|
|
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
|
2015-08-26 06:21:41 +03:00
|
|
|
wheelEvent.buttons = 0;
|
2016-03-31 12:35:24 +03:00
|
|
|
wheelEvent.mDeltaMode = DeltaModeForDeltaType(mDeltaType);
|
2016-03-31 17:36:49 +03:00
|
|
|
wheelEvent.mMayHaveMomentum = mMayHaveMomentum;
|
2016-03-31 17:45:55 +03:00
|
|
|
wheelEvent.mIsMomentum = mIsMomentum;
|
2016-03-31 12:55:59 +03:00
|
|
|
wheelEvent.mDeltaX = mDeltaX;
|
2016-03-31 12:09:47 +03:00
|
|
|
wheelEvent.mDeltaY = mDeltaY;
|
2016-03-31 18:10:46 +03:00
|
|
|
wheelEvent.mLineOrPageDeltaX = mLineOrPageDeltaX;
|
2016-03-31 18:10:09 +03:00
|
|
|
wheelEvent.mLineOrPageDeltaY = mLineOrPageDeltaY;
|
2016-01-27 09:09:13 +03:00
|
|
|
wheelEvent.mAllowToOverrideSystemScrollSpeed =
|
|
|
|
mAllowToOverrideSystemScrollSpeed;
|
2015-08-12 01:04:55 +03:00
|
|
|
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
|
2017-06-06 03:45:31 +03:00
|
|
|
wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber;
|
2015-08-26 06:21:41 +03:00
|
|
|
return wheelEvent;
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:06:26 +03:00
|
|
|
bool
|
2015-12-01 04:14:31 +03:00
|
|
|
ScrollWheelInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
|
2015-01-09 21:39:08 +03:00
|
|
|
{
|
2015-12-01 04:06:45 +03:00
|
|
|
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mOrigin);
|
2015-07-03 22:06:26 +03:00
|
|
|
if (!point) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mLocalOrigin = *point;
|
|
|
|
return true;
|
2015-01-09 21:39:08 +03:00
|
|
|
}
|
|
|
|
|
2015-12-02 00:46:07 +03:00
|
|
|
bool
|
|
|
|
ScrollWheelInput::IsCustomizedByUserPrefs() const
|
|
|
|
{
|
|
|
|
return mUserDeltaMultiplierX != 1.0 ||
|
|
|
|
mUserDeltaMultiplierY != 1.0;
|
|
|
|
}
|
|
|
|
|
2017-06-06 02:09:40 +03:00
|
|
|
KeyboardInput::KeyboardInput(const WidgetKeyboardEvent& aEvent)
|
|
|
|
: InputData(KEYBOARD_INPUT,
|
|
|
|
aEvent.mTime,
|
|
|
|
aEvent.mTimeStamp,
|
|
|
|
aEvent.mModifiers)
|
|
|
|
, mKeyCode(aEvent.mKeyCode)
|
|
|
|
, mCharCode(aEvent.mCharCode)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
{
|
|
|
|
switch (aEvent.mMessage) {
|
|
|
|
case eKeyPress: {
|
|
|
|
mType = KeyboardInput::KEY_PRESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eKeyUp: {
|
|
|
|
mType = KeyboardInput::KEY_UP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eKeyDown: {
|
|
|
|
mType = KeyboardInput::KEY_DOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
mType = KeyboardInput::KEY_OTHER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.GetShortcutKeyCandidates(mShortcutCandidates);
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyboardInput::KeyboardInput()
|
|
|
|
: InputData(KEYBOARD_INPUT)
|
2018-06-15 17:48:51 +03:00
|
|
|
, mType(KEY_DOWN)
|
2017-06-06 02:09:40 +03:00
|
|
|
, mKeyCode(0)
|
|
|
|
, mCharCode(0)
|
|
|
|
, mHandledByAPZ(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-09 21:39:08 +03:00
|
|
|
} // namespace mozilla
|