Changeset 247702 in webkit


Ignore:
Timestamp:
Jul 22, 2019 3:14:48 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[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:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247701 r247702  
     12019-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
     4        https://bugs.webkit.org/show_bug.cgi?id=200013
     5        <rdar://problem/52526901>
     6
     7        Reviewed by Simon Fraser.
     8
     9        After <https://trac.webkit.org/r244141>, we no longer attempt to scroll to reveal the text selection in
     10        UIWebView after changing the selection, due to how we use the legacy document view rect in legacy WebKit when
     11        computing the visual viewport. This causes the viewRect in RenderLayer::scrollRectToVisible to be the same size
     12        as the content size, which then causes us to always scroll to the origin when revealing the selection.
     13
     14        To make selection revealing work again in legacy WebKit, conditionally restore the old behavior of using the
     15        unobscured content rect as the view rect, only in the case where scrolling is delegated and the platform widget
     16        is present.
     17
     18        Test: WebKitLegacy.ScrollToRevealSelection
     19
     20        * page/FrameView.cpp:
     21        (WebCore::FrameView::viewRectExpandedByContentInsets const):
     22        (WebCore::FrameView::visualViewportRectExpandedByContentInsets const): Deleted.
     23
     24        Additionally rename visualViewportRectExpandedByContentInsets to viewRectExpandedByContentInsets, to reflect the
     25        fact that this may either be the visual viewport rect or unobscured content rect.
     26
     27        * page/FrameView.h:
     28        * rendering/RenderLayer.cpp:
     29        (WebCore::RenderLayer::scrollRectToVisible):
     30
    1312019-07-22  Brent Fulgham  <bfulgham@apple.com>
    232
  • trunk/Source/WebCore/page/FrameView.cpp

    r247529 r247702  
    19441944}
    19451945
    1946 IntRect FrameView::visualViewportRectExpandedByContentInsets() const
    1947 {
    1948     FloatRect unobscuredContentRect = this->visualViewportRect();
     1946IntRect FrameView::viewRectExpandedByContentInsets() const
     1947{
     1948    FloatRect viewRect;
     1949    if (delegatesScrolling() && platformWidget())
     1950        viewRect = unobscuredContentRect();
     1951    else
     1952        viewRect = visualViewportRect();
     1953
    19491954    if (auto* page = frame().page())
    1950         unobscuredContentRect.expand(page->contentInsets());
    1951     return IntRect(unobscuredContentRect);
     1955        viewRect.expand(page->contentInsets());
     1956
     1957    return IntRect(viewRect);
    19521958}
    19531959
  • trunk/Source/WebCore/page/FrameView.h

    r247667 r247702  
    328328#endif
    329329
    330     IntRect visualViewportRectExpandedByContentInsets() const;
     330    IntRect viewRectExpandedByContentInsets() const;
    331331   
    332332    bool fixedElementsLayoutRelativeToFrame() const;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r247540 r247702  
    26902690            // FIXME: ContentInsets should be taken care of in UI process side. webkit.org/b/199682
    26912691            // To do that, getRectToExpose needs to return the additional scrolling to do beyond content rect.
    2692             LayoutRect viewRect = frameView.visualViewportRectExpandedByContentInsets();
     2692            LayoutRect viewRect = frameView.viewRectExpandedByContentInsets();
    26932693
    26942694            // FIXME: webkit.org/b/199683 FrameView::visibleContentRect is wrong when content insets are present
  • trunk/Tools/ChangeLog

    r247695 r247702  
     12019-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] [WK1] UIWebView always jumps to the top left corner when scrolling to reveal the selection
     4        https://bugs.webkit.org/show_bug.cgi?id=200013
     5        <rdar://problem/52526901>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a new API test to verify that inserting text in UIWebView causes the document to scroll.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollToRevealSelection.mm: Added.
     13        (-[LegacyLoadingDelegate webViewDidFinishLoad:]):
     14        (-[LegacyLoadingDelegate waitForDidFinishLoad]):
     15        * TestWebKitAPI/ios/UIKitSPI.h:
     16
    1172019-07-22  Jer Noble  <jer.noble@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r247695 r247702  
    929929                F42D634422A1729F00D2FB3A /* AutocorrectionTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */; };
    930930                F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
     931                F434CA1A22E65BCA005DDB26 /* ScrollToRevealSelection.mm in Sources */ = {isa = PBXBuildFile; fileRef = F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */; };
    931932                F43E3BBF20DADA1E00A4E7ED /* WKScrollViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */; };
    932933                F43E3BC120DADBC500A4E7ED /* fixed-nav-bar.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */; };
     
    23662367                F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutocorrectionTestsIOS.mm; sourceTree = "<group>"; };
    23672368                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; };
     2369                F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollToRevealSelection.mm; path = ScrollToRevealSelection.mm; sourceTree = "<group>"; };
    23682370                F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKScrollViewTests.mm; sourceTree = "<group>"; };
    23692371                F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "fixed-nav-bar.html"; sourceTree = "<group>"; };
     
    25672569                                BCB9E7C711234E3A00A137E0 /* TestsController.h */,
    25682570                                7C83E0361D0A5F7000FEBCF3 /* Utilities.h */,
     2571                                7CBD5A2222DE42A6004A9E32 /* WTFStringUtilities.cpp */,
    25692572                                44A622C114A0E2B60048515B /* WTFStringUtilities.h */,
    2570                                 7CBD5A2222DE42A6004A9E32 /* WTFStringUtilities.cpp */,
    25712573                        );
    25722574                        name = Source;
     
    39083910                                E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */,
    39093911                                CDC0932A21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm */,
     3912                                F434CA1922E65BCA005DDB26 /* ScrollToRevealSelection.mm */,
    39103913                                0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */,
    39113914                        );
     
    41384141                                7C83DE991D0A590C00FEBCF3 /* AtomString.cpp in Sources */,
    41394142                                1ADAD1501D77A9F600212586 /* BlockPtr.mm in Sources */,
    4140                                 7CBD5A2322DE42A6004A9E32 /* WTFStringUtilities.cpp in Sources */,
    41414143                                7C83DE9C1D0A590C00FEBCF3 /* BloomFilter.cpp in Sources */,
    41424144                                7C83DEA01D0A590C00FEBCF3 /* CheckedArithmeticOperations.cpp in Sources */,
     
    42154217                                57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */,
    42164218                                7C83DF631D0A590C00FEBCF3 /* WTFString.cpp in Sources */,
     4219                                7CBD5A2322DE42A6004A9E32 /* WTFStringUtilities.cpp in Sources */,
    42174220                        );
    42184221                        runOnlyForDeploymentPostprocessing = 0;
     
    42944297                                5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */,
    42954298                                51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */,
    4296                                 7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
    42974299                                5C19A5241FD0F60100EEA323 /* CookiePrivateBrowsing.mm in Sources */,
    42984300                                9B1F6F781F90558400B55744 /* CopyHTML.mm in Sources */,
     
    45544556                                CDC0932B21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm in Sources */,
    45554557                                7CCE7F121A411AE600447C4C /* ScrollPinningBehaviors.cpp in Sources */,
     4558                                F434CA1A22E65BCA005DDB26 /* ScrollToRevealSelection.mm in Sources */,
    45564559                                F4C8797F2059D8D3009CD00B /* ScrollViewInsetTests.mm in Sources */,
    45574560                                0FF1134E22D68679009A81DA /* ScrollViewScrollabilityTests.mm in Sources */,
     
    47134716                                CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
    47144717                                9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
     4718                                7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
    47154719                                9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
    47164720                        );
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r247524 r247702  
    4343#import <UIKit/UIWebFormAccessory.h>
    4444
     45IGNORE_WARNINGS_BEGIN("deprecated-implementations")
     46#import <UIKit/UIWebBrowserView.h>
     47#import <UIKit/UIWebView_Private.h>
     48IGNORE_WARNINGS_END
     49
    4550#if PLATFORM(IOS)
    4651@protocol UIDragSession;
     
    156161@end
    157162
     163IGNORE_WARNINGS_BEGIN("deprecated-implementations")
     164
     165@interface UIWebBrowserView : UIView <UIKeyInput>
     166@end
     167
     168@interface UIWebView (Private)
     169- (UIWebBrowserView *)_browserView;
     170@end
     171
     172IGNORE_WARNINGS_END
     173
    158174#endif
    159175
Note: See TracChangeset for help on using the changeset viewer.