From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/dom/UserGestureIndicator.h | 59 ++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'Source/WebCore/dom/UserGestureIndicator.h') diff --git a/Source/WebCore/dom/UserGestureIndicator.h b/Source/WebCore/dom/UserGestureIndicator.h index d137c005d..f044f65aa 100644 --- a/Source/WebCore/dom/UserGestureIndicator.h +++ b/Source/WebCore/dom/UserGestureIndicator.h @@ -23,33 +23,68 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef UserGestureIndicator_h -#define UserGestureIndicator_h +#pragma once +#include #include +#include +#include +#include +#include namespace WebCore { +class Document; + enum ProcessingUserGestureState { - DefinitelyProcessingUserGesture, - PossiblyProcessingUserGesture, - DefinitelyNotProcessingUserGesture + ProcessingUserGesture, + ProcessingPotentialUserGesture, + NotProcessingUserGesture +}; + +class UserGestureToken : public RefCounted { +public: + static RefPtr create(ProcessingUserGestureState state) + { + return adoptRef(new UserGestureToken(state)); + } + + WEBCORE_EXPORT ~UserGestureToken(); + + ProcessingUserGestureState state() const { return m_state; } + bool processingUserGesture() const { return m_state == ProcessingUserGesture; } + bool processingUserGestureForMedia() const { return m_state == ProcessingUserGesture || m_state == ProcessingPotentialUserGesture; } + + void addDestructionObserver(WTF::Function&& observer) + { + m_destructionObservers.append(WTFMove(observer)); + } + +private: + UserGestureToken(ProcessingUserGestureState state) + : m_state(state) + { + } + + ProcessingUserGestureState m_state = NotProcessingUserGesture; + Vector> m_destructionObservers; }; class UserGestureIndicator { WTF_MAKE_NONCOPYABLE(UserGestureIndicator); public: - static bool processingUserGesture(); + WEBCORE_EXPORT static RefPtr currentUserGesture(); - explicit UserGestureIndicator(ProcessingUserGestureState); - ~UserGestureIndicator(); + WEBCORE_EXPORT static bool processingUserGesture(); + WEBCORE_EXPORT static bool processingUserGestureForMedia(); + // If a document is provided, its last known user gesture timestamp is updated. + WEBCORE_EXPORT explicit UserGestureIndicator(std::optional, Document* = nullptr); + WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr); + WEBCORE_EXPORT ~UserGestureIndicator(); private: - static ProcessingUserGestureState s_state; - ProcessingUserGestureState m_previousState; + RefPtr m_previousToken; }; } - -#endif -- cgit v1.2.1