Bug 134228

Summary: Implement WebPageProxy::windowAndViewFramesChanged
Product: WebKit Reporter: Martin Hock <mhock>
Component: WebKit2Assignee: Martin Hock <mhock>
Status: RESOLVED INVALID    
Severity: Normal CC: benjamin, bfulgham, ian, thorton
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: iPhone / iPad   
OS: Unspecified   
Attachments:
Description Flags
patch benjamin: review+

Description Martin Hock 2014-06-23 17:03:45 PDT
Implement WebPageProxy::windowAndViewFramesChanged.
Comment 1 Martin Hock 2014-06-23 17:12:50 PDT
Created attachment 233656 [details]
patch
Comment 2 Tim Horton 2014-06-23 17:23:55 PDT
Comment on attachment 233656 [details]
patch

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

> Source/WebKit2/UIProcess/ios/WKContentView.mm:260
> +        [self.window addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:nullptr];

I don't think this works, did you test this?
Comment 3 Benjamin Poulain 2014-06-23 17:27:14 PDT
Comment on attachment 233656 [details]
patch

lgtm. What was the initial size bug?
Comment 4 Benjamin Poulain 2014-06-23 17:28:29 PDT
Comment on attachment 233656 [details]
patch

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

> Source/WebKit2/UIProcess/ios/WKContentView.mm:253
> +    // All observations are for bounds changes.
> +    _page->windowAndViewFramesChanged(self.window.bounds, self.window.bounds.origin);

It would be best to assert the keyPath.

You may want to call self.window.bounds only once since obj-c dispatch is not cheap.
Comment 5 Ian Henderson 2014-06-23 17:32:02 PDT
Why do web pages care about the window frame?  Could we give them the WKWebView size instead?
Comment 6 Benjamin Poulain 2014-06-23 17:57:03 PDT
(In reply to comment #5)
> Why do web pages care about the window frame?  Could we give them the WKWebView size instead?

There is no clear specification of what window.outerWidth/height should be on mobile. This matches the usage.

One of the problem with reporting WKWebView's size is that some people use outerWidth/height to detect the screen orientation.