diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 1e4dc59756df..8dd81af17af9 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -54,11 +54,6 @@ struct ParamTraits { static void Log(const paramType& aParam, std::wstring* aLog) {} }; -template <> -struct ParamTraits - : public ContiguousEnumSerializer {}; - template <> struct ParamTraits : public ContiguousEnumSerializerReceiveInputEvent(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 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 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; } diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 5f8c82602930..c8e4cf8eba3c 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -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* 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( diff --git a/gfx/layers/apz/src/APZInputBridge.cpp b/gfx/layers/apz/src/APZInputBridge.cpp index 369abcef5c7f..34543f48ffde 100644 --- a/gfx/layers/apz/src/APZInputBridge.cpp +++ b/gfx/layers/apz/src/APZInputBridge.cpp @@ -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 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 diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index f95443c00334..ac2d1eb98d17 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -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& 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& 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& 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& 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; } } diff --git a/gfx/layers/apz/test/gtest/InputUtils.h b/gfx/layers/apz/test/gtest/InputUtils.h index 534a9554e260..80a1bf52350d 100644 --- a/gfx/layers/apz/test/gtest/InputUtils.h +++ b/gfx/layers/apz/test/gtest/InputUtils.h @@ -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& aBehaviours); * The classes that currently implement these are APZCTreeManager and @@ -49,13 +47,12 @@ inline MultiTouchInput CreateMultiTouchInput( } template -nsEventStatus TouchDown(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult TouchDown(const RefPtr& 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 @@ -64,7 +61,7 @@ nsEventStatus TouchMove(const RefPtr& 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 @@ -73,72 +70,67 @@ nsEventStatus TouchUp(const RefPtr& 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 -nsEventStatus Wheel(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, const ScreenPoint& aDelta, - TimeStamp aTime, uint64_t* aOutInputBlockId = nullptr) { +APZEventResult Wheel(const RefPtr& 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 -nsEventStatus SmoothWheel(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, - const ScreenPoint& aDelta, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult SmoothWheel(const RefPtr& 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 -nsEventStatus MouseDown(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult MouseDown(const RefPtr& 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 -nsEventStatus MouseMove(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult MouseMove(const RefPtr& 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 -nsEventStatus MouseUp(const RefPtr& aTarget, - const ScreenIntPoint& aPoint, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult MouseUp(const RefPtr& 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 -nsEventStatus PanGesture(PanGestureInput::PanGestureType aType, - const RefPtr& aTarget, - const ScreenIntPoint& aPoint, - const ScreenPoint& aDelta, TimeStamp aTime, - uint64_t* aOutInputBlockId = nullptr) { +APZEventResult PanGesture(PanGestureInput::PanGestureType aType, + const RefPtr& 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 diff --git a/gfx/layers/apz/test/gtest/TestBasic.cpp b/gfx/layers/apz/test/gtest/TestBasic.cpp index 890d2d438aa0..a52d45689480 100644 --- a/gfx/layers/apz/test/gtest/TestBasic.cpp +++ b/gfx/layers/apz/test/gtest/TestBasic.cpp @@ -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()); diff --git a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp index a5fe0e42db20..dc9eff237418 100644 --- a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp +++ b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp @@ -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 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 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()) ; diff --git a/gfx/layers/apz/test/gtest/TestHitTesting.cpp b/gfx/layers/apz/test/gtest/TestHitTesting.cpp index 87b4c322ff9d..0e7d77fb30f3 100644 --- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp +++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp @@ -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); } diff --git a/gfx/layers/apz/test/gtest/TestInputQueue.cpp b/gfx/layers/apz/test/gtest/TestInputQueue.cpp index a8ac0a33a018..665a276b0339 100644 --- a/gfx/layers/apz/test/gtest/TestInputQueue.cpp +++ b/gfx/layers/apz/test/gtest/TestInputQueue.cpp @@ -17,22 +17,21 @@ TEST_F(APZCTreeManagerTester, WheelInterruptedByMouseDrag) { UpdateHitTestingTree(); RefPtr 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 diff --git a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp index a217180124da..dde28dcfa0c5 100644 --- a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp +++ b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp @@ -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(); diff --git a/gfx/layers/apz/test/gtest/TestTreeManager.cpp b/gfx/layers/apz/test/gtest/TestTreeManager.cpp index a3bb5a8c111d..fac087ca5111 100644 --- a/gfx/layers/apz/test/gtest/TestTreeManager.cpp +++ b/gfx/layers/apz/test/gtest/TestTreeManager.cpp @@ -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); } diff --git a/gfx/layers/ipc/APZInputBridgeChild.cpp b/gfx/layers/ipc/APZInputBridgeChild.cpp index a958a4ab8b40..3fa0389f9d14 100644 --- a/gfx/layers/ipc/APZInputBridgeChild.cpp +++ b/gfx/layers/ipc/APZInputBridgeChild.cpp @@ -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; } } } diff --git a/gfx/layers/ipc/APZInputBridgeChild.h b/gfx/layers/ipc/APZInputBridgeChild.h index 61ce13fe2846..88e1d28c0a13 100644 --- a/gfx/layers/ipc/APZInputBridgeChild.h +++ b/gfx/layers/ipc/APZInputBridgeChild.h @@ -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, diff --git a/gfx/layers/ipc/APZInputBridgeParent.cpp b/gfx/layers/ipc/APZInputBridgeParent.cpp index a1f1bedeb9c1..447182171a48 100644 --- a/gfx/layers/ipc/APZInputBridgeParent.cpp +++ b/gfx/layers/ipc/APZInputBridgeParent.cpp @@ -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(); diff --git a/gfx/layers/ipc/APZInputBridgeParent.h b/gfx/layers/ipc/APZInputBridgeParent.h index 8c53aff6b9b7..94d917a80fc6 100644 --- a/gfx/layers/ipc/APZInputBridgeParent.h +++ b/gfx/layers/ipc/APZInputBridgeParent.h @@ -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); diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 50a349ba72a2..f0c3130cf3fb 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -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 { } }; +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + +template <> +struct ParamTraits { + 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 { typedef mozilla::layers::SLGuidAndRenderRoot paramType; diff --git a/gfx/layers/ipc/PAPZInputBridge.ipdl b/gfx/layers/ipc/PAPZInputBridge.ipdl index a81909abd893..160a74f81c41 100644 --- a/gfx/layers/ipc/PAPZInputBridge.ipdl +++ b/gfx/layers/ipc/PAPZInputBridge.ipdl @@ -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); diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 39a3ad459416..0322ecfab183 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -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; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 3e7eef9d9847..74bfdb4ff571 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -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(swipeInfo.allowedDirections, inputBlockId); + MakeUnique(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; } diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 0bb61da37226..ad2eb0db167a 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -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 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 r = new DispatchWheelEventOnMainThread( - mWheelInput, mWidget, result, mInputBlockId, mGuid); + RefPtr r = + new DispatchWheelEventOnMainThread(mWheelInput, mWidget, result); mMainMessageLoop->PostTask(r.forget()); return NS_OK; } @@ -1088,25 +1083,20 @@ class DispatchWheelInputOnControllerThread : public Runnable { ScrollWheelInput mWheelInput; RefPtr 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); } } diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 59a3b73a7b11..52038ff32db2 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -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& aRects);