- Revision
- 252125
- Author
- cdu...@apple.com
- Date
- 2019-11-05 22:41:51 -0800 (Tue, 05 Nov 2019)
Log Message
[iOS] Scroll position does not get restored when doing a history navigation while the reader view is shown
https://bugs.webkit.org/show_bug.cgi?id=203871
<rdar://problem/56564603>
Reviewed by Tim Horton.
Source/WebKit:
Previously, attempts to restore the scroll position on the web view while it is being dynamically resized
would get ignored. Instead, we now delay restoring the scroll position until after the view is resized.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _restorePageScrollPosition:scrollOrigin:previousObscuredInset:scale:]):
(-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
Tools:
Add API test coverage.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/simple-tall.html:
* TestWebKitAPI/Tests/WebKitCocoa/RestoreScrollPosition.mm: Added.
(TestWebKitAPI::TEST):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (252124 => 252125)
--- trunk/Source/WebKit/ChangeLog 2019-11-06 06:36:28 UTC (rev 252124)
+++ trunk/Source/WebKit/ChangeLog 2019-11-06 06:41:51 UTC (rev 252125)
@@ -1,3 +1,18 @@
+2019-11-05 Chris Dumez <cdu...@apple.com>
+
+ [iOS] Scroll position does not get restored when doing a history navigation while the reader view is shown
+ https://bugs.webkit.org/show_bug.cgi?id=203871
+ <rdar://problem/56564603>
+
+ Reviewed by Tim Horton.
+
+ Previously, attempts to restore the scroll position on the web view while it is being dynamically resized
+ would get ignored. Instead, we now delay restoring the scroll position until after the view is resized.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _restorePageScrollPosition:scrollOrigin:previousObscuredInset:scale:]):
+ (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
+
2019-11-05 Kate Cheney <katherine_che...@apple.com>
Layout test website-data-removal-for-site-navigated-to-with-link-decoration.html is a flaky failure
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (252124 => 252125)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-06 06:36:28 UTC (rev 252124)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-06 06:41:51 UTC (rev 252125)
@@ -2189,8 +2189,14 @@
- (void)_restorePageScrollPosition:(Optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)obscuredInsets scale:(double)scale
{
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
+ // Defer scroll position restoration until after the current resize completes.
+ RetainPtr<WKWebView> retainedSelf = self;
+ _callbacksDeferredDuringResize.append([retainedSelf, scrollPosition, scrollOrigin, obscuredInsets, scale] {
+ [retainedSelf _restorePageScrollPosition:scrollPosition scrollOrigin:scrollOrigin previousObscuredInset:obscuredInsets scale:scale];
+ });
return;
+ }
if (![self usesStandardContentView])
return;
@@ -2207,8 +2213,14 @@
- (void)_restorePageStateToUnobscuredCenter:(Optional<WebCore::FloatPoint>)center scale:(double)scale
{
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
+ // Defer scroll position restoration until after the current resize completes.
+ RetainPtr<WKWebView> retainedSelf = self;
+ _callbacksDeferredDuringResize.append([retainedSelf, center, scale] {
+ [retainedSelf _restorePageStateToUnobscuredCenter:center scale:scale];
+ });
return;
+ }
if (![self usesStandardContentView])
return;
Modified: trunk/Tools/ChangeLog (252124 => 252125)
--- trunk/Tools/ChangeLog 2019-11-06 06:36:28 UTC (rev 252124)
+++ trunk/Tools/ChangeLog 2019-11-06 06:41:51 UTC (rev 252125)
@@ -1,3 +1,18 @@
+2019-11-05 Chris Dumez <cdu...@apple.com>
+
+ [iOS] Scroll position does not get restored when doing a history navigation while the reader view is shown
+ https://bugs.webkit.org/show_bug.cgi?id=203871
+ <rdar://problem/56564603>
+
+ Reviewed by Tim Horton.
+
+ Add API test coverage.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/simple-tall.html:
+ * TestWebKitAPI/Tests/WebKitCocoa/RestoreScrollPosition.mm: Added.
+ (TestWebKitAPI::TEST):
+
2019-11-05 Jonathan Bedard <jbed...@apple.com>
REGRESSION(r252031): layout tests fail to run in non apple ports after r252031 (Follow-up fix)
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (252124 => 252125)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-06 06:36:28 UTC (rev 252124)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-06 06:41:51 UTC (rev 252125)
@@ -243,6 +243,7 @@
46C519E81D3563FD00DAA51A /* LocalStorageNullEntries.localstorage-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46C519E41D35629600DAA51A /* LocalStorageNullEntries.localstorage-shm */; };
46E66A901F0D75590026D83C /* WKWebViewDiagnosticLogging.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46E66A8F1F0D75590026D83C /* WKWebViewDiagnosticLogging.mm */; };
46E816F81E79E29C00375ADC /* RestoreStateAfterTermination.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46E816F71E79E29100375ADC /* RestoreStateAfterTermination.mm */; };
+ 46EBD8472372320F00223A6E /* RestoreScrollPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46EBD846237231E600223A6E /* RestoreScrollPosition.mm */; };
4909EE3A2D09480C88982D56 /* Markable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EC79F168BE454E579E417B05 /* Markable.cpp */; };
4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
510477721D298DDD009747EB /* IDBDeleteRecovery.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */; };
@@ -1765,6 +1766,7 @@
46C519E41D35629600DAA51A /* LocalStorageNullEntries.localstorage-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "LocalStorageNullEntries.localstorage-shm"; sourceTree = "<group>"; };
46E66A8F1F0D75590026D83C /* WKWebViewDiagnosticLogging.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewDiagnosticLogging.mm; sourceTree = "<group>"; };
46E816F71E79E29100375ADC /* RestoreStateAfterTermination.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreStateAfterTermination.mm; sourceTree = "<group>"; };
+ 46EBD846237231E600223A6E /* RestoreScrollPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreScrollPosition.mm; sourceTree = "<group>"; };
4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = getUserMedia.html; sourceTree = "<group>"; };
4A410F4D19AF7BEF002EBAB6 /* ondevicechange.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ondevicechange.html; sourceTree = "<group>"; };
@@ -2945,6 +2947,7 @@
51C8E1A41F26AC5400BF731B /* ResourceLoadStatistics.mm */,
5CCB10E02134579D00AC5AF0 /* ResponsivenessTimer.mm */,
5CCB10DD2134579C00AC5AF0 /* ResponsivenessTimerDoesntFireEarly.mm */,
+ 46EBD846237231E600223A6E /* RestoreScrollPosition.mm */,
5CCB10DE2134579D00AC5AF0 /* RestoreSessionStateWithoutNavigation.mm */,
A180C0F91EE67DF000468F47 /* RunOpenPanel.mm */,
F4D2986D20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm */,
@@ -4789,6 +4792,7 @@
5CCB10E1213457D300AC5AF0 /* ResponsivenessTimer.mm in Sources */,
512C4C9E20EAA40D004945EA /* ResponsivenessTimerCrash.mm in Sources */,
5CCB10E2213457D500AC5AF0 /* ResponsivenessTimerDoesntFireEarly.mm in Sources */,
+ 46EBD8472372320F00223A6E /* RestoreScrollPosition.mm in Sources */,
83B6DE6F1EE75221001E792F /* RestoreSessionState.cpp in Sources */,
7CCE7F111A411AE600447C4C /* RestoreSessionStateContainingFormData.cpp in Sources */,
5CCB10E3213457D800AC5AF0 /* RestoreSessionStateWithoutNavigation.mm in Sources */,
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/simple-tall.html (252124 => 252125)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/simple-tall.html 2019-11-06 06:36:28 UTC (rev 252124)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/simple-tall.html 2019-11-06 06:41:51 UTC (rev 252125)
@@ -1,3 +1,4 @@
+<meta name='viewport' content='width=device-width, initial-scale=1'>
<!DOCTYPE html>
<html>
<body>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreScrollPosition.mm (0 => 252125)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreScrollPosition.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreScrollPosition.mm 2019-11-06 06:41:51 UTC (rev 252125)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+
+namespace TestWebKitAPI {
+
+#if PLATFORM(IOS_FAMILY)
+
+TEST(WebKit, RestoreScrollPositionDuringResize)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ processPoolConfiguration.get().pageCacheEnabled = NO;
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:webViewConfiguration.get()]);
+ [webView synchronouslyLoadTestPageNamed:@"simple-tall"];
+ [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+ [webView waitForNextPresentationUpdate];
+
+ CGPoint contentOffsetAfterScrolling = [webView scrollView].contentOffset;
+ EXPECT_EQ(0, contentOffsetAfterScrolling.x);
+ EXPECT_EQ(1000, contentOffsetAfterScrolling.y);
+
+ [webView synchronouslyLoadTestPageNamed:@"simple"];
+ [webView waitForNextPresentationUpdate];
+
+ contentOffsetAfterScrolling = [webView scrollView].contentOffset;
+ EXPECT_EQ(0, contentOffsetAfterScrolling.x);
+ EXPECT_EQ(0, contentOffsetAfterScrolling.y);
+
+ [webView _beginAnimatedResizeWithUpdates:^{
+ [webView setFrame:CGRectMake(0, 0, [webView frame].size.width + 100, 500)];
+ }];
+ [webView synchronouslyGoBack];
+
+ TestWebKitAPI::Util::sleep(0.5);
+ [webView _endAnimatedResize];
+
+ // Should restore the scroll position.
+ int timeout = 0;
+ do {
+ if (timeout)
+ TestWebKitAPI::Util::sleep(0.1);
+ } while ([webView scrollView].contentOffset.y != 1000 && ++timeout <= 30);
+
+ contentOffsetAfterScrolling = [webView scrollView].contentOffset;
+ EXPECT_EQ(0, contentOffsetAfterScrolling.x);
+ EXPECT_EQ(1000, contentOffsetAfterScrolling.y);
+}
+
+#endif
+
+}