Skip to content
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

Align cursor implementation to W3C cursors #2162

Merged
merged 18 commits into from
Aug 20, 2024

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Aug 14, 2024

Cherry pick facebook@d3e3e2a and extend the macOS implementation to help make the 0.75 merge easier.

Summary:

Some history:
0ef7992 Added cursor support to React Native macOS initially. facebook@73664f5 upstreamed a subset of that support (auto and pointer) for iOS and visionOS. Then, facebook@d3e3e2a extended the cursor implementation in React Native Fabric to support all the web cursor values (so that out of trees platforms like windows and macOS could implement support). We are one of those out of tree platforms.. so let's implement the new cursor api. Since the cursor creation code is now much more complex, I refactored the paper and fabric implementation to be shared via a new RCTCursor.m file that's an added diff to React Native macOS.

Some notes:

  • This is technically a breaking change because we remove support for the cursor disappearing-item that was available from Appkit but not part of the web cursors. Additionally, We add support for vertical-text which is missing from upstream.
  • facebook@d3e3e2a only extended the Fabric definition. We support cursors on Paper too, so we'll need to add diffs to port the new values to paper.
  • Natively, macOS more or less supports a subset of the web cursors (see NSCursor with some only available as of macOS 15 (currently still in Beta). This means there are some cursor values (ex: all-scroll) we don't support
  • Some cursors are only available on macOS 15+ (which requires a minimum of Xcode 16). Some of these new cursors are also replacing now-deprecated cursors. I took extra care to add both a compile time check (to make sure we're backwards compatible with older Xcode versions) and a runtime availability check (to make sure we are backwards compatible with previous macOS versions).

Test Plan:

Updated the test page with all the cursors.

Screen.Recording.2024-08-20.at.11.07.59.AM.mov

@Saadnajmi Saadnajmi marked this pull request as ready for review August 15, 2024 05:53
@Saadnajmi Saadnajmi requested a review from a team as a code owner August 15, 2024 05:53
@Saadnajmi Saadnajmi changed the title [Cherry-Pick] Align cursor implementation to W3C cursors Align cursor implementation to W3C cursors Aug 15, 2024
@Saadnajmi Saadnajmi enabled auto-merge (squash) August 20, 2024 18:20
@Saadnajmi Saadnajmi disabled auto-merge August 20, 2024 18:21
@Saadnajmi Saadnajmi merged commit 1164bc9 into microsoft:main Aug 20, 2024
16 checks passed
@Saadnajmi Saadnajmi deleted the cursor-extenstion branch August 20, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants