Title: [250365] trunk
Revision
250365
Author
[email protected]
Date
2019-09-25 15:54:16 -0700 (Wed, 25 Sep 2019)

Log Message

Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
https://bugs.webkit.org/show_bug.cgi?id=202125

Reviewed by Tim Horton.

Source/WebCore:

Test: editing/selection/ios/update-selection-after-iframe-scroll.html

When we end scrolling, make sure that iframes get a final update to ensure that the
selection is in the correct position. Pipe that to WebKit/UIProcess via
frame specific plath.

* loader/EmptyClients.cpp:
* page/EditorClient.h:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):

Source/WebKit:

Add additional calls into UIKit differentiate between main frame scrolling and overflow/iframe scrolling.
Add piping for iframe specific scrolling.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _willStartScrollingOrZooming]):
(-[WKContentView _didEndScrollingOrZooming]):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::subFrameScrollPositionChanged):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::subFrameScrollPositionChanged):

Source/WebKitLegacy/mac:

Filling out unused functions needed for new fix.

* WebCoreSupport/WebEditorClient.h:

LayoutTests:

Test that an iframe selection is updated after a scroll is completed.

* editing/selection/ios/update-selection-after-iframe-scroll-expected.txt: Added.
* editing/selection/ios/update-selection-after-iframe-scroll.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (250364 => 250365)


--- trunk/LayoutTests/ChangeLog	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/LayoutTests/ChangeLog	2019-09-25 22:54:16 UTC (rev 250365)
@@ -1,3 +1,15 @@
+2019-09-25  Megan Gardner  <[email protected]>
+
+        Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
+        https://bugs.webkit.org/show_bug.cgi?id=202125
+
+        Reviewed by Tim Horton.
+
+        Test that an iframe selection is updated after a scroll is completed.
+
+        * editing/selection/ios/update-selection-after-iframe-scroll-expected.txt: Added.
+        * editing/selection/ios/update-selection-after-iframe-scroll.html: Added.
+
 2019-09-25  Alicia Boya GarcĂ­a  <[email protected]>
 
         [GTK] Unreviewed test gardening

Added: trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll-expected.txt (0 => 250365)


--- trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll-expected.txt	2019-09-25 22:54:16 UTC (rev 250365)
@@ -0,0 +1,23 @@
+PASS selectionRectsBefore[0].top is 74
+PASS selectionRectsBefore[0].width is 184
+PASS selectionRectsBefore[0].left is 10
+PASS selectionRectsBefore[0].height is 19
+PASS selectionRectsBefore[1].top is 93
+PASS selectionRectsBefore[1].width is 167
+PASS selectionRectsBefore[1].left is 10
+PASS selectionRectsBefore[1].height is 20
+PASS selectionRectsAfter[0].top is 24
+PASS selectionRectsAfter[0].width is 184
+PASS selectionRectsAfter[0].left is 10
+PASS selectionRectsAfter[0].height is 19
+PASS selectionRectsAfter[1].top is 43
+PASS selectionRectsAfter[1].width is 167
+PASS selectionRectsAfter[1].left is 10
+PASS selectionRectsAfter[1].height is 20
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+This test verifies that a selection in an iframe area is kept up to date after scrolling. To test manually, tap the frame and scroll the editable area down; the selection move to account for the new scroll position.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Added: trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll.html (0 => 250365)


--- trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll.html	2019-09-25 22:54:16 UTC (rev 250365)
@@ -0,0 +1,104 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AsyncFrameScrollingEnabled=true ] -->
+<html>
+<head>
+<script src=""
+<script src=''></script>
+<script src=''></script>
+<meta name=viewport content='width=device-width'>
+<style>
+body, html {
+    width: 100%;
+    height: 100%;
+    margin: 0;
+}
+
+#target {
+    width: 320px;
+    height: 160px;
+}
+</style>
+<script>
+
+jsTestIsAsync = true;
+function rectsAreEqual(rects, otherRects)
+{
+    if (rects.length != otherRects.length)
+        return false;
+
+    for (let i = 0; i < rects.length; ++i) {
+        if (rects[i].top != otherRects[i].top
+            || rects[i].left != otherRects[i].left
+            || rects[i].width != otherRects[i].width
+            || rects[i].height != otherRects[i].height)
+            return false;
+    }
+
+    return true;
+}
+
+async function waitForSelectionRectsToChange(fromRects)
+{
+    let rects = fromRects;
+    while (rectsAreEqual(rects, fromRects))
+        rects = await UIHelper.getUISelectionViewRects();
+    return rects;
+}
+
+addEventListener('load', async function() {
+    description('This test verifies that a selection in an iframe area is kept up to date after scrolling. To test manually, tap the frame and scroll the editable area down; the selection move to account for the new scroll position.');
+
+    const iframe = document.getElementById('scrollingiframe');
+
+    await UIHelper.activateElementAndWaitForInputSession(iframe);
+    selectionRectsBefore = await waitForSelectionRectsToChange([]);
+
+    await UIHelper.immediateScrollElementAtContentPointToOffset(100, 400, 0, 50);
+    selectionRectsAfter = await waitForSelectionRectsToChange(selectionRectsBefore);
+
+    shouldBe('selectionRectsBefore[0].top', '74');
+    shouldBe('selectionRectsBefore[0].width', '184');
+    shouldBe('selectionRectsBefore[0].left', '10');
+    shouldBe('selectionRectsBefore[0].height', '19');
+    shouldBe('selectionRectsBefore[1].top', '93');
+    shouldBe('selectionRectsBefore[1].width', '167');
+    shouldBe('selectionRectsBefore[1].left', '10');
+    shouldBe('selectionRectsBefore[1].height', '20');
+
+    shouldBe('selectionRectsAfter[0].top', '24');
+    shouldBe('selectionRectsAfter[0].width', '184');
+    shouldBe('selectionRectsAfter[0].left', '10');
+    shouldBe('selectionRectsAfter[0].height', '19');
+    shouldBe('selectionRectsAfter[1].top', '43');
+    shouldBe('selectionRectsAfter[1].width', '167');
+    shouldBe('selectionRectsAfter[1].left', '10');
+    shouldBe('selectionRectsAfter[1].height', '20');
+
+    finishJSTest();
+});
+</script>
+</head>
+
+<body>
+<iframe width="200" height="500" scrolling="yes" srcdoc="
+    <div id='editor' contenteditable>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p id='select-target'>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+        <p>The quick brown fox jumped over the lazy dog.</p>
+    </div>
+    <script>
+        addEventListener('click', event => {
+        getSelection().selectAllChildren(document.getElementById('select-target'));
+        event.preventDefault();
+    });
+    </script>
+        " id="scrollingiframe"></iframe>
+<div id="description"></div>
+
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (250364 => 250365)


--- trunk/Source/WebCore/ChangeLog	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebCore/ChangeLog	2019-09-25 22:54:16 UTC (rev 250365)
@@ -1,3 +1,21 @@
+2019-09-25  Megan Gardner  <[email protected]>
+
+        Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
+        https://bugs.webkit.org/show_bug.cgi?id=202125
+
+        Reviewed by Tim Horton.
+
+        Test: editing/selection/ios/update-selection-after-iframe-scroll.html
+
+        When we end scrolling, make sure that iframes get a final update to ensure that the 
+        selection is in the correct position. Pipe that to WebKit/UIProcess via
+        frame specific plath.
+
+        * loader/EmptyClients.cpp:
+        * page/EditorClient.h:
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
+
 2019-09-25  Wenson Hsieh  <[email protected]>
 
         Page temporarily jumps to an excessively small viewport scale while loading usatoday.com

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (250364 => 250365)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2019-09-25 22:54:16 UTC (rev 250365)
@@ -216,6 +216,7 @@
     void textWillBeDeletedInTextField(Element*) final { }
     void textDidChangeInTextArea(Element*) final { }
     void overflowScrollPositionChanged() final { }
+    void subFrameScrollPositionChanged() final { }
 
 #if PLATFORM(IOS_FAMILY)
     void startDelayingAndCoalescingContentChangeNotifications() final { }

Modified: trunk/Source/WebCore/page/EditorClient.h (250364 => 250365)


--- trunk/Source/WebCore/page/EditorClient.h	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebCore/page/EditorClient.h	2019-09-25 22:54:16 UTC (rev 250365)
@@ -129,6 +129,7 @@
     virtual void textWillBeDeletedInTextField(Element*) = 0;
     virtual void textDidChangeInTextArea(Element*) = 0;
     virtual void overflowScrollPositionChanged() = 0;
+    virtual void subFrameScrollPositionChanged() = 0;
 
 #if PLATFORM(IOS_FAMILY)
     virtual void startDelayingAndCoalescingContentChangeNotifications() = 0;

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (250364 => 250365)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-09-25 22:54:16 UTC (rev 250365)
@@ -342,6 +342,11 @@
     LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll node " << scrollingNodeID << " scrollPosition " << scrollPosition << " action " << scrollingLayerPositionAction);
 
     auto& frameView = *frameViewPtr;
