Bug 208575 - Add an SPI to allow UserStyleSheet injection to target a specific WKWebView
Summary: Add an SPI to allow UserStyleSheet injection to target a specific WKWebView
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-03-04 08:51 PST by Antoine Quint
Modified: 2020-04-02 15:35 PDT (History)
7 users (show)

See Also:


Attachments
Patch (24.60 KB, patch)
2020-03-04 09:10 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (25.03 KB, patch)
2020-03-04 09:57 PST, Antoine Quint
beidson: 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-03-04 08:51:43 PST
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView
Comment 1 Antoine Quint 2020-03-04 09:10:31 PST
Created attachment 392421 [details]
Patch
Comment 2 Antoine Quint 2020-03-04 09:10:37 PST
<rdar://problem/59773690>
Comment 3 Antoine Quint 2020-03-04 09:57:10 PST
Created attachment 392433 [details]
Patch
Comment 4 Alex Christensen 2020-03-04 10:50:47 PST
Comment on attachment 392433 [details]
Patch

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

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

Nit: extra space.

> Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp:457
> +                page->injectUserStyleSheet(userStyleSheet);

Why do we need a separate way to inject a stylesheet?  Can't we just use the existing way, but if there is a page id and it's different than the current page id, do nothing?
Comment 5 Brady Eidson 2020-03-04 10:55:15 PST
Comment on attachment 392433 [details]
Patch

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

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

Extra space here too

>> Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp:457
>> +                page->injectUserStyleSheet(userStyleSheet);
> 
> Why do we need a separate way to inject a stylesheet?  Can't we just use the existing way, but if there is a page id and it's different than the current page id, do nothing?

I know the answer - WebCore page's don't know their page id, so the page id check has to be up in WebKit.
Comment 6 Antoine Quint 2020-03-04 12:05:48 PST
Committed r257870: <https://trac.webkit.org/changeset/257870>
Comment 7 Antoine Quint 2020-03-05 09:29:13 PST
Some followup work in bug 208644.