VOOZH about

URL: https://phabricator.services.mozilla.com/D297193

⇱ ⚙ D297193 Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS first;


Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS first;
ClosedPublic

Authored by edgar on Apr 29 2026, 12:08 AM.
Referenced Files
Unknown Object (File)
Mon, Jun 8, 6:57 PM
Unknown Object (File)
Sun, Jun 7, 4:43 AM
Unknown Object (File)
Wed, Jun 3, 12:58 PM
Unknown Object (File)
Wed, Jun 3, 12:58 PM
Unknown Object (File)
Wed, Jun 3, 12:58 PM
Unknown Object (File)
Wed, Jun 3, 12:58 PM
Unknown Object (File)
Wed, Jun 3, 10:25 AM
Unknown Object (File)
Wed, Jun 3, 5:33 AM
Subscribers

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
smaug added inline comments.
dom/webidl/PointerLockOptions.webidl
10 ↗(On Diff #1261147)

We need a pref for this, I think. Something which is enabled only once most platforms (desktop at least, probably) support the feature.
So, add dom.pointer-lock.unadjusted-movement.enabled pref check here?

edgar requested changes to this revision.Apr 30 2026, 11:11 AM
edgar added a subscriber: edgar.
Comment Actions

Thanks for the patch. I have some suggestion.

dom/base/PointerLockManager.cpp
107

Mapping twice seems unnecessary, could we map the to Promise reject method directly?

widget/nsIWidget.h
1936

Can we reuse by making it taking the argument instead?
And make reseting the in Cocoa implmentation.

This revision now requires changes to proceed.Apr 30 2026, 11:11 AM
edgar updated this revision to Diff 1268526.
edgar retitled this revision from Bug 1829401 - Add unadjustedMovement option and Promise return to Element.requestPointerLock r?#dom-core to WIP: Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS first;.
edgar edited the summary of this revision. (Show Details)
edgar updated this revision to Diff 1268828.
edgar requested review of this revision.May 7 2026, 12:04 PM
edgar updated this revision to Diff 1268870.
edgar retitled this revision from WIP: Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS first; to Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS first;.
Comment Actions

Can't say about nsCocoaWindow.mm

dom/base/PointerLockManager.cpp
267

Nit, s/do/does/

267

File perhaps a followup to match the spec also in this case?

512

presshell->GetRootWidget() doesn't work here?

562

Curious, have we tested that doing non-unadjustedmovement lock after doing unadjusted movement lock works? Even just locally.

widget/nsIWidget.h
1939

SupportsUnadjustedMovement() might read a bit better, no?

Comment Actions

Can't say about nsCocoaWindow.mm

@mstange, can you help to review the changes in , thanks!

edgar marked 2 inline comments as done.May 7 2026, 1:39 PM
edgar added inline comments.
dom/base/PointerLockManager.cpp
267
edgar marked 2 inline comments as done.May 7 2026, 2:10 PM
edgar added inline comments.
dom/base/PointerLockManager.cpp
512

It works. Fixed.

edgar marked an inline comment as done.May 7 2026, 2:15 PM
edgar marked an inline comment as done.
edgar added inline comments.
widget/nsIWidget.h
1939

I was considering that, but ended up using , switched back. :)

edgar marked an inline comment as done.May 7 2026, 2:17 PM
mstange added a project: testing-approved.
Comment Actions

The code changes are fine but the API is really strange. "Is supporting" sounds like something that depends on the moment and can change over time, but nsCocoaWindow just checks a pref. Could this be a NativePointerLockMode enum instead? Maybe with Unlocked, LockedRegular, LockedUnadjusted variants - or maybe Locked/Unlocked should be kept in a separate state.
"UpdateNativePointerLockUnadjustedMovement" sounds like something that takes a movement delta, not a bool. If this could be SetNativePointerLockMode it would read more clearly.
Why is InitIsSupportingUnadjustedMovement a separate message? Could the mode be passed when the actual pointer lock begins?

This revision is now accepted and ready to land.May 7 2026, 2:49 PM
Comment Actions

Oh, InitIsSupportingUnadjustedMovement goes from parent to content, I see.

