<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207689] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207689">207689</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-21 11:45:39 -0700 (Fri, 21 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement basic pointer lock behavior for WebKit and WebKit2.
https://bugs.webkit.org/show_bug.cgi?id=162745
Patch by Jeremy Jones <jeremyj@apple.com> on 2016-10-21
Reviewed by Simon Fraser.
Source/WebCore:
When ENABLE_POINTER_LOCK is enabled, these tests now pass with DumpRenderTree.
LayoutTests/pointer-lock/lock-already-locked.html
LayoutTests/pointer-lock/lock-element-not-in-dom.html
LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html
LayoutTests/pointer-lock/mouse-event-api.html
Export pointer lock symbols and cancel pointer lock on "escape".
* dom/Document.h: Export symbols.
* dom/Element.h: Export symbols.
* page/EventHandler.cpp:
(WebCore::EventHandler::keyEvent): Cancel pointer lock on "escape".
* page/PointerLockController.cpp: Add missing include.
* page/PointerLockController.h: Export symbols.
Source/WebKit/mac:
Add basic pointer lock functionality. User permission is not yet implemented.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::requestPointerLock):
(WebChromeClient::requestPointerUnlock):
Source/WebKit2:
Enable basic pointer lock functionality by plumbing requests through WebPage IPC.
Pass through mouse movement deltas.
Unlock pointer when view is no longer visible.
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent): Pass along mouse movement.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchViewStateChange): Unlock pointer when page is not visible.
(WebKit::WebPageProxy::requestPointerLock): Hide and disassociate pointer.
(WebKit::WebPageProxy::requestPointerUnlock): Show and associate pointer.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in: Add methods.
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::requestPointerLock): Pass along to web page.
(WebKit::WebChromeClient::requestPointerUnlock): Ditto.
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didAcquirePointerLock): Forward to PointerLockController.
(WebKit::WebPage::didNotAcquirePointerLock): Ditto.
(WebKit::WebPage::didLosePointerLock): Ditto.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Add methods.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#trunkSourceWebCorepageEventHandlercpp">trunk/Source/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePointerLockControllercpp">trunk/Source/WebCore/page/PointerLockController.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePointerLockControllerh">trunk/Source/WebCore/page/PointerLockController.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebChromeClienth">trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebChromeClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebEventConversioncpp">trunk/Source/WebKit2/Shared/WebEventConversion.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/ChangeLog        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-10-21 Jeremy Jones <jeremyj@apple.com>
+
+ Implement basic pointer lock behavior for WebKit and WebKit2.
+ https://bugs.webkit.org/show_bug.cgi?id=162745
+
+ Reviewed by Simon Fraser.
+
+ When ENABLE_POINTER_LOCK is enabled, these tests now pass with DumpRenderTree.
+ LayoutTests/pointer-lock/lock-already-locked.html
+ LayoutTests/pointer-lock/lock-element-not-in-dom.html
+ LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html
+ LayoutTests/pointer-lock/mouse-event-api.html
+
+ Export pointer lock symbols and cancel pointer lock on "escape".
+
+ * dom/Document.h: Export symbols.
+ * dom/Element.h: Export symbols.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::keyEvent): Cancel pointer lock on "escape".
+ * page/PointerLockController.cpp: Add missing include.
+ * page/PointerLockController.h: Export symbols.
+
</ins><span class="cx"> 2016-10-21 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><span class="cx"> WebCore::PlatformMediaSession::stopSession + 13
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1515,6 +1515,7 @@
</span><span class="cx">                 3F42B31E1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */; };
</span><span class="cx">                 3FBC4AF3189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBC4AF1189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm */; };
</span><span class="cx">                 3FBC4AF4189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AF2189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFC434F192406A900A0D3B5 /* PointerLockController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 3FFFF9A8159D9A550020BBD5 /* WebKitCSSViewportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */; };
</span><span class="cx">                 3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */; };
</span><span class="cx">                 3FFFF9AD159D9B060020BBD5 /* ViewportStyleResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */; };
</span><span class="lines">@@ -26492,6 +26493,7 @@
</span><span class="cx">                                 BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */,
</span><span class="cx">                                 BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */,
</span><span class="cx">                                 B2B1F7170D00CAA8004AEA64 /* PointerEventsHitRules.h in Headers */,
</span><ins>+                                3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */,
</ins><span class="cx">                                 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */,
</span><span class="cx">                                 97059978107D975200A50A7C /* PolicyCallback.h in Headers */,
</span><span class="cx">                                 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/dom/Document.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1123,8 +1123,8 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><del>- void exitPointerLock();
- Element* pointerLockElement() const;
</del><ins>+ WEBCORE_EXPORT void exitPointerLock();
+ WEBCORE_EXPORT Element* pointerLockElement() const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/dom/Element.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -477,7 +477,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><del>- void requestPointerLock();
</del><ins>+ WEBCORE_EXPORT void requestPointerLock();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(INDIE_UI)
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/page/ChromeClient.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -405,7 +405,6 @@
</span><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><span class="cx"> virtual bool requestPointerLock() { return false; }
</span><span class="cx"> virtual void requestPointerUnlock() { }
</span><del>- virtual bool isPointerLocked() { return false; }
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> virtual FloatSize minimumWindowSize() const { return FloatSize(100, 100); };
</span></span></pre></div>
<a id="trunkSourceWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventHandler.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventHandler.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/page/EventHandler.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> #include "PlatformKeyboardEvent.h"
</span><span class="cx"> #include "PlatformWheelEvent.h"
</span><span class="cx"> #include "PluginDocument.h"
</span><ins>+#include "PointerLockController.h"
</ins><span class="cx"> #include "RenderFrameSet.h"
</span><span class="cx"> #include "RenderLayer.h"
</span><span class="cx"> #include "RenderListBox.h"
</span><span class="lines">@@ -3062,6 +3063,13 @@
</span><span class="cx">
</span><span class="cx"> LOG(Editing, "EventHandler %p keyEvent (text %s keyIdentifier %s)", this, initialKeyEvent.text().utf8().data(), initialKeyEvent.keyIdentifier().utf8().data());
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+ if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE && m_frame.page()->pointerLockController().element()) {
+ m_frame.page()->pointerLockController().requestPointerUnlock();
+ return true;
+ }
+#endif
+
</ins><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx"> if (m_frame.document()->webkitIsFullScreen() && !isKeyEventAllowedInFullScreen(initialKeyEvent))
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="trunkSourceWebCorepagePointerLockControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PointerLockController.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PointerLockController.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/page/PointerLockController.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "ChromeClient.h"
</span><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "Event.h"
</span><ins>+#include "EventNames.h"
</ins><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "PlatformMouseEvent.h"
</span><span class="cx"> #include "VoidCallback.h"
</span><span class="lines">@@ -63,13 +64,17 @@
</span><span class="cx"> enqueueEvent(eventNames().pointerlockerrorEvent, target);
</span><span class="cx"> return;
</span><span class="cx"> }
</span><ins>+ m_element = target;
</ins><span class="cx"> enqueueEvent(eventNames().pointerlockchangeEvent, target);
</span><del>- m_element = target;
- } else if (m_page.chrome().client().requestPointerLock()) {
</del><ins>+ } else {
</ins><span class="cx"> m_lockPending = true;
</span><span class="cx"> m_element = target;
</span><del>- } else
- enqueueEvent(eventNames().pointerlockerrorEvent, target);
</del><ins>+ if (!m_page.chrome().client().requestPointerLock()) {
+ m_element = nullptr;
+ m_lockPending = false;
+ enqueueEvent(eventNames().pointerlockerrorEvent, target);
+ }
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PointerLockController::requestPointerUnlock()
</span></span></pre></div>
<a id="trunkSourceWebCorepagePointerLockControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PointerLockController.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PointerLockController.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebCore/page/PointerLockController.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -50,9 +50,9 @@
</span><span class="cx"> bool lockPending() const;
</span><span class="cx"> Element* element() const;
</span><span class="cx">
</span><del>- void didAcquirePointerLock();
- void didNotAcquirePointerLock();
- void didLosePointerLock();
</del><ins>+ WEBCORE_EXPORT void didAcquirePointerLock();
+ WEBCORE_EXPORT void didNotAcquirePointerLock();
+ WEBCORE_EXPORT void didLosePointerLock();
</ins><span class="cx"> void dispatchLockedMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType);
</span><span class="cx">
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-21 Jeremy Jones <jeremyj@apple.com>
+
+ Implement basic pointer lock behavior for WebKit and WebKit2.
+ https://bugs.webkit.org/show_bug.cgi?id=162745
+
+ Reviewed by Simon Fraser.
+
+ Add basic pointer lock functionality. User permission is not yet implemented.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::requestPointerLock):
+ (WebChromeClient::requestPointerUnlock):
+
</ins><span class="cx"> 2016-10-19 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> [macOS] [iOS] Disable variation fonts on macOS El Capitan and iOS 9
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -135,6 +135,11 @@
</span><span class="cx"> #if ENABLE(INPUT_TYPE_COLOR)
</span><span class="cx"> std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) override;
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(POINTER_LOCK)
+ bool requestPointerLock() override;
+ void requestPointerUnlock() override;
+#endif
</ins><span class="cx">
</span><span class="cx"> WebCore::KeyboardUIMode keyboardUIMode() override;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebChromeClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> #import <WebCore/NotImplemented.h>
</span><span class="cx"> #import <WebCore/Page.h>
</span><span class="cx"> #import <WebCore/PlatformScreen.h>
</span><ins>+#import <WebCore/PointerLockController.h>
</ins><span class="cx"> #import <WebCore/ResourceRequest.h>
</span><span class="cx"> #import <WebCore/SerializedCryptoKeyWrap.h>
</span><span class="cx"> #import <WebCore/Widget.h>
</span><span class="lines">@@ -709,6 +710,34 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+bool WebChromeClient::requestPointerLock()
+{
+#if PLATFORM(MAC)
+ if (![m_webView page])
+ return false;
+
+ CGDisplayHideCursor(CGMainDisplayID());
+ CGAssociateMouseAndMouseCursorPosition(false);
+ [m_webView page]->pointerLockController().didAcquirePointerLock();
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+void WebChromeClient::requestPointerUnlock()
+{
+#if PLATFORM(MAC)
+ CGDisplayShowCursor(CGMainDisplayID());
+ CGAssociateMouseAndMouseCursorPosition(true);
+ if ([m_webView page])
+ [m_webView page]->pointerLockController().didLosePointerLock();
+#endif
+}
+#endif
+
</ins><span class="cx"> void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
</span><span class="cx"> {
</span><span class="cx"> BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-10-21 Jeremy Jones <jeremyj@apple.com>
+
+ Implement basic pointer lock behavior for WebKit and WebKit2.
+ https://bugs.webkit.org/show_bug.cgi?id=162745
+
+ Reviewed by Simon Fraser.
+
+ Enable basic pointer lock functionality by plumbing requests through WebPage IPC.
+ Pass through mouse movement deltas.
+ Unlock pointer when view is no longer visible.
+
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent): Pass along mouse movement.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::dispatchViewStateChange): Unlock pointer when page is not visible.
+ (WebKit::WebPageProxy::requestPointerLock): Hide and disassociate pointer.
+ (WebKit::WebPageProxy::requestPointerUnlock): Show and associate pointer.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in: Add methods.
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::requestPointerLock): Pass along to web page.
+ (WebKit::WebChromeClient::requestPointerUnlock): Ditto.
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::didAcquirePointerLock): Forward to PointerLockController.
+ (WebKit::WebPage::didNotAcquirePointerLock): Ditto.
+ (WebKit::WebPage::didLosePointerLock): Ditto.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in: Add methods.
+
</ins><span class="cx"> 2016-10-21 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Implement InputEvent.getTargetRanges() for the input events spec
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebEventConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -100,6 +100,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> m_position = webEvent.position();
</span><ins>+#if ENABLE(POINTER_LOCK)
+ m_movementDelta = WebCore::IntPoint(webEvent.deltaX(), webEvent.deltaY());
+#endif
</ins><span class="cx"> m_globalPosition = webEvent.globalPosition();
</span><span class="cx"> m_clickCount = webEvent.clickCount();
</span><span class="cx"> #if PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -1549,6 +1549,11 @@
</span><span class="cx"> if ((changed & ViewState::IsVisible) && !isViewVisible())
</span><span class="cx"> m_process->responsivenessTimer().stop();
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+ if ((changed & ViewState::IsVisible) && !isViewVisible())
+ requestPointerUnlock();
+#endif
+
</ins><span class="cx"> if (changed & ViewState::IsInWindow) {
</span><span class="cx"> if (isInWindow())
</span><span class="cx"> viewDidEnterWindow();
</span><span class="lines">@@ -6620,5 +6625,37 @@
</span><span class="cx">
</span><span class="cx"> m_process->send(Messages::WebPage::SetUserInterfaceLayoutDirection(static_cast<uint32_t>(userInterfaceLayoutDirection)), m_pageID);
</span><span class="cx"> }
</span><ins>+
+#if ENABLE(POINTER_LOCK)
+void WebPageProxy::requestPointerLock()
+{
+ if (!isViewVisible()) {
+ m_process->send(Messages::WebPage::DidNotAcquirePointerLock(), m_pageID);
+ return;
+ }
</ins><span class="cx">
</span><ins>+ didAllowPointerLock();
+}
+
+void WebPageProxy::didAllowPointerLock()
+{
+ CGDisplayHideCursor(CGMainDisplayID());
+ CGAssociateMouseAndMouseCursorPosition(false);
+ m_process->send(Messages::WebPage::DidAcquirePointerLock(), m_pageID);
+}
+
+void WebPageProxy::didDenyPointerLock()
+{
+ m_process->send(Messages::WebPage::DidNotAcquirePointerLock(), m_pageID);
+}
+
+void WebPageProxy::requestPointerUnlock()
+{
+ CGDisplayShowCursor(CGMainDisplayID());
+ CGAssociateMouseAndMouseCursorPosition(true);
+ m_process->send(Messages::WebPage::DidLosePointerLock(), m_pageID);
+}
+#endif
+
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -946,6 +946,11 @@
</span><span class="cx"> void handleMediaEvent(WebCore::MediaEventType);
</span><span class="cx"> void setVolumeOfMediaElement(double, uint64_t);
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(POINTER_LOCK)
+ void didAllowPointerLock();
+ void didDenyPointerLock();
+#endif
</ins><span class="cx">
</span><span class="cx"> // WebPopupMenuProxy::Client
</span><span class="cx"> NativeWebMouseEvent* currentlyProcessedMouseDownEvent() override;
</span><span class="lines">@@ -1168,6 +1173,11 @@
</span><span class="cx"> void failedToShowPopupMenu() override;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+ void requestPointerLock();
+ void requestPointerUnlock();
+#endif
+
</ins><span class="cx"> void didCreateMainFrame(uint64_t frameID);
</span><span class="cx"> void didCreateSubframe(uint64_t frameID);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -458,6 +458,11 @@
</span><span class="cx"> SetMockMediaPlaybackTargetPickerState(String name, unsigned pickerState)
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+ RequestPointerLock()
+ RequestPointerUnlock()
+#endif
+
</ins><span class="cx"> ImageOrMediaDocumentSizeChanged(WebCore::IntSize newSize)
</span><span class="cx">
</span><span class="cx"> UseFixedLayoutDidChange(bool useFixedLayout)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -455,6 +455,19 @@
</span><span class="cx"> return m_page->keyboardUIMode();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+bool WebChromeClient::requestPointerLock()
+{
+ m_page->send(Messages::WebPageProxy::RequestPointerLock());
+ return true;
+}
+
+void WebChromeClient::requestPointerUnlock()
+{
+ m_page->send(Messages::WebPageProxy::RequestPointerUnlock());
+}
+#endif
+
</ins><span class="cx"> void WebChromeClient::invalidateRootView(const IntRect&)
</span><span class="cx"> {
</span><span class="cx"> // Do nothing here, there's no concept of invalidating the window in the web process.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -191,6 +191,11 @@
</span><span class="cx"> #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
</span><span class="cx"> void scheduleAnimation() override;
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(POINTER_LOCK)
+ bool requestPointerLock() override;
+ void requestPointerUnlock() override;
+#endif
</ins><span class="cx">
</span><span class="cx"> void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) override;
</span><span class="cx"> bool shouldNotifyOnFormChanges() override;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx"> #include <WebCore/PageThrottler.h>
</span><span class="cx"> #include <WebCore/PlatformKeyboardEvent.h>
</span><span class="cx"> #include <WebCore/PluginDocument.h>
</span><ins>+#include <WebCore/PointerLockController.h>
</ins><span class="cx"> #include <WebCore/PrintContext.h>
</span><span class="cx"> #include <WebCore/Range.h>
</span><span class="cx"> #include <WebCore/RenderLayer.h>
</span><span class="lines">@@ -5613,4 +5614,21 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+void WebPage::didAcquirePointerLock()
+{
+ corePage()->pointerLockController().didAcquirePointerLock();
+}
+
+void WebPage::didNotAcquirePointerLock()
+{
+ corePage()->pointerLockController().didNotAcquirePointerLock();
+}
+
+void WebPage::didLosePointerLock()
+{
+ corePage()->pointerLockController().didLosePointerLock();
+}
+#endif
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -961,6 +961,12 @@
</span><span class="cx"> #if ENABLE(GAMEPAD)
</span><span class="cx"> void gamepadActivity(const Vector<GamepadData>&);
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(POINTER_LOCK)
+ void didAcquirePointerLock();
+ void didNotAcquirePointerLock();
+ void didLosePointerLock();
+#endif
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebPage(uint64_t pageID, const WebPageCreationParameters&);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (207688 => 207689)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-10-21 18:37:47 UTC (rev 207688)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-10-21 18:45:39 UTC (rev 207689)
</span><span class="lines">@@ -428,6 +428,12 @@
</span><span class="cx"> SetShouldPlayToPlaybackTarget(uint64_t contextId, bool shouldPlay)
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(POINTER_LOCK)
+ DidAcquirePointerLock()
+ DidNotAcquirePointerLock()
+ DidLosePointerLock()
+#endif
+
</ins><span class="cx"> ClearWheelEventTestTrigger()
</span><span class="cx"> SetShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>