Changeset 216335 in webkit
- Timestamp:
- May 6, 2017, 7:53:51 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r216334 r216335 1 2017-05-06 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Make rotation tests more reliable 4 https://bugs.webkit.org/show_bug.cgi?id=171778 5 6 Reviewed by Tim Horton. 7 8 New baseline. 9 10 * fast/events/ios/rotation/zz-no-rotation-expected.txt: 11 * fast/events/ios/rotation/zz-no-rotation.html: 12 1 13 2017-05-06 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/fast/events/ios/rotation/zz-no-rotation-expected.txt
r216291 r216335 3 3 TEST COMPLETE 4 4 PASS window.innerWidth is 320 5 PASS window.innerHeight is 5 685 PASS window.innerHeight is 548 6 6 This test checks that the view is not left in a rotated state after the previous tests. -
trunk/LayoutTests/fast/events/ios/rotation/zz-no-rotation.html
r216291 r216335 9 9 { 10 10 shouldBe("window.innerWidth", "320"); 11 shouldBe("window.innerHeight", "5 68");11 shouldBe("window.innerHeight", "548"); 12 12 } 13 13 window.addEventListener('load', doTest, false); -
trunk/Source/WebKit2/ChangeLog
r216328 r216335 1 2017-05-06 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Make rotation tests more reliable 4 https://bugs.webkit.org/show_bug.cgi?id=171778 5 6 Reviewed by Tim Horton. 7 8 Switching between "safari-style" rotation and normal rotation left state on the WKWebView 9 that would cause later viewport-sensitive tests to fail. The WKWebView would be left 10 with override layout parameters, and an override orientation, and these caused viewport 11 size to leak into later tests, and WebCore orientation to not get reset correctly. 12 13 Also, WKWebView was unregistering for UIWindowDidRotateNotification notifications when 14 an override orientation was set, and would never re-register, causing lost orientationchanged 15 events. 16 17 Fix by exposing WKWebView SPI to clear the various bits of overide state. Also don't unregister 18 from the UIWindowDidRotateNotification notification; it's already ignored anyway if it fires. 19 20 Also wait for a visible content rect update after resizing the WKWebVeiw between tests, to make sure 21 the WebProcess is caught up before proceeding with the test. 22 23 * UIProcess/API/Cocoa/WKWebView.mm: 24 (-[WKWebView _setInterfaceOrientationOverride:]): 25 (-[WKWebView _clearInterfaceOrientationOverride]): 26 (-[WKWebView _beginAnimatedResizeWithUpdates:]): 27 (-[WKWebView _clearOverrideLayoutParameters]): 28 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 29 1 30 2017-05-06 Konstantin Tokarev <annulen@yandex.ru> 2 31 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r216249 r216335 4563 4563 - (void)_setInterfaceOrientationOverride:(UIInterfaceOrientation)interfaceOrientation 4564 4564 { 4565 if (!_overridesInterfaceOrientation)4566 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIWindowDidRotateNotification object:nil];4567 4568 4565 _overridesInterfaceOrientation = YES; 4569 4566 … … 4581 4578 ASSERT(_overridesInterfaceOrientation); 4582 4579 return _interfaceOrientationOverride; 4580 } 4581 4582 - (void)_clearInterfaceOrientationOverride 4583 { 4584 _overridesInterfaceOrientation = NO; 4585 _interfaceOrientationOverride = UIInterfaceOrientationPortrait; 4583 4586 } 4584 4587 … … 4677 4680 if (_overridesInterfaceOrientation) 4678 4681 _page->setDeviceOrientation(newOrientation); 4682 4679 4683 [self _scheduleVisibleContentRectUpdate]; 4680 4684 return; … … 4916 4920 } 4917 4921 4922 - (void)_clearOverrideLayoutParameters 4923 { 4924 _overridesMinimumLayoutSize = NO; 4925 _minimumLayoutSizeOverride = CGSizeZero; 4926 4927 _overridesMaximumUnobscuredSize = NO; 4928 _maximumUnobscuredSizeOverride = CGSizeZero; 4929 } 4930 4918 4931 - (UIView *)_viewForFindUI 4919 4932 { -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r216197 r216335 191 191 - (void)_overrideLayoutParametersWithMinimumLayoutSize:(CGSize)minimumLayoutSize maximumUnobscuredSizeOverride:(CGSize)maximumUnobscuredSizeOverride WK_API_AVAILABLE(ios(9_0)); 192 192 193 - (void)_clearOverrideLayoutParameters; 194 - (void)_clearInterfaceOrientationOverride; 195 193 196 - (UIView *)_viewForFindUI; 194 197 -
trunk/Tools/ChangeLog
r216326 r216335 1 2017-05-06 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Make rotation tests more reliable 4 https://bugs.webkit.org/show_bug.cgi?id=171778 5 6 Reviewed by Tim Horton. 7 8 Switching between "safari-style" rotation and normal rotation left state on the WKWebView 9 that would cause later viewport-sensitive tests to fail. The WKWebView would be left 10 with override layout parameters, and an override orientation, and these caused viewport 11 size to leak into later tests, and WebCore orientation to not get reset correctly. 12 13 Also, WKWebView was unregistering for UIWindowDidRotateNotification notifications when 14 an override orientation was set, and would never re-register, causing lost orientationchanged 15 events. 16 17 Fix by exposing WKWebView SPI to clear the various bits of overide state. Also don't unregister 18 from the UIWindowDidRotateNotification notification; it's already ignored anyway if it fires. 19 20 Also wait for a visible content rect update after resizing the WKWebVeiw between tests, to make sure 21 the WebProcess is caught up before proceeding with the test. 22 23 * WebKitTestRunner/ios/PlatformWebViewIOS.mm: 24 (-[PlatformWebViewController viewWillTransitionToSize:withTransitionCoordinator:]): 25 * WebKitTestRunner/ios/TestControllerIOS.mm: 26 (WTR::TestController::platformResetStateToConsistentValues): 27 (WTR::TestController::platformConfigureViewForTest): 28 1 29 2017-05-06 Csaba Osztrogonác <ossy@webkit.org> 2 30 -
trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
r216291 r216335 109 109 @end 110 110 111 @interface PlatformWebViewController : UIViewController112 @end113 114 @implementation PlatformWebViewController115 116 - (void)viewWillTransitionToSize:(CGSize)toSize withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator117 {118 [super viewWillTransitionToSize:toSize withTransitionCoordinator:coordinator];119 120 TestRunnerWKWebView *webView = WTR::TestController::singleton().mainWebView()->platformView();121 122 if (webView.usesSafariLikeRotation)123 [webView _setInterfaceOrientationOverride:[[UIApplication sharedApplication] statusBarOrientation]];124 125 [coordinator animateAlongsideTransition: ^(id<UIViewControllerTransitionCoordinatorContext> context) {126 if (webView.usesSafariLikeRotation) {127 [webView _beginAnimatedResizeWithUpdates:^{128 auto size = self.view.bounds.size;129 webView.frame = self.view.bounds;130 [webView _overrideLayoutParametersWithMinimumLayoutSize:size maximumUnobscuredSizeOverride:size];131 [webView _setInterfaceOrientationOverride:[[UIApplication sharedApplication] statusBarOrientation]];132 }];133 } else134 webView.frame = self.view.bounds;135 } completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {136 webView.frame = self.view.bounds;137 if (webView.usesSafariLikeRotation)138 [webView _endAnimatedResize];139 140 [webView _didEndRotation];141 }];142 }143 144 @end145 146 111 namespace WTR { 147 112 … … 150 115 HeightRespectsStatusBar 151 116 }; 117 118 static CGRect viewRectForWindowRect(CGRect, PlatformWebView::WebViewSizingMode); 119 120 } // namespace WTR 121 122 @interface PlatformWebViewController : UIViewController 123 @end 124 125 @implementation PlatformWebViewController 126 127 - (void)viewWillTransitionToSize:(CGSize)toSize withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator 128 { 129 [super viewWillTransitionToSize:toSize withTransitionCoordinator:coordinator]; 130 131 TestRunnerWKWebView *webView = WTR::TestController::singleton().mainWebView()->platformView(); 132 133 if (webView.usesSafariLikeRotation) 134 [webView _setInterfaceOrientationOverride:[[UIApplication sharedApplication] statusBarOrientation]]; 135 136 [coordinator animateAlongsideTransition: ^(id<UIViewControllerTransitionCoordinatorContext> context) { 137 // This code assumes that we should take the status bar into account, which we only do for flexible viewport tests, 138 // but it only makes sense to test rotation with a flexible viewport anyway. 139 if (webView.usesSafariLikeRotation) { 140 [webView _beginAnimatedResizeWithUpdates:^{ 141 webView.frame = viewRectForWindowRect(self.view.bounds, WTR::PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar); 142 [webView _overrideLayoutParametersWithMinimumLayoutSize:webView.frame.size maximumUnobscuredSizeOverride:webView.frame.size]; 143 [webView _setInterfaceOrientationOverride:[[UIApplication sharedApplication] statusBarOrientation]]; 144 }]; 145 } else 146 webView.frame = viewRectForWindowRect(self.view.bounds, WTR::PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar); 147 } completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { 148 webView.frame = viewRectForWindowRect(self.view.bounds, WTR::PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar); 149 if (webView.usesSafariLikeRotation) 150 [webView _endAnimatedResize]; 151 152 [webView _didEndRotation]; 153 }]; 154 } 155 156 @end 157 158 namespace WTR { 152 159 153 160 static CGRect viewRectForWindowRect(CGRect windowRect, PlatformWebView::WebViewSizingMode mode) -
trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm
r216291 r216335 83 83 [[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait animated:NO]; 84 84 85 if (PlatformWebView* webView = mainWebView()) { 86 webView->platformView()._stableStateOverride = nil; 87 webView->platformView().usesSafariLikeRotation = NO; 88 UIScrollView *scrollView = webView->platformView().scrollView; 85 if (PlatformWebView* platformWebView = mainWebView()) { 86 TestRunnerWKWebView *webView = platformWebView->platformView(); 87 webView._stableStateOverride = nil; 88 webView.usesSafariLikeRotation = NO; 89 webView.overrideSafeAreaInsets = UIEdgeInsetsZero; 90 [webView _clearOverrideLayoutParameters]; 91 [webView _clearInterfaceOrientationOverride]; 92 93 UIScrollView *scrollView = webView.scrollView; 89 94 [scrollView _removeAllAnimations:YES]; 90 95 [scrollView setZoomScale:1 animated:NO]; 91 96 [scrollView setContentOffset:CGPointZero]; 92 93 webView->platformView().overrideSafeAreaInsets = UIEdgeInsetsZero;94 97 } 95 98 } … … 97 100 void TestController::platformConfigureViewForTest(const TestInvocation& test) 98 101 { 99 if (test.options().useFlexibleViewport) { 100 CGRect screenBounds = [UIScreen mainScreen].bounds; 101 mainWebView()->resizeTo(screenBounds.size.width, screenBounds.size.height, PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar); 102 // We also pass data to InjectedBundle::beginTesting() to have it call 103 // WKBundlePageSetUseTestingViewportConfiguration(false). 102 if (!test.options().useFlexibleViewport) 103 return; 104 105 TestRunnerWKWebView *webView = mainWebView()->platformView(); 106 CGRect screenBounds = [UIScreen mainScreen].bounds; 107 108 CGSize oldSize = webView.bounds.size; 109 mainWebView()->resizeTo(screenBounds.size.width, screenBounds.size.height, PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar); 110 CGSize newSize = webView.bounds.size; 111 112 if (!CGSizeEqualToSize(oldSize, newSize)) { 113 __block bool doneResizing = false; 114 [webView _doAfterNextVisibleContentRectUpdate: ^{ 115 doneResizing = true; 116 }]; 117 118 platformRunUntil(doneResizing, 10); 119 if (!doneResizing) 120 WTFLogAlways("Timed out waiting for view resize to complete in platformConfigureViewForTest()"); 104 121 } 122 123 // We also pass data to InjectedBundle::beginTesting() to have it call 124 // WKBundlePageSetUseTestingViewportConfiguration(false). 105 125 } 106 126
Note:
See TracChangeset
for help on using the changeset viewer.