diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/UserGestureIndicator.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/dom/UserGestureIndicator.h')
-rw-r--r-- | Source/WebCore/dom/UserGestureIndicator.h | 59 |
1 files changed, 47 insertions, 12 deletions
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 <wtf/Function.h> #include <wtf/Noncopyable.h> +#include <wtf/Optional.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> namespace WebCore { +class Document; + enum ProcessingUserGestureState { - DefinitelyProcessingUserGesture, - PossiblyProcessingUserGesture, - DefinitelyNotProcessingUserGesture + ProcessingUserGesture, + ProcessingPotentialUserGesture, + NotProcessingUserGesture +}; + +class UserGestureToken : public RefCounted<UserGestureToken> { +public: + static RefPtr<UserGestureToken> 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<void (UserGestureToken&)>&& observer) + { + m_destructionObservers.append(WTFMove(observer)); + } + +private: + UserGestureToken(ProcessingUserGestureState state) + : m_state(state) + { + } + + ProcessingUserGestureState m_state = NotProcessingUserGesture; + Vector<WTF::Function<void (UserGestureToken&)>> m_destructionObservers; }; class UserGestureIndicator { WTF_MAKE_NONCOPYABLE(UserGestureIndicator); public: - static bool processingUserGesture(); + WEBCORE_EXPORT static RefPtr<UserGestureToken> 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<ProcessingUserGestureState>, Document* = nullptr); + WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr<UserGestureToken>); + WEBCORE_EXPORT ~UserGestureIndicator(); private: - static ProcessingUserGestureState s_state; - ProcessingUserGestureState m_previousState; + RefPtr<UserGestureToken> m_previousToken; }; } - -#endif |