Changeset 244141 in webkit


Ignore:
Timestamp:
Apr 10, 2019 11:47:25 AM (5 years ago)
Author:
Megan Gardner
Message:

Fix text autoscrolling when typing in modern webkit
https://bugs.webkit.org/show_bug.cgi?id=196718
Source/WebCore:

<rdar://problem/49225507>

Reviewed by Tim Horton.

Tests: fast/events/autoscroll-when-input-is-offscreen.html

fast/events/autoscroll-with-software-keyboard.html

We have been relying on UIKit to scroll editable text, but
since we cannot give them enough information for them to always
do the right thing, we should just do all the work in WebKit.
This has the added benifit of fixing some tricky autoscrolling
bugs that have cropped up recently.

  • editing/Editor.cpp:

(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::revealSelectionAfterEditingOperation):
We should be scrolling the main frame in WebKit. We have been relying on UIKit,
but we cannot give them enough information to guarantee a correct scroll, so just
do all the work in WebKit.

  • page/FrameView.cpp:

(WebCore::FrameView::unobscuredContentRectExpandedByContentInsets const):
Update to use the rect that is actually visible, accounting for the software keyboard.

Source/WebKit:

<rdar://problem/49225507>

Reviewed by Tim Horton.

For staging only. We need to turn off UIKit's scrolling behavior to land
the changes we are making. To keep from the build ever breaking,
I am temporarily circumventing the changes in UIKit. This will be removed
once the next UIKit submission happens.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKUIWKTextInteractionAssistant scrollSelectionToVisible]):
(-[WKContentView setUpTextSelectionAssistant]):

LayoutTests:

Reviewed by Tim Horton.

  • fast/events/autoscroll-when-input-is-offscreen-expected.txt: Added.
  • fast/events/autoscroll-when-input-is-offscreen.html: Added.
  • fast/events/autoscroll-with-software-keyboard-expected.txt: Added.
  • fast/events/autoscroll-with-software-keyboard.html: Added.