+    
+    if (!frameViewPtr->frame().isMainFrame()) {
+        if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
+            m_page->editorClient().subFrameScrollPositionChanged();
+    }
 
     if (scrollingNodeID == frameView.scrollingNodeID()) {
         reconcileScrollingState(frameView, scrollPosition, layoutViewportOrigin, scrollType, ViewportRectStability::Stable, scrollingLayerPositionAction);

Modified: trunk/Source/WebKit/ChangeLog (250364 => 250365)


--- trunk/Source/WebKit/ChangeLog	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/ChangeLog	2019-09-25 22:54:16 UTC (rev 250365)
@@ -1,3 +1,23 @@
+2019-09-25  Megan Gardner  <[email protected]>
+
+        Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
+        https://bugs.webkit.org/show_bug.cgi?id=202125
+
+        Reviewed by Tim Horton.
+
+        Add additional calls into UIKit differentiate between main frame scrolling and overflow/iframe scrolling.
+        Add piping for iframe specific scrolling.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _willStartScrollingOrZooming]):
+        (-[WKContentView _didEndScrollingOrZooming]):
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::subFrameScrollPositionChanged):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::subFrameScrollPositionChanged):
+
 2019-09-25  Wenson Hsieh  <[email protected]>
 
         Page temporarily jumps to an excessively small viewport scale while loading usatoday.com

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (250364 => 250365)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-09-25 22:54:16 UTC (rev 250365)
@@ -1088,6 +1088,11 @@
 
 #endif // USE(APPLE_INTERNAL_SDK)
 
+@interface UITextInteractionAssistant (Staging_55645619)
+- (void)didEndScrollingOrZooming;
+- (void)willStartScrollingOrZooming;
+@end
+
 @interface UIGestureRecognizer (Staging_45970040)
 @property (nonatomic, readonly, getter=_modifierFlags) UIKeyModifierFlags modifierFlags;
 @end

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (250364 => 250365)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-09-25 22:54:16 UTC (rev 250365)
@@ -2715,7 +2715,10 @@
 
 - (void)_willStartScrollingOrZooming
 {
-    [_textSelectionAssistant willStartScrollingOverflow];
+    if ([_textSelectionAssistant respondsToSelector:@selector(willStartScrollingOrZooming)])
+        [_textSelectionAssistant willStartScrollingOrZooming];
+    else
+        [_textSelectionAssistant willStartScrollingOverflow];
     _page->setIsScrollingOrZooming(true);
 
 #if PLATFORM(WATCHOS)
@@ -2735,7 +2738,10 @@
 - (void)_didEndScrollingOrZooming
 {
     if (!_needsDeferredEndScrollingSelectionUpdate) {
-        [_textSelectionAssistant didEndScrollingOverflow];
+        if ([_textSelectionAssistant respondsToSelector:@selector(didEndScrollingOrZooming)])
+            [_textSelectionAssistant didEndScrollingOrZooming];
+        else
+            [_textSelectionAssistant didEndScrollingOverflow];
     }
     _page->setIsScrollingOrZooming(false);
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp (250364 => 250365)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp	2019-09-25 22:54:16 UTC (rev 250365)
@@ -424,6 +424,11 @@
 {
     notImplemented();
 }
+
+void WebEditorClient::subFrameScrollPositionChanged()
+{
+    notImplemented();
+}
 #endif
 
 static bool getActionTypeForKeyEvent(KeyboardEvent* event, WKInputFieldActionType& type)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (250364 => 250365)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2019-09-25 22:54:16 UTC (rev 250365)
@@ -113,6 +113,7 @@
     void textWillBeDeletedInTextField(WebCore::Element*) final;
     void textDidChangeInTextArea(WebCore::Element*) final;
     void overflowScrollPositionChanged() final;
+    void subFrameScrollPositionChanged() final;
 
 #if PLATFORM(COCOA)
     void setInsertionPasteboard(const String& pasteboardName) final;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm (250364 => 250365)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm	2019-09-25 22:54:16 UTC (rev 250365)
@@ -102,6 +102,11 @@
     m_page->didChangeOverflowScrollPosition();
 }
 
+void WebEditorClient::subFrameScrollPositionChanged()
+{
+    m_page->didChangeOverflowScrollPosition();
+}
+
 bool WebEditorClient::shouldAllowSingleClickToChangeSelection(WebCore::Node& targetNode, const WebCore::VisibleSelection& newSelection) const
 {
     // The text selection assistant will handle selection in the case where we are already editing the node

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (250364 => 250365)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2019-09-25 22:54:16 UTC (rev 250365)
@@ -1,3 +1,14 @@
+2019-09-25  Megan Gardner  <[email protected]>
+
+        Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
+        https://bugs.webkit.org/show_bug.cgi?id=202125
+
+        Reviewed by Tim Horton.
+
+        Filling out unused functions needed for new fix.
+
+        * WebCoreSupport/WebEditorClient.h:
+
 2019-09-24  Alex Christensen  <[email protected]>
 
         Remove SchemeRegistry's list of URL schemes allowing local storage in private browsing, which is unused

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h (250364 => 250365)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2019-09-25 22:53:29 UTC (rev 250364)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2019-09-25 22:54:16 UTC (rev 250365)
@@ -138,6 +138,7 @@
     void textWillBeDeletedInTextField(WebCore::Element*) final;
     void textDidChangeInTextArea(WebCore::Element*) final;
     void overflowScrollPositionChanged() final { };
+    void subFrameScrollPositionChanged() final { };
 
 #if PLATFORM(IOS_FAMILY)
     void startDelayingAndCoalescingContentChangeNotifications() final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to