Title: [105720] trunk/Source/WebKit/chromium
Revision
105720
Author
[email protected]
Date
2012-01-24 03:29:01 -0800 (Tue, 24 Jan 2012)

Log Message

[Chromium] Add WebKit API for Pointer Lock
https://bugs.webkit.org/show_bug.cgi?id=76410

Reviewed by Darin Fisher.

Breaking up https://bugs.webkit.org/show_bug.cgi?id=75762
into a series of patches, this stubs out the API.

* public/WebWidget.h:
(WebKit::WebWidget::didCompletePointerLock):
(WebKit::WebWidget::didNotCompletePointerLock):
(WebKit::WebWidget::didLosePointerLock):
* public/WebWidgetClient.h:
(WebKit::WebWidgetClient::requestPointerLock):
(WebKit::WebWidgetClient::requestPointerUnlock):
(WebKit::WebWidgetClient::isPointerLocked):
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::requestPointerLock):
(WebKit::ChromeClientImpl::requestPointerUnlock):
(WebKit::ChromeClientImpl::isPointerLocked):
* src/ChromeClientImpl.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::handleInputEvent):
(WebKit::WebViewImpl::didCompletePointerLock):
(WebKit::WebViewImpl::didNotCompletePointerLock):
(WebKit::WebViewImpl::didLosePointerLock):
(WebKit::WebViewImpl::requestPointerLock):
(WebKit::WebViewImpl::requestPointerUnlock):
(WebKit::WebViewImpl::isPointerLocked):
(WebKit::WebViewImpl::pointerLockMouseEvent):
* src/WebViewImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (105719 => 105720)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-01-24 11:29:01 UTC (rev 105720)
@@ -1,3 +1,37 @@
+2012-01-24  Vincent Scheib  <[email protected]>
+
+        [Chromium] Add WebKit API for Pointer Lock
+        https://bugs.webkit.org/show_bug.cgi?id=76410
+
+        Reviewed by Darin Fisher.
+
+        Breaking up https://bugs.webkit.org/show_bug.cgi?id=75762
+        into a series of patches, this stubs out the API.
+
+        * public/WebWidget.h:
+        (WebKit::WebWidget::didCompletePointerLock):
+        (WebKit::WebWidget::didNotCompletePointerLock):
+        (WebKit::WebWidget::didLosePointerLock):
+        * public/WebWidgetClient.h:
+        (WebKit::WebWidgetClient::requestPointerLock):
+        (WebKit::WebWidgetClient::requestPointerUnlock):
+        (WebKit::WebWidgetClient::isPointerLocked):
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::requestPointerLock):
+        (WebKit::ChromeClientImpl::requestPointerUnlock):
+        (WebKit::ChromeClientImpl::isPointerLocked):
+        * src/ChromeClientImpl.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleInputEvent):
+        (WebKit::WebViewImpl::didCompletePointerLock):
+        (WebKit::WebViewImpl::didNotCompletePointerLock):
+        (WebKit::WebViewImpl::didLosePointerLock):
+        (WebKit::WebViewImpl::requestPointerLock):
+        (WebKit::WebViewImpl::requestPointerUnlock):
+        (WebKit::WebViewImpl::isPointerLocked):
+        (WebKit::WebViewImpl::pointerLockMouseEvent):
+        * src/WebViewImpl.h:
+
 2012-01-23  Sheriff Bot  <[email protected]>
 
         Unreviewed.  Rolled DEPS.

Modified: trunk/Source/WebKit/chromium/public/WebWidget.h (105719 => 105720)


--- trunk/Source/WebKit/chromium/public/WebWidget.h	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/public/WebWidget.h	2012-01-24 11:29:01 UTC (rev 105720)
@@ -44,6 +44,7 @@
 namespace WebKit {
 
 class WebInputEvent;
+class WebMouseEvent;
 class WebString;
 struct WebPoint;
 template <typename T> class WebVector;
@@ -170,6 +171,16 @@
     // to render its contents.
     virtual bool isAcceleratedCompositingActive() const { return false; }
 
+    // Calling WebWidgetClient::requestPointerLock() will result in one
+    // return call to didAcquirePointerLock() or didNotAcquirePointerLock().
+    virtual void didAcquirePointerLock() { }
+    virtual void didNotAcquirePointerLock() { }
+
+    // Pointer lock was held, but has been lost. This may be due to a
+    // request via WebWidgetClient::requestPointerUnlock(), or for other
+    // reasons such as the user exiting lock, window focus changing, etc.
+    virtual void didLosePointerLock() { }
+
 protected:
     ~WebWidget() { }
 };

Modified: trunk/Source/WebKit/chromium/public/WebWidgetClient.h (105719 => 105720)


--- trunk/Source/WebKit/chromium/public/WebWidgetClient.h	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/public/WebWidgetClient.h	2012-01-24 11:29:01 UTC (rev 105720)
@@ -126,6 +126,21 @@
     // reset the input method by cancelling any ongoing composition.
     virtual void resetInputMethod() { }
 
