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

Unified Diff: Source/platform/UserGestureIndicator.cpp

Issue 82693006: Adding handlers for user gesture callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed unit test bug Created 7 years, 1 month 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
« no previous file with comments | « Source/platform/UserGestureIndicator.h ('k') | Source/web/WebUserGestureIndicator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/UserGestureIndicator.cpp
diff --git a/Source/platform/UserGestureIndicator.cpp b/Source/platform/UserGestureIndicator.cpp
index 03d219537a755790da17f7bf8602c9a560633c6b..811a820ade68d9faa973133c7f82bc009bb0524a 100644
--- a/Source/platform/UserGestureIndicator.cpp
+++ b/Source/platform/UserGestureIndicator.cpp
@@ -29,6 +29,7 @@
#include "wtf/Assertions.h"
#include "wtf/CurrentTime.h"
#include "wtf/MainThread.h"
+#include "wtf/Vector.h"
namespace WebCore {
@@ -112,6 +113,7 @@ static bool isDefinite(ProcessingUserGestureState state)
ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture;
UserGestureIndicator* UserGestureIndicator::s_topmostIndicator = 0;
+UserGestureHandler* UserGestureIndicator::s_handler = 0;
UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
: m_previousState(s_state)
@@ -131,10 +133,17 @@ UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
s_state = state;
}
- if (state == DefinitelyProcessingNewUserGesture)
+ bool shouldNotifyHandler = false;
+ if (state == DefinitelyProcessingNewUserGesture) {
static_cast<GestureToken*>(m_token.get())->addGesture();
- else if (state == DefinitelyProcessingUserGesture && s_topmostIndicator == this)
+ shouldNotifyHandler = true;
+ } else if (state == DefinitelyProcessingUserGesture && s_topmostIndicator == this) {
static_cast<GestureToken*>(m_token.get())->addGesture();
+ shouldNotifyHandler = true;
+ }
+
+ if (shouldNotifyHandler && s_handler)
+ s_handler->onGesture();
ASSERT(isDefinite(s_state));
}
@@ -158,6 +167,9 @@ UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token)
}
}
s_state = DefinitelyProcessingUserGesture;
+
+ if (s_handler)
+ s_handler->onGesture();
}
ASSERT(isDefinite(s_state));
@@ -194,6 +206,11 @@ UserGestureToken* UserGestureIndicator::currentToken()
return s_topmostIndicator->m_token.get();
}
+void UserGestureIndicator::setHandler(UserGestureHandler* handler)
+{
+ s_handler = handler;
+}
+
UserGestureIndicatorDisabler::UserGestureIndicatorDisabler()
: m_savedState(UserGestureIndicator::s_state)
, m_savedIndicator(UserGestureIndicator::s_topmostIndicator)
« no previous file with comments | « Source/platform/UserGestureIndicator.h ('k') | Source/web/WebUserGestureIndicator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698