Bug 179646 - Long pressing a phone number with spaces in it results in a link sheet instead of a data detectors sheet
Summary: Long pressing a phone number with spaces in it results in a link sheet instea...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-13 17:39 PST by Tim Horton
Modified: 2017-11-14 09:44 PST (History)
6 users (show)

See Also:


Attachments
Patch (6.91 KB, patch)
2017-11-13 17:40 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (12.27 KB, patch)
2017-11-13 22:37 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (12.27 KB, patch)
2017-11-13 22:38 PST, Tim Horton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2017-11-13 17:39:39 PST
Long pressing a phone number with spaces in it results in a link sheet instead of a data detectors sheet
Comment 1 Tim Horton 2017-11-13 17:40:08 PST
Created attachment 326832 [details]
Patch
Comment 2 Tim Horton 2017-11-13 17:40:30 PST
<rdar://problem/35337288>
Comment 3 Darin Adler 2017-11-13 18:32:28 PST
Comment on attachment 326832 [details]
Patch

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

> Source/WebCore/editing/cocoa/DataDetection.h:65
> +    WEBCORE_EXPORT static bool URLCanBePresentedByDataDetectors(const URL&);

I don’t think this function needs the word “URL” in its name. Either linkCanBePresentefdByDataDetectors or canBePresentedByDataDetectors seems fine to me.

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:559
> +    NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation->url];

Why isn’t this just:

    NSURL *targetURL = _positionInformation->url;

Does the _web_URLWithWTFString method do something special that the NSURL operator from WebCore::URL does not?
Comment 4 Wenson Hsieh 2017-11-13 18:37:03 PST
I think writing a test for this wouldn't be too bad — you can find similar tests in ActionSheetTests. Checking that the resulting _WKActivatedElementInfo's type is not a link, image or attachment after simulating a long press would cover this.
Comment 5 Tim Horton 2017-11-13 21:18:01 PST
(In reply to Darin Adler from comment #3)
> Comment on attachment 326832 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=326832&action=review
> 
> > Source/WebCore/editing/cocoa/DataDetection.h:65
> > +    WEBCORE_EXPORT static bool URLCanBePresentedByDataDetectors(const URL&);
> 
> I don’t think this function needs the word “URL” in its name. Either
> linkCanBePresentefdByDataDetectors or canBePresentedByDataDetectors seems
> fine to me.

Sure!

> > Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:559
> > +    NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation->url];
> 
> Why isn’t this just:
> 
>     NSURL *targetURL = _positionInformation->url;
> 
> Does the _web_URLWithWTFString method do something special that the NSURL
> operator from WebCore::URL does not?

I think somebody got confused and thought _positionInformation->url was a string. I’ll fix it.

(In reply to Wenson Hsieh from comment #4)
> I think writing a test for this wouldn't be too bad — you can find similar
> tests in ActionSheetTests. Checking that the resulting
> _WKActivatedElementInfo's type is not a link, image or attachment after
> simulating a long press would cover this.

Good idea!
Comment 6 Tim Horton 2017-11-13 21:26:20 PST
> > > Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:559
> > > +    NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation->url];
> > 
> > Why isn’t this just:
> > 
> >     NSURL *targetURL = _positionInformation->url;
> > 
> > Does the _web_URLWithWTFString method do something special that the NSURL
> > operator from WebCore::URL does not?
> 
> I think somebody got confused and thought _positionInformation->url was a
> string. I’ll fix it.

Actually, it *used to be* a string, until https://trac.webkit.org/changeset/216152/webkit, but I missed some cleanup!
Comment 7 Tim Horton 2017-11-13 22:37:30 PST
Created attachment 326857 [details]
Patch
Comment 8 Tim Horton 2017-11-13 22:38:15 PST
Created attachment 326858 [details]
Patch
Comment 9 WebKit Commit Bot 2017-11-14 09:44:21 PST
Comment on attachment 326858 [details]
Patch

Clearing flags on attachment: 326858

Committed r224819: <https://trac.webkit.org/changeset/224819>
Comment 10 WebKit Commit Bot 2017-11-14 09:44:22 PST
All reviewed patches have been landed.  Closing bug.