+    // Requests to lock the mouse cursor. If true is returned, the success
+    // result will be asynchronously returned via a single call to
+    // WebWidget::didAcquirePointerLock() or
+    // WebWidget::didNotAcquirePointerLock().
+    // If false, the request has been denied synchronously.
+    virtual bool requestPointerLock() { return false; }
+
+    // Cause the pointer lock to be released. This may be called at any time,
+    // including when a lock is pending but not yet acquired.
+    // WebWidget::didLosePointerLock() is called when unlock is complete.
+    virtual void requestPointerUnlock() { }
+
+    // Returns true iff the pointer is locked to this widget.
+    virtual bool isPointerLocked() { return false; }
+
 protected:
     ~WebWidgetClient() { }
 };

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (105719 => 105720)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-01-24 11:29:01 UTC (rev 105720)
@@ -1018,4 +1018,21 @@
     m_webView->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
 }
 
+#if ENABLE(POINTER_LOCK)
+bool ChromeClientImpl::requestPointerLock()
+{
+    return m_webView->requestPointerLock();
+}
+
+void ChromeClientImpl::requestPointerUnlock()
+{
+    return m_webView->requestPointerUnlock();
+}
+
+bool ChromeClientImpl::isPointerLocked()
+{
+    return m_webView->isPointerLocked();
+}
+#endif
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.h (105719 => 105720)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.h	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.h	2012-01-24 11:29:01 UTC (rev 105720)
@@ -205,6 +205,12 @@
     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;
     virtual void numWheelEventHandlersChanged(unsigned);
 
+#if ENABLE(POINTER_LOCK)
+    virtual bool requestPointerLock();
+    virtual void requestPointerUnlock();
+    virtual bool isPointerLocked();
+#endif
+
 private:
     void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
     void setCursor(const WebCursorInfo&);

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (105719 => 105720)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-01-24 11:29:01 UTC (rev 105720)
@@ -1331,6 +1331,13 @@
 
     m_currentInputEvent = &inputEvent;
 
+#if ENABLE(POINTER_LOCK)
+    if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) {
+      pointerLockMouseEvent(inputEvent);
+      return true;
+    }
+#endif
+
     if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) {
         // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
         RefPtr<Node> node = m_mouseCaptureNode;
@@ -1742,6 +1749,21 @@
 #endif
 }
 
+void WebViewImpl::didAcquirePointerLock()
+{
+    // FIXME: Implement when PointerLockController lands.
+}
+
+void WebViewImpl::didNotAcquirePointerLock()
+{
+    // FIXME: Implement when PointerLockController lands.
+}
+
+void WebViewImpl::didLosePointerLock()
+{
+    // FIXME: Implement when PointerLockController lands.
+}
+
 // WebView --------------------------------------------------------------------
 
 WebSettings* WebViewImpl::settings()
@@ -3176,4 +3198,27 @@
 }
 #endif
 
+#if ENABLE(POINTER_LOCK)
+bool WebViewImpl::requestPointerLock()
+{
+    return m_client && m_client->requestPointerLock();
+}
+
+void WebViewImpl::requestPointerUnlock()
+{
+    if (m_client)
+        m_client->requestPointerUnlock();
+}
+
+bool WebViewImpl::isPointerLocked()
+{
+    return m_client && m_client->isPointerLocked();
+}
+
+void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event)
+{
+    // FIXME: Implement when PointerLockController lands.
+}
+#endif
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (105719 => 105720)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-01-24 11:22:26 UTC (rev 105719)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-01-24 11:29:01 UTC (rev 105720)
@@ -129,6 +129,9 @@
     virtual bool caretOrSelectionRange(size_t* location, size_t* length);
     virtual void setTextDirection(WebTextDirection direction);
     virtual bool isAcceleratedCompositingActive() const;
+    virtual void didAcquirePointerLock();
+    virtual void didNotAcquirePointerLock();
+    virtual void didLosePointerLock();
 
     // WebView methods:
     virtual void initializeMainFrame(WebFrameClient*);
@@ -469,6 +472,14 @@
     bool hasHorizontalScrollbar();
     bool hasVerticalScrollbar();
 
+    // Pointer Lock calls allow a page to capture all mouse events and
+    // disable the system cursor.
+#if ENABLE(POINTER_LOCK)
+    virtual bool requestPointerLock();
+    virtual void requestPointerUnlock();
+    virtual bool isPointerLocked();
+#endif
+
 private:
     bool computePageScaleFactorLimits();
     float clampPageScaleFactorToLimits(float scale);
@@ -522,6 +533,10 @@
     void updateLayerTreeViewport();
 #endif
 
+#if ENABLE(POINTER_LOCK)
+    void pointerLockMouseEvent(const WebInputEvent&);
+#endif
+
     WebViewClient* m_client;
     WebAutofillClient* m_autofillClient;
     WebPermissionClient* m_permissionClient;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to