Bug 209372

Summary: Adopt -[UIWindowScene interfaceOrientation] when determining device orientation
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: WebKit2Assignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, darin, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
darin: review+
Patch for landing none

Description Wenson Hsieh 2020-03-20 21:38:47 PDT
<rdar://problem/60491857>
Comment 1 Wenson Hsieh 2020-03-21 16:26:31 PDT
Created attachment 394183 [details]
Patch
Comment 2 Darin Adler 2020-03-22 09:52:52 PDT
Comment on attachment 394183 [details]
Patch

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

How can we make an automated test for this?

> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:229
> +    auto *application = UIApplication.sharedApplication;

Just auto would be better. Let’s dodge the * placement issue.

> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:234
> +    else if (auto *windowScene = self.window.windowScene)

Ditto.
Comment 3 Wenson Hsieh 2020-03-22 12:00:19 PDT
Comment on attachment 394183 [details]
Patch

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

I considered writing an API test for this that would mock out -_appAdoptsUISceneLifecycle to return YES, but I don't think such a test would be very useful. Generally, writing an API test for this is tricky, because TestWebKitAPI isn't even a UI application on iOS, and so the UIApplication, windows, and their window scenes would all need to be mocked by the test.

I think when we eventually convert WebKitTestRunnerApp into a scene-based UIApplication, we'll be able to get test coverage for this codepath.

>> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:229
>> +    auto *application = UIApplication.sharedApplication;
> 
> Just auto would be better. Let’s dodge the * placement issue.

Sounds good — changed to just auto.

>> Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:234
>> +    else if (auto *windowScene = self.window.windowScene)
> 
> Ditto.

Changed to just auto.
Comment 4 Wenson Hsieh 2020-03-22 12:05:28 PDT
Created attachment 394222 [details]
Patch for landing
Comment 5 EWS 2020-03-22 12:29:44 PDT
Committed r258821: <https://trac.webkit.org/changeset/258821>

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