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) |