Title: [235153] trunk
Revision
235153
Author
megan_gard...@apple.com
Date
2018-08-21 18:41:50 -0700 (Tue, 21 Aug 2018)

Log Message

Change Selection modification to not snap the grabber when selecting above or below the selection anchor
https://bugs.webkit.org/show_bug.cgi?id=188826

Reviewed by Tim Horton.

Selecting single lines is sometimes difficult because we currently snap selections to single
characters if we move past the position of the other anchor in our selection. This patch changes
this behaviour to reflect the behaviour in the rest of this system, which snaps the selection
to the position on the line of the other anchor, rather than snapping it all the way a single
Source/WebKit:

character.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::rangeForPointInRootViewCoordinates):

LayoutTests:

character. This updates the tests to reflect this new behaviour.

* fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html:
* fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (235152 => 235153)


--- trunk/LayoutTests/ChangeLog	2018-08-22 01:24:52 UTC (rev 235152)
+++ trunk/LayoutTests/ChangeLog	2018-08-22 01:41:50 UTC (rev 235153)
@@ -1,3 +1,19 @@
+2018-08-21  Megan Gardner  <megan_gard...@apple.com>
+
+        Change Selection modification to not snap the grabber when selecting above or below the selection anchor
+        https://bugs.webkit.org/show_bug.cgi?id=188826
+
+        Reviewed by Tim Horton.
+
+        Selecting single lines is sometimes difficult because we currently snap selections to single
+        characters if we move past the position of the other anchor in our selection. This patch changes
+        this behaviour to reflect the behaviour in the rest of this system, which snaps the selection
+        to the position on the line of the other anchor, rather than snapping it all the way a single
+        character. This updates the tests to reflect this new behaviour.
+
+        * fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:
+
 2018-08-21  Yusuke Suzuki  <yusukesuz...@slowstart.org>
 
         Support "name" option for dedicated workers

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html (235152 => 235153)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html	2018-08-22 01:24:52 UTC (rev 235152)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html	2018-08-22 01:41:50 UTC (rev 235153)
@@ -63,7 +63,7 @@
             output += '<br>';
 
             var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4);
-            if (document.getSelection().toString() == "s")
+            if (document.getSelection().toString() == "sed")
                 output += 'PASS: Correct Selection';
             else
                 output += 'FAIL: failed to reduce selection to a single character by dragging up. Incorrect Selection: ' + document.getSelection().toString();

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html (235152 => 235153)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html	2018-08-22 01:24:52 UTC (rev 235152)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html	2018-08-22 01:41:50 UTC (rev 235153)
@@ -63,7 +63,7 @@
             output += '<br>';
 
             var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4);
-            if (document.getSelection().toString() == "t")
+            if (document.getSelection().toString() == "ut")
                 output += 'PASS: Correct Selection';
             else
                 output += 'FAIL: failed to reduce selection to a single character by dragging down. Incorrect Selection: ' + document.getSelection().toString();

Modified: trunk/Source/WebKit/ChangeLog (235152 => 235153)


--- trunk/Source/WebKit/ChangeLog	2018-08-22 01:24:52 UTC (rev 235152)
+++ trunk/Source/WebKit/ChangeLog	2018-08-22 01:41:50 UTC (rev 235153)
@@ -1,3 +1,19 @@
+2018-08-21  Megan Gardner  <megan_gard...@apple.com>
+
+        Change Selection modification to not snap the grabber when selecting above or below the selection anchor
+        https://bugs.webkit.org/show_bug.cgi?id=188826
+
+        Reviewed by Tim Horton.
+
+        Selecting single lines is sometimes difficult because we currently snap selections to single
+        characters if we move past the position of the other anchor in our selection. This patch changes
+        this behaviour to reflect the behaviour in the rest of this system, which snaps the selection
+        to the position on the line of the other anchor, rather than snapping it all the way a single
+        character.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::rangeForPointInRootViewCoordinates):
+
 2018-08-21  Daniel Bates  <daba...@apple.com>
 
         Cleanup: Remove unused file-local static variable from TextCheckerIOS.mm

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (235152 => 235153)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-08-22 01:24:52 UTC (rev 235152)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-08-22 01:41:50 UTC (rev 235153)
@@ -1217,7 +1217,25 @@
 
 static RefPtr<Range> rangeForPointInRootViewCoordinates(Frame& frame, const IntPoint& pointInRootViewCoordinates, bool baseIsStart)
 {
-    IntPoint pointInDocument = frame.view()->rootViewToContents(pointInRootViewCoordinates);
+    VisibleSelection existingSelection = frame.selection().selection();
+    VisiblePosition selectionStart = existingSelection.visibleStart();
+    VisiblePosition selectionEnd = existingSelection.visibleEnd();
+    
+    IntPoint adjustedPoint = pointInRootViewCoordinates;
+    
+    if (baseIsStart) {
+        IntRect caret = existingSelection.visibleStart().absoluteCaretBounds();
+        int startY = caret.center().y();
+        if (adjustedPoint.y() < startY)
+            adjustedPoint.setY(startY);
+    } else {
+        IntRect caret = existingSelection.visibleEnd().absoluteCaretBounds();
+        int endY = caret.center().y();
+        if (adjustedPoint.y() > endY)
+            adjustedPoint.setY(endY);
+    }
+    
+    IntPoint pointInDocument = frame.view()->rootViewToContents(adjustedPoint);
     VisiblePosition result;
     RefPtr<Range> range;
     
@@ -1227,10 +1245,6 @@
     else
         result = frame.visiblePositionForPoint(pointInDocument).deepEquivalent();
     
-    VisibleSelection existingSelection = frame.selection().selection();
-    VisiblePosition selectionStart = existingSelection.visibleStart();
-    VisiblePosition selectionEnd = existingSelection.visibleEnd();
-    
     if (baseIsStart) {
         if (comparePositions(result, selectionStart) <= 0)
             result = selectionStart.next();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to