WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
191918
[Cocoa] Add WKWebView SPI to trigger and remove data detection
https://bugs.webkit.org/show_bug.cgi?id=191918
Summary
[Cocoa] Add WKWebView SPI to trigger and remove data detection
Wenson Hsieh
Reported
2018-11-22 19:09:21 PST
<
rdar://problem/36185051
>
Attachments
Patch
(41.76 KB, patch)
2018-11-23 11:56 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Fix the GTK build
(41.71 KB, patch)
2018-11-23 12:05 PST
,
Wenson Hsieh
thorton
: review+
Details
Formatted Diff
Diff
Patch for EWS
(42.98 KB, patch)
2018-11-23 23:27 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch for EWS
(43.42 KB, patch)
2018-11-24 00:05 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch for EWS
(44.41 KB, patch)
2018-11-24 09:57 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Wenson Hsieh
Comment 1
2018-11-23 11:56:37 PST
Created
attachment 355532
[details]
Patch
Wenson Hsieh
Comment 2
2018-11-23 12:05:47 PST
Created
attachment 355533
[details]
Fix the GTK build
Tim Horton
Comment 3
2018-11-23 13:13:56 PST
Comment on
attachment 355533
[details]
Fix the GTK build View in context:
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> Source/WebKit/ChangeLog:10 > + `-_removeAllDataDetectedContent:`, to allow internal WebKit clients to run data detection and add links to data
Does it actually remove the data detected *content*? or just the links? Also, should this just be a side effect of turning Data Detectors off via the existing API??
Wenson Hsieh
Comment 4
2018-11-23 21:27:51 PST
Comment on
attachment 355533
[details]
Fix the GTK build View in context:
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
>> Source/WebKit/ChangeLog:10 >> + `-_removeAllDataDetectedContent:`, to allow internal WebKit clients to run data detection and add links to data > > Does it actually remove the data detected *content*? or just the links? > > Also, should this just be a side effect of turning Data Detectors off via the existing API??
This just removes links added by data detectors, and resets Frame's m_dataDetectionResults. I had considered making this a side effect of turning data detectors on or off, but it seems that this is only exposed on the web view configuration via dataDetectorTypes. IIUC, changes to the configuration aren't normally propagated to the web view after the web view is already initialized with the configuration. An alternative is adding an SPI property on either WKWebView or WKPreferences that's something like _dataDetectorTypes, and we would add or remove data detectors in web content when this property is modified. WDYT?
Tim Horton
Comment 5
2018-11-23 21:45:20 PST
Comment on
attachment 355533
[details]
Fix the GTK build View in context:
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
>>> Source/WebKit/ChangeLog:10 >>> + `-_removeAllDataDetectedContent:`, to allow internal WebKit clients to run data detection and add links to data >> >> Does it actually remove the data detected *content*? or just the links? >> >> Also, should this just be a side effect of turning Data Detectors off via the existing API?? > > This just removes links added by data detectors, and resets Frame's m_dataDetectionResults. > > I had considered making this a side effect of turning data detectors on or off, but it seems that this is only exposed on the web view configuration via dataDetectorTypes. IIUC, changes to the configuration aren't normally propagated to the web view after the web view is already initialized with the configuration. > > An alternative is adding an SPI property on either WKWebView or WKPreferences that's something like _dataDetectorTypes, and we would add or remove data detectors in web content when this property is modified. WDYT?
Aha, I see. I didn't realize it was a Configuration thing. No, I don't think you need to add more dataDetectorTypes equivalents. The API one is good. In that case the only thing I object to is the word "content" in the method name.
Wenson Hsieh
Comment 6
2018-11-23 22:06:47 PST
Comment on
attachment 355533
[details]
Fix the GTK build View in context:
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
>>>> Source/WebKit/ChangeLog:10 >>>> + `-_removeAllDataDetectedContent:`, to allow internal WebKit clients to run data detection and add links to data >>> >>> Does it actually remove the data detected *content*? or just the links? >>> >>> Also, should this just be a side effect of turning Data Detectors off via the existing API?? >> >> This just removes links added by data detectors, and resets Frame's m_dataDetectionResults. >> >> I had considered making this a side effect of turning data detectors on or off, but it seems that this is only exposed on the web view configuration via dataDetectorTypes. IIUC, changes to the configuration aren't normally propagated to the web view after the web view is already initialized with the configuration. >> >> An alternative is adding an SPI property on either WKWebView or WKPreferences that's something like _dataDetectorTypes, and we would add or remove data detectors in web content when this property is modified. WDYT? > > Aha, I see. I didn't realize it was a Configuration thing. No, I don't think you need to add more dataDetectorTypes equivalents. The API one is good. > > In that case the only thing I object to is the word "content" in the method name.
Sound good. How about one of: -_removeDataDetectedLinks: or -_removeDataDetectionResults:? Or...perhaps something more general, such as -_resetDataDetection:?
Tim Horton
Comment 7
2018-11-23 22:06:52 PST
Comment on
attachment 355533
[details]
Fix the GTK build View in context:
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:197 > +- (void)_removeAllDataDetectedContent:(dispatch_block_t)completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
Also, why is one available on both platforms and the other only on iOS?
> Source/WebKit/WebProcess/WebPage/WebPage.cpp:3396 > +void WebPage::removeAllDataDetectedContent(CallbackID callbackID)
Didn't Alex invent some new thing to replace CallbackID? See
https://trac.webkit.org/changeset/237294/webkit
Wenson Hsieh
Comment 8
2018-11-23 22:08:56 PST
(In reply to Tim Horton from
comment #7
)
> Comment on
attachment 355533
[details]
> Fix the GTK build > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:197 > > +- (void)_removeAllDataDetectedContent:(dispatch_block_t)completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > Also, why is one available on both platforms and the other only on iOS?
I first tried to make both available on macOS/iOS, but realized that WKDataDetectorTypes is iOS-only :/
> > > Source/WebKit/WebProcess/WebPage/WebPage.cpp:3396 > > +void WebPage::removeAllDataDetectedContent(CallbackID callbackID) > > Didn't Alex invent some new thing to replace CallbackID? See >
https://trac.webkit.org/changeset/237294/webkit
Nice, I'll give this a shot!
Tim Horton
Comment 9
2018-11-23 22:09:17 PST
(In reply to Wenson Hsieh from
comment #6
)
> Comment on
attachment 355533
[details]
> Fix the GTK build > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> > >>>> Source/WebKit/ChangeLog:10 > >>>> + `-_removeAllDataDetectedContent:`, to allow internal WebKit clients to run data detection and add links to data > >>> > >>> Does it actually remove the data detected *content*? or just the links? > >>> > >>> Also, should this just be a side effect of turning Data Detectors off via the existing API?? > >> > >> This just removes links added by data detectors, and resets Frame's m_dataDetectionResults. > >> > >> I had considered making this a side effect of turning data detectors on or off, but it seems that this is only exposed on the web view configuration via dataDetectorTypes. IIUC, changes to the configuration aren't normally propagated to the web view after the web view is already initialized with the configuration. > >> > >> An alternative is adding an SPI property on either WKWebView or WKPreferences that's something like _dataDetectorTypes, and we would add or remove data detectors in web content when this property is modified. WDYT? > > > > Aha, I see. I didn't realize it was a Configuration thing. No, I don't think you need to add more dataDetectorTypes equivalents. The API one is good. > > > > In that case the only thing I object to is the word "content" in the method name. > > Sound good. How about one of: -_removeDataDetectedLinks: or
Probably that one ^^ (slightly humorous because one of the subtypes is WKDataDetectorTypeLink but I don't think that matters, and the API doc does say "add links around...".
> -_removeDataDetectionResults:? Or...perhaps something more general, such as > -_resetDataDetection:?
Wenson Hsieh
Comment 10
2018-11-23 23:27:32 PST
Created
attachment 355554
[details]
Patch for EWS
Wenson Hsieh
Comment 11
2018-11-23 23:29:51 PST
(In reply to Wenson Hsieh from
comment #8
)
> (In reply to Tim Horton from
comment #7
) > > Comment on
attachment 355533
[details]
> > Fix the GTK build > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:197 > > > +- (void)_removeAllDataDetectedContent:(dispatch_block_t)completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > > > Also, why is one available on both platforms and the other only on iOS? > > I first tried to make both available on macOS/iOS, but realized that > WKDataDetectorTypes is iOS-only :/ > > > > > > Source/WebKit/WebProcess/WebPage/WebPage.cpp:3396 > > > +void WebPage::removeAllDataDetectedContent(CallbackID callbackID) > > > > Didn't Alex invent some new thing to replace CallbackID? See > >
https://trac.webkit.org/changeset/237294/webkit
> > Nice, I'll give this a shot!
This mostly just worked, but needs a small tweak in WebKit/scripts/webkit/messages.py to support declaring async completion handlers with no arguments, like so: DetectDataInAllFrames(uint64_t types) -> () Async RemoveDataDetectedLinks() -> () Async
Wenson Hsieh
Comment 12
2018-11-24 00:05:06 PST
Created
attachment 355555
[details]
Patch for EWS
Wenson Hsieh
Comment 13
2018-11-24 09:51:48 PST
(In reply to Wenson Hsieh from
comment #11
)
> (In reply to Wenson Hsieh from
comment #8
) > > (In reply to Tim Horton from
comment #7
) > > > Comment on
attachment 355533
[details]
> > > Fix the GTK build > > > > > > View in context: > > >
https://bugs.webkit.org/attachment.cgi?id=355533&action=review
> > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:197 > > > > +- (void)_removeAllDataDetectedContent:(dispatch_block_t)completion WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > > > > > Also, why is one available on both platforms and the other only on iOS? > > > > I first tried to make both available on macOS/iOS, but realized that > > WKDataDetectorTypes is iOS-only :/ > > > > > > > > > Source/WebKit/WebProcess/WebPage/WebPage.cpp:3396 > > > > +void WebPage::removeAllDataDetectedContent(CallbackID callbackID) > > > > > > Didn't Alex invent some new thing to replace CallbackID? See > > >
https://trac.webkit.org/changeset/237294/webkit
> > > > Nice, I'll give this a shot! > > This mostly just worked, but needs a small tweak in > WebKit/scripts/webkit/messages.py to support declaring async completion > handlers with no arguments, like so: > > DetectDataInAllFrames(uint64_t types) -> () Async > RemoveDataDetectedLinks() -> () Async
I realized that I actually don't need this messages.py adjustment if I use this async CompletionHandler as an opportunity to just send back a DataDetectionResult, instead of propagating the DataDetectionResult as a separate IPC message. This has the added bonus of eliminating the need for an extra IPC message, but does require a small tweak in DataDetectionResult to make DataDetectionResult use the new decoding format: static std::optional<DataDetectionResult> decode(IPC::Decoder&); instead of: static bool decode(IPC::Decoder&, DataDetectionResult&);
Wenson Hsieh
Comment 14
2018-11-24 09:57:26 PST
Created
attachment 355564
[details]
Patch for EWS
WebKit Commit Bot
Comment 15
2018-11-24 13:06:16 PST
Comment on
attachment 355564
[details]
Patch for EWS Clearing flags on attachment: 355564 Committed
r238471
: <
https://trac.webkit.org/changeset/238471
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug