Bug 227265 - [Live Text] [macOS] Add an internal option to disable inline text selection in images
Summary: [Live Text] [macOS] Add an internal option to disable inline text selection i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-22 12:29 PDT by Wenson Hsieh
Modified: 2021-06-22 18:33 PDT (History)
5 users (show)

See Also:


Attachments
For EWS (45.91 KB, patch)
2021-06-22 13:38 PDT, Wenson Hsieh
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
For EWS (45.95 KB, patch)
2021-06-22 13:58 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix GTK/WPE/Win builds (48.01 KB, patch)
2021-06-22 16:02 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix GTK/WPE/Win builds (2) (48.00 KB, patch)
2021-06-22 16:15 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2021-06-22 12:29:52 PDT
Add an (off-by-default) internal feature flag to control whether or not we should allow inline text selection inside images. When disallowing inline text selection in images, we will instead have a context menu action to "Quick Look", which will automatically be retitled to either "Look Up in Quick Look" or "Select Text in Quick Look" depending on the presence of recognized text or visual search results for the image.
Comment 1 Wenson Hsieh 2021-06-22 12:34:58 PDT
rdar://79460142
Comment 2 Wenson Hsieh 2021-06-22 13:38:58 PDT Comment hidden (obsolete)
Comment 3 Wenson Hsieh 2021-06-22 13:58:25 PDT
Created attachment 431991 [details]
For EWS
Comment 4 Tim Horton 2021-06-22 14:18:20 PDT
Comment on attachment 431991 [details]
For EWS

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

> Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:238
>  void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)

These seem ... slightly silly, instead of just passing the nice pretty enum. But also fine.

> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:553
> +                page->computeHasVisualSearchResults(imageURL, *imageBitmap, [weakThis = makeWeakPtr(protectedThis.get()), quickLookItemToInsertIfNeeded = WTFMove(*quickLookItemToInsertIfNeeded)] (bool hasVisualSearchResults) mutable {

This function is getting a bit out of hand, maybe the visual search stuff can be in its own? (also then you could drop a lot of the `protectedThis`)

> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:607
> +        auto item = retainPtr([m_menu itemAtIndex:itemIndex]);

Not sure what the retainPtr() is for! Where's the item going to go?
Comment 5 Wenson Hsieh 2021-06-22 15:32:18 PDT
Comment on attachment 431991 [details]
For EWS

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

>> Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:238
>>  void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
> 
> These seem ... slightly silly, instead of just passing the nice pretty enum. But also fine.

Good point — I'll change this so that we just have `computeHasImageAnalysisResults` instead of both `computeHasTextRecognitionResults` and `computeHasVisualSearchResults`.

>> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:553
>> +                page->computeHasVisualSearchResults(imageURL, *imageBitmap, [weakThis = makeWeakPtr(protectedThis.get()), quickLookItemToInsertIfNeeded = WTFMove(*quickLookItemToInsertIfNeeded)] (bool hasVisualSearchResults) mutable {
> 
> This function is getting a bit out of hand, maybe the visual search stuff can be in its own? (also then you could drop a lot of the `protectedThis`)

Sounds good — I pulled the logic in this ENABLE(IMAGE_ANALYSIS) block out into a separate helper method named `insertOrUpdateQuickLookImageItem`.

>> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:607
>> +        auto item = retainPtr([m_menu itemAtIndex:itemIndex]);
> 
> Not sure what the retainPtr() is for! Where's the item going to go?

I suppose the item's not going anywhere :P removed the RetainPtr.
Comment 6 Wenson Hsieh 2021-06-22 16:02:27 PDT Comment hidden (obsolete)
Comment 7 Wenson Hsieh 2021-06-22 16:15:34 PDT
Created attachment 432005 [details]
Fix GTK/WPE/Win builds (2)
Comment 8 EWS 2021-06-22 18:33:02 PDT
Committed r279164 (239061@main): <https://commits.webkit.org/239061@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 432005 [details].