Diff
Modified: branches/safari-608.1-branch/Source/WebCore/ChangeLog (247856 => 247857)
--- branches/safari-608.1-branch/Source/WebCore/ChangeLog 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Source/WebCore/ChangeLog 2019-07-26 07:24:32 UTC (rev 247857)
@@ -1,3 +1,79 @@
+2019-07-26 Babak Shafiei <bshaf...@apple.com>
+
+ Cherry-pick r247702. rdar://problem/53575418
+
+ [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
+ https://bugs.webkit.org/show_bug.cgi?id=200013
+ <rdar://problem/52526901>
+
+ Reviewed by Simon Fraser.
+
+ Source/WebCore:
+
+ After <https://trac.webkit.org/r244141>, we no longer attempt to scroll to reveal the text selection in
+ UIWebView after changing the selection, due to how we use the legacy document view rect in legacy WebKit when
+ computing the visual viewport. This causes the viewRect in RenderLayer::scrollRectToVisible to be the same size
+ as the content size, which then causes us to always scroll to the origin when revealing the selection.
+
+ To make selection revealing work again in legacy WebKit, conditionally restore the old behavior of using the
+ unobscured content rect as the view rect, only in the case where scrolling is delegated and the platform widget
+ is present.
+
+ Test: WebKitLegacy.ScrollToRevealSelection
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::viewRectExpandedByContentInsets const):
+ (WebCore::FrameView::visualViewportRectExpandedByContentInsets const): Deleted.
+
+ Additionally rename visualViewportRectExpandedByContentInsets to viewRectExpandedByContentInsets, to reflect the
+ fact that this may either be the visual viewport rect or unobscured content rect.
+
+ * page/FrameView.h:
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::scrollRectToVisible):
+
+ Tools:
+
+ Add a new API test to verify that inserting text in UIWebView causes the document to scroll.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm: Added.
+ (-[LegacyLoadingDelegate webViewDidFinishLoad:]):
+ (-[LegacyLoadingDelegate waitForDidFinishLoad]):
+ * TestWebKitAPI/ios/UIKitSPI.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-22 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
+ https://bugs.webkit.org/show_bug.cgi?id=200013
+ <rdar://problem/52526901>
+
+ Reviewed by Simon Fraser.
+
+ After <https://trac.webkit.org/r244141>, we no longer attempt to scroll to reveal the text selection in
+ UIWebView after changing the selection, due to how we use the legacy document view rect in legacy WebKit when
+ computing the visual viewport. This causes the viewRect in RenderLayer::scrollRectToVisible to be the same size
+ as the content size, which then causes us to always scroll to the origin when revealing the selection.
+
+ To make selection revealing work again in legacy WebKit, conditionally restore the old behavior of using the
+ unobscured content rect as the view rect, only in the case where scrolling is delegated and the platform widget
+ is present.
+
+ Test: WebKitLegacy.ScrollToRevealSelection
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::viewRectExpandedByContentInsets const):
+ (WebCore::FrameView::visualViewportRectExpandedByContentInsets const): Deleted.
+
+ Additionally rename visualViewportRectExpandedByContentInsets to viewRectExpandedByContentInsets, to reflect the
+ fact that this may either be the visual viewport rect or unobscured content rect.
+
+ * page/FrameView.h:
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::scrollRectToVisible):
+
2019-07-25 Alan Coon <alanc...@apple.com>
Cherry-pick r247620. rdar://problem/53519933
Modified: branches/safari-608.1-branch/Source/WebCore/page/FrameView.cpp (247856 => 247857)
--- branches/safari-608.1-branch/Source/WebCore/page/FrameView.cpp 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Source/WebCore/page/FrameView.cpp 2019-07-26 07:24:32 UTC (rev 247857)
@@ -1965,12 +1965,18 @@
});
}
-IntRect FrameView::visualViewportRectExpandedByContentInsets() const
+IntRect FrameView::viewRectExpandedByContentInsets() const
{
- FloatRect unobscuredContentRect = this->visualViewportRect();
+ FloatRect viewRect;
+ if (delegatesScrolling() && platformWidget())
+ viewRect = unobscuredContentRect();
+ else
+ viewRect = visualViewportRect();
+
if (auto* page = frame().page())
- unobscuredContentRect.expand(page->contentInsets());
- return IntRect(unobscuredContentRect);
+ viewRect.expand(page->contentInsets());
+
+ return IntRect(viewRect);
}
bool FrameView::fixedElementsLayoutRelativeToFrame() const
Modified: branches/safari-608.1-branch/Source/WebCore/page/FrameView.h (247856 => 247857)
--- branches/safari-608.1-branch/Source/WebCore/page/FrameView.h 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Source/WebCore/page/FrameView.h 2019-07-26 07:24:32 UTC (rev 247857)
@@ -332,7 +332,7 @@
WEBCORE_EXPORT static LayoutRect rectForViewportConstrainedObjects(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, ScrollBehaviorForFixedElements);
#endif
- IntRect visualViewportRectExpandedByContentInsets() const;
+ IntRect viewRectExpandedByContentInsets() const;
bool fixedElementsLayoutRelativeToFrame() const;
Modified: branches/safari-608.1-branch/Source/WebCore/rendering/RenderLayer.cpp (247856 => 247857)
--- branches/safari-608.1-branch/Source/WebCore/rendering/RenderLayer.cpp 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Source/WebCore/rendering/RenderLayer.cpp 2019-07-26 07:24:32 UTC (rev 247857)
@@ -2689,7 +2689,7 @@
#else
// FIXME: ContentInsets should be taken care of in UI process side. webkit.org/b/199682
// To do that, getRectToExpose needs to return the additional scrolling to do beyond content rect.
- LayoutRect viewRect = frameView.visualViewportRectExpandedByContentInsets();
+ LayoutRect viewRect = frameView.viewRectExpandedByContentInsets();
// FIXME: webkit.org/b/199683 FrameView::visibleContentRect is wrong when content insets are present
maxScrollPosition = frameView.scrollPositionFromOffset(ScrollPosition(frameView.totalContentsSize() - flooredIntSize(viewRect.size())));
Modified: branches/safari-608.1-branch/Tools/ChangeLog (247856 => 247857)
--- branches/safari-608.1-branch/Tools/ChangeLog 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Tools/ChangeLog 2019-07-26 07:24:32 UTC (rev 247857)
@@ -1,3 +1,65 @@
+2019-07-26 Babak Shafiei <bshaf...@apple.com>
+
+ Cherry-pick r247702. rdar://problem/53575418
+
+ [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
+ https://bugs.webkit.org/show_bug.cgi?id=200013
+ <rdar://problem/52526901>
+
+ Reviewed by Simon Fraser.
+
+ Source/WebCore:
+
+ After <https://trac.webkit.org/r244141>, we no longer attempt to scroll to reveal the text selection in
+ UIWebView after changing the selection, due to how we use the legacy document view rect in legacy WebKit when
+ computing the visual viewport. This causes the viewRect in RenderLayer::scrollRectToVisible to be the same size
+ as the content size, which then causes us to always scroll to the origin when revealing the selection.
+
+ To make selection revealing work again in legacy WebKit, conditionally restore the old behavior of using the
+ unobscured content rect as the view rect, only in the case where scrolling is delegated and the platform widget
+ is present.
+
+ Test: WebKitLegacy.ScrollToRevealSelection
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::viewRectExpandedByContentInsets const):
+ (WebCore::FrameView::visualViewportRectExpandedByContentInsets const): Deleted.
+
+ Additionally rename visualViewportRectExpandedByContentInsets to viewRectExpandedByContentInsets, to reflect the
+ fact that this may either be the visual viewport rect or unobscured content rect.
+
+ * page/FrameView.h:
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::scrollRectToVisible):
+
+ Tools:
+
+ Add a new API test to verify that inserting text in UIWebView causes the document to scroll.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm: Added.
+ (-[LegacyLoadingDelegate webViewDidFinishLoad:]):
+ (-[LegacyLoadingDelegate waitForDidFinishLoad]):
+ * TestWebKitAPI/ios/UIKitSPI.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-22 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
+ https://bugs.webkit.org/show_bug.cgi?id=200013
+ <rdar://problem/52526901>
+
+ Reviewed by Simon Fraser.
+
+ Add a new API test to verify that inserting text in UIWebView causes the document to scroll.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm: Added.
+ (-[LegacyLoadingDelegate webViewDidFinishLoad:]):
+ (-[LegacyLoadingDelegate waitForDidFinishLoad]):
+ * TestWebKitAPI/ios/UIKitSPI.h:
+
2019-07-25 Alan Coon <alanc...@apple.com>
Cherry-pick r247692. rdar://problem/53519923
Modified: branches/safari-608.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (247856 => 247857)
--- branches/safari-608.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-07-26 07:24:32 UTC (rev 247857)
@@ -925,6 +925,7 @@
F41AB9AA1EF4696B0083FA08 /* textarea-to-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F41AB9951EF4692C0083FA08 /* textarea-to-input.html */; };
F42D634422A1729F00D2FB3A /* AutocorrectionTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */; };
F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
+ F434CA1A22E65BCA005DDB26 /* ScrollToRevealSelection.mm in Sources */ = {isa = PBXBuildFile; fileRef = F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */; };
F43E3BBF20DADA1E00A4E7ED /* WKScrollViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */; };
F43E3BC120DADBC500A4E7ED /* fixed-nav-bar.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */; };
F442851D2140DF2900CCDA22 /* NSFontPanelTesting.mm in Sources */ = {isa = PBXBuildFile; fileRef = F442851C2140DF2900CCDA22 /* NSFontPanelTesting.mm */; };
@@ -2360,6 +2361,7 @@
F41AB99E1EF4692C0083FA08 /* div-and-large-image.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "div-and-large-image.html"; sourceTree = "<group>"; };
F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutocorrectionTestsIOS.mm; sourceTree = "<group>"; };
F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKitCocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; };
+ F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollToRevealSelection.mm; path = ScrollToRevealSelection.mm; sourceTree = "<group>"; };
F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKScrollViewTests.mm; sourceTree = "<group>"; };
F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "fixed-nav-bar.html"; sourceTree = "<group>"; };
F442851B2140DF2900CCDA22 /* NSFontPanelTesting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontPanelTesting.h; sourceTree = "<group>"; };
@@ -2561,6 +2563,7 @@
BC131AA8117131FC00B69727 /* TestsController.cpp */,
BCB9E7C711234E3A00A137E0 /* TestsController.h */,
7C83E0361D0A5F7000FEBCF3 /* Utilities.h */,
+ 7CBD5A2222DE42A6004A9E32 /* WTFStringUtilities.cpp */,
44A622C114A0E2B60048515B /* WTFStringUtilities.h */,
);
name = Source;
@@ -3900,6 +3903,7 @@
CDC8E4851BC5B19400594FEC /* AudioSessionCategoryIOS.mm */,
E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */,
CDC0932A21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm */,
+ F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */,
0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */,
);
path = ios;
@@ -4206,6 +4210,7 @@
37C7CC2D1EA4146B007BD956 /* WeakLinking.cpp in Sources */,
57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */,
7C83DF631D0A590C00FEBCF3 /* WTFString.cpp in Sources */,
+ 7CBD5A2322DE42A6004A9E32 /* WTFStringUtilities.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4544,6 +4549,7 @@
CE0947372063223B003C9BA0 /* SchemeRegistry.mm in Sources */,
CDC0932B21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm in Sources */,
7CCE7F121A411AE600447C4C /* ScrollPinningBehaviors.cpp in Sources */,
+ F434CA1A22E65BCA005DDB26 /* ScrollToRevealSelection.mm in Sources */,
F4C8797F2059D8D3009CD00B /* ScrollViewInsetTests.mm in Sources */,
0FF1134E22D68679009A81DA /* ScrollViewScrollabilityTests.mm in Sources */,
CE06DF9B1E1851F200E570C9 /* SecurityOrigin.cpp in Sources */,
@@ -4703,6 +4709,7 @@
93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
+ 7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Added: branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm (0 => 247857)
--- branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm (rev 0)
+++ branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm 2019-07-26 07:24:32 UTC (rev 247857)
@@ -0,0 +1,76 @@
+/*
+ * 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"
+
+#if PLATFORM(IOS_FAMILY)
+
+IGNORE_WARNINGS_BEGIN("deprecated-implementations")
+
+#import "PlatformUtilities.h"
+#import "UIKitSPI.h"
+#import <wtf/RetainPtr.h>
+
+@interface LegacyLoadingDelegate : NSObject <UIWebViewDelegate>
+- (void)waitForDidFinishLoad;
+@end
+
+@implementation LegacyLoadingDelegate {
+ BOOL _loadComplete;
+}
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView
+{
+ _loadComplete = YES;
+}
+
+- (void)waitForDidFinishLoad
+{
+ EXPECT_FALSE(_loadComplete);
+ TestWebKitAPI::Util::run(&_loadComplete);
+}
+
+@end
+
+TEST(WebKitLegacy, ScrollToRevealSelection)
+{
+ auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ [window setHidden:NO];
+ auto webView = adoptNS([[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ [window addSubview:webView.get()];
+ auto delegate = adoptNS([[LegacyLoadingDelegate alloc] init]);
+ [webView setDelegate:delegate.get()];
+ [webView loadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><body style='font-size: 100px;' contenteditable>" baseURL:nil];
+ [delegate waitForDidFinishLoad];
+ [webView stringByEvaluatingJavaScriptFromString:@"document.body.focus()"];
+ for (int i = 0; i < 10; ++i)
+ [[webView _browserView] insertText:@"\n"];
+
+ EXPECT_GT([[webView scrollView] contentOffset].y, 0);
+}
+
+IGNORE_WARNINGS_END
+
+#endif // PLATFORM(IOS_FAMILY)
Modified: branches/safari-608.1-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h (247856 => 247857)
--- branches/safari-608.1-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h 2019-07-26 06:53:38 UTC (rev 247856)
+++ branches/safari-608.1-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h 2019-07-26 07:24:32 UTC (rev 247857)
@@ -42,6 +42,11 @@
#import <UIKit/UIWKTextInteractionAssistant.h>
#import <UIKit/UIWebFormAccessory.h>
+IGNORE_WARNINGS_BEGIN("deprecated-implementations")
+#import <UIKit/UIWebBrowserView.h>
+#import <UIKit/UIWebView_Private.h>
+IGNORE_WARNINGS_END
+
#if PLATFORM(IOS)
@protocol UIDragSession;
@class UIDragInteraction;
@@ -155,6 +160,17 @@
- (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler;
@end
+IGNORE_WARNINGS_BEGIN("deprecated-implementations")
+
+@interface UIWebBrowserView : UIView <UIKeyInput>
+@end
+
+@interface UIWebView (Private)
+- (UIWebBrowserView *)_browserView;
+@end
+
+IGNORE_WARNINGS_END
+
#endif
#if __has_include(<UIKit/UITextAutofillSuggestion.h>)