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

Unified Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2408333004: Move persistent gesture state to Document, add DocumentUserGestureToken (Closed)
Patch Set: Re-add dropped null check Created 4 years, 2 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/core/input/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index 75d6b411101fce61600b66355c55b3ac5ae57eb1..a40a5bc065dff8cd721b95a119fcf4bc36e0dad3 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -34,6 +34,7 @@
#include "core/clipboard/DataTransfer.h"
#include "core/dom/DOMNodeIds.h"
#include "core/dom/Document.h"
+#include "core/dom/DocumentUserGestureToken.h"
#include "core/dom/TouchList.h"
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/dom/shadow/ShadowRoot.h"
@@ -572,10 +573,6 @@ WebInputEventResult EventHandler::handleMousePressEvent(
WebPointerProperties::Button::NoButton)
return WebInputEventResult::HandledSuppressed;
- UserGestureIndicator gestureIndicator(UserGestureToken::create());
- m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
- UserGestureIndicator::currentToken();
-
if (m_eventHandlerWillResetCapturingMouseEventsNode)
m_capturingMouseEventsNode = nullptr;
m_mouseEventManager->handleMousePressEventUpdateStates(mouseEvent);
@@ -619,6 +616,11 @@ WebInputEventResult EventHandler::handleMousePressEvent(
return result;
}
+ UserGestureIndicator gestureIndicator(
+ DocumentUserGestureToken::create(m_frame->document()));
+ m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken =
+ UserGestureIndicator::currentToken();
+
if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) {
// We store whether middle click autoscroll is in progress before calling
// stopAutoscroll() because it will set m_autoscrollType to NoAutoscroll on
@@ -897,20 +899,6 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(
if (!mouseEvent.fromTouch())
m_frame->selection().setCaretBlinkingSuspended(false);
- std::unique_ptr<UserGestureIndicator> gestureIndicator;
-
- if (m_frame->localFrameRoot()
- ->eventHandler()
- .m_lastMouseDownUserGestureToken) {
- gestureIndicator = wrapUnique(new UserGestureIndicator(
- m_frame->localFrameRoot()
- ->eventHandler()
- .m_lastMouseDownUserGestureToken.release()));
- } else {
- gestureIndicator =
- wrapUnique(new UserGestureIndicator(UserGestureToken::create()));
- }
-
if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) {
if (Page* page = m_frame->page())
page->autoscrollController().handleMouseReleaseForMiddleClickAutoscroll(
@@ -951,6 +939,24 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(
if (subframe)
return passMouseReleaseEventToSubframe(mev, subframe);
+ // Mouse events will be associated with the Document where mousedown
+ // occurred. If, e.g., there is a mousedown, then a drag to a different
+ // Document and mouseup there, the mouseup's gesture will be associated with
+ // the mousedown's Document. It's not absolutely certain that this is the
+ // correct behavior.
+ std::unique_ptr<UserGestureIndicator> gestureIndicator;
+ if (m_frame->localFrameRoot()
+ ->eventHandler()
+ .m_lastMouseDownUserGestureToken) {
+ gestureIndicator = wrapUnique(new UserGestureIndicator(
+ m_frame->localFrameRoot()
+ ->eventHandler()
+ .m_lastMouseDownUserGestureToken.release()));
+ } else {
+ gestureIndicator = wrapUnique(new UserGestureIndicator(
+ DocumentUserGestureToken::create(m_frame->document())));
+ }
+
WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(
EventTypeNames::mouseup, mev.innerNode(), mev.event());
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp ('k') | third_party/WebKit/Source/core/input/GestureManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698