- Revision
- 261623
- Author
- [email protected]
- Date
- 2020-05-13 10:28:32 -0700 (Wed, 13 May 2020)
Log Message
Cherry-pick r259892. rdar://problem/63189085
[iOS] Unable to select text by tap-hold or double tap-hold when allowsLinkPreview property is set to NO
https://bugs.webkit.org/show_bug.cgi?id=210191
<rdar://problem/60454016>
Reviewed by Tim Horton.
Source/WebKit:
In iOS 13.4, UIWKTextInteractionAssistant no longer uses the (misleadingly-named) "force press" gesture to drive
text selection when performing a long press. Instead, it now uses the UIVariableDelayLoupeGestureRecognizer,
i.e. the text interaction assistant's loupe gesture recognizer.
The highlight long press gesture, which is only enabled when `allowsLinkPreview` is set to `NO`, is currently
allowed to recognize alongside the force press gesture but not the loupe gesture. This means that when link
previews are disabled, we'll end up allowing the highlight long press gesture to prevent text selection. A
similar issue already exists for the tap-and-half gesture as well.
To fix this, we allow the highlight long press gesture to recognize alongside both gestures.
Test: editing/selection/ios/select-text-with-link-preview-disabled.html
* UIProcess/ios/WKContentViewInteraction.mm:
(tapAndAHalfRecognizerClass):
While UITapAndAHalfRecognizer is declared in a UIKit private header, it is (perhaps unintentionally) not
exported, so attempting to call +[UITapAndAHalfRecognizer class] leads to a linker error. Work around this by
dynamically grabbing the `Class` from the class name.
The tap and half gesture recognizer is private in UIKit and only used for text interaction gestures, so we
always want the highlight long press gesture to be able to recognize alongside it.
(-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
Also clean up some existing code by replacing `.get().`s with Objective-C bracket operators.
LayoutTests:
Add a test to verify that text can be selected by long pressing when link previews are disabled.
* editing/selection/ios/select-text-with-link-preview-disabled-expected.txt: Added.
* editing/selection/ios/select-text-with-link-preview-disabled.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Added Paths
Diff
Modified: branches/safari-609-branch/LayoutTests/ChangeLog (261622 => 261623)
--- branches/safari-609-branch/LayoutTests/ChangeLog 2020-05-13 17:14:31 UTC (rev 261622)
+++ branches/safari-609-branch/LayoutTests/ChangeLog 2020-05-13 17:28:32 UTC (rev 261623)
@@ -1,3 +1,65 @@
+2020-05-13 Alan Coon <[email protected]>
+
+ Cherry-pick r259892. rdar://problem/63189085
+
+ [iOS] Unable to select text by tap-hold or double tap-hold when allowsLinkPreview property is set to NO
+ https://bugs.webkit.org/show_bug.cgi?id=210191
+ <rdar://problem/60454016>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ In iOS 13.4, UIWKTextInteractionAssistant no longer uses the (misleadingly-named) "force press" gesture to drive
+ text selection when performing a long press. Instead, it now uses the UIVariableDelayLoupeGestureRecognizer,
+ i.e. the text interaction assistant's loupe gesture recognizer.
+
+ The highlight long press gesture, which is only enabled when `allowsLinkPreview` is set to `NO`, is currently
+ allowed to recognize alongside the force press gesture but not the loupe gesture. This means that when link
+ previews are disabled, we'll end up allowing the highlight long press gesture to prevent text selection. A
+ similar issue already exists for the tap-and-half gesture as well.
+
+ To fix this, we allow the highlight long press gesture to recognize alongside both gestures.
+
+ Test: editing/selection/ios/select-text-with-link-preview-disabled.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (tapAndAHalfRecognizerClass):
+
+ While UITapAndAHalfRecognizer is declared in a UIKit private header, it is (perhaps unintentionally) not
+ exported, so attempting to call +[UITapAndAHalfRecognizer class] leads to a linker error. Work around this by
+ dynamically grabbing the `Class` from the class name.
+
+ The tap and half gesture recognizer is private in UIKit and only used for text interaction gestures, so we
+ always want the highlight long press gesture to be able to recognize alongside it.
+
+ (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+
+ Also clean up some existing code by replacing `.get().`s with Objective-C bracket operators.
+
+ LayoutTests:
+
+ Add a test to verify that text can be selected by long pressing when link previews are disabled.
+
+ * editing/selection/ios/select-text-with-link-preview-disabled-expected.txt: Added.
+ * editing/selection/ios/select-text-with-link-preview-disabled.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-04-10 Wenson Hsieh <[email protected]>
+
+ [iOS] Unable to select text by tap-hold or double tap-hold when allowsLinkPreview property is set to NO
+ https://bugs.webkit.org/show_bug.cgi?id=210191
+ <rdar://problem/60454016>
+
+ Reviewed by Tim Horton.
+
+ Add a test to verify that text can be selected by long pressing when link previews are disabled.
+
+ * editing/selection/ios/select-text-with-link-preview-disabled-expected.txt: Added.
+ * editing/selection/ios/select-text-with-link-preview-disabled.html: Added.
+
2020-05-12 Alan Coon <[email protected]>
Cherry-pick r261480. rdar://problem/63151931
Added: branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled-expected.txt (0 => 261623)
--- branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled-expected.txt (rev 0)
+++ branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled-expected.txt 2020-05-13 17:28:32 UTC (rev 261623)
@@ -0,0 +1,10 @@
+This test verifies that it is possible to select text when link previews are disabled using WebKit API. This test requires WebKitTestRunner, since it exercises web view API to disable link previews.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getSelection().toString() is "Testing"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Testing
Added: branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled.html (0 => 261623)
--- branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled.html (rev 0)
+++ branches/safari-609-branch/LayoutTests/editing/selection/ios/select-text-with-link-preview-disabled.html 2020-05-13 17:28:32 UTC (rev 261623)
@@ -0,0 +1,32 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true allowsLinkPreview=false ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<script src=""
+<script src=""
+<style>
+html, body {
+ width: 100%;
+ margin: 0;
+}
+
+#target {
+ font-size: 24px;
+}
+</style>
+<script>
+ jsTestIsAsync = true;
+
+ async function runTest()
+ {
+ description("This test verifies that it is possible to select text when link previews are disabled using WebKit API. This test requires WebKitTestRunner, since it exercises web view API to disable link previews.");
+
+ await UIHelper.longPressElement(target);
+ shouldBeEqualToString("getSelection().toString()", "Testing");
+ finishJSTest();
+ }
+</script>
+<body _onload_="runTest()">
+ <div id="target">Testing</div>
+</body>
+</html>
Modified: branches/safari-609-branch/Source/WebKit/ChangeLog (261622 => 261623)
--- branches/safari-609-branch/Source/WebKit/ChangeLog 2020-05-13 17:14:31 UTC (rev 261622)
+++ branches/safari-609-branch/Source/WebKit/ChangeLog 2020-05-13 17:28:32 UTC (rev 261623)
@@ -1,3 +1,87 @@
+2020-05-13 Alan Coon <[email protected]>
+
+ Cherry-pick r259892. rdar://problem/63189085
+
+ [iOS] Unable to select text by tap-hold or double tap-hold when allowsLinkPreview property is set to NO
+ https://bugs.webkit.org/show_bug.cgi?id=210191
+ <rdar://problem/60454016>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ In iOS 13.4, UIWKTextInteractionAssistant no longer uses the (misleadingly-named) "force press" gesture to drive
+ text selection when performing a long press. Instead, it now uses the UIVariableDelayLoupeGestureRecognizer,
+ i.e. the text interaction assistant's loupe gesture recognizer.
+
+ The highlight long press gesture, which is only enabled when `allowsLinkPreview` is set to `NO`, is currently
+ allowed to recognize alongside the force press gesture but not the loupe gesture. This means that when link
+ previews are disabled, we'll end up allowing the highlight long press gesture to prevent text selection. A
+ similar issue already exists for the tap-and-half gesture as well.
+
+ To fix this, we allow the highlight long press gesture to recognize alongside both gestures.
+
+ Test: editing/selection/ios/select-text-with-link-preview-disabled.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (tapAndAHalfRecognizerClass):
+
+ While UITapAndAHalfRecognizer is declared in a UIKit private header, it is (perhaps unintentionally) not
+ exported, so attempting to call +[UITapAndAHalfRecognizer class] leads to a linker error. Work around this by
+ dynamically grabbing the `Class` from the class name.
+
+ The tap and half gesture recognizer is private in UIKit and only used for text interaction gestures, so we
+ always want the highlight long press gesture to be able to recognize alongside it.
+
+ (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+
+ Also clean up some existing code by replacing `.get().`s with Objective-C bracket operators.
+
+ LayoutTests:
+
+ Add a test to verify that text can be selected by long pressing when link previews are disabled.
+
+ * editing/selection/ios/select-text-with-link-preview-disabled-expected.txt: Added.
+ * editing/selection/ios/select-text-with-link-preview-disabled.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-04-10 Wenson Hsieh <[email protected]>
+
+ [iOS] Unable to select text by tap-hold or double tap-hold when allowsLinkPreview property is set to NO
+ https://bugs.webkit.org/show_bug.cgi?id=210191
+ <rdar://problem/60454016>
+
+ Reviewed by Tim Horton.
+
+ In iOS 13.4, UIWKTextInteractionAssistant no longer uses the (misleadingly-named) "force press" gesture to drive
+ text selection when performing a long press. Instead, it now uses the UIVariableDelayLoupeGestureRecognizer,
+ i.e. the text interaction assistant's loupe gesture recognizer.
+
+ The highlight long press gesture, which is only enabled when `allowsLinkPreview` is set to `NO`, is currently
+ allowed to recognize alongside the force press gesture but not the loupe gesture. This means that when link
+ previews are disabled, we'll end up allowing the highlight long press gesture to prevent text selection. A
+ similar issue already exists for the tap-and-half gesture as well.
+
+ To fix this, we allow the highlight long press gesture to recognize alongside both gestures.
+
+ Test: editing/selection/ios/select-text-with-link-preview-disabled.html
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (tapAndAHalfRecognizerClass):
+
+ While UITapAndAHalfRecognizer is declared in a UIKit private header, it is (perhaps unintentionally) not
+ exported, so attempting to call +[UITapAndAHalfRecognizer class] leads to a linker error. Work around this by
+ dynamically grabbing the `Class` from the class name.
+
+ The tap and half gesture recognizer is private in UIKit and only used for text interaction gestures, so we
+ always want the highlight long press gesture to be able to recognize alongside it.
+
+ (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+
+ Also clean up some existing code by replacing `.get().`s with Objective-C bracket operators.
+
2020-05-12 Mark Lam <[email protected]>
Cherry-pick r261549. rdar://problem/63156073
Modified: branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261622 => 261623)
--- branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-13 17:14:31 UTC (rev 261622)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-13 17:28:32 UTC (rev 261623)
@@ -2056,6 +2056,16 @@
return (a == x && b == y) || (b == x && a == y);
}
+static Class tapAndAHalfRecognizerClass()
+{
+ static dispatch_once_t onceToken;
+ static Class theClass;
+ dispatch_once(&onceToken, ^{
+ theClass = NSClassFromString(@"UITapAndAHalfRecognizer");
+ });
+ return theClass;
+}
+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer
{
#if ENABLE(IOS_TOUCH_EVENTS)
@@ -2076,22 +2086,32 @@
return YES;
#endif
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000
#if PLATFORM(MACCATALYST)
- if (isSamePair(gestureRecognizer, otherGestureRecognizer, _textInteractionAssistant.get().loupeGesture, _textInteractionAssistant.get().forcePressGesture))
+ if (isSamePair(gestureRecognizer, otherGestureRecognizer, [_textInteractionAssistant loupeGesture], [_textInteractionAssistant forcePressGesture]))
return YES;
- if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), _textInteractionAssistant.get().loupeGesture))
+ if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), [_textInteractionAssistant loupeGesture]))
return YES;
if (([gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) || ([otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] && [gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]]))
return YES;
-#endif
- if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _textInteractionAssistant.get().forcePressGesture))
+#endif // PLATFORM(MACCATALYST)
+
+ if (gestureRecognizer == _highlightLongPressGestureRecognizer.get() || otherGestureRecognizer == _highlightLongPressGestureRecognizer.get()) {
+ auto forcePressGesture = [_textInteractionAssistant forcePressGesture];
+ if (gestureRecognizer == forcePressGesture || otherGestureRecognizer == forcePressGesture)
+ return YES;
+
+ auto loupeGesture = [_textInteractionAssistant loupeGesture];
+ if (gestureRecognizer == loupeGesture || otherGestureRecognizer == loupeGesture)
+ return YES;
+
+ if ([gestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()] || [otherGestureRecognizer isKindOfClass:tapAndAHalfRecognizerClass()])
+ return YES;
+ }
+
+ if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), [_textInteractionAssistant singleTapGesture]))
return YES;
-#endif
- if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), _textInteractionAssistant.get().singleTapGesture))
- return YES;
if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), _nonBlockingDoubleTapGestureRecognizer.get()))
return YES;