Bug 219952

Summary: Suppress the image extraction interaction while editing text
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: PlatformAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: hi, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
hi: review+
Patch for landing none

Description Wenson Hsieh 2020-12-16 10:28:52 PST
<rdar://problem/72390053>
Comment 1 Wenson Hsieh 2020-12-16 10:46:02 PST
Created attachment 416347 [details]
Patch
Comment 2 Devin Rousso 2020-12-16 11:52:52 PST
Comment on attachment 416347 [details]
Patch

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

r=me

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:211
> +        if (interaction)

NIT: IMO it's a bit weird that we'd have an object that's supposed to suppress an interaction also function if no interaction is given.  Should we `ASSERT(interaction);`?  There's no harm in doing it as written, but it does seem a little odd to me :P

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1297
> +    if (self._imageExtractionEnabled && (!_isBlurringFocusedElement || !_isChangingFocus))

Are there any other flags we should also be checking (e.g. `_textInteractionIsHappening`)?

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1298
> +        _suppressImageExtractionToken = isEditable ? makeUnique<WebKit::SuppressInteractionToken>(self, _imageExtractionInteraction.get()) : nullptr;

NIT: Is the `<WebKit::SuppressInteractionToken>` necessary?  I think this can be implicit.
Comment 3 Wenson Hsieh 2020-12-16 12:02:13 PST
Comment on attachment 416347 [details]
Patch

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

Thanks for the review!

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:211
>> +        if (interaction)
> 
> NIT: IMO it's a bit weird that we'd have an object that's supposed to suppress an interaction also function if no interaction is given.  Should we `ASSERT(interaction);`?  There's no harm in doing it as written, but it does seem a little odd to me :P

Good point! Since the only place that creates one of these is behind `_imageExtractionEnabled`, the interaction should always be nonnull here. I'll add an `ASSERT(interaction);` to clarify this.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1297
>> +    if (self._imageExtractionEnabled && (!_isBlurringFocusedElement || !_isChangingFocus))
> 
> Are there any other flags we should also be checking (e.g. `_textInteractionIsHappening`)?

I /think/ this should be it, since the intent was just to avoid introducing the interaction just to remove it again when changing focus between editable fields.

IIUC, `_textInteractionIsHappening` is just about pencil, which (I think) shouldn't conflict with the new image extraction interaction.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:1298
>> +        _suppressImageExtractionToken = isEditable ? makeUnique<WebKit::SuppressInteractionToken>(self, _imageExtractionInteraction.get()) : nullptr;
> 
> NIT: Is the `<WebKit::SuppressInteractionToken>` necessary?  I think this can be implicit.

Yes, it's necessary since this is outside of any `using namespace WebCore;` (since we're in an ObjC @implementation block, this code isn't wrapped inside a `namespace WebKit`).
Comment 4 Wenson Hsieh 2020-12-16 12:11:26 PST
Created attachment 416354 [details]
Patch for landing
Comment 5 EWS 2020-12-16 12:40:14 PST
Committed r270901: <https://trac.webkit.org/changeset/270901>

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