Bug 210653 - Allow the UserStyleLevel to be set through _WKUserStyleSheet
Summary: Allow the UserStyleLevel to be set through _WKUserStyleSheet
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-17 05:31 PDT by Antoine Quint
Modified: 2020-04-17 12:04 PDT (History)
7 users (show)

See Also:


Attachments
Patch (20.00 KB, patch)
2020-04-17 06:27 PDT, Antoine Quint
thorton: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2020-04-17 05:31:53 PDT
Allow the UserStyleLevel to be set through _WKUserStyleSheet
Comment 1 Antoine Quint 2020-04-17 05:37:42 PDT
<rdar://problem/60506645>
Comment 2 Antoine Quint 2020-04-17 06:27:19 PDT
Created attachment 396762 [details]
Patch
Comment 3 Tim Horton 2020-04-17 06:34:33 PDT
Comment on attachment 396762 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:-47
> -- (instancetype)initWithSource:(NSString *)source forWKWebView:(WKWebView *)webView forMainFrameOnly:(BOOL)forMainFrameOnly userContentWorld:(_WKUserContentWorld *)userContentWorld;

Huh? Are there no clients of this SPI? (And, how sure are you?)

> Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm:98
> +    // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?

I think there is precedent for this (maybe look at WKWebViewConfiguration, which is most people’s first WK object).
Comment 4 Tim Horton 2020-04-17 06:38:38 PDT
Comment on attachment 396762 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:52
> +- (instancetype)initWithSource:(NSString *)source forWKWebView:(WKWebView *)webView forMainFrameOnly:(BOOL)forMainFrameOnly level:(_WKUserStyleLevel)level userContentWorld:(_WKUserContentWorld *)userContentWorld;

This needs availability

> Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:55
> +- (instancetype)initWithSource:(NSString *)source forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist baseURL:(NSURL *)baseURL level:(_WKUserStyleLevel)level userContentWorld:(_WKUserContentWorld *)userContentWorld;

This needs availability

> Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:733
> +// Add two tests, where we set the default explicitly, and where we set to author level.

What is this, a fixme? Or just stale?
Comment 5 Antoine Quint 2020-04-17 06:44:39 PDT
(In reply to Tim Horton from comment #4)
> Comment on attachment 396762 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=396762&action=review
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:52
> > +- (instancetype)initWithSource:(NSString *)source forWKWebView:(WKWebView *)webView forMainFrameOnly:(BOOL)forMainFrameOnly level:(_WKUserStyleLevel)level userContentWorld:(_WKUserContentWorld *)userContentWorld;
> 
> This needs availability
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:55
> > +- (instancetype)initWithSource:(NSString *)source forMainFrameOnly:(BOOL)forMainFrameOnly legacyWhitelist:(NSArray<NSString *> *)legacyWhitelist legacyBlacklist:(NSArray<NSString *> *)legacyBlacklist baseURL:(NSURL *)baseURL level:(_WKUserStyleLevel)level userContentWorld:(_WKUserContentWorld *)userContentWorld;
> 
> This needs availability

Will add TBA in both cases.

> > Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:733
> > +// Add two tests, where we set the default explicitly, and where we set to author level.
> 
> What is this, a fixme? Or just stale?

Stale, will remove!
Comment 6 Antoine Quint 2020-04-17 06:46:40 PDT
(In reply to Tim Horton from comment #3)
> Comment on attachment 396762 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=396762&action=review
> 
> > Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h:-47
> > -- (instancetype)initWithSource:(NSString *)source forWKWebView:(WKWebView *)webView forMainFrameOnly:(BOOL)forMainFrameOnly userContentWorld:(_WKUserContentWorld *)userContentWorld;
> 
> Huh? Are there no clients of this SPI? (And, how sure are you?)

This was added just over a month ago in r257870. I've looked and haven't found any use for this SPI that I'm not also changing in some Internal patch.

> > Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm:98
> > +    // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
> 
> I think there is precedent for this (maybe look at WKWebViewConfiguration,
> which is most people’s first WK object).

I stupidly copy-paster the other _WKUserStyleSheet initializers which had this line. Emphasis on "stupidly".
Comment 7 Antoine Quint 2020-04-17 08:47:49 PDT
Committed r260254: <https://trac.webkit.org/changeset/260254>
Comment 8 Antoine Quint 2020-04-17 12:00:10 PDT
Build fix in r260269.
Comment 9 Antti Koivisto 2020-04-17 12:04:44 PDT
Comment on attachment 396762 [details]
Patch

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

> Source/WebKit/ChangeLog:9
> +        Add a new _WKUserStyleLevel enum such that we may provide the specificity level of the backing UserStyleSheet, represented by the UserStyleLevel enum in WebCore.

cascade level!