Bug 1564195 - Group the results of APZInputBridge::ReceiveInputEvent() into a struct. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D46376

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-09-19 02:45:21 +00:00
parent ddc9712d7e
commit a61744ca91
23 changed files with 405 additions and 510 deletions

View File

@ -54,11 +54,6 @@ struct ParamTraits<mozilla::dom::RemoteDOMEvent> {
static void Log(const paramType& aParam, std::wstring* aLog) {}
};
template <>
struct ParamTraits<nsEventStatus>
: public ContiguousEnumSerializer<nsEventStatus, nsEventStatus_eIgnore,
nsEventStatus_eSentinel> {};
template <>
struct ParamTraits<nsSizeMode>
: public ContiguousEnumSerializer<nsSizeMode, nsSizeMode_Normal,

View File

@ -20,6 +20,49 @@ namespace layers {
class APZInputBridgeParent;
struct ScrollableLayerGuid;
/**
* Represents the outcome of APZ receiving and processing an input event.
* This is returned from APZInputBridge::ReceiveInputEvent() and related APIs.
*/
struct APZEventResult {
/**
* Creates a default result with a status of eIgnore, no block ID, and empty
* target guid.
*/
APZEventResult();
/**
* A status flag indicated how APZ handled the event.
* The interpretation of each value is as follows:
*
* nsEventStatus_eConsumeNoDefault is returned to indicate the
* APZ is consuming this event and the caller should discard the event with
* extreme prejudice. The exact scenarios under which this is returned is
* implementation-dependent and may vary.
* nsEventStatus_eIgnore is returned to indicate that the APZ code didn't
* use this event. This might be because it was directed at a point on
* the screen where there was no APZ, or because the thing the user was
* trying to do was not allowed. (For example, attempting to pan a
* non-pannable document).
* nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ
* code may have used this event to do some user-visible thing. Note that
* in some cases CONSUMED is returned even if the event was NOT used. This
* is because we cannot always know at the time of event delivery whether
* the event will be used or not. So we err on the side of sending
* CONSUMED when we are uncertain.
*/
nsEventStatus mStatus;
/**
* The guid of the APZC this event was delivered to.
*/
ScrollableLayerGuid mTargetGuid;
/**
* If this event started or was added to an input block, the id of that
* input block, otherwise InputBlockState::NO_BLOCK_ID.
*/
uint64_t mInputBlockId;
};
/**
* This class lives in the main process, and is accessed via the controller
* thread (which is the process main thread for desktop, and the Java UI
@ -42,32 +85,11 @@ class APZInputBridge {
* handle them. The event may need to be converted to a WidgetInputEvent
* by the caller if it wants to do this.
*
* The following values may be returned by this function:
* nsEventStatus_eConsumeNoDefault is returned to indicate the
* APZ is consuming this event and the caller should discard the event with
* extreme prejudice. The exact scenarios under which this is returned is
* implementation-dependent and may vary.
* nsEventStatus_eIgnore is returned to indicate that the APZ code didn't
* use this event. This might be because it was directed at a point on
* the screen where there was no APZ, or because the thing the user was
* trying to do was not allowed. (For example, attempting to pan a
* non-pannable document).
* nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ
* code may have used this event to do some user-visible thing. Note that
* in some cases CONSUMED is returned even if the event was NOT used. This
* is because we cannot always know at the time of event delivery whether
* the event will be used or not. So we err on the side of sending
* CONSUMED when we are uncertain.
*
* @param aEvent input event object; is modified in-place
* @param aOutTargetGuid returns the guid of the apzc this event was
* delivered to. May be null.
* @param aOutInputBlockId returns the id of the input block that this event
* was added to, if that was the case. May be null.
* @return The result of processing the event. Refer to the documentation of
* APZEventResult and its field.
*/
virtual nsEventStatus ReceiveInputEvent(InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) = 0;
virtual APZEventResult ReceiveInputEvent(InputData& aEvent) = 0;
/**
* WidgetInputEvent handler. Transforms |aEvent| (which is assumed to be an
@ -85,9 +107,7 @@ class APZInputBridge {
*
* See documentation for other ReceiveInputEvent above.
*/
nsEventStatus ReceiveInputEvent(WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
APZEventResult ReceiveInputEvent(WidgetInputEvent& aEvent);
// Returns the kind of wheel event action, if any, that will be (or was)
// performed by APZ. If this returns true, the event must not perform a

View File

@ -1249,16 +1249,15 @@ void APZCTreeManager::MarkAsDetached(LayersId aLayersId) {
mDetachedLayersIds.insert(aLayersId);
}
nsEventStatus APZCTreeManager::ReceiveInputEvent(
InputData& aEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
APZEventResult APZCTreeManager::ReceiveInputEvent(InputData& aEvent) {
APZThreadUtils::AssertOnControllerThread();
APZEventResult result;
// Ignore input events when there are active tabs that are recording or
// replaying. APZ does not work with the special layers constructed by
// the middleman processes being communicated with here.
if (dom::BrowserParent::AreRecordReplayTabsActive()) {
return nsEventStatus_eIgnore;
return result;
}
// Use a RAII class for updating the focus sequence number of this event
@ -1283,22 +1282,17 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
// Check if the mToolbarAnimator consumed the event.
if (isConsumed == nsEventStatus_eConsumeNoDefault) {
APZCTM_LOG("Dynamic toolbar consumed event");
return isConsumed;
result.mStatus = isConsumed;
return result;
}
}
#endif // (MOZ_WIDGET_ANDROID)
// Initialize aOutInputBlockId to a sane value, and then later we overwrite
// it if the input event goes into a block.
if (aOutInputBlockId) {
*aOutInputBlockId = InputBlockState::NO_BLOCK_ID;
}
nsEventStatus result = nsEventStatus_eIgnore;
CompositorHitTestInfo hitResult = CompositorHitTestInvisibleToHit;
switch (aEvent.mInputType) {
case MULTITOUCH_INPUT: {
MultiTouchInput& touchInput = aEvent.AsMultiTouchInput();
result = ProcessTouchInput(touchInput, aOutTargetGuid, aOutInputBlockId);
result = ProcessTouchInput(touchInput);
break;
}
case MOUSE_INPUT: {
@ -1350,8 +1344,8 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
// that we need.
confFlags.mTargetConfirmed = false;
}
result = mInputQueue->ReceiveInputEvent(apzc, confFlags, mouseInput,
aOutInputBlockId);
result.mStatus = mInputQueue->ReceiveInputEvent(
apzc, confFlags, mouseInput, &result.mInputBlockId);
// If we're starting an async scrollbar drag
if (apzDragEnabled && startsDrag && hitScrollbarNode &&
@ -1360,7 +1354,7 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
SetupScrollbarDrag(mouseInput, hitScrollbarNode, apzc.get());
}
if (result == nsEventStatus_eConsumeDoDefault) {
if (result.mStatus == nsEventStatus_eConsumeDoDefault) {
// This input event is part of a drag block, so whether or not it is
// directed at a scrollbar depends on whether the drag block started
// on a scrollbar.
@ -1368,7 +1362,7 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
}
// Update the out-parameters so they are what the caller expects.
apzc->GetGuid(aOutTargetGuid);
apzc->GetGuid(&result.mTargetGuid);
if (!hitScrollbar) {
// The input was not targeted at a scrollbar, so we untransform it
@ -1391,7 +1385,7 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
// to apply the callback transform in the main thread, so we remove
// the scrollid from the guid. We need to keep the layersId intact so
// that the response from the child process doesn't get discarded.
aOutTargetGuid->mScrollId = ScrollableLayerGuid::NULL_SCROLL_ID;
result.mTargetGuid.mScrollId = ScrollableLayerGuid::NULL_SCROLL_ID;
}
}
break;
@ -1422,7 +1416,8 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
if (apzc) {
SynthesizePinchGestureFromMouseWheel(wheelInput, apzc);
}
return nsEventStatus_eConsumeNoDefault;
result.mStatus = nsEventStatus_eConsumeNoDefault;
return result;
}
MOZ_ASSERT(wheelInput.mAPZAction == APZWheelAction::Scroll);
@ -1443,12 +1438,12 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
return result;
}
result = mInputQueue->ReceiveInputEvent(
result.mStatus = mInputQueue->ReceiveInputEvent(
apzc, TargetConfirmationFlags{hitResult}, wheelInput,
aOutInputBlockId);
&result.mInputBlockId);
// Update the out-parameters so they are what the caller expects.
apzc->GetGuid(aOutTargetGuid);
apzc->GetGuid(&result.mTargetGuid);
wheelInput.mOrigin = *untransformedOrigin;
}
break;
@ -1499,12 +1494,12 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
return result;
}
result = mInputQueue->ReceiveInputEvent(
result.mStatus = mInputQueue->ReceiveInputEvent(
apzc, TargetConfirmationFlags{hitResult}, panInput,
aOutInputBlockId);
&result.mInputBlockId);
// Update the out-parameters so they are what the caller expects.
apzc->GetGuid(aOutTargetGuid);
apzc->GetGuid(&result.mTargetGuid);
panInput.mPanStartPoint = *untransformedStartPoint;
panInput.mPanDisplacement = *untransformedDisplacement;
@ -1529,12 +1524,12 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
return result;
}
result = mInputQueue->ReceiveInputEvent(
result.mStatus = mInputQueue->ReceiveInputEvent(
apzc, TargetConfirmationFlags{hitResult}, pinchInput,
aOutInputBlockId);
&result.mInputBlockId);
// Update the out-parameters so they are what the caller expects.
apzc->GetGuid(aOutTargetGuid);
apzc->GetGuid(&result.mTargetGuid);
pinchInput.mFocusPoint = *untransformedFocusPoint;
}
break;
@ -1555,12 +1550,12 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
return result;
}
result = mInputQueue->ReceiveInputEvent(
result.mStatus = mInputQueue->ReceiveInputEvent(
apzc, TargetConfirmationFlags{hitResult}, tapInput,
aOutInputBlockId);
&result.mInputBlockId);
// Update the out-parameters so they are what the caller expects.
apzc->GetGuid(aOutTargetGuid);
apzc->GetGuid(&result.mTargetGuid);
tapInput.mPoint = *untransformedPoint;
}
break;
@ -1642,14 +1637,14 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent(
APZ_KEY_LOG("Dispatching key input with apzc=%p\n", targetApzc.get());
// Dispatch the event to the input queue.
result = mInputQueue->ReceiveInputEvent(targetApzc,
TargetConfirmationFlags{true},
keyInput, aOutInputBlockId);
result.mStatus = mInputQueue->ReceiveInputEvent(
targetApzc, TargetConfirmationFlags{true}, keyInput,
&result.mInputBlockId);
// Any keyboard event that is dispatched to the input queue at this point
// should have been consumed
MOZ_ASSERT(result == nsEventStatus_eConsumeDoDefault ||
result == nsEventStatus_eConsumeNoDefault);
MOZ_ASSERT(result.mStatus == nsEventStatus_eConsumeDoDefault ||
result.mStatus == nsEventStatus_eConsumeNoDefault);
keyInput.mHandledByAPZ = true;
focusSetter.MarkAsNonFocusChanging();
@ -1733,9 +1728,8 @@ APZCTreeManager::GetTouchInputBlockAPZC(
return apzc.forget();
}
nsEventStatus APZCTreeManager::ProcessTouchInput(
MultiTouchInput& aInput, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
APZEventResult APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput) {
APZEventResult result; // mStatus == eIgnore
aInput.mHandledByAPZ = true;
nsTArray<TouchBehaviorFlags> touchBehaviors;
HitTestingTreeNodeAutoLock hitScrollbarNode;
@ -1753,7 +1747,8 @@ nsEventStatus APZCTreeManager::ProcessTouchInput(
if (mRetainedTouchIdentifier == -1) {
mRetainedTouchIdentifier = mApzcForInputBlock->GetLastTouchIdentifier();
}
return nsEventStatus_eConsumeNoDefault;
result.mStatus = nsEventStatus_eConsumeNoDefault;
return result;
}
mHitResultForInputBlock = CompositorHitTestInvisibleToHit;
@ -1786,11 +1781,8 @@ nsEventStatus APZCTreeManager::ProcessTouchInput(
mApzcForInputBlock.get());
}
nsEventStatus result = nsEventStatus_eIgnore;
if (mInScrollbarTouchDrag) {
result = ProcessTouchInputForScrollbarDrag(
aInput, hitScrollbarNode, aOutTargetGuid, aOutInputBlockId);
result = ProcessTouchInputForScrollbarDrag(aInput, hitScrollbarNode);
} else {
// If we receive a touch-cancel, it means all touches are finished, so we
// can stop ignoring any that we were ignoring.
@ -1814,22 +1806,19 @@ nsEventStatus APZCTreeManager::ProcessTouchInput(
}
}
if (aInput.mTouches.IsEmpty()) {
return nsEventStatus_eConsumeNoDefault;
result.mStatus = nsEventStatus_eConsumeNoDefault;
return result;
}
}
if (mApzcForInputBlock) {
MOZ_ASSERT(mHitResultForInputBlock != CompositorHitTestInvisibleToHit);
mApzcForInputBlock->GetGuid(aOutTargetGuid);
uint64_t inputBlockId = 0;
result = mInputQueue->ReceiveInputEvent(
mApzcForInputBlock->GetGuid(&result.mTargetGuid);
result.mStatus = mInputQueue->ReceiveInputEvent(
mApzcForInputBlock, TargetConfirmationFlags{mHitResultForInputBlock},
aInput, &inputBlockId,
aInput, &result.mInputBlockId,
touchBehaviors.IsEmpty() ? Nothing() : Some(touchBehaviors));
if (aOutInputBlockId) {
*aOutInputBlockId = inputBlockId;
}
// For computing the event to pass back to Gecko, use up-to-date
// transforms (i.e. not anything cached in an input block). This ensures
@ -1845,7 +1834,8 @@ nsEventStatus APZCTreeManager::ProcessTouchInput(
Maybe<ScreenIntPoint> untransformedScreenPoint =
UntransformBy(outTransform, touchData.mScreenPoint);
if (!untransformedScreenPoint) {
return nsEventStatus_eIgnore;
result.mStatus = nsEventStatus_eIgnore;
return result;
}
touchData.mScreenPoint = *untransformedScreenPoint;
}
@ -1881,10 +1871,9 @@ static MouseInput::MouseType MultiTouchTypeToMouseType(
return MouseInput::MOUSE_NONE;
}
nsEventStatus APZCTreeManager::ProcessTouchInputForScrollbarDrag(
APZEventResult APZCTreeManager::ProcessTouchInputForScrollbarDrag(
MultiTouchInput& aTouchInput,
const HitTestingTreeNodeAutoLock& aScrollThumbNode,
ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId) {
const HitTestingTreeNodeAutoLock& aScrollThumbNode) {
MOZ_ASSERT(mRetainedTouchIdentifier == -1);
MOZ_ASSERT(mApzcForInputBlock);
MOZ_ASSERT(aTouchInput.mTouches.Length() == 1);
@ -1907,8 +1896,9 @@ nsEventStatus APZCTreeManager::ProcessTouchInputForScrollbarDrag(
// earliest, be confirmed in the subsequent SetupScrollbarDrag() call.
TargetConfirmationFlags targetConfirmed{false};
nsEventStatus result = mInputQueue->ReceiveInputEvent(
mApzcForInputBlock, targetConfirmed, mouseInput, aOutInputBlockId);
APZEventResult result;
result.mStatus = mInputQueue->ReceiveInputEvent(
mApzcForInputBlock, targetConfirmed, mouseInput, &result.mInputBlockId);
// |aScrollThumbNode| is non-null iff. this is the event that starts the drag.
// If so, set up the drag.
@ -1916,7 +1906,7 @@ nsEventStatus APZCTreeManager::ProcessTouchInputForScrollbarDrag(
SetupScrollbarDrag(mouseInput, aScrollThumbNode, mApzcForInputBlock.get());
}
mApzcForInputBlock->GetGuid(aOutTargetGuid);
mApzcForInputBlock->GetGuid(&result.mTargetGuid);
// Since the input was targeted at a scrollbar:
// - The original touch event (which will be sent on to content) will
@ -1926,7 +1916,7 @@ nsEventStatus APZCTreeManager::ProcessTouchInputForScrollbarDrag(
// Both of these match the behaviour of mouse events that target a scrollbar;
// see the code for handling mouse events in ReceiveInputEvent() for
// additional explanation.
aOutTargetGuid->mScrollId = ScrollableLayerGuid::NULL_SCROLL_ID;
result.mTargetGuid.mScrollId = ScrollableLayerGuid::NULL_SCROLL_ID;
return result;
}

View File

@ -228,42 +228,10 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
wr::RenderRoot aRenderRoot);
/**
* General handler for incoming input events. Manipulates the frame metrics
* based on what type of input it is. For example, a PinchGestureEvent will
* cause scaling. This should only be called externally to this class, and
* must be called on the controller thread.
*
* This function transforms |aEvent| to have its coordinates in DOM space.
* This is so that the event can be passed through the DOM and content can
* handle them. The event may need to be converted to a WidgetInputEvent
* by the caller if it wants to do this.
*
* The following values may be returned by this function:
* nsEventStatus_eConsumeNoDefault is returned to indicate the
* APZ is consuming this event and the caller should discard the event with
* extreme prejudice. The exact scenarios under which this is returned is
* implementation-dependent and may vary.
* nsEventStatus_eIgnore is returned to indicate that the APZ code didn't
* use this event. This might be because it was directed at a point on
* the screen where there was no APZ, or because the thing the user was
* trying to do was not allowed. (For example, attempting to pan a
* non-pannable document).
* nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ
* code may have used this event to do some user-visible thing. Note that
* in some cases CONSUMED is returned even if the event was NOT used. This
* is because we cannot always know at the time of event delivery whether
* the event will be used or not. So we err on the side of sending
* CONSUMED when we are uncertain.
*
* @param aEvent input event object; is modified in-place
* @param aOutTargetGuid returns the guid of the apzc this event was
* delivered to. May be null.
* @param aOutInputBlockId returns the id of the input block that this event
* was added to, if that was the case. May be null.
* Refer to the documentation of APZInputBridge::ReceiveInputEvent() and
* APZEventResult.
*/
nsEventStatus ReceiveInputEvent(InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) override;
APZEventResult ReceiveInputEvent(InputData& aEvent) override;
/**
* Set the keyboard shortcuts to use for translating keyboard events.
@ -701,9 +669,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
nsTArray<TouchBehaviorFlags>* aOutTouchBehaviors,
gfx::CompositorHitTestInfo* aOutHitResult, LayersId* aOutLayersId,
HitTestingTreeNodeAutoLock* aOutHitScrollbarNode);
nsEventStatus ProcessTouchInput(MultiTouchInput& aInput,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
APZEventResult ProcessTouchInput(MultiTouchInput& aInput);
/**
* Given a mouse-down event that hit a scroll thumb node, set up APZ
* dragging of the scroll thumb.
@ -734,10 +700,9 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
* The ID of the input block for the touch-drag gesture.
* @return See ReceiveInputEvent() for what the return value means.
*/
nsEventStatus ProcessTouchInputForScrollbarDrag(
APZEventResult ProcessTouchInputForScrollbarDrag(
MultiTouchInput& aInput,
const HitTestingTreeNodeAutoLock& aScrollThumbNode,
ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId);
const HitTestingTreeNodeAutoLock& aScrollThumbNode);
void FlushRepaintsToClearScreenToGeckoTransform();
void SynthesizePinchGestureFromMouseWheel(

View File

@ -7,6 +7,7 @@
#include "mozilla/layers/APZInputBridge.h"
#include "InputData.h" // for MouseInput, etc
#include "InputBlockState.h" // for InputBlockState
#include "mozilla/dom/WheelEventBinding.h" // for WheelEvent constants
#include "mozilla/EventStateManager.h" // for EventStateManager
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread, etc
@ -22,6 +23,10 @@
namespace mozilla {
namespace layers {
APZEventResult::APZEventResult()
: mStatus(nsEventStatus_eIgnore),
mInputBlockId(InputBlockState::NO_BLOCK_ID) {}
static bool WillHandleMouseEvent(const WidgetMouseEventBase& aEvent) {
return aEvent.mMessage == eMouseMove || aEvent.mMessage == eMouseDown ||
aEvent.mMessage == eMouseUp || aEvent.mMessage == eDragEnd ||
@ -40,16 +45,10 @@ Maybe<APZWheelAction> APZInputBridge::ActionForWheelEvent(
return EventStateManager::APZWheelActionFor(aEvent);
}
nsEventStatus APZInputBridge::ReceiveInputEvent(
WidgetInputEvent& aEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
APZEventResult APZInputBridge::ReceiveInputEvent(WidgetInputEvent& aEvent) {
APZThreadUtils::AssertOnControllerThread();
// Initialize aOutInputBlockId to a sane value, and then later we overwrite
// it if the input event goes into a block.
if (aOutInputBlockId) {
*aOutInputBlockId = 0;
}
APZEventResult result;
switch (aEvent.mClass) {
case eMouseEventClass:
@ -77,26 +76,24 @@ nsEventStatus APZInputBridge::ReceiveInputEvent(
input.mOrigin =
ScreenPoint(mouseEvent.mRefPoint.x, mouseEvent.mRefPoint.y);
nsEventStatus status =
ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
result = ReceiveInputEvent(input);
mouseEvent.mRefPoint.x = input.mOrigin.x;
mouseEvent.mRefPoint.y = input.mOrigin.y;
mouseEvent.mFlags.mHandledByAPZ = input.mHandledByAPZ;
mouseEvent.mFocusSequenceNumber = input.mFocusSequenceNumber;
aEvent.mLayersId = input.mLayersId;
return status;
return result;
}
ProcessUnhandledEvent(&mouseEvent.mRefPoint, aOutTargetGuid,
ProcessUnhandledEvent(&mouseEvent.mRefPoint, &result.mTargetGuid,
&aEvent.mFocusSequenceNumber, &aEvent.mLayersId);
return nsEventStatus_eIgnore;
return result;
}
case eTouchEventClass: {
WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
MultiTouchInput touchInput(touchEvent);
nsEventStatus result =
ReceiveInputEvent(touchInput, aOutTargetGuid, aOutInputBlockId);
result = ReceiveInputEvent(touchInput);
// touchInput was modified in-place to possibly remove some
// touch points (if we are overscrolled), and the coordinates were
// modified using the APZ untransform. We need to copy these changes
@ -162,45 +159,45 @@ nsEventStatus APZInputBridge::ReceiveInputEvent(
&wheelEvent, &input.mUserDeltaMultiplierX,
&input.mUserDeltaMultiplierY);
nsEventStatus status =
ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
result = ReceiveInputEvent(input);
wheelEvent.mRefPoint.x = input.mOrigin.x;
wheelEvent.mRefPoint.y = input.mOrigin.y;
wheelEvent.mFlags.mHandledByAPZ = input.mHandledByAPZ;
wheelEvent.mFocusSequenceNumber = input.mFocusSequenceNumber;
aEvent.mLayersId = input.mLayersId;
return status;
return result;
}
}
UpdateWheelTransaction(aEvent.mRefPoint, aEvent.mMessage);
ProcessUnhandledEvent(&aEvent.mRefPoint, aOutTargetGuid,
ProcessUnhandledEvent(&aEvent.mRefPoint, &result.mTargetGuid,
&aEvent.mFocusSequenceNumber, &aEvent.mLayersId);
return nsEventStatus_eIgnore;
result.mStatus = nsEventStatus_eIgnore;
return result;
}
case eKeyboardEventClass: {
WidgetKeyboardEvent& keyboardEvent = *aEvent.AsKeyboardEvent();
KeyboardInput input(keyboardEvent);
nsEventStatus status =
ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
result = ReceiveInputEvent(input);
keyboardEvent.mFlags.mHandledByAPZ = input.mHandledByAPZ;
keyboardEvent.mFocusSequenceNumber = input.mFocusSequenceNumber;
return status;
return result;
}
default: {
UpdateWheelTransaction(aEvent.mRefPoint, aEvent.mMessage);
ProcessUnhandledEvent(&aEvent.mRefPoint, aOutTargetGuid,
ProcessUnhandledEvent(&aEvent.mRefPoint, &result.mTargetGuid,
&aEvent.mFocusSequenceNumber, &aEvent.mLayersId);
return nsEventStatus_eIgnore;
return result;
}
}
MOZ_ASSERT_UNREACHABLE("Invalid WidgetInputEvent type.");
return nsEventStatus_eConsumeNoDefault;
result.mStatus = nsEventStatus_eConsumeNoDefault;
return result;
}
} // namespace layers

View File

@ -274,14 +274,14 @@ class TestAsyncPanZoomController : public AsyncPanZoomController {
mWaitForMainThread(false),
mcc(aMcc) {}
nsEventStatus ReceiveInputEvent(const InputData& aEvent,
ScrollableLayerGuid* aDummy,
uint64_t* aOutInputBlockId) {
APZEventResult ReceiveInputEvent(const InputData& aEvent) {
// This is a function whose signature matches exactly the ReceiveInputEvent
// on APZCTreeManager. This allows us to templates for functions like
// TouchDown, TouchUp, etc so that we can reuse the code for dispatching
// events into both APZC and APZCTM.
return ReceiveInputEvent(aEvent, aOutInputBlockId);
APZEventResult result;
result.mStatus = ReceiveInputEvent(aEvent, &result.mInputBlockId);
return result;
}
nsEventStatus ReceiveInputEvent(const InputData& aEvent,
@ -523,30 +523,25 @@ void APZCTesterBase::Tap(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeDuration aTapLength,
nsEventStatus (*aOutEventStatuses)[2],
uint64_t* aOutInputBlockId) {
// Even if the caller doesn't care about the block id, we need it to set the
// allowed touch behaviour below, so make sure aOutInputBlockId is non-null.
uint64_t blockId;
if (!aOutInputBlockId) {
aOutInputBlockId = &blockId;
}
nsEventStatus status =
TouchDown(aTarget, aPoint, mcc->Time(), aOutInputBlockId);
APZEventResult result = TouchDown(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[0] = status;
(*aOutEventStatuses)[0] = result.mStatus;
}
if (aOutInputBlockId) {
*aOutInputBlockId = result.mInputBlockId;
}
mcc->AdvanceBy(aTapLength);
// If touch-action is enabled then simulate the allowed touch behaviour
// notification that the main thread is supposed to deliver.
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId);
result.mStatus != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, result.mInputBlockId);
}
status = TouchUp(aTarget, aPoint, mcc->Time());
result.mStatus = TouchUp(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
(*aOutEventStatuses)[1] = result.mStatus;
}
}
@ -598,19 +593,22 @@ void APZCTesterBase::Pan(const RefPtr<InputReceiver>& aTarget,
}
// Make sure the move is large enough to not be handled as a tap
nsEventStatus status =
APZEventResult result =
TouchDown(aTarget,
ScreenIntPoint(aTouchStart.x + overcomeTouchToleranceX,
aTouchStart.y + overcomeTouchToleranceY),
mcc->Time(), aOutInputBlockId);
mcc->Time());
if (aOutInputBlockId) {
*aOutInputBlockId = result.mInputBlockId;
}
if (aOutEventStatuses) {
(*aOutEventStatuses)[0] = status;
(*aOutEventStatuses)[0] = result.mStatus;
}
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
// Allowed touch behaviours must be set after sending touch-start.
if (status != nsEventStatus_eConsumeNoDefault) {
if (result.mStatus != nsEventStatus_eConsumeNoDefault) {
if (aAllowedTouchBehaviors) {
EXPECT_EQ(1UL, aAllowedTouchBehaviors->Length());
aTarget->SetAllowedTouchBehavior(*aOutInputBlockId,
@ -620,27 +618,27 @@ void APZCTesterBase::Pan(const RefPtr<InputReceiver>& aTarget,
}
}
status = TouchMove(aTarget, aTouchStart, mcc->Time());
result.mStatus = TouchMove(aTarget, aTouchStart, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
(*aOutEventStatuses)[1] = result.mStatus;
}
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
status = TouchMove(aTarget, aTouchEnd, mcc->Time());
result.mStatus = TouchMove(aTarget, aTouchEnd, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = status;
(*aOutEventStatuses)[2] = result.mStatus;
}
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
if (!(aOptions & PanOptions::KeepFingerDown)) {
status = TouchUp(aTarget, aTouchEnd, mcc->Time());
result.mStatus = TouchUp(aTarget, aTouchEnd, mcc->Time());
} else {
status = nsEventStatus_eIgnore;
result.mStatus = nsEventStatus_eIgnore;
}
if (aOutEventStatuses) {
(*aOutEventStatuses)[3] = status;
(*aOutEventStatuses)[3] = result.mStatus;
}
if ((aOptions & PanOptions::NoFling)) {
@ -688,45 +686,44 @@ void APZCTesterBase::DoubleTap(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint,
nsEventStatus (*aOutEventStatuses)[4],
uint64_t (*aOutInputBlockIds)[2]) {
uint64_t blockId;
nsEventStatus status = TouchDown(aTarget, aPoint, mcc->Time(), &blockId);
APZEventResult result = TouchDown(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[0] = status;
(*aOutEventStatuses)[0] = result.mStatus;
}
if (aOutInputBlockIds) {
(*aOutInputBlockIds)[0] = blockId;
(*aOutInputBlockIds)[0] = result.mInputBlockId;
}
mcc->AdvanceByMillis(10);
// If touch-action is enabled then simulate the allowed touch behaviour
// notification that the main thread is supposed to deliver.
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, blockId);
result.mStatus != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, result.mInputBlockId);
}
status = TouchUp(aTarget, aPoint, mcc->Time());
result.mStatus = TouchUp(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
(*aOutEventStatuses)[1] = result.mStatus;
}
mcc->AdvanceByMillis(10);
status = TouchDown(aTarget, aPoint, mcc->Time(), &blockId);
result = TouchDown(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = status;
(*aOutEventStatuses)[2] = result.mStatus;
}
if (aOutInputBlockIds) {
(*aOutInputBlockIds)[1] = blockId;
(*aOutInputBlockIds)[1] = result.mInputBlockId;
}
mcc->AdvanceByMillis(10);
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, blockId);
result.mStatus != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, result.mInputBlockId);
}
status = TouchUp(aTarget, aPoint, mcc->Time());
result.mStatus = TouchUp(aTarget, aPoint, mcc->Time());
if (aOutEventStatuses) {
(*aOutEventStatuses)[3] = status;
(*aOutEventStatuses)[3] = result.mStatus;
}
}

View File

@ -16,9 +16,7 @@
/* The InputReceiver template parameter used in the helper functions below needs
* to be a class that implements functions with the signatures:
* nsEventStatus ReceiveInputEvent(const InputData& aEvent,
* ScrollableLayerGuid* aGuid,
* uint64_t* aOutInputBlockId);
* APZEventResult ReceiveInputEvent(const InputData& aEvent);
* void SetAllowedTouchBehavior(uint64_t aInputBlockId,
* const nsTArray<uint32_t>& aBehaviours);
* The classes that currently implement these are APZCTreeManager and
@ -49,13 +47,12 @@ inline MultiTouchInput CreateMultiTouchInput(
}
template <class InputReceiver>
nsEventStatus TouchDown(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult TouchDown(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime) {
MultiTouchInput mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aPoint));
return aTarget->ReceiveInputEvent(mti, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(mti);
}
template <class InputReceiver>
@ -64,7 +61,7 @@ nsEventStatus TouchMove(const RefPtr<InputReceiver>& aTarget,
MultiTouchInput mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aPoint));
return aTarget->ReceiveInputEvent(mti, nullptr, nullptr);
return aTarget->ReceiveInputEvent(mti).mStatus;
}
template <class InputReceiver>
@ -73,72 +70,67 @@ nsEventStatus TouchUp(const RefPtr<InputReceiver>& aTarget,
MultiTouchInput mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aPoint));
return aTarget->ReceiveInputEvent(mti, nullptr, nullptr);
return aTarget->ReceiveInputEvent(mti).mStatus;
}
template <class InputReceiver>
nsEventStatus Wheel(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, const ScreenPoint& aDelta,
TimeStamp aTime, uint64_t* aOutInputBlockId = nullptr) {
APZEventResult Wheel(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, const ScreenPoint& aDelta,
TimeStamp aTime) {
ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0,
ScrollWheelInput::SCROLLMODE_INSTANT,
ScrollWheelInput::SCROLLDELTA_PIXEL, aPoint, aDelta.x,
aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone);
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
nsEventStatus SmoothWheel(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint,
const ScreenPoint& aDelta, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult SmoothWheel(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint,
const ScreenPoint& aDelta, TimeStamp aTime) {
ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0,
ScrollWheelInput::SCROLLMODE_SMOOTH,
ScrollWheelInput::SCROLLDELTA_LINE, aPoint, aDelta.x,
aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone);
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
nsEventStatus MouseDown(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult MouseDown(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime) {
MouseInput input(MouseInput::MOUSE_DOWN, MouseInput::ButtonType::LEFT_BUTTON,
0, 0, aPoint, MillisecondsSinceStartup(aTime), aTime, 0);
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
nsEventStatus MouseMove(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult MouseMove(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime) {
MouseInput input(MouseInput::MOUSE_MOVE, MouseInput::ButtonType::LEFT_BUTTON,
0, 0, aPoint, MillisecondsSinceStartup(aTime), aTime, 0);
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
nsEventStatus MouseUp(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult MouseUp(const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint, TimeStamp aTime) {
MouseInput input(MouseInput::MOUSE_UP, MouseInput::ButtonType::LEFT_BUTTON, 0,
0, aPoint, MillisecondsSinceStartup(aTime), aTime, 0);
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
nsEventStatus PanGesture(PanGestureInput::PanGestureType aType,
const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint,
const ScreenPoint& aDelta, TimeStamp aTime,
uint64_t* aOutInputBlockId = nullptr) {
APZEventResult PanGesture(PanGestureInput::PanGestureType aType,
const RefPtr<InputReceiver>& aTarget,
const ScreenIntPoint& aPoint,
const ScreenPoint& aDelta, TimeStamp aTime) {
PanGestureInput input(aType, MillisecondsSinceStartup(aTime), aTime, aPoint,
aDelta, 0 /* Modifiers */);
if (aType == PanGestureInput::PANGESTURE_END) {
input.mFollowedByMomentum = true;
}
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
return aTarget->ReceiveInputEvent(input);
}
#endif // mozilla_layers_InputUtils_h

View File

@ -339,12 +339,10 @@ TEST_F(APZCBasicTester, OverScroll_Bug1152051b) {
// to schedule a new one since we're still overscrolled. We don't pan because
// panning can trigger functions that clear the overscroll animation state
// in other ways.
uint64_t blockId;
nsEventStatus status =
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &blockId);
APZEventResult result = TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time());
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(apzc, blockId);
result.mStatus != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(apzc, result.mInputBlockId);
}
TouchUp(apzc, ScreenIntPoint(10, 10), mcc->Time());

View File

@ -292,7 +292,8 @@ class APZCFlingStopTester : public APZCGestureDetectorTester {
EXPECT_GT(finalPoint.y, point.y);
// Now we put our finger down to stop the fling
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &blockId);
blockId =
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time()).mInputBlockId;
// Re-sample to make sure it hasn't moved
apzc->SampleContentTransformForFrame(&viewTransform, point,
@ -389,14 +390,13 @@ class APZCLongPressTester : public APZCGestureDetectorTester {
void DoLongPressTest(uint32_t aBehavior) {
MakeApzcUnzoomable();
uint64_t blockId = 0;
nsEventStatus status =
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &blockId);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
APZEventResult result =
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time());
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, result.mStatus);
uint64_t blockId = result.mInputBlockId;
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
result.mStatus != nsEventStatus_eConsumeNoDefault) {
// SetAllowedTouchBehavior() must be called after sending touch-start.
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(aBehavior);
@ -441,9 +441,9 @@ class APZCLongPressTester : public APZCGestureDetectorTester {
// Finally, simulate lifting the finger. Since the long-press wasn't
// prevent-defaulted, we should get a long-tap-up event.
check.Call("preHandleLongTapUp");
status = TouchUp(apzc, ScreenIntPoint(10, 10), mcc->Time());
result.mStatus = TouchUp(apzc, ScreenIntPoint(10, 10), mcc->Time());
mcc->RunThroughDelayedTasks();
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, result.mStatus);
check.Call("postHandleLongTapUp");
apzc->AssertStateIsReset();
@ -456,13 +456,13 @@ class APZCLongPressTester : public APZCGestureDetectorTester {
int touchX = 10, touchStartY = 10, touchEndY = 50;
uint64_t blockId = 0;
nsEventStatus status = TouchDown(apzc, ScreenIntPoint(touchX, touchStartY),
mcc->Time(), &blockId);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
APZEventResult result =
TouchDown(apzc, ScreenIntPoint(touchX, touchStartY), mcc->Time());
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, result.mStatus);
uint64_t blockId = result.mInputBlockId;
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
result.mStatus != nsEventStatus_eConsumeNoDefault) {
// SetAllowedTouchBehavior() must be called after sending touch-start.
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(aBehavior);
@ -502,15 +502,16 @@ class APZCLongPressTester : public APZCGestureDetectorTester {
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, mcc->Time());
mti.mTouches.AppendElement(SingleTouchData(
0, ParentLayerPoint(touchX, touchEndY), ScreenSize(0, 0), 0, 0));
status = apzc->ReceiveInputEvent(mti, nullptr);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
result.mStatus = apzc->ReceiveInputEvent(mti, nullptr);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, result.mStatus);
EXPECT_CALL(*mcc, HandleTap(TapType::eSingleTap,
LayoutDevicePoint(touchX, touchEndY), 0,
apzc->GetGuid(), _))
.Times(0);
status = TouchUp(apzc, ScreenIntPoint(touchX, touchEndY), mcc->Time());
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
result.mStatus =
TouchUp(apzc, ScreenIntPoint(touchX, touchEndY), mcc->Time());
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, result.mStatus);
ParentLayerPoint pointOut;
AsyncTransform viewTransformOut;
@ -705,17 +706,16 @@ TEST_F(APZCGestureDetectorTester, LongPressInterruptedByWheel) {
// point in time.
EXPECT_CALL(*mcc, HandleTap(TapType::eLongTap, _, _, _, _)).Times(1);
uint64_t touchBlockId = 0;
uint64_t wheelBlockId = 0;
nsEventStatus status =
TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &touchBlockId);
APZEventResult result = TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time());
uint64_t touchBlockId = result.mInputBlockId;
if (StaticPrefs::layout_css_touch_action_enabled() &&
status != nsEventStatus_eConsumeNoDefault) {
result.mStatus != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(apzc, touchBlockId);
}
mcc->AdvanceByMillis(10);
Wheel(apzc, ScreenIntPoint(10, 10), ScreenPoint(0, -10), mcc->Time(),
&wheelBlockId);
uint64_t wheelBlockId =
Wheel(apzc, ScreenIntPoint(10, 10), ScreenPoint(0, -10), mcc->Time())
.mInputBlockId;
EXPECT_NE(touchBlockId, wheelBlockId);
mcc->AdvanceByMillis(1000);
}
@ -734,12 +734,12 @@ TEST_F(APZCGestureDetectorTester, TapTimeoutInterruptedByWheel) {
MakeApzcZoomable();
uint64_t touchBlockId = 0;
uint64_t wheelBlockId = 0;
Tap(apzc, ScreenIntPoint(10, 10), TimeDuration::FromMilliseconds(100),
nullptr, &touchBlockId);
mcc->AdvanceByMillis(10);
Wheel(apzc, ScreenIntPoint(10, 10), ScreenPoint(0, -10), mcc->Time(),
&wheelBlockId);
uint64_t wheelBlockId =
Wheel(apzc, ScreenIntPoint(10, 10), ScreenPoint(0, -10), mcc->Time())
.mInputBlockId;
EXPECT_NE(touchBlockId, wheelBlockId);
while (mcc->RunThroughDelayedTasks())
;

View File

@ -493,13 +493,13 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
SingleTouchData(0, touchPoint, ScreenSize(0, 0), 0, 0));
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(mti, nullptr, nullptr));
manager->ReceiveInputEvent(mti).mStatus);
EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint);
check.Call("post-first-touch-start");
// Send a touchend to clear state
mti.mType = MultiTouchInput::MULTITOUCH_END;
manager->ReceiveInputEvent(mti, nullptr, nullptr);
manager->ReceiveInputEvent(mti);
mcc->AdvanceByMillis(1000);
@ -518,13 +518,13 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
// a repaint
mti.mType = MultiTouchInput::MULTITOUCH_START;
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(mti, nullptr, nullptr));
manager->ReceiveInputEvent(mti).mStatus);
EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint);
check.Call("post-second-touch-start");
mti.mType = MultiTouchInput::MULTITOUCH_END;
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(mti, nullptr, nullptr));
manager->ReceiveInputEvent(mti).mStatus);
EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint);
}
@ -545,7 +545,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnWheelEvents) {
ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10,
false, WheelDeltaAdjustmentStrategy::eNone);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(swi, nullptr, nullptr));
manager->ReceiveInputEvent(swi).mStatus);
EXPECT_EQ(origin, swi.mOrigin);
AsyncTransform viewTransform;
@ -573,7 +573,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10,
false, WheelDeltaAdjustmentStrategy::eNone);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(swi, nullptr, nullptr));
manager->ReceiveInputEvent(swi).mStatus);
EXPECT_EQ(origin, swi.mOrigin);
AsyncTransform viewTransform;
@ -604,7 +604,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 0,
false, WheelDeltaAdjustmentStrategy::eNone);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault,
manager->ReceiveInputEvent(swi, nullptr, nullptr));
manager->ReceiveInputEvent(swi).mStatus);
EXPECT_EQ(origin, swi.mOrigin);
}
@ -632,8 +632,8 @@ TEST_F(APZHitTestingTester, Bug1148350) {
mcc->RunThroughDelayedTasks();
check.Call("Tapped without transform");
uint64_t blockId;
TouchDown(manager, ScreenIntPoint(100, 100), mcc->Time(), &blockId);
uint64_t blockId =
TouchDown(manager, ScreenIntPoint(100, 100), mcc->Time()).mInputBlockId;
if (StaticPrefs::layout_css_touch_action_enabled()) {
SetDefaultAllowedTouchBehavior(manager, blockId);
}

View File

@ -17,22 +17,21 @@ TEST_F(APZCTreeManagerTester, WheelInterruptedByMouseDrag) {
UpdateHitTestingTree();
RefPtr<TestAsyncPanZoomController> apzc = ApzcOf(root);
uint64_t dragBlockId = 0;
uint64_t wheelBlockId = 0;
uint64_t tmpBlockId = 0;
// First start the mouse drag
MouseDown(apzc, ScreenIntPoint(5, 5), mcc->Time(), &dragBlockId);
MouseMove(apzc, ScreenIntPoint(6, 6), mcc->Time(), &tmpBlockId);
uint64_t dragBlockId =
MouseDown(apzc, ScreenIntPoint(5, 5), mcc->Time()).mInputBlockId;
uint64_t tmpBlockId =
MouseMove(apzc, ScreenIntPoint(6, 6), mcc->Time()).mInputBlockId;
EXPECT_EQ(dragBlockId, tmpBlockId);
// Insert the wheel event, check that it has a new block id
SmoothWheel(apzc, ScreenIntPoint(6, 6), ScreenPoint(0, 1), mcc->Time(),
&wheelBlockId);
uint64_t wheelBlockId =
SmoothWheel(apzc, ScreenIntPoint(6, 6), ScreenPoint(0, 1), mcc->Time())
.mInputBlockId;
EXPECT_NE(dragBlockId, wheelBlockId);
// Continue the drag, check that the block id is the same as before
MouseMove(apzc, ScreenIntPoint(7, 5), mcc->Time(), &tmpBlockId);
tmpBlockId = MouseMove(apzc, ScreenIntPoint(7, 5), mcc->Time()).mInputBlockId;
EXPECT_EQ(dragBlockId, tmpBlockId);
// Finish the wheel animation

View File

@ -291,12 +291,12 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1073250) {
SingleTouchData(0, ScreenIntPoint(10, 40), ScreenSize(0, 0), 0, 0));
secondFingerDown.mTouches.AppendElement(
SingleTouchData(1, ScreenIntPoint(30, 20), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(secondFingerDown, nullptr, nullptr);
manager->ReceiveInputEvent(secondFingerDown);
// Release the fingers.
MultiTouchInput fingersUp = secondFingerDown;
fingersUp.mType = MultiTouchInput::MULTITOUCH_END;
manager->ReceiveInputEvent(fingersUp, nullptr, nullptr);
manager->ReceiveInputEvent(fingersUp);
// Allow any animations to run their course.
child->AdvanceAnimationsUntilEnd();
@ -334,12 +334,12 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1231228) {
SingleTouchData(0, ScreenIntPoint(10, 40), ScreenSize(0, 0), 0, 0));
secondFingerDown.mTouches.AppendElement(
SingleTouchData(1, ScreenIntPoint(30, 20), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(secondFingerDown, nullptr, nullptr);
manager->ReceiveInputEvent(secondFingerDown);
// Release the fingers.
MultiTouchInput fingersUp = secondFingerDown;
fingersUp.mType = MultiTouchInput::MULTITOUCH_END;
manager->ReceiveInputEvent(fingersUp, nullptr, nullptr);
manager->ReceiveInputEvent(fingersUp);
// Allow any animations to run their course.
child->AdvanceAnimationsUntilEnd();
@ -417,12 +417,12 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1240202b) {
SingleTouchData(0, ScreenIntPoint(10, 90), ScreenSize(0, 0), 0, 0));
secondFingerDown.mTouches.AppendElement(
SingleTouchData(1, ScreenIntPoint(10, 80), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(secondFingerDown, nullptr, nullptr);
manager->ReceiveInputEvent(secondFingerDown);
// Release the fingers.
MultiTouchInput fingersUp = secondFingerDown;
fingersUp.mType = MultiTouchInput::MULTITOUCH_END;
manager->ReceiveInputEvent(fingersUp, nullptr, nullptr);
manager->ReceiveInputEvent(fingersUp);
// Allow any animations to run their course.
child->AdvanceAnimationsUntilEnd();

View File

@ -148,7 +148,7 @@ TEST_F(APZCTreeManagerGenericTester, Bug1194876) {
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mcc->Time());
mti.mTouches.AppendElement(
SingleTouchData(0, ParentLayerPoint(25, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
blockId = manager->ReceiveInputEvent(mti).mInputBlockId;
manager->ContentReceivedInputBlock(blockId, false);
targets.AppendElement(ApzcOf(layers[0])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
@ -160,7 +160,7 @@ TEST_F(APZCTreeManagerGenericTester, Bug1194876) {
// layers[1] is the RCD layer, it will end up being the multitouch target.
mti.mTouches.AppendElement(
SingleTouchData(1, ParentLayerPoint(75, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
blockId = manager->ReceiveInputEvent(mti).mInputBlockId;
manager->ContentReceivedInputBlock(blockId, false);
targets.AppendElement(ApzcOf(layers[0])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
@ -189,7 +189,7 @@ TEST_F(APZCTreeManagerGenericTester, TargetChangesMidGesture_Bug1570559) {
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mcc->Time());
mti.mTouches.AppendElement(
SingleTouchData(0, ParentLayerPoint(25, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
blockId = manager->ReceiveInputEvent(mti).mInputBlockId;
manager->ContentReceivedInputBlock(blockId, /* default prevented = */ false);
targets.AppendElement(ApzcOf(layers[1])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
@ -201,7 +201,7 @@ TEST_F(APZCTreeManagerGenericTester, TargetChangesMidGesture_Bug1570559) {
// child's gesture state.
mti.mTouches.AppendElement(
SingleTouchData(1, ParentLayerPoint(75, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
blockId = manager->ReceiveInputEvent(mti).mInputBlockId;
manager->ContentReceivedInputBlock(blockId, /* default prevented = */ true);
targets.AppendElement(ApzcOf(layers[1])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
@ -224,7 +224,7 @@ TEST_F(APZCTreeManagerGenericTester, Bug1198900) {
ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10,
false, WheelDeltaAdjustmentStrategy::eNone);
uint64_t blockId;
manager->ReceiveInputEvent(swi, nullptr, &blockId);
blockId = manager->ReceiveInputEvent(swi).mInputBlockId;
manager->ContentReceivedInputBlock(blockId, /* preventDefault= */ true);
}

View File

@ -34,17 +34,14 @@ void APZInputBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
mDestroyed = true;
}
nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
InputData& aEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
APZEventResult APZInputBridgeChild::ReceiveInputEvent(InputData& aEvent) {
APZEventResult res;
switch (aEvent.mInputType) {
case MULTITOUCH_INPUT: {
MultiTouchInput& event = aEvent.AsMultiTouchInput();
MultiTouchInput processedEvent;
nsEventStatus res;
SendReceiveMultiTouchInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceiveMultiTouchInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -53,9 +50,7 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
MouseInput& event = aEvent.AsMouseInput();
MouseInput processedEvent;
nsEventStatus res;
SendReceiveMouseInputEvent(event, &res, &processedEvent, aOutTargetGuid,
aOutInputBlockId);
SendReceiveMouseInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -64,9 +59,7 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
PanGestureInput& event = aEvent.AsPanGestureInput();
PanGestureInput processedEvent;
nsEventStatus res;
SendReceivePanGestureInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceivePanGestureInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -75,9 +68,7 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
PinchGestureInput& event = aEvent.AsPinchGestureInput();
PinchGestureInput processedEvent;
nsEventStatus res;
SendReceivePinchGestureInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceivePinchGestureInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -86,9 +77,7 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
TapGestureInput& event = aEvent.AsTapGestureInput();
TapGestureInput processedEvent;
nsEventStatus res;
SendReceiveTapGestureInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceiveTapGestureInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -97,9 +86,7 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
ScrollWheelInput& event = aEvent.AsScrollWheelInput();
ScrollWheelInput processedEvent;
nsEventStatus res;
SendReceiveScrollWheelInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceiveScrollWheelInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
@ -108,16 +95,15 @@ nsEventStatus APZInputBridgeChild::ReceiveInputEvent(
KeyboardInput& event = aEvent.AsKeyboardInput();
KeyboardInput processedEvent;
nsEventStatus res;
SendReceiveKeyboardInputEvent(event, &res, &processedEvent,
aOutTargetGuid, aOutInputBlockId);
SendReceiveKeyboardInputEvent(event, &res, &processedEvent);
event = processedEvent;
return res;
}
default: {
MOZ_ASSERT_UNREACHABLE("Invalid InputData type.");
return nsEventStatus_eConsumeNoDefault;
res.mStatus = nsEventStatus_eConsumeNoDefault;
return res;
}
}
}

View File

@ -20,9 +20,7 @@ class APZInputBridgeChild : public PAPZInputBridgeChild, public APZInputBridge {
APZInputBridgeChild();
void Destroy();
nsEventStatus ReceiveInputEvent(InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) override;
APZEventResult ReceiveInputEvent(InputData& aEvent) override;
protected:
void ProcessUnhandledEvent(LayoutDeviceIntPoint* aRefPoint,

View File

@ -24,90 +24,77 @@ APZInputBridgeParent::APZInputBridgeParent(const LayersId& aLayersId) {
APZInputBridgeParent::~APZInputBridgeParent() {}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceiveMultiTouchInputEvent(
const MultiTouchInput& aEvent, nsEventStatus* aOutStatus,
MultiTouchInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const MultiTouchInput& aEvent, APZEventResult* aOutResult,
MultiTouchInput* aOutEvent) {
MultiTouchInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceiveMouseInputEvent(
const MouseInput& aEvent, nsEventStatus* aOutStatus, MouseInput* aOutEvent,
ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId) {
const MouseInput& aEvent, APZEventResult* aOutResult,
MouseInput* aOutEvent) {
MouseInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceivePanGestureInputEvent(
const PanGestureInput& aEvent, nsEventStatus* aOutStatus,
PanGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const PanGestureInput& aEvent, APZEventResult* aOutResult,
PanGestureInput* aOutEvent) {
PanGestureInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceivePinchGestureInputEvent(
const PinchGestureInput& aEvent, nsEventStatus* aOutStatus,
PinchGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const PinchGestureInput& aEvent, APZEventResult* aOutResult,
PinchGestureInput* aOutEvent) {
PinchGestureInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceiveTapGestureInputEvent(
const TapGestureInput& aEvent, nsEventStatus* aOutStatus,
TapGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const TapGestureInput& aEvent, APZEventResult* aOutResult,
TapGestureInput* aOutEvent) {
TapGestureInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceiveScrollWheelInputEvent(
const ScrollWheelInput& aEvent, nsEventStatus* aOutStatus,
ScrollWheelInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const ScrollWheelInput& aEvent, APZEventResult* aOutResult,
ScrollWheelInput* aOutEvent) {
ScrollWheelInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();
}
mozilla::ipc::IPCResult APZInputBridgeParent::RecvReceiveKeyboardInputEvent(
const KeyboardInput& aEvent, nsEventStatus* aOutStatus,
KeyboardInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) {
const KeyboardInput& aEvent, APZEventResult* aOutResult,
KeyboardInput* aOutEvent) {
KeyboardInput event = aEvent;
*aOutStatus = mTreeManager->InputBridge()->ReceiveInputEvent(
event, aOutTargetGuid, aOutInputBlockId);
*aOutResult = mTreeManager->InputBridge()->ReceiveInputEvent(event);
*aOutEvent = event;
return IPC_OK();

View File

@ -21,39 +21,32 @@ class APZInputBridgeParent : public PAPZInputBridgeParent {
explicit APZInputBridgeParent(const LayersId& aLayersId);
mozilla::ipc::IPCResult RecvReceiveMultiTouchInputEvent(
const MultiTouchInput& aEvent, nsEventStatus* aOutStatus,
MultiTouchInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const MultiTouchInput& aEvent, APZEventResult* aOutResult,
MultiTouchInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceiveMouseInputEvent(
const MouseInput& aEvent, nsEventStatus* aOutStatus,
MouseInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
mozilla::ipc::IPCResult RecvReceiveMouseInputEvent(const MouseInput& aEvent,
APZEventResult* aOutResult,
MouseInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceivePanGestureInputEvent(
const PanGestureInput& aEvent, nsEventStatus* aOutStatus,
PanGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const PanGestureInput& aEvent, APZEventResult* aOutResult,
PanGestureInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceivePinchGestureInputEvent(
const PinchGestureInput& aEvent, nsEventStatus* aOutStatus,
PinchGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const PinchGestureInput& aEvent, APZEventResult* aOutResult,
PinchGestureInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceiveTapGestureInputEvent(
const TapGestureInput& aEvent, nsEventStatus* aOutStatus,
TapGestureInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const TapGestureInput& aEvent, APZEventResult* aOutResult,
TapGestureInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceiveScrollWheelInputEvent(
const ScrollWheelInput& aEvent, nsEventStatus* aOutStatus,
ScrollWheelInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const ScrollWheelInput& aEvent, APZEventResult* aOutResult,
ScrollWheelInput* aOutEvent);
mozilla::ipc::IPCResult RecvReceiveKeyboardInputEvent(
const KeyboardInput& aEvent, nsEventStatus* aOutStatus,
KeyboardInput* aOutEvent, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
const KeyboardInput& aEvent, APZEventResult* aOutResult,
KeyboardInput* aOutEvent);
mozilla::ipc::IPCResult RecvUpdateWheelTransaction(
const LayoutDeviceIntPoint& aRefPoint, const EventMessage& aEventMessage);

View File

@ -14,6 +14,7 @@
#include "ipc/IPCMessageUtils.h"
#include "ipc/nsGUIEventIPC.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/layers/APZInputBridge.h"
#include "mozilla/layers/APZTypes.h"
#include "mozilla/layers/AsyncDragMetrics.h"
#include "mozilla/layers/CompositorOptions.h"
@ -518,6 +519,29 @@ struct ParamTraits<mozilla::layers::ScrollableLayerGuid> {
}
};
template <>
struct ParamTraits<nsEventStatus>
: public ContiguousEnumSerializer<nsEventStatus, nsEventStatus_eIgnore,
nsEventStatus_eSentinel> {};
template <>
struct ParamTraits<mozilla::layers::APZEventResult> {
typedef mozilla::layers::APZEventResult paramType;
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, aParam.mStatus);
WriteParam(aMsg, aParam.mTargetGuid);
WriteParam(aMsg, aParam.mInputBlockId);
}
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
return (ReadParam(aMsg, aIter, &aResult->mStatus) &&
ReadParam(aMsg, aIter, &aResult->mTargetGuid) &&
ReadParam(aMsg, aIter, &aResult->mInputBlockId));
}
};
template <>
struct ParamTraits<mozilla::layers::SLGuidAndRenderRoot> {
typedef mozilla::layers::SLGuidAndRenderRoot paramType;

View File

@ -5,8 +5,8 @@
using LayoutDeviceIntPoint from "Units.h";
using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h";
using struct mozilla::layers::APZEventResult from "mozilla/layers/APZInputBridge.h";
using nsEventStatus from "mozilla/EventForwards.h";
using EventMessage from "mozilla/EventForwards.h";
using class mozilla::MultiTouchInput from "InputData.h";
using class mozilla::MouseInput from "InputData.h";
@ -40,46 +40,32 @@ parent:
// implement the ReceiveInputEvent methods
sync ReceiveMultiTouchInputEvent(MultiTouchInput aEvent)
returns (nsEventStatus aOutStatus,
MultiTouchInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
MultiTouchInput aOutEvent);
sync ReceiveMouseInputEvent(MouseInput aEvent)
returns (nsEventStatus aOutStatus,
MouseInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
MouseInput aOutEvent);
sync ReceivePanGestureInputEvent(PanGestureInput aEvent)
returns (nsEventStatus aOutStatus,
PanGestureInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
PanGestureInput aOutEvent);
sync ReceivePinchGestureInputEvent(PinchGestureInput aEvent)
returns (nsEventStatus aOutStatus,
PinchGestureInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
PinchGestureInput aOutEvent);
sync ReceiveTapGestureInputEvent(TapGestureInput aEvent)
returns (nsEventStatus aOutStatus,
TapGestureInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
TapGestureInput aOutEvent);
sync ReceiveScrollWheelInputEvent(ScrollWheelInput aEvent)
returns (nsEventStatus aOutStatus,
ScrollWheelInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
ScrollWheelInput aOutEvent);
sync ReceiveKeyboardInputEvent(KeyboardInput aEvent)
returns (nsEventStatus aOutStatus,
KeyboardInput aOutEvent,
ScrollableLayerGuid aOutTargetGuid,
uint64_t aOutInputBlockId);
returns (APZEventResult aOutResult,
KeyboardInput aOutEvent);
async UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint, EventMessage aEventMessage);

View File

@ -517,18 +517,15 @@ class nsWindow::NPZCSupport final
// to do?
WheelDeltaAdjustmentStrategy::eNone);
ScrollableLayerGuid guid;
uint64_t blockId;
nsEventStatus status =
controller->InputBridge()->ReceiveInputEvent(input, &guid, &blockId);
APZEventResult result = controller->InputBridge()->ReceiveInputEvent(input);
if (status == nsEventStatus_eConsumeNoDefault) {
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return true;
}
PostInputEvent([input, guid, blockId, status](nsWindow* window) {
PostInputEvent([input, result](nsWindow* window) {
WidgetWheelEvent wheelEvent = input.ToWidgetWheelEvent(window);
window->ProcessUntransformedAPZEvent(&wheelEvent, guid, blockId, status);
window->ProcessUntransformedAPZEvent(&wheelEvent, result);
});
return true;
@ -632,18 +629,15 @@ class nsWindow::NPZCSupport final
ConvertButtons(buttons), origin, aTime,
GetEventTimeStamp(aTime), GetModifiers(aMetaState));
ScrollableLayerGuid guid;
uint64_t blockId;
nsEventStatus status =
controller->InputBridge()->ReceiveInputEvent(input, &guid, &blockId);
APZEventResult result = controller->InputBridge()->ReceiveInputEvent(input);
if (status == nsEventStatus_eConsumeNoDefault) {
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return true;
}
PostInputEvent([input, guid, blockId, status](nsWindow* window) {
PostInputEvent([input, result](nsWindow* window) {
WidgetMouseEvent mouseEvent = input.ToWidgetMouseEvent(window);
window->ProcessUntransformedAPZEvent(&mouseEvent, guid, blockId, status);
window->ProcessUntransformedAPZEvent(&mouseEvent, result);
});
return true;
@ -750,19 +744,16 @@ class nsWindow::NPZCSupport final
ScreenSize::FromUnknownSize(radius), orien, pressure[i]));
}
ScrollableLayerGuid guid;
uint64_t blockId;
nsEventStatus status =
controller->InputBridge()->ReceiveInputEvent(input, &guid, &blockId);
APZEventResult result = controller->InputBridge()->ReceiveInputEvent(input);
if (status == nsEventStatus_eConsumeNoDefault) {
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return true;
}
// Dispatch APZ input event on Gecko thread.
PostInputEvent([input, guid, blockId, status](nsWindow* window) {
PostInputEvent([input, result](nsWindow* window) {
WidgetTouchEvent touchEvent = input.ToWidgetTouchEvent(window);
window->ProcessUntransformedAPZEvent(&touchEvent, guid, blockId, status);
window->ProcessUntransformedAPZEvent(&touchEvent, result);
window->DispatchHitTest(touchEvent);
});
return true;

View File

@ -2708,9 +2708,7 @@ void nsChildView::ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {
nsEventStatus nsChildView::DispatchAPZInputEvent(InputData& aEvent) {
if (mAPZC) {
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
return mAPZC->InputBridge()->ReceiveInputEvent(aEvent, &guid, &inputBlockId);
return mAPZC->InputBridge()->ReceiveInputEvent(aEvent).mStatus;
}
return nsEventStatus_eIgnore;
}
@ -2729,14 +2727,12 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
WidgetWheelEvent event(true, eWheel, this);
if (mAPZC) {
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result = nsEventStatus_eIgnore;
APZEventResult result;
switch (aEvent.mInputType) {
case PANGESTURE_INPUT: {
result = mAPZC->InputBridge()->ReceiveInputEvent(aEvent, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
result = mAPZC->InputBridge()->ReceiveInputEvent(aEvent);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return;
}
@ -2747,7 +2743,7 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
SwipeInfo swipeInfo = SendMayStartSwipe(panInput);
event.mCanTriggerSwipe = swipeInfo.wantsSwipe;
if (swipeInfo.wantsSwipe) {
if (result == nsEventStatus_eIgnore) {
if (result.mStatus == nsEventStatus_eIgnore) {
// APZ has determined and that scrolling horizontally in the
// requested direction is impossible, so it didn't do any
// scrolling for the event.
@ -2762,12 +2758,12 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
// we'll still get a call to ReportSwipeStarted, and we will
// discard the queued events at that point.
mSwipeEventQueue =
MakeUnique<SwipeEventQueue>(swipeInfo.allowedDirections, inputBlockId);
MakeUnique<SwipeEventQueue>(swipeInfo.allowedDirections, result.mInputBlockId);
}
}
}
if (mSwipeEventQueue && mSwipeEventQueue->inputBlockId == inputBlockId) {
if (mSwipeEventQueue && mSwipeEventQueue->inputBlockId == result.mInputBlockId) {
mSwipeEventQueue->queuedEvents.AppendElement(panInput);
}
break;
@ -2779,8 +2775,8 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
// we need to run. Using the InputData variant would bypass that and
// go straight to the APZCTreeManager subclass.
event = aEvent.AsScrollWheelInput().ToWidgetWheelEvent(this);
result = mAPZC->InputBridge()->ReceiveInputEvent(event, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
result = mAPZC->InputBridge()->ReceiveInputEvent(event);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return;
}
break;
@ -2790,7 +2786,7 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
return;
}
if (event.mMessage == eWheel && (event.mDeltaX != 0 || event.mDeltaY != 0)) {
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
ProcessUntransformedAPZEvent(&event, result);
}
return;
}

View File

@ -958,18 +958,21 @@ void nsBaseWidget::UpdateZoomConstraints(
bool nsBaseWidget::AsyncPanZoomEnabled() const { return !!mAPZC; }
nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent(
WidgetInputEvent* aEvent, const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId, nsEventStatus aApzResponse) {
WidgetInputEvent* aEvent, const APZEventResult& aApzResult) {
MOZ_ASSERT(NS_IsMainThread());
InputAPZContext context(aGuid, aInputBlockId, aApzResponse);
ScrollableLayerGuid targetGuid = aApzResult.mTargetGuid;
uint64_t inputBlockId = aApzResult.mInputBlockId;
InputAPZContext context(aApzResult.mTargetGuid, inputBlockId,
aApzResult.mStatus);
// If this is an event that the APZ has targeted to an APZC in the root
// process, apply that APZC's callback-transform before dispatching the
// event. If the event is instead targeted to an APZC in the child process,
// the transform will be applied in the child process before dispatching
// the event there (see e.g. BrowserChild::RecvRealTouchEvent()).
if (aGuid.mLayersId == mCompositorSession->RootLayerTreeId()) {
APZCCallbackHelper::ApplyCallbackTransform(*aEvent, aGuid,
if (aApzResult.mTargetGuid.mLayersId ==
mCompositorSession->RootLayerTreeId()) {
APZCCallbackHelper::ApplyCallbackTransform(*aEvent, targetGuid,
GetDefaultScale());
}
@ -980,7 +983,7 @@ nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent(
UniquePtr<WidgetEvent> original(aEvent->Duplicate());
DispatchEvent(aEvent, status);
if (mAPZC && !InputAPZContext::WasRoutedToChildProcess() && aInputBlockId) {
if (mAPZC && !InputAPZContext::WasRoutedToChildProcess() && inputBlockId) {
// EventStateManager did not route the event into the child process.
// It's safe to communicate to APZ that the event has been processed.
// Note that here aGuid.mLayersId might be different from
@ -997,30 +1000,30 @@ nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent(
if (touchEvent->mMessage == eTouchStart) {
if (StaticPrefs::layout_css_touch_action_enabled()) {
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(
this, GetDocument(), *(original->AsTouchEvent()), aInputBlockId,
this, GetDocument(), *(original->AsTouchEvent()), inputBlockId,
mSetAllowedTouchBehaviorCallback);
}
postLayerization = APZCCallbackHelper::SendSetTargetAPZCNotification(
this, GetDocument(), *(original->AsTouchEvent()), rootLayersId,
aInputBlockId);
inputBlockId);
}
mAPZEventState->ProcessTouchEvent(*touchEvent, aGuid, aInputBlockId,
aApzResponse, status);
mAPZEventState->ProcessTouchEvent(*touchEvent, targetGuid, inputBlockId,
aApzResult.mStatus, status);
} else if (WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent()) {
MOZ_ASSERT(wheelEvent->mFlags.mHandledByAPZ);
postLayerization = APZCCallbackHelper::SendSetTargetAPZCNotification(
this, GetDocument(), *(original->AsWheelEvent()), rootLayersId,
aInputBlockId);
inputBlockId);
if (wheelEvent->mCanTriggerSwipe) {
ReportSwipeStarted(aInputBlockId, wheelEvent->TriggersSwipe());
ReportSwipeStarted(inputBlockId, wheelEvent->TriggersSwipe());
}
mAPZEventState->ProcessWheelEvent(*wheelEvent, aInputBlockId);
mAPZEventState->ProcessWheelEvent(*wheelEvent, inputBlockId);
} else if (WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent()) {
MOZ_ASSERT(mouseEvent->mFlags.mHandledByAPZ);
postLayerization = APZCCallbackHelper::SendSetTargetAPZCNotification(
this, GetDocument(), *(original->AsMouseEvent()), rootLayersId,
aInputBlockId);
mAPZEventState->ProcessMouseEvent(*mouseEvent, aInputBlockId);
inputBlockId);
mAPZEventState->ProcessMouseEvent(*mouseEvent, inputBlockId);
}
if (postLayerization && postLayerization->Register()) {
Unused << postLayerization.release();
@ -1034,29 +1037,22 @@ class DispatchWheelEventOnMainThread : public Runnable {
public:
DispatchWheelEventOnMainThread(const ScrollWheelInput& aWheelInput,
nsBaseWidget* aWidget,
nsEventStatus aAPZResult,
uint64_t aInputBlockId,
ScrollableLayerGuid aGuid)
const APZEventResult& aAPZResult)
: mozilla::Runnable("DispatchWheelEventOnMainThread"),
mWheelInput(aWheelInput),
mWidget(aWidget),
mAPZResult(aAPZResult),
mInputBlockId(aInputBlockId),
mGuid(aGuid) {}
mAPZResult(aAPZResult) {}
NS_IMETHOD Run() override {
WidgetWheelEvent wheelEvent = mWheelInput.ToWidgetWheelEvent(mWidget);
mWidget->ProcessUntransformedAPZEvent(&wheelEvent, mGuid, mInputBlockId,
mAPZResult);
mWidget->ProcessUntransformedAPZEvent(&wheelEvent, mAPZResult);
return NS_OK;
}
private:
ScrollWheelInput mWheelInput;
nsBaseWidget* mWidget;
nsEventStatus mAPZResult;
uint64_t mInputBlockId;
ScrollableLayerGuid mGuid;
APZEventResult mAPZResult;
};
class DispatchWheelInputOnControllerThread : public Runnable {
@ -1068,17 +1064,16 @@ class DispatchWheelInputOnControllerThread : public Runnable {
mMainMessageLoop(MessageLoop::current()),
mWheelInput(aWheelEvent),
mAPZC(aAPZC),
mWidget(aWidget),
mInputBlockId(0) {}
mWidget(aWidget) {}
NS_IMETHOD Run() override {
nsEventStatus result = mAPZC->InputBridge()->ReceiveInputEvent(
mWheelInput, &mGuid, &mInputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
APZEventResult result =
mAPZC->InputBridge()->ReceiveInputEvent(mWheelInput);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
}
RefPtr<Runnable> r = new DispatchWheelEventOnMainThread(
mWheelInput, mWidget, result, mInputBlockId, mGuid);
RefPtr<Runnable> r =
new DispatchWheelEventOnMainThread(mWheelInput, mWidget, result);
mMainMessageLoop->PostTask(r.forget());
return NS_OK;
}
@ -1088,25 +1083,20 @@ class DispatchWheelInputOnControllerThread : public Runnable {
ScrollWheelInput mWheelInput;
RefPtr<IAPZCTreeManager> mAPZC;
nsBaseWidget* mWidget;
uint64_t mInputBlockId;
ScrollableLayerGuid mGuid;
};
void nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result =
mAPZC->InputBridge()->ReceiveInputEvent(aInput, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
APZEventResult result = mAPZC->InputBridge()->ReceiveInputEvent(aInput);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return;
}
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
ProcessUntransformedAPZEvent(&event, result);
} else {
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
@ -1119,17 +1109,14 @@ void nsBaseWidget::DispatchPanGestureInput(PanGestureInput& aInput) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result =
mAPZC->InputBridge()->ReceiveInputEvent(aInput, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
APZEventResult result = mAPZC->InputBridge()->ReceiveInputEvent(aInput);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return;
}
WidgetWheelEvent event = aInput.ToWidgetWheelEvent(this);
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
ProcessUntransformedAPZEvent(&event, result);
} else {
WidgetWheelEvent event = aInput.ToWidgetWheelEvent(this);
@ -1142,15 +1129,11 @@ nsEventStatus nsBaseWidget::DispatchInputEvent(WidgetInputEvent* aEvent) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
if (APZThreadUtils::IsControllerThread()) {
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result = mAPZC->InputBridge()->ReceiveInputEvent(
*aEvent, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
return result;
APZEventResult result = mAPZC->InputBridge()->ReceiveInputEvent(*aEvent);
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return result.mStatus;
}
return ProcessUntransformedAPZEvent(aEvent, guid, inputBlockId, result);
return ProcessUntransformedAPZEvent(aEvent, result);
}
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
if (wheelEvent) {
@ -1172,9 +1155,7 @@ void nsBaseWidget::DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
mAPZC->InputBridge()->ReceiveInputEvent(*aEvent, &guid, &inputBlockId);
mAPZC->InputBridge()->ReceiveInputEvent(*aEvent);
}
}

View File

@ -60,6 +60,7 @@ class CompositorBridgeParent;
class IAPZCTreeManager;
class GeckoContentController;
class APZEventState;
struct APZEventResult;
class CompositorSession;
class ImageContainer;
struct ScrollableLayerGuid;
@ -483,10 +484,9 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
CreateRootContentController();
// Dispatch an event that has already been routed through APZ.
nsEventStatus ProcessUntransformedAPZEvent(mozilla::WidgetInputEvent* aEvent,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId,
nsEventStatus aApzResponse);
nsEventStatus ProcessUntransformedAPZEvent(
mozilla::WidgetInputEvent* aEvent,
const mozilla::layers::APZEventResult& aApzResult);
const LayoutDeviceIntRegion RegionFromArray(
const nsTArray<LayoutDeviceIntRect>& aRects);