diff options
Diffstat (limited to 'gfx/layers/apz/util/ActiveElementManager.h')
-rw-r--r-- | gfx/layers/apz/util/ActiveElementManager.h | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/gfx/layers/apz/util/ActiveElementManager.h b/gfx/layers/apz/util/ActiveElementManager.h index f8a6f07261..1f2e1e4aad 100644 --- a/gfx/layers/apz/util/ActiveElementManager.h +++ b/gfx/layers/apz/util/ActiveElementManager.h @@ -9,6 +9,7 @@ #include "nsCOMPtr.h" #include "nsISupportsImpl.h" +#include "mozilla/EnumSet.h" namespace mozilla { @@ -23,6 +24,10 @@ namespace layers { class DelayedClearElementActivation; +namespace apz { +enum class SingleTapState : uint8_t; +} // namespace apz + /** * Manages setting and clearing the ':active' CSS pseudostate in the presence * of touch input. @@ -46,9 +51,9 @@ class ActiveElementManager final { /** * Handle a touch-start state notification from APZ. This notification * may be delayed until after touch listeners have responded to the APZ. - * @param aCanBePan whether the touch can be a pan + * @param aCanBePanOrZoom whether the touch can be a pan or double-tap-to-zoom */ - void HandleTouchStart(bool aCanBePan); + void HandleTouchStart(bool aCanBePanOrZoom); /** * Clear the active element. */ @@ -57,12 +62,12 @@ class ActiveElementManager final { * Handle a touch-end or touch-cancel event. * @param aWasClick whether the touch was a click */ - void HandleTouchEndEvent(bool aWasClick); + bool HandleTouchEndEvent(apz::SingleTapState aState); /** * Handle a touch-end state notification from APZ. This notification may be * delayed until after touch listeners have responded to the APZ. */ - void HandleTouchEnd(); + bool HandleTouchEnd(apz::SingleTapState aState); /** * Possibly clear active element sate in response to a single tap. */ @@ -76,17 +81,39 @@ class ActiveElementManager final { /** * The target of the first touch point in the current touch block. */ - nsCOMPtr<dom::Element> mTarget; + RefPtr<dom::Element> mTarget; /** - * Whether the current touch block can be a pan. Set in HandleTouchStart(). + * Whether the current touch block can be a pan or double-tap-to-zoom. Set in + * HandleTouchStart(). */ - bool mCanBePan; + bool mCanBePanOrZoom; /** - * Whether mCanBePan has been set for the current touch block. + * Whether mCanBePanOrZoom has been set for the current touch block. * We need to keep track of this to allow HandleTouchStart() and * SetTargetElement() to be called in either order. */ - bool mCanBePanSet; + bool mCanBePanOrZoomSet; + + bool mSingleTapBeforeActivation; + + enum class TouchEndState : uint8_t { + GotTouchEndNotification, + GotTouchEndEvent, + }; + using TouchEndStates = EnumSet<TouchEndState>; + + /** + * A flag tracks whether `APZStateChange::eEndTouch` notification has arrived + * and whether `eTouchEnd` event has arrived. + */ + TouchEndStates mTouchEndState; + + /** + * A tri-state variable to represent the single tap state when both of + * `APZStateChange::eEndTouch` notification and `eTouchEnd` event arrived. + */ + apz::SingleTapState mSingleTapState; + /** * A task for calling SetActive() after a timeout. */ @@ -103,6 +130,8 @@ class ActiveElementManager final { void ResetTouchBlockState(); void SetActiveTask(const nsCOMPtr<dom::Element>& aTarget); void CancelTask(); + // Returns true if the function changed the active element state. + bool MaybeChangeActiveState(apz::SingleTapState aState); }; } // namespace layers |