Bug 237408 - [iOS] Support PDF search when using a find interaction
Summary: [iOS] Support PDF search when using a find interaction
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Aditya Keerthi
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-02 22:34 PST by Aditya Keerthi
Modified: 2022-03-21 17:23 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.37 KB, patch)
2022-03-02 22:37 PST, Aditya Keerthi
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (8.76 KB, patch)
2022-03-02 22:56 PST, Aditya Keerthi
wenson_hsieh: review+
Details | Formatted Diff | Diff
Patch for landing (9.52 KB, patch)
2022-03-17 10:18 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Address post-landing feedback (1.33 KB, patch)
2022-03-21 13:58 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aditya Keerthi 2022-03-02 22:34:22 PST
...
Comment 1 Aditya Keerthi 2022-03-02 22:34:46 PST
rdar://89437334
Comment 2 Aditya Keerthi 2022-03-02 22:37:23 PST
Created attachment 453698 [details]
Patch
Comment 3 Aditya Keerthi 2022-03-02 22:56:08 PST
Created attachment 453699 [details]
Patch
Comment 4 Wenson Hsieh 2022-03-14 08:49:07 PDT
Comment on attachment 453699 [details]
Patch

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

> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:787
> +        if ([_customContentView conformsToProtocol:@protocol(_UITextSearching)])
> +            [_findInteraction setSearchableObject:(id<_UITextSearching>)_customContentView.get()];
> +        else
> +            [_findInteraction setSearchableObject:_contentView.get()];

Nit - perhaps you could factor this out into a helper function, and use it both here and in `-_setFindInteractionEnabled:` below.

> Source/WebKit/UIProcess/ios/WKPDFView.mm:101
> +    auto pos = adoptNS([[WKPDFFoundTextPosition alloc] init]);

Nit - we usually don't abbreviate local variable names. Maybe rename to `position`?
Comment 5 Aditya Keerthi 2022-03-17 10:18:06 PDT
Created attachment 454986 [details]
Patch for landing
Comment 6 Aditya Keerthi 2022-03-17 10:18:43 PDT
(In reply to Wenson Hsieh from comment #4)
> Comment on attachment 453699 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453699&action=review

Thanks for the review!
 
> > Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:787
> > +        if ([_customContentView conformsToProtocol:@protocol(_UITextSearching)])
> > +            [_findInteraction setSearchableObject:(id<_UITextSearching>)_customContentView.get()];
> > +        else
> > +            [_findInteraction setSearchableObject:_contentView.get()];
> 
> Nit - perhaps you could factor this out into a helper function, and use it
> both here and in `-_setFindInteractionEnabled:` below.

Done.
 
> > Source/WebKit/UIProcess/ios/WKPDFView.mm:101
> > +    auto pos = adoptNS([[WKPDFFoundTextPosition alloc] init]);
> 
> Nit - we usually don't abbreviate local variable names. Maybe rename to
> `position`?

Done.
Comment 7 EWS 2022-03-17 14:59:07 PDT
Committed r291445 (248568@main): <https://commits.webkit.org/248568@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 454986 [details].
Comment 8 Darin Adler 2022-03-21 13:14:52 PDT
Comment on attachment 454986 [details]
Patch for landing

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

> Source/WebKit/UIProcess/ios/WKPDFView.mm:718
> +    NSInteger offset = from.index - to.index;
> +
> +    if (offset < 0)
> +        return NSOrderedAscending;
> +
> +    if (offset > 0)
> +        return NSOrderedDescending;
> +
> +    return NSOrderedSame;

Probably not a real risk here, but typically doing subtraction to determine ordering can introduce overflow, so it’s better not to use that pattern.
Comment 9 Aditya Keerthi 2022-03-21 13:58:32 PDT
Reopening to attach new patch.
Comment 10 Aditya Keerthi 2022-03-21 13:58:33 PDT
Created attachment 455273 [details]
Address post-landing feedback
Comment 11 EWS 2022-03-21 17:23:17 PDT
Committed r291591 (248685@main): <https://commits.webkit.org/248685@main>

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