Title: [221906] trunk
Revision
221906
Author
[email protected]
Date
2017-09-11 23:51:50 -0700 (Mon, 11 Sep 2017)

Log Message

REGRESSION (r221272): WKWebView gets stuck zoomed in if the web process crashes
https://bugs.webkit.org/show_bug.cgi?id=176767
<rdar://problem/34196874>

Reviewed by Dan Bernstein.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
Reset the "last sent" layout parameters when the Web Content process exits.
They're no longer "last sent", and if we short-circuit from sending them
again (from under _didRelaunchProcess), we will never send the correct
layout width (until it changes).

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
(TEST):
Add a test ensuring that override layout size persists through Web
Content process crash.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (221905 => 221906)


--- trunk/Source/WebKit/ChangeLog	2017-09-12 05:50:47 UTC (rev 221905)
+++ trunk/Source/WebKit/ChangeLog	2017-09-12 06:51:50 UTC (rev 221906)
@@ -1,3 +1,18 @@
+2017-09-11  Tim Horton  <[email protected]>
+
+        REGRESSION (r221272): WKWebView gets stuck zoomed in if the web process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=176767
+        <rdar://problem/34196874>
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _processDidExit]):
+        Reset the "last sent" layout parameters when the Web Content process exits.
+        They're no longer "last sent", and if we short-circuit from sending them
+        again (from under _didRelaunchProcess), we will never send the correct
+        layout width (until it changes).
+
 2017-09-11  Wenson Hsieh  <[email protected]>
 
         [iOS WK2] Support tapping to add items to the current drag session in web content

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (221905 => 221906)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-09-12 05:50:47 UTC (rev 221905)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-09-12 06:51:50 UTC (rev 221906)
@@ -1511,6 +1511,9 @@
     _scrollViewBackgroundColor = WebCore::Color();
     _delayUpdateVisibleContentRects = NO;
     _hadDelayedUpdateVisibleContentRects = NO;
+    _lastSentMinimumLayoutSize = std::nullopt;
+    _lastSentMaximumUnobscuredSize = std::nullopt;
+    _lastSentDeviceOrientation = std::nullopt;
 
     _frozenVisibleContentRect = std::nullopt;
     _frozenUnobscuredContentRect = std::nullopt;

Modified: trunk/Tools/ChangeLog (221905 => 221906)


--- trunk/Tools/ChangeLog	2017-09-12 05:50:47 UTC (rev 221905)
+++ trunk/Tools/ChangeLog	2017-09-12 06:51:50 UTC (rev 221906)
@@ -1,3 +1,16 @@
+2017-09-11  Tim Horton  <[email protected]>
+
+        REGRESSION (r221272): WKWebView gets stuck zoomed in if the web process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=176767
+        <rdar://problem/34196874>
+
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
+        (TEST):
+        Add a test ensuring that override layout size persists through Web
+        Content process crash.
+
 2017-09-11  Wenson Hsieh  <[email protected]>
 
         [iOS WK2] Support tapping to add items to the current drag session in web content

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm (221905 => 221906)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2017-09-12 05:50:47 UTC (rev 221905)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2017-09-12 06:51:50 UTC (rev 221906)
@@ -63,14 +63,14 @@
 
 static RetainPtr<AnimatedResizeWebView> createAnimatedResizeWebView()
 {
-    RetainPtr<_WKProcessPoolConfiguration> processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     [processPoolConfiguration setIgnoreSynchronousMessagingTimeoutsForTesting:YES];
-    RetainPtr<WKProcessPool> processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
 
-    RetainPtr<WKWebViewConfiguration> webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [webViewConfiguration setProcessPool:processPool.get()];
 
-    RetainPtr<AnimatedResizeWebView> webView = adoptNS([[AnimatedResizeWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto webView = adoptNS([[AnimatedResizeWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
 
     return webView;
 }
@@ -92,7 +92,7 @@
 
     auto navigationDelegate = createFirstVisuallyNonEmptyWatchingNavigationDelegate();
     [webView setNavigationDelegate:navigationDelegate.get()];
-    RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     [window addSubview:webView.get()];
     [window setHidden:NO];
 
@@ -116,7 +116,7 @@
 
     auto navigationDelegate = createFirstVisuallyNonEmptyWatchingNavigationDelegate();
     [webView setNavigationDelegate:navigationDelegate.get()];
-    RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     [window addSubview:webView.get()];
     [window setHidden:NO];
 
@@ -147,7 +147,7 @@
     [webView loadHTMLString:@"<head></head>" baseURL:nil];
     [webView _test_waitForDidFinishNavigation];
 
-    RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     [window addSubview:webView.get()];
     [window setHidden:NO];
 
@@ -157,7 +157,7 @@
 
     // Load a page that will change the state of viewport-fit,
     // in the middle of the resize.
-    [webView loadHTMLString:@"<head><meta name='viewport' content='viewport-fit=cover' /></head>" baseURL:nil];
+    [webView loadHTMLString:@"<head><meta name='viewport' content='viewport-fit=cover'></head>" baseURL:nil];
     [webView _test_waitForDidFinishNavigation];
 
     didChangeSafeAreaShouldAffectObscuredInsets = false;
@@ -191,10 +191,10 @@
 
     [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(200, 50) maximumUnobscuredSizeOverride:CGSizeMake(200, 50)];
 
-    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1' /></head>" baseURL:nil];
+    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
     [webView _test_waitForDidFinishNavigation];
 
-    RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     [window addSubview:webView.get()];
     [window setHidden:NO];
 
@@ -218,4 +218,35 @@
     TestWebKitAPI::Util::run(&didReadLayoutSize);
 }
 
+TEST(WebKit, OverrideLayoutSizeIsRestoredAfterProcessRelaunch)
+{
+    auto webView = createAnimatedResizeWebView();
+    [webView setUIDelegate:webView.get()];
+
+    [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(200, 50) maximumUnobscuredSizeOverride:CGSizeMake(200, 50)];
+
+    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
+    [webView _test_waitForDidFinishNavigation];
+
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    [window addSubview:webView.get()];
+    [window setHidden:NO];
+
+    [webView _killWebContentProcessAndResetState];
+    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
+    [webView _test_waitForDidFinishNavigation];
+
+    __block bool didReadLayoutSize = false;
+    [webView evaluateJavaScript:@"[window.innerWidth, window.innerHeight]" completionHandler:^(id value, NSError *error) {
+        CGFloat innerWidth = [[value objectAtIndex:0] floatValue];
+        CGFloat innerHeight = [[value objectAtIndex:1] floatValue];
+
+        EXPECT_EQ(innerWidth, 200);
+        EXPECT_EQ(innerHeight, 50);
+
+        didReadLayoutSize = true;
+    }];
+    TestWebKitAPI::Util::run(&didReadLayoutSize);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to