Bug 238714

Summary: [macOS] Add helper methods to install and uninstall VKCImageAnalysisOverlayView
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: PlatformAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: akeerthi, hi, katherine_cheney, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
For EWS
ews-feeder: commit-queue-
Fix Big Sur build
ews-feeder: commit-queue-
Fix Big Sur build
none
For landing ews-feeder: commit-queue-

Description Wenson Hsieh 2022-04-03 10:40:21 PDT
.
Comment 1 Wenson Hsieh 2022-04-03 12:00:46 PDT Comment hidden (obsolete)
Comment 2 Wenson Hsieh 2022-04-03 12:52:44 PDT Comment hidden (obsolete)
Comment 3 Wenson Hsieh 2022-04-03 13:00:22 PDT
Created attachment 456511 [details]
Fix Big Sur build
Comment 4 Tim Horton 2022-04-04 10:33:13 PDT
Comment on attachment 456511 [details]
Fix Big Sur build

View in context: https://bugs.webkit.org/attachment.cgi?id=456511&action=review

> Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:1172
> +        return CGRectMake(0, 0, 1, 1);

Why does this have a non-zero size?

> Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:5960
> +bool WebViewImpl::shouldAvoidUpdatingCursorAtPoint(NSPoint locationInView) const

Not totally sure this mechanism is a good idea, e.g. if you cmd-tab to a window with a web view and then don't update the cursor. Can you instead just force the cursor you want to be set?
Comment 5 Wenson Hsieh 2022-04-04 12:18:41 PDT
(In reply to Tim Horton from comment #4)
> Comment on attachment 456511 [details]
> Fix Big Sur build
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=456511&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:1172
> > +        return CGRectMake(0, 0, 1, 1);
> 
> Why does this have a non-zero size?

So I just decided to fall back to the default value here (i.e., as if the delegate were unimplemented), which is the unit rect (0, 0, 1, 1). The return value of this delegate method is a normalized rect relative to the bounds of the WKWebView.

> 
> > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:5960
> > +bool WebViewImpl::shouldAvoidUpdatingCursorAtPoint(NSPoint locationInView) const
> 
> Not totally sure this mechanism is a good idea, e.g. if you cmd-tab to a
> window with a web view and then don't update the cursor. Can you instead
> just force the cursor you want to be set?

That's a good point! I'll see if I can change this...
Comment 6 Wenson Hsieh 2022-04-04 12:42:34 PDT
(In reply to Wenson Hsieh from comment #5)
> (In reply to Tim Horton from comment #4)
> > Comment on attachment 456511 [details]
> > Fix Big Sur build
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=456511&action=review
> > 
> > > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:1172
> > > +        return CGRectMake(0, 0, 1, 1);
> > 
> > Why does this have a non-zero size?
> 
> So I just decided to fall back to the default value here (i.e., as if the
> delegate were unimplemented), which is the unit rect (0, 0, 1, 1). The
> return value of this delegate method is a normalized rect relative to the
> bounds of the WKWebView.
> 
> > 
> > > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:5960
> > > +bool WebViewImpl::shouldAvoidUpdatingCursorAtPoint(NSPoint locationInView) const
> > 
> > Not totally sure this mechanism is a good idea, e.g. if you cmd-tab to a
> > window with a web view and then don't update the cursor. Can you instead
> > just force the cursor you want to be set?
> 
> That's a good point! I'll see if I can change this...

Chatted with Tim on Slack about this; the overall approach seems okay since we're not avoiding cursor updates — just letting the native VisionKit views set the cursor on our behalf. I'll rename this method to something like, `imageAnalysisOverlayViewHasCursorAtPoint()`, to make this interaction clear.
Comment 7 Wenson Hsieh 2022-04-04 12:56:46 PDT
Created attachment 456611 [details]
For landing
Comment 8 EWS 2022-04-04 14:17:16 PDT
Committed r292316 (249209@main): <https://commits.webkit.org/249209@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 456611 [details].
Comment 9 Radar WebKit Bug Importer 2022-04-04 14:18:18 PDT
<rdar://problem/91260885>