Location:
trunk
Files:
8 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244112 r244141  
     12019-04-10  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Fix text autoscrolling when typing in modern webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=196718
     5
     6        Reviewed by Tim Horton.
     7
     8        * fast/events/autoscroll-when-input-is-offscreen-expected.txt: Added.
     9        * fast/events/autoscroll-when-input-is-offscreen.html: Added.
     10        * fast/events/autoscroll-with-software-keyboard-expected.txt: Added.
     11        * fast/events/autoscroll-with-software-keyboard.html: Added.
     12
    1132019-04-10  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r244115 r244141  
     12019-04-10  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Fix text autoscrolling when typing in modern webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=196718
     5        <rdar://problem/49225507>
     6
     7        Reviewed by Tim Horton.
     8
     9        Tests: fast/events/autoscroll-when-input-is-offscreen.html
     10               fast/events/autoscroll-with-software-keyboard.html
     11
     12        We have been relying on UIKit to scroll editable text, but
     13        since we cannot give them enough information for them to always
     14        do the right thing, we should just do all the work in WebKit.
     15        This has the added benifit of fixing some tricky autoscrolling
     16        bugs that have cropped up recently.
     17
     18        * editing/Editor.cpp:
     19        (WebCore::Editor::insertTextWithoutSendingTextEvent):
     20        (WebCore::Editor::revealSelectionAfterEditingOperation):
     21        We should be scrolling the main frame in WebKit. We have been relying on UIKit,
     22        but we cannot give them enough information to guarantee a correct scroll, so just
     23        do all the work in WebKit.
     24        * page/FrameView.cpp:
     25        (WebCore::FrameView::unobscuredContentRectExpandedByContentInsets const):
     26        Update to use the rect that is actually visible, accounting for the software keyboard.
     27
    1282019-04-10  Ross Kirsling  <ross.kirsling@sony.com>
    229
  • trunk/Source/WebCore/editing/Editor.cpp

    r243195 r244141  
    12811281            if (Frame* editedFrame = document->frame())
    12821282                if (Page* page = editedFrame->page()) {
    1283 #if PLATFORM(IOS_FAMILY)
    1284                     SelectionRevealMode revealMode = SelectionRevealMode::RevealUpToMainFrame;
    1285 #else
    12861283                    SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
    1287 #endif
    12881284                    page->focusController().focusedOrMainFrame().selection().revealSelection(revealMode, ScrollAlignment::alignCenterIfNeeded);
    12891285                }
     
    30563052        return;
    30573053
    3058 #if PLATFORM(IOS_FAMILY)
    3059     SelectionRevealMode revealMode = SelectionRevealMode::RevealUpToMainFrame;
    3060 #else
    30613054    SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
    3062 #endif
    3063 
    30643055    m_frame.selection().revealSelection(revealMode, alignment, revealExtentOption);
    30653056}
  • trunk/Source/WebCore/page/FrameView.cpp

    r244098 r244141  
    19941994}
    19951995
    1996 IntRect FrameView::unobscuredContentRectExpandedByContentInsets() const
    1997 {
    1998     FloatRect unobscuredContentRect = this->unobscuredContentRect();
     1996IntRect FrameView::visualViewportRectExpandedByContentInsets() const
     1997{
     1998    FloatRect unobscuredContentRect = this->visualViewportRect();
    19991999    if (auto* page = frame().page())
    20002000        unobscuredContentRect.expand(page->contentInsets());
  • trunk/Source/WebCore/page/FrameView.h

    r244098 r244141  
    330330#endif
    331331
    332     IntRect unobscuredContentRectExpandedByContentInsets() const;
     332    IntRect visualViewportRectExpandedByContentInsets() const;
    333333   
    334334    bool fixedElementsLayoutRelativeToFrame() const;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r244068 r244141  
    25692569            LayoutRect viewRect = frameView.visibleContentRect();
    25702570#else
    2571             LayoutRect viewRect = frameView.unobscuredContentRectExpandedByContentInsets();
     2571            LayoutRect viewRect = frameView.visualViewportRectExpandedByContentInsets();
    25722572#endif
    25732573            // Move the target rect into "scrollView contents" coordinates.
  • trunk/Source/WebKit/ChangeLog

    r244140 r244141  
     12019-04-10  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Fix text autoscrolling when typing in modern webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=196718
     5        <rdar://problem/49225507>
     6
     7        Reviewed by Tim Horton.
     8
     9        For staging only. We need to turn off UIKit's scrolling behavior to land
     10        the changes we are making. To keep from the build ever breaking,
     11        I am temporarily circumventing the changes in UIKit. This will be removed
     12        once the next UIKit submission happens.
     13
     14        * UIProcess/ios/WKContentViewInteraction.mm:
     15        (-[WKUIWKTextInteractionAssistant scrollSelectionToVisible]):
     16        (-[WKContentView setUpTextSelectionAssistant]):
     17
    1182019-04-10  Wenson Hsieh  <wenson_hsieh@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r244096 r244141  
    155155#endif
    156156
     157// For staging with UIKit, will be removed ASAP.
     158@interface WKUIWKTextInteractionAssistant : UIWKTextInteractionAssistant
     159@end
     160
     161@implementation WKUIWKTextInteractionAssistant
     162- (void)scrollSelectionToVisible
     163{
     164}
     165@end
     166
    157167namespace WebKit {
    158168using namespace WebCore;
     
    23722382{
    23732383    if (!_textSelectionAssistant)
    2374         _textSelectionAssistant = adoptNS([[UIWKTextInteractionAssistant alloc] initWithView:self]);
     2384        _textSelectionAssistant = adoptNS([[WKUIWKTextInteractionAssistant alloc] initWithView:self]);
    23752385    else {
    23762386        // Reset the gesture recognizers in case editability has changed.
Note: See TracChangeset for help on using the changeset viewer.