Diff
Modified: trunk/Source/WebCore/ChangeLog (293834 => 293835)
--- trunk/Source/WebCore/ChangeLog 2022-05-05 15:18:38 UTC (rev 293834)
+++ trunk/Source/WebCore/ChangeLog 2022-05-05 15:36:07 UTC (rev 293835)
@@ -1,3 +1,18 @@
+2022-05-05 Kate Cheney <[email protected]>
+
+ Right click using trackpad crashes Safari
+ https://bugs.webkit.org/show_bug.cgi?id=240030
+ rdar://91786269
+
+ Reviewed by Tim Horton.
+
+ Trackpad on iOS should mimic mac selection behavior and block context
+ menu clicks that are not made on a text node.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::selectClosestContextualWordOrLinkFromHitTestResult):
+ (WebCore::EventHandler::sendContextMenuEvent):
+
2022-05-05 Youenn Fablet <[email protected]>
Add SharedVideoFrameReader/SharedVideoFrameWriter logging for error cases
Modified: trunk/Source/WebCore/page/EventHandler.cpp (293834 => 293835)
--- trunk/Source/WebCore/page/EventHandler.cpp 2022-05-05 15:18:38 UTC (rev 293834)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2022-05-05 15:36:07 UTC (rev 293835)
@@ -566,6 +566,12 @@
void EventHandler::selectClosestContextualWordOrLinkFromHitTestResult(const HitTestResult& result, AppendTrailingWhitespace appendTrailingWhitespace)
{
+ // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
+ // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
+ // available for text selections. But only if we're above text.
+ if (!m_frame.selection().selection().isContentEditable() && !is<Text>(result.targetNode()))
+ return;
+
RefPtr urlElement = result.URLElement();
if (!urlElement || !isDraggableLink(*urlElement)) {
if (RefPtr targetNode = result.targetNode()) {
@@ -3272,11 +3278,7 @@
return false;
if (m_frame.editor().behavior().shouldSelectOnContextualMenuClick()
- && !m_frame.selection().contains(viewportPos)
- // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
- // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
- // available for text selections. But only if we're above text.
- && (m_frame.selection().selection().isContentEditable() || (mouseEvent.targetNode() && mouseEvent.targetNode()->isTextNode()))) {
+ && !m_frame.selection().contains(viewportPos)) {
m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
selectClosestContextualWordOrLinkFromHitTestResult(mouseEvent.hitTestResult(), shouldAppendTrailingWhitespace(mouseEvent, m_frame));
}
Modified: trunk/Tools/ChangeLog (293834 => 293835)
--- trunk/Tools/ChangeLog 2022-05-05 15:18:38 UTC (rev 293834)
+++ trunk/Tools/ChangeLog 2022-05-05 15:36:07 UTC (rev 293835)
@@ -1,3 +1,16 @@
+2022-05-05 Kate Cheney <[email protected]>
+
+ Right click using trackpad crashes Safari
+ https://bugs.webkit.org/show_bug.cgi?id=240030
+ rdar://91786269
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/emptyTable.html: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm:
+ (TEST):
+
2022-05-04 Jonathan Bedard <[email protected]>
[webkitbugspy] Include mocks in package
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (293834 => 293835)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-05-05 15:18:38 UTC (rev 293834)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-05-05 15:36:07 UTC (rev 293835)
@@ -258,6 +258,7 @@
498D030A26376B34009CBFAD /* resourceLoadStatisticsMissingUniqueIndex.db in Copy Resources */ = {isa = PBXBuildFile; fileRef = 498D030926376B2C009CBFAD /* resourceLoadStatisticsMissingUniqueIndex.db */; };
4995A6F025E8772000E5F0A9 /* csp-document-uri-report.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4995A6EF25E876A300E5F0A9 /* csp-document-uri-report.html */; };
49D2E5C22731E3BC00BCCAED /* file-with-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 49D2E5C12731E37400BCCAED /* file-with-iframe.html */; };
+ 49D902B328209B3300E2C3B8 /* emptyTable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 49D902B228209B0500E2C3B8 /* emptyTable.html */; };
4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
510477721D298DDD009747EB /* IDBDeleteRecovery.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */; };
510477731D298DDD009747EB /* IDBDeleteRecovery.sqlite3-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 510477701D298D85009747EB /* IDBDeleteRecovery.sqlite3-shm */; };
@@ -1356,6 +1357,7 @@
F44D06451F395C26001A0E29 /* editor-state-test-harness.html in Copy Resources */,
F4BDA43027F8D19C00F9647D /* element-fullscreen.html in Copy Resources */,
51C8E1A91F27F49600BF731B /* EmptyGrandfatheredResourceLoadStatistics.plist in Copy Resources */,
+ 49D902B328209B3300E2C3B8 /* emptyTable.html in Copy Resources */,
A14AAB651E78DC5400C1ADC2 /* encrypted.pdf in Copy Resources */,
F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */,
F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */,
@@ -2075,6 +2077,7 @@
49AEEF6B2407358600C87E4C /* InAppBrowserPrivacy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InAppBrowserPrivacy.mm; sourceTree = "<group>"; };
49D2E5C12731E37400BCCAED /* file-with-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "file-with-iframe.html"; sourceTree = "<group>"; };
49D7FBA7241FDDDA00AB67FA /* in-app-browser-privacy-local-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "in-app-browser-privacy-local-file.html"; sourceTree = "<group>"; };
+ 49D902B228209B0500E2C3B8 /* emptyTable.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = emptyTable.html; sourceTree = "<group>"; };
49EF6AD42677C0BE007967DC /* AppPrivacyReport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppPrivacyReport.mm; sourceTree = "<group>"; };
4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
4A410F4D19AF7BEF002EBAB4 /* invalidDeviceIDHashSalts */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.bplist; path = invalidDeviceIDHashSalts; sourceTree = "<group>"; };
@@ -4779,6 +4782,7 @@
290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
118153432208B7AC00B2CCD2 /* deferred-script-load.html */,
118153452208B7E500B2CCD2 /* deferred-script.js */,
+ 49D902B228209B0500E2C3B8 /* emptyTable.html */,
A14AAB641E78DC3F00C1ADC2 /* encrypted.pdf */,
07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */,
C5E1AFFD16B22179006CC1F2 /* execCopy.html */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/emptyTable.html (0 => 293835)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/emptyTable.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/emptyTable.html 2022-05-05 15:36:07 UTC (rev 293835)
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<style>
+ body, html {
+ font-family: system-ui;
+ margin: 0;
+ }
+
+ table {
+ border-collapse: collapse;
+ }
+
+ th, td {
+ padding: 0.5em;
+ border: 1px solid #DDD;
+ width: 200px;
+ height: 20px;
+ }
+
+ tr:nth-child(even) {
+ background-color: #EFEFEF;
+ }
+
+ div + div {
+ margin-top: 1em;
+ }
+</style>
+</head>
+<body>
+ <div>
+ <table>
+ <tbody>
+ <tr>
+ <th></th>
+ <th></th>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="target">Hello</div>
+</body>
+</html>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm (293834 => 293835)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm 2022-05-05 15:18:38 UTC (rev 293834)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm 2022-05-05 15:36:07 UTC (rev 293835)
@@ -37,6 +37,7 @@
#import <WebKit/WKWebViewPrivateForTesting.h>
#import <WebKit/WKWebpagePreferencesPrivate.h>
#import <WebKit/WebKit.h>
+#import <pal/spi/cocoa/RevealSPI.h>
#import <wtf/BlockPtr.h>
#import <wtf/MonotonicTime.h>
#import <wtf/RetainPtr.h>
@@ -70,6 +71,7 @@
@interface WKContentView ()
- (void)mouseGestureRecognizerChanged:(WKMouseGestureRecognizer *)gestureRecognizer;
+- (void)prepareSelectionForContextMenuWithLocationInView:(CGPoint)locationInView completionHandler:(void(^)(BOOL shouldPresentMenu, RVItem *item))completionHandler;
@end
@interface WKTestingEvent : UIEvent
@@ -170,6 +172,25 @@
TestWebKitAPI::Util::run(&done);
}
+TEST(iOSMouseSupport, RightClickOutsideOfTextNodeDoesNotSelect)
+{
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ [webView synchronouslyLoadTestPageNamed:@"emptyTable"];
+ [webView stringByEvaluatingJavaScript:@"getSelection().selectAllChildren(document.getElementById('target'))"];
+
+ auto contentView = [webView wkContentView];
+
+ __block bool done = false;
+ [contentView prepareSelectionForContextMenuWithLocationInView:CGPointMake(100, 10) completionHandler:^(BOOL, RVItem *) {
+ NSNumber *result = [webView objectByEvaluatingJavaScript:@"window.getSelection().isCollapsed"];
+ EXPECT_FALSE([result boolValue]);
+ done = true;
+ }];
+
+ TestWebKitAPI::Util::run(&done);
+}
+
TEST(iOSMouseSupport, TrackButtonMaskFromTouchStart)
{
auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);