Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2a69be73858f1d556fc285c6f9810867b43365f4
      
https://github.com/WebKit/WebKit/commit/2a69be73858f1d556fc285c6f9810867b43365f4
  Author: Richard Robinson <[email protected]>
  Date:   2026-05-26 (Tue, 26 May 2026)

  Changed paths:
    M Source/WebKit/UIProcess/mac/PageClientImplMac.mm

  Log Message:
  -----------
  WebView on macOS fights with other views for NSCursor control
https://bugs.webkit.org/show_bug.cgi?id=315425
rdar://177373957

Reviewed by Aditya Keerthi.

Consider a SwiftUI view like this:

```swift
struct ContentView: View {
    @State private var page = WebPage()

    var body: some View {
        ZStack {
            WebView(page)

            Button {
            } label: {
                Text("CLICK ME")
                    .frame(width: 100, height: 100)
            }
            .frame(width: 100, height: 100)
            .pointerStyle(.default)
        }
        .toolbar {
            Button("Click me") {

            }
        }
    }
}
```

which contains a WebView with a button atop it, and a toolbar above the WebView.

When the user moves the mouse from the WebView to either the button or the 
toolbar, the cursor sometimes
changes from the I-beam cursor to the arrow cursor, however this commonly does 
not actually happen; instead,
the cursor unexpectedly stays the I-beam cursor.

This is because after the mouse moves to the new view, and the new view 
requests whatever cursor it wants,
a delayed IPC message may arrive in WebKit resulting in 
`PageClientImpl::setCursor` getting called, which
then incorrectly sets the cursor to whatever WebKit had it set as.

Fix by performing a hit-test in that method and returning early in the case the 
web view is not the hit view.

This also incidentally fixes a small correctness bug in the 
`imageAnalysisOverlayViewHasCursorAtPoint` check,
since it was originally using screen coordinates as window coordinates.

Note that even with this fix, the developer still needs to use

```
.pointerStyle(.default)
```

on the non-web view view, since the system doesn't request the cursor become 
the default cursor by default, and
therefore just would stay as-is otherwise.

* Source/WebKit/UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::setCursor):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to