Comment Actions

Oh, InitIsSupportingUnadjustedMovement goes from parent to content, I see.

Right, (It was ) is an API for querying whether the platform supports reporting unadjusted movement. Not all platforms support this capability, such as Linux X11. (Naming suggestions are welcome!)
The intention to check the pref is because I don't want and goes too different logic.

Could this be a NativePointerLockMode enum instead? Maybe with Unlocked, LockedRegular, LockedUnadjusted variants - or maybe Locked/Unlocked should be kept in a separate state.

Right, NativePointerLockMode maybe can be a , I will try this.

"UpdateNativePointerLockUnadjustedMovement" sounds like something that takes a movement delta, not a bool. If this could be SetNativePointerLockMode it would read more clearly.

Will rename to .

Comment Actions

@mstange, mind taking another look? Thanks!

Comment Actions

@mstange, mind taking another look? Thanks!

I am going to land the patch as is for now, feel free to let me know if there is anything I should address, I will do that in a follow-up, thanks!

Comment Actions

Looks good to me, thanks!

As a follow-up you could make more use of PointerLockMode in places where you currently have bools, e.g. in .

Comment Actions

Looks good to me, thanks!

As a follow-up you could make more use of PointerLockMode in places where you currently have bools, e.g. in .

I filed bug 2037988 as follow-up, thank you!

This revision is now accepted and ready to land.May 8 2026, 9:18 PM
edgar edited the summary of this revision. (Show Details)

Revision Contents

PathSizeCoverage (All)Coverage (Touched)
dom/
base/
6 lines96%
Loading...
7 lines--
15 lines100%
Loading...
100 lines--
events/
3 lines85%
Loading...
7 lines89%
Loading...
ipc/
3 lines91%
Loading...
6 lines--
6 lines96%
Loading...
15 lines--
10 lines--
webidl/
8 lines--
modules/
libpref/
init/
9 lines--
testing/
web-platform/
meta/
pointerlock/
1 line--
12 lines--
6 lines--
17 lines--
tests/
pointerlock/
58 lines--
widget/
12 lines86%
Loading...
13 lines--
7 lines100%
Loading...
cocoa/
10 lines--
75 lines--
gtk/
2 lines0%
Loading...
3 lines0%
Loading...
21 lines67%
Loading...
CommitTreeParentsAuthorSummaryDate
90143df1b5db7a455d0ed929Edgar Chen
Bug 1829401 - Part 2: Support unadjustedMovement option and implement on macOS… (Show More…)

Diff 1270892

dom/base/Element.h

Loading...

dom/base/Element.cpp

Loading...

dom/base/PointerLockManager.h

Loading...

dom/base/PointerLockManager.cpp

Loading...

dom/events/EventStateManager.h

Loading...

dom/events/EventStateManager.cpp

Loading...

dom/ipc/BrowserChild.h

Loading...

dom/ipc/BrowserChild.cpp

Loading...

dom/ipc/BrowserParent.h

Loading...

dom/ipc/BrowserParent.cpp

Loading...

dom/ipc/PBrowser.ipdl

Loading...

dom/webidl/Element.webidl

Loading...

modules/libpref/init/StaticPrefList.yaml

Loading...

testing/web-platform/meta/pointerlock/__dir__.ini

Loading...

testing/web-platform/meta/pointerlock/pointerlock-maintains-mousedown.html.ini

Loading...

testing/web-platform/meta/pointerlock/pointerlock_unadjustedMovement.html.ini

Loading...

testing/web-platform/meta/pointerlock/pointerlock_unadjustedMovement_update.html.ini

Loading...

testing/web-platform/tests/pointerlock/pointerlock_unadjustedMovement_update.html

Loading...

widget/PuppetWidget.h

Loading...

widget/PuppetWidget.cpp

Loading...

widget/WidgetMessageUtils.h

Loading...

widget/cocoa/nsCocoaWindow.h

Loading...

widget/cocoa/nsCocoaWindow.mm

Loading...

widget/gtk/nsWindowWayland.h

Loading...

widget/gtk/nsWindowWayland.cpp

Loading...

widget/nsIWidget.h

Loading...