Skip to content

[AppKit Gestures] Only mouse tracking mode produces pointer events#64980

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
aprotyas:eng/314880
May 17, 2026
Merged

[AppKit Gestures] Only mouse tracking mode produces pointer events#64980
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
aprotyas:eng/314880

Conversation

@aprotyas
Copy link
Copy Markdown
Member

@aprotyas aprotyas commented May 15, 2026

d197477

[AppKit Gestures] Only mouse tracking mode produces pointer events
https://bugs.webkit.org/show_bug.cgi?id=314880
rdar://177139516

Reviewed by Tim Horton.

A single click via the gesture controller's synthetic click flow does
not fire pointerdown/pointerup on the page -- we only see the final
click event.

We address this issue by adding an input source check on the suppression
condition in dispatchPointerEventIfNeeded, since it is currently
short circuiting away non-iOS synthetic events that do not otherwise
have a pointer event dispatch path.

Test: AppKitGesturesTests.singleClickFiresPointerMouseAndClickEvents

* Source/WebCore/dom/Element.cpp:
(WebCore::dispatchPointerEventIfNeeded):
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKitGesturesTests.swift:
(AppKitGesturesTests.singleClickFiresPointerMouseAndClickEvents(_:)):

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

f5e268a

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

@aprotyas aprotyas self-assigned this May 15, 2026
@aprotyas aprotyas added the UI Events For bugs related to user interactions like keyboard, mouse, and touch events. label May 15, 2026
try await loadHTML()

let expectedEvents = ["pointerdown", "mousedown", "pointerup", "mouseup", "click"]
let jsEventList = expectedEvents.map { "\"\($0)\"" }.joined(separator: ", ")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can use # for the string literal to avoid having to escape it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll try it out

@@ -77,6 +77,44 @@ struct AppKitGesturesTests {
self.window.makeKeyAndOrderFront(nil)
}

@Test(
.bug("https://webkit.org/b/314880", "Only mouse tracking mode produces pointer events")
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can probably make this parameterized for content editable and not right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Probably, I need to double check click behavior over editable content, but I'll adjust accordingly.

for (const eventType of [\(jsEventList)]) {
target.addEventListener(eventType, e => window.eventLog.push(e.type));
}
return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does this return null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Artifact from a first draft of the test. Return isn't necessary here. I'll remove it

let eventLog = try #require(try await page.callJavaScript("return window.eventLog;") as? [String])

for eventType in expectedEvents {
#expect(eventLog.contains(eventType), "expected '\(eventType)' in event log: \(eventLog)")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the comment isn't necessary, Swift Testing will automatically tell you the values in the failure case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll fix it

Comment thread Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKitGesturesTests.swift Outdated
await page.waitForPendingMouseEvents()
await page.waitForNextPresentationUpdate()

let eventLog = try #require(try await page.callJavaScript("return window.eventLog;") as? [String])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let eventLog = try #require(try await page.callJavaScript("return window.eventLog;") as? [String])
let eventLog = try await #require(page.callJavaScript("return window.eventLog;") as? [String])

"""
window.eventLog = [];
const target = document.getElementById("div");
for (const eventType of [\(jsEventList)]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should use a JS parameter, and use the arguments parameter to callJavaScript to populate it

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 15, 2026
@aprotyas aprotyas removed the merging-blocked Applied to prevent a change from being merged label May 16, 2026
@aprotyas
Copy link
Copy Markdown
Member Author

Thank you for the review!

@aprotyas aprotyas added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 17, 2026
https://bugs.webkit.org/show_bug.cgi?id=314880
rdar://177139516

Reviewed by Tim Horton.

A single click via the gesture controller's synthetic click flow does
not fire pointerdown/pointerup on the page -- we only see the final
click event.

We address this issue by adding an input source check on the suppression
condition in dispatchPointerEventIfNeeded, since it is currently
short circuiting away non-iOS synthetic events that do not otherwise
have a pointer event dispatch path.

Test: AppKitGesturesTests.singleClickFiresPointerMouseAndClickEvents

* Source/WebCore/dom/Element.cpp:
(WebCore::dispatchPointerEventIfNeeded):
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKitGesturesTests.swift:
(AppKitGesturesTests.singleClickFiresPointerMouseAndClickEvents(_:)):

Canonical link: https://commits.webkit.org/313371@main
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 313371@main (d197477): https://commits.webkit.org/313371@main

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

@webkit-commit-queue webkit-commit-queue merged commit d197477 into WebKit:main May 17, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 17, 2026
@aprotyas aprotyas deleted the eng/314880 branch May 17, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UI Events For bugs related to user interactions like keyboard, mouse, and touch events.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants