[iOS] WebKitTestRunner: Tests fail due to incorrect web view size
authorjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2015 23:47:43 +0000 (23:47 +0000)
committerjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2015 23:47:43 +0000 (23:47 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=139736>
<rdar://problem/19282196>

This starts happening after we fail to reset the test controller to
consistent values in TestInvocation::invoke(). When we terminate the
web process and relaunch it, the new WebPage object created in the web
process is using the default ViewportConfiguration with dimensions of
1024x768.

The PageClient on iOS currently notifies the WKWebView and the
WKContentView when the web process is relaunched. This patch extends
that to also notify the WKView.

Reviewed by Benjamin Poulain.

* UIProcess/API/Cocoa/WKViewPrivate.h:
Declare -_didRelaunchProcess.

* UIProcess/API/ios/WKViewIOS.mm:
(-[WKView _commonInitializationWithContextRef:pageGroupRef:relatedToPage:]):
Call the new method that accepts a WKView.
(-[WKView _didRelaunchProcess]):
Call -_frameOrBoundsChanged to update the web process's size to the
size of the WKView.

* UIProcess/ios/PageClientImplIOS.h:
Add a constructor that takes a WKView, and add a member var to hold it.

* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::PageClientImpl):
Implement the constructor that takes a WKView.
(WebKit::PageClientImpl::didRelaunchProcess):
Tell the WKView that the web process relaunched.

* UIProcess/ios/WKContentView.h:
Declare an initializer that takes a WKView.

* UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
Split out from -[WKContentView initWithFrame:processPool:configuration:webView:].
(-[WKContentView initWithFrame:processPool:configuration:webView:]):
Perform some initialization, including creating the PageClient, and
call the common initializer.
(-[WKContentView initWithFrame:processPool:configuration:wkView:]):
Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178870 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm

index 7f7fc81..c2bcfb4 100644 (file)
@@ -1,3 +1,53 @@
+2015-01-20  Jon Honeycutt  <jhoneycutt@apple.com>
+
+        [iOS] WebKitTestRunner: Tests fail due to incorrect web view size
+
+        <https://bugs.webkit.org/show_bug.cgi?id=139736>
+        <rdar://problem/19282196>
+
+        This starts happening after we fail to reset the test controller to
+        consistent values in TestInvocation::invoke(). When we terminate the
+        web process and relaunch it, the new WebPage object created in the web
+        process is using the default ViewportConfiguration with dimensions of
+        1024x768.
+
+        The PageClient on iOS currently notifies the WKWebView and the
+        WKContentView when the web process is relaunched. This patch extends
+        that to also notify the WKView.
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        Declare -_didRelaunchProcess.
+
+        * UIProcess/API/ios/WKViewIOS.mm:
+        (-[WKView _commonInitializationWithContextRef:pageGroupRef:relatedToPage:]):
+        Call the new method that accepts a WKView.
+        (-[WKView _didRelaunchProcess]):
+        Call -_frameOrBoundsChanged to update the web process's size to the
+        size of the WKView.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        Add a constructor that takes a WKView, and add a member var to hold it.
+
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::PageClientImpl):
+        Implement the constructor that takes a WKView.
+        (WebKit::PageClientImpl::didRelaunchProcess):
+        Tell the WKView that the web process relaunched.
+
+        * UIProcess/ios/WKContentView.h:
+        Declare an initializer that takes a WKView.
+
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
+        Split out from -[WKContentView initWithFrame:processPool:configuration:webView:].
+        (-[WKContentView initWithFrame:processPool:configuration:webView:]):
+        Perform some initialization, including creating the PageClient, and
+        call the common initializer.
+        (-[WKContentView initWithFrame:processPool:configuration:wkView:]):
+        Ditto.
+
 2015-01-21  Sam Weinig  <sam@webkit.org>
 
         Add WKPageGroupRef SPI for user content filters
index 49e6364..a719a79 100644 (file)
@@ -57,6 +57,7 @@
 
 - (void)_beginInteractiveObscuredInsetsChange;
 - (void)_endInteractiveObscuredInsetsChange;
+- (void)_didRelaunchProcess;
 
 #else
 
index ae39885..9756bbd 100644 (file)
@@ -223,7 +223,7 @@ using namespace WebKit;
     webPageConfiguration.pageGroup = toImpl(pageGroupRef);
     webPageConfiguration.relatedPage = toImpl(relatedPage);
 
-    _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds processPool:*toImpl(contextRef) configuration:WTF::move(webPageConfiguration) webView:nil]);
+    _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds processPool:*toImpl(contextRef) configuration:WTF::move(webPageConfiguration) wkView:self]);
 
     [[_contentView layer] setAnchorPoint:CGPointZero];
     [_contentView setFrame:bounds];
@@ -337,6 +337,12 @@ using namespace WebKit;
     _minimumLayoutSizeOverride = minimumLayoutSizeOverride;
 }
 
+- (void)_didRelaunchProcess
+{
+    // Update the WebView to our size rather than the default size it will have after being relaunched.
+    [self _frameOrBoundsChanged];
+}
+
 - (UIEdgeInsets)_obscuredInsets
 {
     return _obscuredInsets;
index 5d1e781..2412b91 100644 (file)
@@ -33,6 +33,7 @@
 #import <wtf/RetainPtr.h>
 
 OBJC_CLASS WKContentView;
+OBJC_CLASS WKView;
 OBJC_CLASS WKWebView;
 OBJC_CLASS WKEditorUndoTargetObjC;
 
@@ -45,6 +46,7 @@ class PageClientImpl : public PageClient
     {
 public:
     PageClientImpl(WKContentView *, WKWebView *);
+    PageClientImpl(WKContentView *, WKView *);
     virtual ~PageClientImpl();
     
 private:
@@ -179,6 +181,7 @@ private:
 
     WKContentView *m_contentView;
     WKWebView *m_webView;
+    WKView *m_wkView;
     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
 };
 } // namespace WebKit
index 3cab28a..aa9273e 100644 (file)
@@ -40,6 +40,7 @@
 #import "WKContentViewInteraction.h"
 #import "WKGeolocationProviderIOS.h"
 #import "WKProcessPoolInternal.h"
+#import "WKViewPrivate.h"
 #import "WKWebViewConfigurationInternal.h"
 #import "WKWebViewContentProviderRegistry.h"
 #import "WKWebViewInternal.h"
@@ -110,6 +111,15 @@ namespace WebKit {
 PageClientImpl::PageClientImpl(WKContentView *contentView, WKWebView *webView)
     : m_contentView(contentView)
     , m_webView(webView)
+    , m_wkView(nil)
+    , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
+{
+}
+
+PageClientImpl::PageClientImpl(WKContentView *contentView, WKView *wkView)
+    : m_contentView(contentView)
+    , m_webView(nil)
+    , m_wkView(wkView)
     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
 {
 }
@@ -213,6 +223,7 @@ void PageClientImpl::didRelaunchProcess()
 {
     [m_contentView _didRelaunchProcess];
     [m_webView _didRelaunchProcess];
+    [m_wkView _didRelaunchProcess];
 }
 
 void PageClientImpl::pageClosed()
index b07765d..b06363b 100644 (file)
@@ -31,6 +31,7 @@
 #import <wtf/RetainPtr.h>
 
 @class WKContentView;
+@class WKView;
 @class WKWebView;
 
 namespace WebCore {
@@ -62,6 +63,7 @@ struct WebPageConfiguration;
 @property (nonatomic, readonly) BOOL isBackground;
 
 - (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView;
+- (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration wkView:(WKView *)webView;
 
 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect
     unobscuredRectInScrollViewCoordinates:(CGRect)unobscuredRectInScrollViewCoordinates
index 8136d7b..0ba01e3 100644 (file)
@@ -178,14 +178,9 @@ private:
     RetainPtr<NSUndoManager> _undoManager;
 }
 
-- (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView
+- (instancetype)_commonInitializationWithProcessPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration
 {
-    if (!(self = [super initWithFrame:frame]))
-        return nil;
-
-    InitializeWebKit2();
-
-    _pageClient = std::make_unique<PageClientImpl>(self, webView);
+    ASSERT(_pageClient);
 
     _page = processPool.createWebPage(*_pageClient, WTF::move(webPageConfiguration));
     _page->initializeWebPage();
@@ -193,8 +188,6 @@ private:
     _page->setUseFixedLayout(true);
     _page->setDelegatesScrolling(true);
 
-    _webView = webView;
-    
     _isBackground = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
 
     WebProcessPool::statistics().wkViewCount++;
@@ -226,6 +219,31 @@ private:
     return self;
 }
 
+- (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+
+    InitializeWebKit2();
+
+    _pageClient = std::make_unique<PageClientImpl>(self, webView);
+    _webView = webView;
+
+    return [self _commonInitializationWithProcessPool:processPool configuration:webPageConfiguration];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration wkView:(WKView *)wkView
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+
+    InitializeWebKit2();
+
+    _pageClient = std::make_unique<PageClientImpl>(self, wkView);
+
+    return [self _commonInitializationWithProcessPool:processPool configuration:webPageConfiguration];
+}
+
 - (void)dealloc
 {
     [self cleanupInteraction];