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

Unified Diff: third_party/WebKit/Source/web/WebFrameWidgetBase.cpp

Issue 2696523003: Unify the code paths for handling mouse events when pointer is locked on (Closed)
Patch Set: remove null check Created 3 years, 10 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/web/WebFrameWidgetBase.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp
index 79e51fc74f47f7e990c4f1dec0e24542238a19db..693abe046345ab9eb7bb9d8c2655e0a5f14043bf 100644
--- a/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp
+++ b/third_party/WebKit/Source/web/WebFrameWidgetBase.cpp
@@ -4,7 +4,9 @@
#include "web/WebFrameWidgetBase.h"
+#include "core/dom/DocumentUserGestureToken.h"
#include "core/frame/FrameHost.h"
+#include "core/frame/FrameView.h"
#include "core/frame/VisualViewport.h"
#include "core/input/EventHandler.h"
#include "core/page/DragActions.h"
@@ -12,9 +14,12 @@
#include "core/page/DragData.h"
#include "core/page/DragSession.h"
#include "core/page/Page.h"
+#include "core/page/PointerLockController.h"
+#include "platform/UserGestureIndicator.h"
#include "public/web/WebAutofillClient.h"
#include "public/web/WebDocument.h"
#include "public/web/WebWidgetClient.h"
+#include "web/WebInputEventConversion.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
@@ -218,4 +223,53 @@ Page* WebFrameWidgetBase::page() const {
return view()->page();
}
+void WebFrameWidgetBase::didAcquirePointerLock() {
+ page()->pointerLockController().didAcquirePointerLock();
+}
+
+void WebFrameWidgetBase::didNotAcquirePointerLock() {
+ page()->pointerLockController().didNotAcquirePointerLock();
+}
+
+void WebFrameWidgetBase::didLosePointerLock() {
+ m_pointerLockGestureToken.clear();
+ page()->pointerLockController().didLosePointerLock();
+}
+
+void WebFrameWidgetBase::pointerLockMouseEvent(const WebInputEvent& event) {
+ std::unique_ptr<UserGestureIndicator> gestureIndicator;
+ AtomicString eventType;
+ switch (event.type()) {
+ case WebInputEvent::MouseDown:
+ eventType = EventTypeNames::mousedown;
+ if (!page() || !page()->pointerLockController().element())
+ break;
+ gestureIndicator = WTF::wrapUnique(
+ new UserGestureIndicator(DocumentUserGestureToken::create(
+ &page()->pointerLockController().element()->document(),
+ UserGestureToken::NewGesture)));
+ m_pointerLockGestureToken = gestureIndicator->currentToken();
+ break;
+ case WebInputEvent::MouseUp:
+ eventType = EventTypeNames::mouseup;
+ gestureIndicator = WTF::wrapUnique(
+ new UserGestureIndicator(m_pointerLockGestureToken.release()));
+ break;
+ case WebInputEvent::MouseMove:
+ eventType = EventTypeNames::mousemove;
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event);
+
+ if (page()) {
+ WebMouseEvent transformedEvent = TransformWebMouseEvent(
+ toWebLocalFrameImpl(localRoot())->frameView(), mouseEvent);
+ page()->pointerLockController().dispatchLockedMouseEvent(transformedEvent,
+ eventType);
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/WebFrameWidgetBase.h ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698