Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: third_party/WebKit/Source/platform/UserGestureIndicator.cpp

Issue 1799253002: Stricter user gestures for touch - measure and warn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/UserGestureIndicator.cpp
diff --git a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
index 62e614d4387c7b67d16545501bdde3f0f971925d..67604a97f75f8b62b40792494fbfe7ea2cc39ca1 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
@@ -123,8 +123,9 @@ ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessi
UserGestureIndicator* UserGestureIndicator::s_topmostIndicator = 0;
bool UserGestureIndicator::s_processedUserGestureSinceLoad = false;
-UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
+UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state, UserGestureUsedCallback* usageCallback)
: m_previousState(DefinitelyNotProcessingUserGesture)
+ , m_usageCallback(usageCallback)
{
// Silently ignore UserGestureIndicators on non-main threads.
if (!isMainThread())
@@ -153,8 +154,9 @@ UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
ASSERT(isDefinite(s_state));
}
-UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token)
+UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token, UserGestureUsedCallback* usageCallback)
: m_previousState(DefinitelyNotProcessingUserGesture)
+ , m_usageCallback(usageCallback)
{
// Silently ignore UserGestureIndicators on non-main threads.
if (!isMainThread())
@@ -192,6 +194,18 @@ UserGestureIndicator::~UserGestureIndicator()
bool UserGestureIndicator::processingUserGesture()
{
+ if (UserGestureIndicator::processingUserGestureUntracked()) {
+ if (s_topmostIndicator->m_usageCallback) {
+ s_topmostIndicator->m_usageCallback->userGestureUsed();
+ s_topmostIndicator->m_usageCallback = nullptr;
+ }
+ return true;
+ }
+ return false;
+}
+
+bool UserGestureIndicator::processingUserGestureUntracked()
+{
if (!isMainThread())
return false;
return s_topmostIndicator && static_cast<GestureToken*>(s_topmostIndicator->currentToken())->hasGestures() && (s_state == DefinitelyProcessingNewUserGesture || s_state == DefinitelyProcessingUserGesture);
@@ -201,7 +215,14 @@ bool UserGestureIndicator::consumeUserGesture()
{
if (!isMainThread() || !s_topmostIndicator)
return false;
- return static_cast<GestureToken*>(s_topmostIndicator->currentToken())->consumeGesture();
+ if (static_cast<GestureToken*>(s_topmostIndicator->currentToken())->consumeGesture()) {
+ if (s_topmostIndicator->m_usageCallback) {
+ s_topmostIndicator->m_usageCallback->userGestureUsed();
+ s_topmostIndicator->m_usageCallback = nullptr;
+ }
+ return true;
+ }
+ return false;
}
UserGestureToken* UserGestureIndicator::currentToken()

Powered by Google App Engine
This is Rietveld 408576698