Bug 190504

Summary: [iOS] Allow SPI clients to lay out at arbitrarily scaled sizes and scale to fit the view
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: WebKit APIAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, commit-queue, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
First pass
none
Fix WPE/GTK builds
thorton: review+
Patch for EWS none

Description Wenson Hsieh 2018-10-11 18:50:47 PDT
<rdar://problem/45117760>
Comment 1 Wenson Hsieh 2018-10-11 20:17:08 PDT
Created attachment 352130 [details]
First pass
Comment 2 Wenson Hsieh 2018-10-11 22:40:28 PDT
Created attachment 352136 [details]
Fix WPE/GTK builds
Comment 3 Tim Horton 2018-10-12 13:21:24 PDT
Comment on attachment 352136 [details]
Fix WPE/GTK builds

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

> Source/WebCore/page/ViewportConfiguration.cpp:434
> +    m_configuration.initialScale *= m_layoutSizeScaleFactor;

Hi-larious

> Source/WebCore/page/ViewportConfiguration.cpp:549
> +    ts.dumpProperty("initialScaleIgnoringLayoutScaleFactor", parameters.initialScaleIgnoringLayoutScaleFactor);

Probably also print out m_layoutSizeScaleFactor??

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5166
>      if (viewScale <= 0 || isnan(viewScale) || isinf(viewScale))
>          [NSException raise:NSInvalidArgumentException format:@"View scale should be a positive number"];

Why is this in the !PLATFORM(MAC) section

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:180
> +@property (nonatomic, setter=_setViewScale:) CGFloat _viewScale WK_API_AVAILABLE(macosx(10.11), ios(9.0));

Whoops

> Tools/ChangeLog:22
> +        Add a new file for UIScriptController methods on Cocoa platforms.

Noice. There's some other stuff we can move here.
Comment 4 Wenson Hsieh 2018-10-12 13:44:36 PDT
Comment on attachment 352136 [details]
Fix WPE/GTK builds

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

>> Source/WebCore/page/ViewportConfiguration.cpp:549
>> +    ts.dumpProperty("initialScaleIgnoringLayoutScaleFactor", parameters.initialScaleIgnoringLayoutScaleFactor);
> 
> Probably also print out m_layoutSizeScaleFactor??

Yes!

>> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:5166
>>          [NSException raise:NSInvalidArgumentException format:@"View scale should be a positive number"];
> 
> Why is this in the !PLATFORM(MAC) section

Can't think of a good reason! Interestingly, WebViewImpl::setViewScale throws this same exception. I'll lift this `+[NSException raise:]` call out of !MAC for now, and move the identical macOS exception throwing logic from WebViewImpl to WKView.

>> Tools/ChangeLog:22
>> +        Add a new file for UIScriptController methods on Cocoa platforms.
> 
> Noice. There's some other stuff we can move here.

Indeed! Will move cross-macOS-iOS functionality here in a followup.

> LayoutTests/resources/ui-helper.js:348
> +        return new Promise(resolve => testRunner.runUIScript(`uiController.setViewScale(${scale})`, () => resolve()));

Note to self: I should just pass `resolve` here rather than wrapping it in another callback.
Comment 5 Wenson Hsieh 2018-10-12 14:49:04 PDT
Created attachment 352206 [details]
Patch for EWS
Comment 6 WebKit Commit Bot 2018-10-12 16:13:45 PDT
Comment on attachment 352206 [details]
Patch for EWS

Clearing flags on attachment: 352206

Committed r237087: <https://trac.webkit.org/changeset/237087>