Skip to content

[Site Isolation] Pointer Lock #46080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

stwrt
Copy link
Member

@stwrt stwrt commented May 29, 2025

25c3c5c

[Site Isolation] Pointer Lock
https://bugs.webkit.org/show_bug.cgi?id=293767
rdar://117910429

Reviewed by NOBODY (OOPS!).

Implement Pointer Lock to work under site isolation.

* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::requestPointerLock):
(WebCore::ChromeClient::requestPointerUnlock):
* Source/WebCore/page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
(WebCore::PointerLockController::requestPointerUnlock):
(WebCore::PointerLockController::requestPointerUnlockAndForceCursorVisible):
* Source/WebKit/UIProcess/API/APIUIClient.h:
(API::UIClient::requestPointerLock):
* Source/WebKit/UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
(WKPageDidAllowPointerLock):
(WKPageDidDenyPointerLock):
* Source/WebKit/UIProcess/Cocoa/UIDelegate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::requestPointerLock):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::requestPointerLock):
(WebKit::WebPageProxy::didAllowPointerLock):
(WebKit::WebPageProxy::didDenyPointerLock):
(WebKit::WebPageProxy::requestPointerUnlock):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::windowWillBeginSheet):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::requestPointerLock):
(WebKit::WebChromeClient::requestPointerUnlock):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::requestPointerLock):
(WebChromeClient::requestPointerUnlock):

25c3c5c

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ❌ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ❌ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ❌ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ❌ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@stwrt stwrt requested a review from cdumez as a code owner May 29, 2025 22:22
@stwrt stwrt self-assigned this May 29, 2025
@stwrt stwrt added the WebKit API For issues and bugs in the Web Kit public embedding APIs label May 29, 2025
@stwrt stwrt requested a review from achristensen07 May 29, 2025 22:22
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 29, 2025
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label May 30, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 418330e to 66eebae Compare May 30, 2025 20:39
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2025
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label May 30, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 66eebae to 23db6a2 Compare May 30, 2025 21:14
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2025
@@ -142,7 +148,12 @@ void PointerLockController::requestPointerUnlock()
return;

m_unlockPending = true;
m_page.chrome().client().requestPointerUnlock();
m_page.chrome().client().requestPointerUnlock([this] (bool result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is repeated in this file, so I think it could be good to put in a function instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unsafe use of pointer capture. Nothing is guaranteeing this has not been deallocated when the callback happens.

@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 13, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 23db6a2 to 792cf13 Compare June 13, 2025 22:05
@webkit-early-warning-system
Copy link
Collaborator

Starting EWS tests for 792cf13. Live statuses available at the PR page, #46080

Copy link
Contributor

@achristensen07 achristensen07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs test coverage with site isolation on.

@@ -142,7 +148,12 @@ void PointerLockController::requestPointerUnlock()
return;

m_unlockPending = true;
m_page.chrome().client().requestPointerUnlock();
m_page.chrome().client().requestPointerUnlock([this] (bool result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unsafe use of pointer capture. Nothing is guaranteeing this has not been deallocated when the callback happens.

@@ -3020,7 +3023,7 @@ void WKPageDidAllowPointerLock(WKPageRef pageRef)
{
CRASH_IF_SUSPENDED;
#if ENABLE(POINTER_LOCK)
toImpl(pageRef)->didAllowPointerLock();
toImpl(pageRef)->didAllowPointerLock([](bool) { });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove WKPageDidAllowPointerLock instead.

@@ -3040,7 +3043,7 @@ void WKPageDidDenyPointerLock(WKPageRef pageRef)
{
CRASH_IF_SUSPENDED;
#if ENABLE(POINTER_LOCK)
toImpl(pageRef)->didDenyPointerLock();
toImpl(pageRef)->didDenyPointerLock([](bool) { });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove WKPageDidDenyPointerLock

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 13, 2025
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 792cf13 to 3684e0c Compare June 23, 2025 20:56
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 23, 2025
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 3684e0c to 4f9005b Compare June 24, 2025 15:50
@stwrt stwrt requested a review from rniwa as a code owner June 24, 2025 15:50
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #41401 (4f9005b)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #41403 (aaa410d)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from aaa410d to 64f7cf8 Compare June 24, 2025 19:08
@stwrt stwrt requested a review from cdumez June 24, 2025 19:10
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 25, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from 64f7cf8 to e8b7011 Compare June 25, 2025 18:41
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 25, 2025
@pascoej
Copy link
Member

pascoej commented Jun 25, 2025

I don't see where a non-empty completion handler is passed to requestPointerLock?

Also please add tests similar to WebKit.PointerLock that utilize site isolated frames.

Copy link
Member

@pascoej pascoej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

https://bugs.webkit.org/show_bug.cgi?id=293767
rdar://117910429

Reviewed by NOBODY (OOPS!).

Implement Pointer Lock to work under site isolation.

* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::requestPointerLock):
(WebCore::ChromeClient::requestPointerUnlock):
* Source/WebCore/page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
(WebCore::PointerLockController::requestPointerUnlock):
(WebCore::PointerLockController::requestPointerUnlockAndForceCursorVisible):
* Source/WebKit/UIProcess/API/APIUIClient.h:
(API::UIClient::requestPointerLock):
* Source/WebKit/UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
(WKPageDidAllowPointerLock):
(WKPageDidDenyPointerLock):
* Source/WebKit/UIProcess/Cocoa/UIDelegate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::requestPointerLock):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::requestPointerLock):
(WebKit::WebPageProxy::didAllowPointerLock):
(WebKit::WebPageProxy::didDenyPointerLock):
(WebKit::WebPageProxy::requestPointerUnlock):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::windowWillBeginSheet):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::requestPointerLock):
(WebKit::WebChromeClient::requestPointerUnlock):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::requestPointerLock):
(WebChromeClient::requestPointerUnlock):
@stwrt stwrt removed the merging-blocked Applied to prevent a change from being merged label Jun 26, 2025
@stwrt stwrt force-pushed the eng/pointer_lock branch from e8b7011 to 25c3c5c Compare June 26, 2025 23:04
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 26, 2025
@stwrt
Copy link
Member Author

stwrt commented Jun 27, 2025

I don't see where a non-empty completion handler is passed to requestPointerLock?

Also please add tests similar to WebKit.PointerLock that utilize site isolated frames.

Working on adding an additional test.

@@ -27,6 +27,7 @@
#if ENABLE(POINTER_LOCK)

#include "ExceptionCode.h"
#include "Page.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should include Page.h if we're moving the implementation of ref/deref to cpp file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merging-blocked Applied to prevent a change from being merged WebKit API For issues and bugs in the Web Kit public embedding APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants