Bug 217784

Summary: Create API to enable/disable text interaction gestures in WKWebView
Product: WebKit Reporter: Kate Cheney <katherine_cheney>
Component: WebKit Misc.Assignee: Kate Cheney <katherine_cheney>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, bdakin, beidson, bfulgham, megan_gardner, sam, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing
none
Patch none

Kate Cheney
Reported 2020-10-15 14:30:25 PDT
We have SPI for this, but it could be useful for other WebKit clients.
Attachments
Patch (13.18 KB, patch)
2020-10-15 14:49 PDT, Kate Cheney
ews-feeder: commit-queue-
Patch (13.13 KB, patch)
2020-10-15 15:14 PDT, Kate Cheney
no flags
Patch (13.16 KB, patch)
2020-10-15 16:23 PDT, Kate Cheney
no flags
Patch (14.46 KB, patch)
2020-10-16 08:06 PDT, Kate Cheney
no flags
Patch (39.69 KB, patch)
2020-12-02 10:42 PST, Kate Cheney
no flags
Patch (40.50 KB, patch)
2020-12-02 11:23 PST, Kate Cheney
no flags
Patch (47.84 KB, patch)
2020-12-02 14:32 PST, Kate Cheney
no flags
Patch (44.21 KB, patch)
2020-12-02 15:56 PST, Kate Cheney
no flags
Patch for landing (43.79 KB, patch)
2020-12-04 11:04 PST, Kate Cheney
no flags
Patch (1.35 KB, patch)
2021-09-14 10:27 PDT, Kate Cheney
no flags
Kate Cheney
Comment 1 2020-10-15 14:31:12 PDT
Kate Cheney
Comment 2 2020-10-15 14:49:53 PDT
Tim Horton
Comment 3 2020-10-15 14:55:42 PDT
Comment on attachment 411491 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411491&action=review > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:469 > + @discussion The default value is YES for iOS, and NO for WatchOS. watchOS is spelled watchOS > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:471 > +@property (nonatomic, setter=setTextInteractionGesturesEnabled:) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); You don't need to specify the setter if it isn't special. > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:472 > +#endif Has the name been API-reviewed? > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > +#if PLATFORM(WATCHOS) > + [self setTextInteractionGesturesEnabled:NO]; Are watchOS clients going to need to set this now, in addition to the other API? (since if either one is NO, you bail from installing the gestures?) > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:2524 > - if (!self.webView.configuration._textInteractionGesturesEnabled) > + if (!self.webView.configuration._textInteractionGesturesEnabled || !self.webView.textInteractionGesturesEnabled) Odd that the SPI is on WKWebViewConfiguration and the API is on WKWebView. Any reason for that?
Kate Cheney
Comment 4 2020-10-15 15:00:36 PDT
(In reply to Tim Horton from comment #3) > Comment on attachment 411491 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=411491&action=review > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:469 > > + @discussion The default value is YES for iOS, and NO for WatchOS. > > watchOS is spelled watchOS > Oops, will fix. > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:471 > > +@property (nonatomic, setter=setTextInteractionGesturesEnabled:) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > You don't need to specify the setter if it isn't special. > Got it -- will remove. > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:472 > > +#endif > > Has the name been API-reviewed? > The review process has been initiated, but the name has not been formally reviewed yet. > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > > +#if PLATFORM(WATCHOS) > > + [self setTextInteractionGesturesEnabled:NO]; > > Are watchOS clients going to need to set this now, in addition to the other > API? (since if either one is NO, you bail from installing the gestures?) > I copied this behavior from the SPI, but maybe I misunderstood what was going on? > > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:2524 > > - if (!self.webView.configuration._textInteractionGesturesEnabled) > > + if (!self.webView.configuration._textInteractionGesturesEnabled || !self.webView.textInteractionGesturesEnabled) > > Odd that the SPI is on WKWebViewConfiguration and the API is on WKWebView. > Any reason for that? Yes, so it can be changed on the fly (see WebKit ChangeLog).
Tim Horton
Comment 5 2020-10-15 15:02:45 PDT
(In reply to katherine_cheney from comment #4) > (In reply to Tim Horton from comment #3) > > Comment on attachment 411491 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=411491&action=review > > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:469 > > > + @discussion The default value is YES for iOS, and NO for WatchOS. > > > > watchOS is spelled watchOS > > > > Oops, will fix. > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:471 > > > +@property (nonatomic, setter=setTextInteractionGesturesEnabled:) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > > > You don't need to specify the setter if it isn't special. > > > > Got it -- will remove. > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:472 > > > +#endif > > > > Has the name been API-reviewed? > > > > The review process has been initiated, but the name has not been formally > reviewed yet. > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > > > +#if PLATFORM(WATCHOS) > > > + [self setTextInteractionGesturesEnabled:NO]; > > > > Are watchOS clients going to need to set this now, in addition to the other > > API? (since if either one is NO, you bail from installing the gestures?) > > > > I copied this behavior from the SPI, but maybe I misunderstood what was > going on? Maybe it's OK because nobody ever turns the SPI ON on watchOS? But if they /did/, you would be introducing a new source of "false", and overriding their preference, right? > > > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:2524 > > > - if (!self.webView.configuration._textInteractionGesturesEnabled) > > > + if (!self.webView.configuration._textInteractionGesturesEnabled || !self.webView.textInteractionGesturesEnabled) > > > > Odd that the SPI is on WKWebViewConfiguration and the API is on WKWebView. > > Any reason for that? > > Yes, so it can be changed on the fly (see WebKit ChangeLog). I guess we'll eventually transition away from the SPI.
Kate Cheney
Comment 6 2020-10-15 15:06:11 PDT
(In reply to Tim Horton from comment #5) > (In reply to katherine_cheney from comment #4) > > (In reply to Tim Horton from comment #3) > > > Comment on attachment 411491 [details] > > > Patch > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > > > > +#if PLATFORM(WATCHOS) > > > > + [self setTextInteractionGesturesEnabled:NO]; > > > > > > Are watchOS clients going to need to set this now, in addition to the other > > > API? (since if either one is NO, you bail from installing the gestures?) > > > > > > > I copied this behavior from the SPI, but maybe I misunderstood what was > > going on? > > Maybe it's OK because nobody ever turns the SPI ON on watchOS? But if they > /did/, you would be introducing a new source of "false", and overriding > their preference, right? > It is pretty explicitly set to NO in WebViewConfiguration init for watchOS, maybe Wenson can explain why that was done for the SPI so we can understand what we need to do here.
Wenson Hsieh
Comment 7 2020-10-15 15:09:31 PDT
(In reply to katherine_cheney from comment #6) > (In reply to Tim Horton from comment #5) > > (In reply to katherine_cheney from comment #4) > > > (In reply to Tim Horton from comment #3) > > > > Comment on attachment 411491 [details] > > > > Patch > > > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > > > > > +#if PLATFORM(WATCHOS) > > > > > + [self setTextInteractionGesturesEnabled:NO]; > > > > > > > > Are watchOS clients going to need to set this now, in addition to the other > > > > API? (since if either one is NO, you bail from installing the gestures?) > > > > > > > > > > I copied this behavior from the SPI, but maybe I misunderstood what was > > > going on? > > > > Maybe it's OK because nobody ever turns the SPI ON on watchOS? But if they > > /did/, you would be introducing a new source of "false", and overriding > > their preference, right? > > > > It is pretty explicitly set to NO in WebViewConfiguration init for watchOS, > maybe Wenson can explain why that was done for the SPI so we can understand > what we need to do here. The default value for that configuration flag is NO on watchOS because we don't want WKWebView clients to allow text selection on watchOS; AFAIK, there are no WebKit clients on watchOS that would want to enable text selection. (I think Tim is suggesting that this could theoretically break behavior for watchOS WebKit clients that currently attempt to enable text selection, but I don't think anyone actually does this, so taking either flag to mean "disable selection" should be fine).
Kate Cheney
Comment 8 2020-10-15 15:14:25 PDT
Kate Cheney
Comment 9 2020-10-15 15:15:57 PDT
(In reply to Wenson Hsieh from comment #7) > (In reply to katherine_cheney from comment #6) > > (In reply to Tim Horton from comment #5) > > > (In reply to katherine_cheney from comment #4) > > > > (In reply to Tim Horton from comment #3) > > > > > Comment on attachment 411491 [details] > > > > > Patch > > > > > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:369 > > > > > > +#if PLATFORM(WATCHOS) > > > > > > + [self setTextInteractionGesturesEnabled:NO]; > > > > > > > > > > Are watchOS clients going to need to set this now, in addition to the other > > > > > API? (since if either one is NO, you bail from installing the gestures?) > > > > > > > > > > > > > I copied this behavior from the SPI, but maybe I misunderstood what was > > > > going on? > > > > > > Maybe it's OK because nobody ever turns the SPI ON on watchOS? But if they > > > /did/, you would be introducing a new source of "false", and overriding > > > their preference, right? > > > > > > > It is pretty explicitly set to NO in WebViewConfiguration init for watchOS, > > maybe Wenson can explain why that was done for the SPI so we can understand > > what we need to do here. > > The default value for that configuration flag is NO on watchOS because we > don't want WKWebView clients to allow text selection on watchOS; AFAIK, > there are no WebKit clients on watchOS that would want to enable text > selection. > > (I think Tim is suggesting that this could theoretically break behavior for > watchOS WebKit clients that currently attempt to enable text selection, but > I don't think anyone actually does this, so taking either flag to mean > "disable selection" should be fine). OK, I see, that's a good point.
Kate Cheney
Comment 10 2020-10-15 16:23:30 PDT
Alex Christensen
Comment 11 2020-10-15 16:33:13 PDT
Comment on attachment 411506 [details] Patch This shouldn't be on WKWebView. It should be on WKWebViewConfiguration if it's something that shouldn't change during the lifetime of the WKWebView and WKPreferences otherwise. Also, the boolean is backed only by ObjC, which is something we try to avoid in WebKit, where the ObjC layer is just a thin wrapper around the C++ objects.
Wenson Hsieh
Comment 12 2020-10-15 16:34:42 PDT
(In reply to Alex Christensen from comment #11) > Comment on attachment 411506 [details] > Patch > > This shouldn't be on WKWebView. It should be on WKWebViewConfiguration if > it's something that shouldn't change during the lifetime of the WKWebView > and WKPreferences otherwise. Also, the boolean is backed only by ObjC, > which is something we try to avoid in WebKit, where the ObjC layer is just a > thin wrapper around the C++ objects. From the ChangeLog entry, the intention was to make this something that can change on the fly.
Alex Christensen
Comment 13 2020-10-15 16:35:25 PDT
Then it should be on WKPreferences.
Alex Christensen
Comment 14 2020-10-15 16:36:22 PDT
Comment on attachment 411506 [details] Patch Also, _textInteractionGesturesEnabled should be deprecated with this as a replacement.
Kate Cheney
Comment 15 2020-10-16 08:06:37 PDT
Kate Cheney
Comment 16 2020-10-16 08:32:43 PDT
Thanks for the comments Alex, I made those changes. I wasn't sure how to set a default for a specific platform (watchOS) in WKPreferences. Is that possible?
Sam Weinig
Comment 17 2020-10-16 09:41:41 PDT
Comment on attachment 411575 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411575&action=review > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > +#if TARGET_OS_IPHONE > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > +*/ > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > +#endif What makes this iOS specific? Or to put this another way, can we make this work on macOS as well? Seems like disabling interacting with text there is still a meaningful concept.
Kate Cheney
Comment 18 2020-10-16 10:51:59 PDT
(In reply to Sam Weinig from comment #17) > Comment on attachment 411575 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=411575&action=review > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > > +#if TARGET_OS_IPHONE > > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > > +*/ > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > +#endif > > What makes this iOS specific? Or to put this another way, can we make this > work on macOS as well? Seems like disabling interacting with text there is > still a meaningful concept. I have not heard of any requests for it to be for macOS, but maybe it could be useful. Potentially out of scope for this patch, which intends only to promote current iOS behavior to API.
Sam Weinig
Comment 19 2020-10-16 11:01:47 PDT
(In reply to katherine_cheney from comment #18) > (In reply to Sam Weinig from comment #17) > > Comment on attachment 411575 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=411575&action=review > > > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > > > +#if TARGET_OS_IPHONE > > > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > > > +*/ > > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > > +#endif > > > > What makes this iOS specific? Or to put this another way, can we make this > > work on macOS as well? Seems like disabling interacting with text there is > > still a meaningful concept. > > I have not heard of any requests for it to be for macOS, but maybe it could > be useful. Potentially out of scope for this patch, which intends only to > promote current iOS behavior to API. I think we should almost always make having these APIs cross-platform the default, unless there is a specific reason against it. Due to Mac Catalyst, this will have to behave correctly on macOS anyway so by not providing it here, we are just creating a false barrier to creating AppKit based apps.
Sam Weinig
Comment 20 2020-10-16 11:02:53 PDT
(In reply to Sam Weinig from comment #19) > (In reply to katherine_cheney from comment #18) > > (In reply to Sam Weinig from comment #17) > > > Comment on attachment 411575 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=411575&action=review > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > > > > +#if TARGET_OS_IPHONE > > > > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > > > > +*/ > > > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > > > +#endif > > > > > > What makes this iOS specific? Or to put this another way, can we make this > > > work on macOS as well? Seems like disabling interacting with text there is > > > still a meaningful concept. > > > > I have not heard of any requests for it to be for macOS, but maybe it could > > be useful. Potentially out of scope for this patch, which intends only to > > promote current iOS behavior to API. Promotion to API is a big deal. When we do it, we need to consider the wider landscape, and re-evaluate decisions made in the past. I would push you to reconsider the scope.
Kate Cheney
Comment 21 2020-10-16 11:33:56 PDT
(In reply to Sam Weinig from comment #20) > (In reply to Sam Weinig from comment #19) > > (In reply to katherine_cheney from comment #18) > > > (In reply to Sam Weinig from comment #17) > > > > Comment on attachment 411575 [details] > > > > Patch > > > > > > > > View in context: > > > > https://bugs.webkit.org/attachment.cgi?id=411575&action=review > > > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > > > > > +#if TARGET_OS_IPHONE > > > > > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > > > > > +*/ > > > > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > > > > +#endif > > > > > > > > What makes this iOS specific? Or to put this another way, can we make this > > > > work on macOS as well? Seems like disabling interacting with text there is > > > > still a meaningful concept. > > > > > > I have not heard of any requests for it to be for macOS, but maybe it could > > > be useful. Potentially out of scope for this patch, which intends only to > > > promote current iOS behavior to API. > > Promotion to API is a big deal. When we do it, we need to consider the wider > landscape, and re-evaluate decisions made in the past. I would push you to > reconsider the scope. Ok. How about a FIXME to implement for macOS which I can work on next? I agree it's a big deal to promote to API and re-evaluating the scope seems like a good idea. It seems logical to me to separate these into two patches, because macOS would require new implementation instead of just copying the SPI, meaning its more likely to potentially introduce a regression and need to be rolled out, in which case it would be nice to have it isolated in its own patch.
Sam Weinig
Comment 22 2020-10-16 16:42:34 PDT
(In reply to katherine_cheney from comment #21) > (In reply to Sam Weinig from comment #20) > > (In reply to Sam Weinig from comment #19) > > > (In reply to katherine_cheney from comment #18) > > > > (In reply to Sam Weinig from comment #17) > > > > > Comment on attachment 411575 [details] > > > > > Patch > > > > > > > > > > View in context: > > > > > https://bugs.webkit.org/attachment.cgi?id=411575&action=review > > > > > > > > > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:67 > > > > > > +#if TARGET_OS_IPHONE > > > > > > +/*! @abstract A Boolean value indicating whether text interaction is disabled. > > > > > > +*/ > > > > > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > > > > > +#endif > > > > > > > > > > What makes this iOS specific? Or to put this another way, can we make this > > > > > work on macOS as well? Seems like disabling interacting with text there is > > > > > still a meaningful concept. > > > > > > > > I have not heard of any requests for it to be for macOS, but maybe it could > > > > be useful. Potentially out of scope for this patch, which intends only to > > > > promote current iOS behavior to API. > > > > Promotion to API is a big deal. When we do it, we need to consider the wider > > landscape, and re-evaluate decisions made in the past. I would push you to > > reconsider the scope. > > Ok. How about a FIXME to implement for macOS which I can work on next? I > agree it's a big deal to promote to API and re-evaluating the scope seems > like a good idea. It seems logical to me to separate these into two patches, > because macOS would require new implementation instead of just copying the > SPI, meaning its more likely to potentially introduce a regression and need > to be rolled out, in which case it would be nice to have it isolated in its > own patch. If you are going to make it work cross platform, I would argue you should do that first and delay introducing API until you are ready, and have tested it in all the relevant configurations.
Radar WebKit Bug Importer
Comment 23 2020-10-22 14:31:18 PDT
Kate Cheney
Comment 24 2020-12-02 10:42:31 PST
Kate Cheney
Comment 25 2020-12-02 11:23:42 PST
Kate Cheney
Comment 26 2020-12-02 14:32:33 PST
Tim Horton
Comment 27 2020-12-02 14:38:33 PST
Comment on attachment 415253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415253&action=review > Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 > +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); Let's not add new C SPI in 2020 if at all possible. > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:145 > + ALLOW_DEPRECATED_DECLARATIONS_BEGIN This doesn't make sense around an ivar (to me) > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:359 > self._textInteractionGesturesEnabled = [coder decodeBoolForKey:@"textInteractionGesturesEnabled"]; This one I understand. > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:419 > + ALLOW_DEPRECATED_DECLARATIONS_BEGIN Nor does it make sense here
Kate Cheney
Comment 28 2020-12-02 15:09:32 PST
(In reply to Tim Horton from comment #27) > Comment on attachment 415253 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415253&action=review > > > Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 > > +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); > > Let's not add new C SPI in 2020 if at all possible. This is the only way I see WebPreferences set in WebKitTestRunner, am I missing another way to do it without using C SPI? > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:145 > > + ALLOW_DEPRECATED_DECLARATIONS_BEGIN > > This doesn't make sense around an ivar (to me) Ok, will remove. > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:359 > > self._textInteractionGesturesEnabled = [coder decodeBoolForKey:@"textInteractionGesturesEnabled"]; > > This one I understand. yay! :) > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:419 > > + ALLOW_DEPRECATED_DECLARATIONS_BEGIN > > Nor does it make sense here Ditto, will remove.
Wenson Hsieh
Comment 29 2020-12-02 15:26:57 PST
Comment on attachment 415253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415253&action=review >>> Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 >>> +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); >> >> Let's not add new C SPI in 2020 if at all possible. > > This is the only way I see WebPreferences set in WebKitTestRunner, am I missing another way to do it without using C SPI? I think you should be able to do an ObjC bridging cast from `WKPreferencesRef` to `WKPreferences *` (i.e. `(__bridge WKPreferences *)`). This has the drawback of not being cross-platform (the code would probably be in TestControllerCocoa), but maybe that's okay here since the API is specific to Cocoa anyways :P
Wenson Hsieh
Comment 30 2020-12-02 15:29:44 PST
(In reply to Wenson Hsieh from comment #29) > Comment on attachment 415253 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415253&action=review > > >>> Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 > >>> +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); > >> > >> Let's not add new C SPI in 2020 if at all possible. > > > > This is the only way I see WebPreferences set in WebKitTestRunner, am I missing another way to do it without using C SPI? > > I think you should be able to do an ObjC bridging cast from > `WKPreferencesRef` to `WKPreferences *` (i.e. `(__bridge WKPreferences *)`). > This has the drawback of not being cross-platform (the code would probably > be in TestControllerCocoa), but maybe that's okay here since the API is > specific to Cocoa anyways :P On second thought, a bridging cast is actually unnecessary, since TestController::cocoaResetStateToConsistentValues can just grab the WKWebView and update the WKWebView's preferences.
Alex Christensen
Comment 31 2020-12-02 15:32:16 PST
Comment on attachment 415253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415253&action=review >>>>> Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 >>>>> +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); >>>> >>>> Let's not add new C SPI in 2020 if at all possible. >>> >>> This is the only way I see WebPreferences set in WebKitTestRunner, am I missing another way to do it without using C SPI? >> >> I think you should be able to do an ObjC bridging cast from `WKPreferencesRef` to `WKPreferences *` (i.e. `(__bridge WKPreferences *)`). This has the drawback of not being cross-platform (the code would probably be in TestControllerCocoa), but maybe that's okay here since the API is specific to Cocoa anyways :P > > On second thought, a bridging cast is actually unnecessary, since TestController::cocoaResetStateToConsistentValues can just grab the WKWebView and update the WKWebView's preferences. Can WKPreferencesSetInternalDebugFeatureForKey or WKPreferencesSetExperimentalFeatureForKey work?
Kate Cheney
Comment 32 2020-12-02 15:56:53 PST
Kate Cheney
Comment 33 2020-12-02 15:59:06 PST
(In reply to Alex Christensen from comment #31) > Comment on attachment 415253 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415253&action=review > > >>>>> Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h:571 > >>>>> +WK_EXPORT void WKPreferencesSetTextInteractionGesturesEnabled(WKPreferencesRef, bool flag); > >>>> > >>>> Let's not add new C SPI in 2020 if at all possible. > >>> > >>> This is the only way I see WebPreferences set in WebKitTestRunner, am I missing another way to do it without using C SPI? > >> > >> I think you should be able to do an ObjC bridging cast from `WKPreferencesRef` to `WKPreferences *` (i.e. `(__bridge WKPreferences *)`). This has the drawback of not being cross-platform (the code would probably be in TestControllerCocoa), but maybe that's okay here since the API is specific to Cocoa anyways :P > > > > On second thought, a bridging cast is actually unnecessary, since TestController::cocoaResetStateToConsistentValues can just grab the WKWebView and update the WKWebView's preferences. > > Can WKPreferencesSetInternalDebugFeatureForKey or > WKPreferencesSetExperimentalFeatureForKey work? I don't think this makes sense because it is not an experimental feature or debug feature. Setting preferences in TestController::cocoaResetStateToConsistentValues() worked though.
Wenson Hsieh
Comment 34 2020-12-03 16:05:45 PST
Comment on attachment 415256 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415256&action=review > Source/WTF/Scripts/Preferences/WebPreferences.yaml:2286 > + default: true Should this default to false on watchOS? (I'd imagine that once we remove the old _textInteractionGesturesEnabled SPI, watchOS WebKit clients shouldn't be required to set `textInteractionGesturesEnabled` to `NO` to get the right behavior). > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:65 > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); I'm not sure if "text interaction gestures" is a term that is really used on macOS to describe selecting text and modifying caret selections…but I'd imagine other folks (both WebKit and outside of WebKit) will have more input here. IMO, `textSelectionEnabled` or `textInteractionEnabled` seem more concise and accurate. > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDisableSelection.mm:58 > + EXPECT_STREQ("", selectedText2.UTF8String); Nit - you can use EXPECT_WK_STREQ here instead to avoid the extra `.UTF8String`. > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDisableSelection.mm:93 > + EXPECT_STREQ("", selectedText2.UTF8String); Ditto.
Kate Cheney
Comment 35 2020-12-04 11:04:04 PST
Created attachment 415432 [details] Patch for landing
Kate Cheney
Comment 36 2020-12-04 11:04:48 PST
(In reply to Wenson Hsieh from comment #34) > Comment on attachment 415256 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415256&action=review > > > Source/WTF/Scripts/Preferences/WebPreferences.yaml:2286 > > + default: true > > Should this default to false on watchOS? (I'd imagine that once we remove > the old _textInteractionGesturesEnabled SPI, watchOS WebKit clients > shouldn't be required to set `textInteractionGesturesEnabled` to `NO` to get > the right behavior). Yes, you're right. Good catch. I fixed this in the patch for landing. > > > Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h:65 > > +@property (nonatomic) BOOL textInteractionGesturesEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > I'm not sure if "text interaction gestures" is a term that is really used on > macOS to describe selecting text and modifying caret selections…but I'd > imagine other folks (both WebKit and outside of WebKit) will have more input > here. IMO, `textSelectionEnabled` or `textInteractionEnabled` seem more > concise and accurate. Ok, I renamed the new preference to 'textInteractionEnabled', and can make adjustments during the API review process based on feedback if needed. > > > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDisableSelection.mm:58 > > + EXPECT_STREQ("", selectedText2.UTF8String); > > Nit - you can use EXPECT_WK_STREQ here instead to avoid the extra > `.UTF8String`. > > > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewDisableSelection.mm:93 > > + EXPECT_STREQ("", selectedText2.UTF8String); > > Ditto. Fixed both of these. Thanks for the review!
EWS
Comment 37 2020-12-04 11:54:19 PST
Committed r270446: <https://trac.webkit.org/changeset/270446> All reviewed patches have been landed. Closing bug and clearing flags on attachment 415432 [details].
Tim Horton
Comment 38 2021-09-14 00:45:10 PDT
Comment on attachment 415432 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=415432&action=review > Source/WTF/Scripts/Preferences/WebPreferences.yaml:2284 > + "PLATFORM(WATCH_OS)": false PLATFORM(WATCH_OS) is not a thing, it's PLATFORM(WATCHOS) :(
Kate Cheney
Comment 39 2021-09-14 10:27:29 PDT
Reopening to attach new patch.
Kate Cheney
Comment 40 2021-09-14 10:27:30 PDT
EWS
Comment 41 2021-09-14 11:51:44 PDT
Committed r282399 (241660@main): <https://commits.webkit.org/241660@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 438153 [details].
Note You need to log in before you can comment on or make changes to this bug.