Bug 127721

Summary: Copy relevant code from the iOS version of WKView to WKWebView
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mitz: review+

Description Anders Carlsson 2014-01-27 16:05:07 PST
Copy relevant code from the iOS version of WKView to WKWebView
Comment 1 Anders Carlsson 2014-01-27 16:05:59 PST
Created attachment 222377 [details]
Patch
Comment 2 mitz 2014-01-27 16:15:42 PST
Comment on attachment 222377 [details]
Patch

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

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:43
> +#endif
> +
> +#if PLATFORM(IOS)

Not necessary

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:96
> +    [_contentView setDelegate:self];
> +    [_contentView layer].anchorPoint = CGPointZero;
> +    [_contentView setFrame:bounds];
> +    [_scrollView addSubview:_contentView.get()];

Please use property syntax here.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:99
> +    [_viewportHandler setDelegate:self];

And here.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:113
> +#pragma mark iOS specific methods

iOS-specific

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:141
> +    return [_contentView browsingContextController];

And here.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:174
> +    CGFloat zoomScale = [_scrollView zoomScale];
> +    CGSize contentsSizeInScrollViewCoordinates = CGSizeMake(newSize.width * zoomScale, newSize.height * zoomScale);
> +    [_scrollView setContentSize:contentsSizeInScrollViewCoordinates];
> +
> +    [_viewportHandler update:^{
> +         [_viewportHandler setDocumentBounds:{CGPointZero, newSize}];
> +    }];
> +}
> +
> +- (void)contentViewDidCommitLoadForMainFrame:(WKContentView *)contentView
> +{
> +    _userHasChangedPageScale = NO;
> +
> +    WKContentType contentType = [_contentView contentType];
> +    [_viewportHandler update:^{
> +        [_viewportHandler clearWebKitViewportConfigurationFlags];
> +        struct _UIWebViewportConfiguration configuration = standardViewportConfiguration;
> +
> +        if (contentType == PlainText) {
> +            CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
> +            configuration.size.width = screenWidth;
> +        } else if (contentType == WKContentType::Image)
> +            configuration.minimumScale = 0.01;
> +
> +        [_viewportHandler resetViewportConfiguration:&configuration];
> +    }];
> +}

And here.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:181
> +        configuration.size = CGSizeMake(320.0, UIWebViewportGrowsAndShrinksToFitHeight);

No need for .0

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:193
> +    [_viewportHandler update:^{
> +        [_viewportHandler applyWebKitViewportArgumentsSize:newSize
> +                                              initialScale:initialScale
> +                                              minimumScale:minimumScale
> +                                              maximumScale:maximumScale
> +                                         allowsUserScaling:allowsUserScaling];

Please fix the weird indentation.
Comment 3 Anders Carlsson 2014-01-27 16:20:19 PST
Committed r162886: <http://trac.webkit.org/changeset/162886>