Bug 127721 - Copy relevant code from the iOS version of WKView to WKWebView
Summary: Copy relevant code from the iOS version of WKView to WKWebView
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-27 16:05 PST by Anders Carlsson
Modified: 2014-01-27 16:20 PST (History)
0 users

See Also:


Attachments
Patch (10.66 KB, patch)
2014-01-27 16:05 PST, Anders Carlsson
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>