From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- gfx/layers/apz/public/APZPublicUtils.h | 5 +- .../apz/public/GeckoContentControllerTypes.h | 4 +- gfx/layers/apz/src/APZCTreeManager.cpp | 23 +--- gfx/layers/apz/src/APZCTreeManager.h | 80 ++++++-------- gfx/layers/apz/src/APZSampler.cpp | 13 +-- gfx/layers/apz/src/APZUtils.h | 8 ++ gfx/layers/apz/src/AsyncPanZoomController.cpp | 41 ++++--- gfx/layers/apz/src/AsyncPanZoomController.h | 13 ++- gfx/layers/apz/src/HitTestingTreeNode.h | 14 +-- gfx/layers/apz/src/InputBlockState.cpp | 12 +-- gfx/layers/apz/src/InputBlockState.h | 14 ++- gfx/layers/apz/src/SampledAPZCState.cpp | 2 + .../apz/test/mochitest/helper_bug1669625.html | 3 +- .../apz/test/mochitest/helper_bug1806400-2.html | 58 ++++++++++ .../apz/test/mochitest/helper_bug1806400-3.html | 49 +++++++++ .../apz/test/mochitest/helper_bug1806400-4.html | 49 +++++++++ .../apz/test/mochitest/helper_bug1806400.html | 54 ++++++++++ .../helper_hittest_iframe_perspective-4.html | 86 +++++++++++++++ .../helper_hittest_pointerevents_svg.html | 8 +- .../helper_scrollframe_activation_on_load.html | 5 +- .../helper_touch_synthesized_mouseevents.html | 9 +- .../apz/test/mochitest/test_group_hittest-3.html | 1 + .../test/mochitest/test_group_touchevents-5.html | 18 ++++ .../apz/test/mochitest/test_layerization.html | 5 +- .../mochitest/test_scroll_inactive_bug1190112.html | 3 +- gfx/layers/apz/util/APZEventState.cpp | 23 ++-- gfx/layers/apz/util/APZEventState.h | 6 +- gfx/layers/apz/util/ActiveElementManager.cpp | 119 ++++++++++++++++----- gfx/layers/apz/util/ActiveElementManager.h | 47 ++++++-- 29 files changed, 591 insertions(+), 181 deletions(-) create mode 100644 gfx/layers/apz/test/mochitest/helper_bug1806400-2.html create mode 100644 gfx/layers/apz/test/mochitest/helper_bug1806400-3.html create mode 100644 gfx/layers/apz/test/mochitest/helper_bug1806400-4.html create mode 100644 gfx/layers/apz/test/mochitest/helper_bug1806400.html create mode 100644 gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective-4.html (limited to 'gfx/layers/apz') diff --git a/gfx/layers/apz/public/APZPublicUtils.h b/gfx/layers/apz/public/APZPublicUtils.h index 6433008b4c..47a07c8fd6 100644 --- a/gfx/layers/apz/public/APZPublicUtils.h +++ b/gfx/layers/apz/public/APZPublicUtils.h @@ -55,9 +55,8 @@ const ScreenMargin CalculatePendingDisplayPort( * between 1 and 8 inclusive. The multiplier is chosen based on the provided * base size, such that multiplier is larger when the base size is larger. * The exact details are somewhat arbitrary and tuned by hand. - * This function is intended to only be used with WebRender, because that is - * the codepath that wants to use a larger displayport alignment, because - * moving the displayport is relatively expensive with WebRender. + * We use a large displayport alignment because moving the displayport is + * relatively expensive with WebRender. */ gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize); diff --git a/gfx/layers/apz/public/GeckoContentControllerTypes.h b/gfx/layers/apz/public/GeckoContentControllerTypes.h index 8ab478eab5..8616455137 100644 --- a/gfx/layers/apz/public/GeckoContentControllerTypes.h +++ b/gfx/layers/apz/public/GeckoContentControllerTypes.h @@ -24,7 +24,7 @@ MOZ_DEFINE_ENUM_CLASS(GeckoContentController_APZStateChange, ( eTransformEnd, /** * APZ started a touch. - * |aArg| is 1 if touch can be a pan, 0 otherwise. + * |aArg| is 1 if touch can be a pan or zoom, 0 otherwise. */ eStartTouch, /** @@ -33,7 +33,7 @@ MOZ_DEFINE_ENUM_CLASS(GeckoContentController_APZStateChange, ( eStartPanning, /** * APZ finished processing a touch. - * |aArg| is 1 if touch was a click, 0 otherwise. + * |aArg| is a `apz::SingleTapState` defined in APZUtils.h. */ eEndTouch )); diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index ef3cde3596..bc0b6a8dc6 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -145,8 +145,7 @@ struct APZCTreeManager::TreeBuildingState { // root node of the layers (sub-)tree, which may not be same as the RCD node // for the subtree, and so we need this mechanism to ensure it gets propagated // to the RCD's APZC instance. Once it is set on the APZC instance, the value - // is cleared back to Nothing(). Note that this is only used in the WebRender - // codepath. + // is cleared back to Nothing(). Maybe mZoomAnimationId; // See corresponding members of APZCTreeManager. These are the same thing, but @@ -538,12 +537,9 @@ APZCTreeManager::UpdateHitTestingTree(const WebRenderScrollDataWrapper& aRoot, AsyncPanZoomController* apzc = node->GetApzc(); aLayerMetrics.SetApzc(apzc); - // GetScrollbarAnimationId is only set when webrender is enabled, - // which limits the extra thumb mapping work to the webrender-enabled - // case where it is needed. - // Note also that when webrender is enabled, a "valid" animation id - // is always nonzero, so we don't need to worry about handling the - // case where WR is enabled and the animation id is zero. + // Note that a "valid" animation id is always nonzero, so we don't + // need to worry about handling the case where the animation id is + // zero. if (node->GetScrollbarAnimationId()) { if (node->IsScrollThumbNode()) { state.mScrollThumbs.push_back(node); @@ -555,11 +551,9 @@ APZCTreeManager::UpdateHitTestingTree(const WebRenderScrollDataWrapper& aRoot, } } - // GetFixedPositionAnimationId is only set when webrender is enabled. if (node->GetFixedPositionAnimationId().isSome()) { state.mFixedPositionInfo.emplace_back(node); } - // GetStickyPositionAnimationId is only set when webrender is enabled. if (node->GetStickyPositionAnimationId().isSome()) { state.mStickyPositionInfo.emplace_back(node); } @@ -2290,8 +2284,7 @@ void APZCTreeManager::SetupScrollbarDrag( // Under some conditions, we can confirm the drag block right away. // Otherwise, we have to wait for a main-thread confirmation. - if (StaticPrefs::apz_drag_initial_enabled() && - // check that the scrollbar's target scroll frame is layerized + if (/* check that the scrollbar's target scroll frame is layerized */ aScrollThumbNode->GetScrollTargetId() == aApzc->GetGuid().mScrollId && !aApzc->IsScrollInfoLayer()) { uint64_t dragBlockId = dragBlock->GetBlockId(); @@ -3537,12 +3530,6 @@ already_AddRefed APZCTreeManager::CommonAncestor( return ancestor.forget(); } -bool APZCTreeManager::IsFixedToRootContent( - const HitTestingTreeNode* aNode) const { - MutexAutoLock lock(mMapLock); - return IsFixedToRootContent(FixedPositionInfo(aNode), lock); -} - bool APZCTreeManager::IsFixedToRootContent( const FixedPositionInfo& aFixedInfo, const MutexAutoLock& aProofOfMapLock) const { diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 71d35fd5a6..939e7572a4 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -199,12 +199,10 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { LayersId aOriginatingLayersId, uint32_t aPaintSequenceNumber); /** - * Called when webrender is enabled, from the sampler thread. This function - * populates the provided transaction with any async scroll offsets needed. - * It also advances APZ animations to the specified sample time, and requests - * another composite if there are still active animations. - * In effect it is the webrender equivalent of (part of) the code in - * AsyncCompositionManager. + * Called from the sampler thread. This function populates the provided + * transaction with any async scroll offsets needed. It also advances APZ + * animations to the specified sample time, and requests another composite if + * there are still active animations. */ void SampleForWebRender(const Maybe& aVsyncId, wr::TransactionWrapper& aTxn, @@ -509,7 +507,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { void AssertOnUpdaterThread(); // Returns a pointer to the WebRenderAPI this APZCTreeManager is for. - // This might be null (for example, if WebRender is not enabled). + // This might be null (for example, during GTests). already_AddRefed GetWebRenderAPI() const; protected: @@ -679,12 +677,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { struct FixedPositionInfo; struct StickyPositionInfo; - // Returns true if |aNode| is a fixed layer that is fixed to the root content - // APZC. - // The map lock is required within these functions; if the map lock is already - // being held by the caller, the second overload should be used. If the map - // lock is not being held at the call site, the first overload should be used. - bool IsFixedToRootContent(const HitTestingTreeNode* aNode) const; + // Returns true if |aFixedInfo| represents a layer that is fixed to the root + // content APZC. bool IsFixedToRootContent(const FixedPositionInfo& aFixedInfo, const MutexAutoLock& aProofOfMapLock) const; @@ -919,15 +913,14 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { } }; /** - * If this APZCTreeManager is being used with WebRender, this vector gets - * populated during a layers update. It holds a package of information needed - * to compute and set the async transforms on scroll thumbs. This information - * is extracted from the HitTestingTreeNodes for the WebRender case because - * accessing the HitTestingTreeNodes requires holding the tree lock which - * we cannot do on the WR sampler thread. mScrollThumbInfo, however, can + * This vector gets populated during a layers update. It holds a package of + * information needed to compute and set the async transforms on scroll + * thumbs. This information is extracted from the HitTestingTreeNodes because + * accessing the HitTestingTreeNodes requires holding the tree lock which we + * cannot do on the WebRender sampler thread. mScrollThumbInfo, however, can * be accessed while just holding the mMapLock which is safe to do on the - * sampler thread. - * mMapLock must be acquired while accessing or modifying mScrollThumbInfo. + * sampler thread. mMapLock must be acquired while accessing or modifying + * mScrollThumbInfo. */ std::vector mScrollThumbInfo; @@ -945,12 +938,11 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { mScrollDirection(aScrollDirection) {} }; /** - * If this APZCTreeManager is being used with WebRender, this vector gets - * populated during a layers update. It holds a package of information needed - * to compute and set the async transforms on root scrollbars. This - * information is extracted from the HitTestingTreeNodes for the WebRender - * case because accessing the HitTestingTreeNodes requires holding the tree - * lock which we cannot do on the WR sampler thread. mRootScrollbarInfo, + * This vector gets populated during a layers update. It holds a package of + * information needed to compute and set the async transforms on root + * scrollbars. This information is extracted from the HitTestingTreeNodes + * because accessing the HitTestingTreeNodes requires holding the tree lock + * which we cannot do on the WebRender sampler thread. mRootScrollbarInfo, * however, can be accessed while just holding the mMapLock which is safe to * do on the sampler thread. * mMapLock must be acquired while accessing or modifying mRootScrollbarInfo. @@ -970,15 +962,14 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { explicit FixedPositionInfo(const HitTestingTreeNode* aNode); }; /** - * If this APZCTreeManager is being used with WebRender, this vector gets - * populated during a layers update. It holds a package of information needed - * to compute and set the async transforms on fixed position content. This - * information is extracted from the HitTestingTreeNodes for the WebRender - * case because accessing the HitTestingTreeNodes requires holding the tree - * lock which we cannot do on the WR sampler thread. mFixedPositionInfo, - * however, can be accessed while just holding the mMapLock which is safe to - * do on the sampler thread. mMapLock must be acquired while accessing or - * modifying mFixedPositionInfo. + * This vector gets populated during a layers update. It holds a package of + * information needed to compute and set the async transforms on fixed + * position content. This information is extracted from the + * HitTestingTreeNodes because accessing the HitTestingTreeNodes requires + * holding the tree lock which we cannot do on the WebRender sampler thread. + * mFixedPositionInfo, however, can be accessed while just holding the + * mMapLock which is safe to do on the sampler thread. mMapLock must be + * acquired while accessing or modifying mFixedPositionInfo. */ std::vector mFixedPositionInfo; @@ -997,15 +988,14 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { explicit StickyPositionInfo(const HitTestingTreeNode* aNode); }; /** - * If this APZCTreeManager is being used with WebRender, this vector gets - * populated during a layers update. It holds a package of information needed - * to compute and set the async transforms on sticky position content. This - * information is extracted from the HitTestingTreeNodes for the WebRender - * case because accessing the HitTestingTreeNodes requires holding the tree - * lock which we cannot do on the WR sampler thread. mStickyPositionInfo, - * however, can be accessed while just holding the mMapLock which is safe to - * do on the sampler thread. mMapLock must be acquired while accessing or - * modifying mStickyPositionInfo. + * This vector gets populated during a layers update. It holds a package of + * information needed to compute and set the async transforms on sticky + * position content. This information is extracted from the + * HitTestingTreeNodes because accessing the HitTestingTreeNodes requires + * holding the tree lock which we cannot do on the WebRender sampler thread. + * mStickyPositionInfo, however, can be accessed while just holding the + * mMapLock which is safe to do on the sampler thread. mMapLock must be + * acquired while accessing or modifying mStickyPositionInfo. */ std::vector mStickyPositionInfo; diff --git a/gfx/layers/apz/src/APZSampler.cpp b/gfx/layers/apz/src/APZSampler.cpp index d0e251cec4..e14535da0d 100644 --- a/gfx/layers/apz/src/APZSampler.cpp +++ b/gfx/layers/apz/src/APZSampler.cpp @@ -125,19 +125,16 @@ AsyncTransform APZSampler::GetCurrentAsyncTransform( ParentLayerRect APZSampler::GetCompositionBounds( const LayersId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, const MutexAutoLock& aProofOfMapLock) const { - // This function can get called on the compositor in case of non WebRender - // get called on the sampler thread in case of WebRender. AssertOnSamplerThread(); RefPtr apzc = mApz->GetTargetAPZC(aLayersId, aScrollId, aProofOfMapLock); if (!apzc) { - // On WebRender it's possible that this function can get called even after - // the target APZC has been already destroyed because destroying the - // animation which triggers this function call is basically processed later - // than the APZC one, i.e. queue mCompositorAnimationsToDelete in - // WebRenderBridgeParent and then remove them in - // WebRenderBridgeParent::RemoveEpochDataPriorTo. + // It's possible that this function can get called even after the target + // APZC has been already destroyed because destroying the animation which + // triggers this function call is basically processed later than the APZC + // one, i.e. queue mCompositorAnimationsToDelete in WebRenderBridgeParent + // and then remove them in WebRenderBridgeParent::RemoveEpochDataPriorTo. return ParentLayerRect(); } diff --git a/gfx/layers/apz/src/APZUtils.h b/gfx/layers/apz/src/APZUtils.h index 6614b6eeae..f36a01f65d 100644 --- a/gfx/layers/apz/src/APZUtils.h +++ b/gfx/layers/apz/src/APZUtils.h @@ -233,6 +233,14 @@ bool AboutToCheckerboard(const FrameMetrics& aPaintedMetrics, */ SideBits GetOverscrollSideBits(const ParentLayerPoint& aOverscrollAmount); +// Represents tri-state when a touch-end event received. +enum class SingleTapState : uint8_t { + NotClick, // The touch-block doesn't trigger a click event + WasClick, // The touch-block did trigger a click event + NotYetDetermined, // It's not yet determined whether the touch-block trigger + // a click event or not since double-tapping might happen +}; + } // namespace apz } // namespace layers diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index edbd2ecffa..a070340421 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -242,11 +242,6 @@ typedef PlatformSpecificStateBase * Setting this pref to true will cause APZ to handle mouse-dragging of * scrollbar thumbs. * - * \li\b apz.drag.initial.enabled - * Setting this pref to true will cause APZ to try to handle mouse-dragging - * of scrollbar thumbs without an initial round-trip to content to start it - * if possible. Only has an effect if apz.drag.enabled is also true. - * * \li\b apz.drag.touch.enabled * Setting this pref to true will cause APZ to handle touch-dragging of * scrollbar thumbs. Only has an effect if apz.drag.enabled is also true. @@ -1310,10 +1305,13 @@ nsEventStatus AsyncPanZoomController::OnTouchStart( if (RefPtr controller = GetGeckoContentController()) { MOZ_ASSERT(GetCurrentTouchBlock()); - controller->NotifyAPZStateChange( - GetGuid(), APZStateChange::eStartTouch, + const bool canBePanOrZoom = GetCurrentTouchBlock()->GetOverscrollHandoffChain()->CanBePanned( - this), + this) || + (ZoomConstraintsAllowDoubleTapZoom() && + GetCurrentTouchBlock()->TouchActionAllowsDoubleTapZoom()); + controller->NotifyAPZStateChange( + GetGuid(), APZStateChange::eStartTouch, canBePanOrZoom, Some(GetCurrentTouchBlock()->GetBlockId())); } mLastTouch.mTimeStamp = mTouchStartTime = aEvent.mTimeStamp; @@ -3112,7 +3110,7 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap( // touch block caused a `click` event or not, thus for long-tap events, // it's not necessary. if (aType != TapType::eLongTapUp) { - touch->SetSingleTapOccurred(); + touch->SetSingleTapState(apz::SingleTapState::WasClick); } } // Because this may be being running as part of @@ -3143,7 +3141,7 @@ void AsyncPanZoomController::OnTouchEndOrCancel() { MOZ_ASSERT(GetCurrentTouchBlock()); controller->NotifyAPZStateChange( GetGuid(), APZStateChange::eEndTouch, - GetCurrentTouchBlock()->SingleTapOccurred(), + static_cast(GetCurrentTouchBlock()->SingleTapState()), Some(GetCurrentTouchBlock()->GetBlockId())); } } @@ -3160,6 +3158,21 @@ nsEventStatus AsyncPanZoomController::OnSingleTapUp( return GenerateSingleTap(TapType::eSingleTap, aEvent.mPoint, aEvent.modifiers); } + + // Ignore the event if it does not have valid local coordinates. + // GenerateSingleTap will not send a tap in this case. + if (!ConvertToGecko(aEvent.mPoint)) { + return nsEventStatus_eIgnore; + } + + // Here we need to wait for the call to OnSingleTapConfirmed, we need to tell + // it to ActiveElementManager so that we can do element activation once + // ActiveElementManager got a single tap event later. + if (TouchBlockState* touch = GetCurrentTouchBlock()) { + if (!touch->IsDuringFastFling()) { + touch->SetSingleTapState(apz::SingleTapState::NotYetDetermined); + } + } return nsEventStatus_eIgnore; } @@ -5304,10 +5317,10 @@ void AsyncPanZoomController::UpdateCheckerboardEvent( const MutexAutoLock& aProofOfLock, uint32_t aMagnitude) { if (mCheckerboardEvent && mCheckerboardEvent->RecordFrameInfo(aMagnitude)) { // This checkerboard event is done. Report some metrics to telemetry. - mozilla::glean::gfx_checkerboard::severity.AccumulateSamples( - {mCheckerboardEvent->GetSeverity()}); - mozilla::glean::gfx_checkerboard::peak_pixel_count.AccumulateSamples( - {mCheckerboardEvent->GetPeak()}); + mozilla::glean::gfx_checkerboard::severity.AccumulateSingleSample( + mCheckerboardEvent->GetSeverity()); + mozilla::glean::gfx_checkerboard::peak_pixel_count.AccumulateSingleSample( + mCheckerboardEvent->GetPeak()); mozilla::glean::gfx_checkerboard::duration.AccumulateRawDuration( mCheckerboardEvent->GetDuration()); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index d0c4537a66..5db831d1bf 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -1133,13 +1133,12 @@ class AsyncPanZoomController { UniquePtr mOverscrollEffect; - // Zoom animation id, used for zooming in WebRender. This should only be - // set on the APZC instance for the root content document (i.e. the one we - // support zooming on), and is only used if WebRender is enabled. The - // animation id itself refers to the transform animation id that was set on - // the stacking context in the WR display list. By changing the transform - // associated with this id, we can adjust the scaling that WebRender applies, - // thereby controlling the zoom. + // Zoom animation id, used for zooming. This should only be set on the APZC + // instance for the root content document (i.e. the one we support zooming + // on). The animation id itself refers to the transform animation id that was + // set on the stacking context in the WR display list. By changing the + // transform associated with this id, we can adjust the scaling that WebRender + // applies, thereby controlling the zoom. Maybe mZoomAnimationId; // Position on screen where user first put their finger down. diff --git a/gfx/layers/apz/src/HitTestingTreeNode.h b/gfx/layers/apz/src/HitTestingTreeNode.h index a4958b1af5..b76f317825 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.h +++ b/gfx/layers/apz/src/HitTestingTreeNode.h @@ -182,16 +182,16 @@ class HitTestingTreeNode { LayersId mLayersId; - // This is only set if WebRender is enabled, and only for HTTNs - // where IsScrollThumbNode() returns true. It holds the animation id that we - // use to move the thumb node to reflect async scrolling. + // This is only set for HTTNs where IsScrollThumbNode() returns true. It holds + // the animation id that we use to move the thumb node to reflect async + // scrolling. Maybe mScrollbarAnimationId; // This is set for scrollbar Container and Thumb layers. ScrollbarData mScrollbarData; - // This is only set if WebRender is enabled. It holds the animation id that - // we use to adjust fixed position content for the toolbar. + // This holds the animation id that we use to adjust fixed position content + // for the toolbar. Maybe mFixedPositionAnimationId; ScrollableLayerGuid::ViewID mFixedPosTarget; @@ -200,8 +200,8 @@ class HitTestingTreeNode { ScrollableLayerGuid::ViewID mStickyPosTarget; LayerRectAbsolute mStickyScrollRangeOuter; LayerRectAbsolute mStickyScrollRangeInner; - // This is only set if WebRender is enabled. It holds the animation id that - // we use to adjust sticky position content for the toolbar. + // This holds the animation id that we use to adjust sticky position content + // for the toolbar. Maybe mStickyPositionAnimationId; LayerIntRect mVisibleRect; diff --git a/gfx/layers/apz/src/InputBlockState.cpp b/gfx/layers/apz/src/InputBlockState.cpp index 367fbf9e90..785df56c10 100644 --- a/gfx/layers/apz/src/InputBlockState.cpp +++ b/gfx/layers/apz/src/InputBlockState.cpp @@ -16,6 +16,7 @@ #include "mozilla/StaticPrefs_test.h" #include "mozilla/Telemetry.h" // for Telemetry #include "mozilla/ToString.h" +#include "mozilla/layers/APZEventState.h" #include "mozilla/layers/IAPZCTreeManager.h" // for AllowedTouchBehavior #include "OverscrollHandoffState.h" #include "QueuedInput.h" @@ -636,12 +637,12 @@ TouchBlockState::TouchBlockState( : CancelableBlockState(aTargetApzc, aFlags), mAllowedTouchBehaviorSet(false), mDuringFastFling(false), - mSingleTapOccurred(false), mInSlop(false), mForLongTap(false), mLongTapWasProcessed(false), mIsWaitingLongTapResult(false), mNeedsWaitTouchMove(false), + mSingleTapState(apz::SingleTapState::NotClick), mTouchCounter(aCounter), mStartTime(GetTargetApzc()->GetFrameTime().Time()) { mOriginalTargetConfirmedState = mTargetConfirmed; @@ -700,13 +701,12 @@ void TouchBlockState::SetDuringFastFling() { bool TouchBlockState::IsDuringFastFling() const { return mDuringFastFling; } -void TouchBlockState::SetSingleTapOccurred() { - TBS_LOG("%p setting single-tap-occurred flag\n", this); - mSingleTapOccurred = true; +void TouchBlockState::SetSingleTapState(apz::SingleTapState aState) { + TBS_LOG("%p setting single-tap-state: %d\n", this, + static_cast(aState)); + mSingleTapState = aState; } -bool TouchBlockState::SingleTapOccurred() const { return mSingleTapOccurred; } - bool TouchBlockState::MustStayActive() { // If this touch block is for long-tap, it doesn't need to be active after the // block was processed, it will be taken over by the original touch block diff --git a/gfx/layers/apz/src/InputBlockState.h b/gfx/layers/apz/src/InputBlockState.h index f20a4a5901..d65b1cb57b 100644 --- a/gfx/layers/apz/src/InputBlockState.h +++ b/gfx/layers/apz/src/InputBlockState.h @@ -454,14 +454,12 @@ class TouchBlockState : public CancelableBlockState { */ bool IsDuringFastFling() const; /** - * Set the single-tap-occurred flag that indicates that this touch block - * triggered a single tap event. + * Set the single-tap state flag that indicates that this touch block + * triggered (1) a click, (2) not a click, or (3) not yet sure it will trigger + * a click or not. */ - void SetSingleTapOccurred(); - /** - * @return true iff the single-tap-occurred flag is set on this block. - */ - bool SingleTapOccurred() const; + void SetSingleTapState(apz::SingleTapState aState); + apz::SingleTapState SingleTapState() const { return mSingleTapState; } /** * @return false iff touch-action is enabled and the allowed touch behaviors @@ -537,7 +535,6 @@ class TouchBlockState : public CancelableBlockState { nsTArray mAllowedTouchBehaviors; bool mAllowedTouchBehaviorSet; bool mDuringFastFling; - bool mSingleTapOccurred; bool mInSlop; // A long tap involves two touch blocks: the original touch // block containing the `touchstart`, and a second one @@ -557,6 +554,7 @@ class TouchBlockState : public CancelableBlockState { // content response for a touch move event. It will be set just before // triggering a long-press event. bool mNeedsWaitTouchMove; + apz::SingleTapState mSingleTapState; ScreenIntPoint mSlopOrigin; // A reference to the InputQueue's touch counter TouchCounter& mTouchCounter; diff --git a/gfx/layers/apz/src/SampledAPZCState.cpp b/gfx/layers/apz/src/SampledAPZCState.cpp index 712a46a3b1..8cdd905aba 100644 --- a/gfx/layers/apz/src/SampledAPZCState.cpp +++ b/gfx/layers/apz/src/SampledAPZCState.cpp @@ -86,6 +86,8 @@ void SampledAPZCState::RemoveFractionalAsyncDelta() { // a snapshot of APZ state (decoupling it from APZ assumptions) and provides // it as an input to the compositor (so all compositor state should be // internally consistent based on this input). + // TODO(bug 1889267): Now that we use WebRender everywhere, can this hack be + // removed? if (mLayoutViewport.TopLeft() == mVisualScrollOffset) { return; } diff --git a/gfx/layers/apz/test/mochitest/helper_bug1669625.html b/gfx/layers/apz/test/mochitest/helper_bug1669625.html index 95d2a4bc2c..4a91c7f0b6 100644 --- a/gfx/layers/apz/test/mochitest/helper_bug1669625.html +++ b/gfx/layers/apz/test/mochitest/helper_bug1669625.html @@ -11,8 +11,7 @@ + + + + +
+
+
+
+ + diff --git a/gfx/layers/apz/test/mochitest/helper_bug1806400-3.html b/gfx/layers/apz/test/mochitest/helper_bug1806400-3.html new file mode 100644 index 0000000000..2e5398119c --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_bug1806400-3.html @@ -0,0 +1,49 @@ + + + +Tests that :active state is changed on a scrollable container without any touch event listeners + + + + + +
+
+
+
+ + diff --git a/gfx/layers/apz/test/mochitest/helper_bug1806400-4.html b/gfx/layers/apz/test/mochitest/helper_bug1806400-4.html new file mode 100644 index 0000000000..46fa95b651 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_bug1806400-4.html @@ -0,0 +1,49 @@ + + + +Tests that double-tap-to-zoom never activates elements inside non scrollable container + + + + + +
+
+ + diff --git a/gfx/layers/apz/test/mochitest/helper_bug1806400.html b/gfx/layers/apz/test/mochitest/helper_bug1806400.html new file mode 100644 index 0000000000..03be0c8535 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_bug1806400.html @@ -0,0 +1,54 @@ + + + +Tests that :active state is changed with `touchstart` event listener + + + + + + + + diff --git a/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective-4.html b/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective-4.html new file mode 100644 index 0000000000..96ea0d3b09 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective-4.html @@ -0,0 +1,86 @@ + + + + + + + Test that events are delivered with correct coordinates to an iframe inide a no-op perspective transform + + + + + + + + + + + + diff --git a/gfx/layers/apz/test/mochitest/helper_hittest_pointerevents_svg.html b/gfx/layers/apz/test/mochitest/helper_hittest_pointerevents_svg.html index 22b880736d..3b8a7cef3e 100644 --- a/gfx/layers/apz/test/mochitest/helper_hittest_pointerevents_svg.html +++ b/gfx/layers/apz/test/mochitest/helper_hittest_pointerevents_svg.html @@ -132,10 +132,10 @@ async function test() { `bottom left of scroller in testcase ${testId}`); } - // With the first two cases (circle masks) both WebRender and non-WebRender - // emit dispatch-to-content regions for the right side, so for now we just - // test for that. Eventually WebRender should be able to stop emitting DTC - // and we can update this test to be more precise in that case. + // With the first two cases (circle masks) WebRender emits dispatch-to-content + // regions for the right side, so for now we just test for that. + // Eventually WebRender should be able to stop emitting DTC + // and we can update this test to be more precise. // For the two rectangular test cases we get precise results rather than // dispatch-to-content. if (testId == 1 || testId == 2) { diff --git a/gfx/layers/apz/test/mochitest/helper_scrollframe_activation_on_load.html b/gfx/layers/apz/test/mochitest/helper_scrollframe_activation_on_load.html index 1947a89a8f..c3f02d23d9 100644 --- a/gfx/layers/apz/test/mochitest/helper_scrollframe_activation_on_load.html +++ b/gfx/layers/apz/test/mochitest/helper_scrollframe_activation_on_load.html @@ -41,9 +41,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1151663 let config = getHitTestConfig(); let heightMultiplier = SpecialPowers.getCharPref("apz.y_stationary_size_multiplier"); - // With WebRender, the effective height multiplier can be reduced - // for alignment reasons. The reduction should be no more than a - // factor of two. + // The effective height multiplier can be reduced for alignment reasons. + // The reduction should be no more than a factor of two. heightMultiplier /= 2; info("effective displayport height multipler is " + heightMultiplier); diff --git a/gfx/layers/apz/test/mochitest/helper_touch_synthesized_mouseevents.html b/gfx/layers/apz/test/mochitest/helper_touch_synthesized_mouseevents.html index 3930cec3c3..b3d7b4352a 100644 --- a/gfx/layers/apz/test/mochitest/helper_touch_synthesized_mouseevents.html +++ b/gfx/layers/apz/test/mochitest/helper_touch_synthesized_mouseevents.html @@ -76,6 +76,13 @@ async function test() { promiseOneEvent(targetElem, "click"), ]; + // Create a promise for :active state change since in the case where the + // target element is inside a scrollable container, APZ delays :active state + // change, it sometimes happens after all the relavant events above. + const activePromise = SimpleTest.promiseWaitForCondition( + () => targetElem.matches(":active"), + "Waiting for :active state change"); + // Perform a tap gesture await synthesizeNativeTap(targetElem, 50, 50); @@ -88,7 +95,7 @@ async function test() { // The value of ui.touch_activation.duration_ms should be set to // a large value. If we did not delay sending the synthesized // mouse events, this test will not timeout. - await Promise.all(mouseEventPromises); + await Promise.all([...mouseEventPromises, activePromise]); clearTimeout(failTimeout); diff --git a/gfx/layers/apz/test/mochitest/test_group_hittest-3.html b/gfx/layers/apz/test/mochitest/test_group_hittest-3.html index f5675ee790..eac0348b89 100644 --- a/gfx/layers/apz/test/mochitest/test_group_hittest-3.html +++ b/gfx/layers/apz/test/mochitest/test_group_hittest-3.html @@ -33,6 +33,7 @@ var prefs = [ var subtests = [ {"file": "helper_hittest_iframe_perspective.html", "prefs": prefs}, {"file": "helper_hittest_iframe_perspective-3.html", "prefs": prefs}, + {"file": "helper_hittest_iframe_perspective-4.html", "prefs": prefs}, ]; if (isApzEnabled()) { diff --git a/gfx/layers/apz/test/mochitest/test_group_touchevents-5.html b/gfx/layers/apz/test/mochitest/test_group_touchevents-5.html index 0eee77a3ae..e6e4eb40fb 100644 --- a/gfx/layers/apz/test/mochitest/test_group_touchevents-5.html +++ b/gfx/layers/apz/test/mochitest/test_group_touchevents-5.html @@ -9,6 +9,12 @@