Skip to content

Custom cursors should not appear outside the web content viewport #47103

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

Conversation

hortont424
Copy link
Contributor

@hortont424 hortont424 commented Jun 24, 2025

d606afc

Custom cursors should not appear outside the web content viewport
https://bugs.webkit.org/show_bug.cgi?id=294886
rdar://150695318

Reviewed by Abrar Rahman Protyasha and Aditya Keerthi.

Align with the other browsers, and hide custom cursors when they are outside of the viewport.
This avoids the potential for confusion between the cursor and external UI.
Chrome and Firefox already behave this way.

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::selectCursor):
Restrict custom cursor presentation such that they only appear when fully insid the viewport.

* LayoutTests/fast/events/mouse-cursor-hidden-when-out-of-bounds-expected.txt: Added.
* LayoutTests/fast/events/mouse-cursor-hidden-when-out-of-bounds.html: Added.
Add a new test that verifies this behavior.

* LayoutTests/fast/events/mouse-cursor.html:
Adjust an existing test that didn't expect this behavior, by adding a margin.

* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:
Propagate test expectations from mouse-cursor.html, which the new test was copied from.

Canonical link: https://commits.webkit.org/296590@main

7aa2cb0

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
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@hortont424 hortont424 requested review from cdumez and rniwa as code owners June 24, 2025 04:25
@hortont424 hortont424 self-assigned this Jun 24, 2025
@hortont424 hortont424 added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Jun 24, 2025
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/js-test.js"></script>

And no need for the -post.js below.

@hortont424 hortont424 force-pushed the eng/Custom-cursors-should-not-appear-outside-the-web-content-viewport branch from fadde5d to 4ff1329 Compare June 24, 2025 04:33
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@hortont424 hortont424 removed the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@hortont424 hortont424 force-pushed the eng/Custom-cursors-should-not-appear-outside-the-web-content-viewport branch from 4ff1329 to 7aa2cb0 Compare June 24, 2025 19:22
@hortont424 hortont424 added the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2025
https://bugs.webkit.org/show_bug.cgi?id=294886
rdar://150695318

Reviewed by Abrar Rahman Protyasha and Aditya Keerthi.

Align with the other browsers, and hide custom cursors when they are outside of the viewport.
This avoids the potential for confusion between the cursor and external UI.
Chrome and Firefox already behave this way.

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::selectCursor):
Restrict custom cursor presentation such that they only appear when fully insid the viewport.

* LayoutTests/fast/events/mouse-cursor-hidden-when-out-of-bounds-expected.txt: Added.
* LayoutTests/fast/events/mouse-cursor-hidden-when-out-of-bounds.html: Added.
Add a new test that verifies this behavior.

* LayoutTests/fast/events/mouse-cursor.html:
Adjust an existing test that didn't expect this behavior, by adding a margin.

* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:
Propagate test expectations from mouse-cursor.html, which the new test was copied from.

Canonical link: https://commits.webkit.org/296590@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Custom-cursors-should-not-appear-outside-the-web-content-viewport branch from 7aa2cb0 to d606afc Compare June 25, 2025 00:49
@webkit-commit-queue
Copy link
Collaborator

Committed 296590@main (d606afc): https://commits.webkit.org/296590@main

Reviewed commits have been landed. Closing PR #47103 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit d606afc into WebKit:main Jun 25, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants