Bug 225615

Summary: Promote `-[WKWebView _pageExtendedBackgroundColor]` SPI to `-[WKWebView underPageBackgroundColor]` API
Product: WebKit Reporter: Devin Rousso <hi>
Component: WebKit APIAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, cdumez, changseok, esprehn+autocc, ews-watchlist, fred.wang, glenn, hi, kangil.han, kondapallykalyan, megan_gardner, pdr, simon.fraser, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
[Patch] logging for EWS
none
[Patch] logging for EWS
none
[Patch] logging for EWS
none
[Patch] logging for EWS
none
Patch
none
Patch none

Description Devin Rousso 2021-05-10 14:32:37 PDT
.
Comment 1 Devin Rousso 2021-05-10 14:32:55 PDT
<rdar://problem/76568094>
Comment 2 Devin Rousso 2021-05-10 15:02:01 PDT
Created attachment 428209 [details]
Patch
Comment 3 Wenson Hsieh 2021-05-10 16:46:40 PDT
Comment on attachment 428209 [details]
Patch

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

> Source/WebCore/page/Page.cpp:2577
> +    if (auto* frameView = mainFrame().view()) {
> +        if (auto* renderView = frameView->renderView()) {

Nit - `if (auto … = makeRefPtr(…))`

> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:493
> +    return webView.underPageBackgroundColor.CGColor;

We seem to have lost the null check for `webView->_page` here, since `-underPageBackgroundColor` dereferences `_page`.

> Source/WebKit/UIProcess/WebPageProxy.cpp:8622
> +#if !PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)

Nit - !PLATFORM(COCOA)?

> Source/WebKit/UIProcess/WebPageProxy.h:2661
> +    bool m_pendingUnderPageBackgroundColorOverrideToDispatch { false };

Nit - m_hasPendingUnderPageBackgroundColorOverrideToDispatch? (The current name makes it sound like it should be a `Color` or `Optional<Color>`)
Comment 4 Devin Rousso 2021-05-10 16:57:14 PDT
Comment on attachment 428209 [details]
Patch

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

>> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:493
>> +    return webView.underPageBackgroundColor.CGColor;
> 
> We seem to have lost the null check for `webView->_page` here, since `-underPageBackgroundColor` dereferences `_page`.

Is it ever actually possible for a `WKWebView` to not have a `_page`?
Comment 5 Wenson Hsieh 2021-05-10 17:04:49 PDT
Comment on attachment 428209 [details]
Patch

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

>>> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:493
>>> +    return webView.underPageBackgroundColor.CGColor;
>> 
>> We seem to have lost the null check for `webView->_page` here, since `-underPageBackgroundColor` dereferences `_page`.
> 
> Is it ever actually possible for a `WKWebView` to not have a `_page`?

`_page` is set very early on when initializing the web view, but it might be theoretically possible for a WebKit client to call into API that requires `_page` before this happens...

Potentially something like trying to `-setBackgroundColor` before calling into the superclass initializer?
Comment 6 Devin Rousso 2021-05-10 18:40:08 PDT
Created attachment 428234 [details]
Patch
Comment 7 Devin Rousso 2021-05-11 12:28:34 PDT
Created attachment 428306 [details]
[Patch] logging for EWS
Comment 8 Devin Rousso 2021-05-11 16:19:23 PDT
Created attachment 428326 [details]
[Patch] logging for EWS
Comment 9 Devin Rousso 2021-05-11 20:45:34 PDT
Created attachment 428339 [details]
[Patch] logging for EWS
Comment 10 Devin Rousso 2021-05-12 00:51:59 PDT
Created attachment 428352 [details]
[Patch] logging for EWS
Comment 11 Devin Rousso 2021-05-12 11:32:20 PDT
Created attachment 428391 [details]
Patch
Comment 12 EWS 2021-05-14 13:35:33 PDT
Tools/Scripts/svn-apply failed to apply attachment 428391 [details] to trunk.
Please resolve the conflicts and upload a new patch.
Comment 13 Devin Rousso 2021-05-14 13:44:49 PDT
Created attachment 428651 [details]
Patch
Comment 14 EWS 2021-05-14 14:34:54 PDT
Committed r277505 (237736@main): <https://commits.webkit.org/237736@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 428651 [details].