Title: [255322] trunk
Revision
255322
Author
timothy_hor...@apple.com
Date
2020-01-28 16:23:03 -0800 (Tue, 28 Jan 2020)

Log Message

macCatalyst: Triple clicking to select a sentence results in an empty selection
https://bugs.webkit.org/show_bug.cgi?id=206863
<rdar://problem/58776993>

Reviewed by Wenson Hsieh.

Source/WebCore:

* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldSelectOnContextualMenuClick const):
* page/ChromeClient.h:
(WebCore::ChromeClient::shouldUseMouseEventsForSelection):
* page/EventHandler.cpp:
(WebCore::EventHandler::canMouseDownStartSelect):
(WebCore::canMouseDownStartSelect): Deleted.
* page/EventHandler.h:
Disable WebCore's mouse-event-driven selection mechanisms on macCatalyst,
where we use a UITextInteraction-driven selection instead. Otherwise,
they conflict with each other in a chaotic fashion.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(-[WKWebView _doAfterProcessingAllPendingMouseEvents:]):
* UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
* UIProcess/API/mac/WKWebViewTestingMac.mm:
(-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): Deleted.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::handleProcessSwapOrExit):
(WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents): Deleted.
(WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
(WebKit::WebViewImpl::flushPendingMouseEventCallbacks): Deleted.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::doAfterProcessingAllPendingMouseEvents):
(WebKit::WebPageProxy::didFinishProcessingAllPendingMouseEvents):
(WebKit::WebPageProxy::flushPendingMouseEventCallbacks):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
Move "doAfterProcessingAllPendingMouseEvents" to WebPage instead of WebViewImpl,
so it can be used on all platforms. Expose it via WKWebView.

* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::shouldUseMouseEventsForSelection):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm: Added.
(-[WKTestingEvent locationInView:]):
(-[WKTestingEvent _setButtonMask:]):
(-[WKTestingEvent _buttonMask]):
(-[WKTestingTouch locationInView:]):
(-[WKTestingTouch setTapCount:]):
(-[WKTestingTouch tapCount]):
(mouseGesture):
(TEST):
Add a test ensuring that simply plumbing mouse events to WebCore
does not result in a selection change in macCatalyst (because UIKit
will handle the selection change itself, instead).

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255321 => 255322)


--- trunk/Source/WebCore/ChangeLog	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebCore/ChangeLog	2020-01-29 00:23:03 UTC (rev 255322)
@@ -1,3 +1,23 @@
+2020-01-28  Tim Horton  <timothy_hor...@apple.com>
+
+        macCatalyst: Triple clicking to select a sentence results in an empty selection
+        https://bugs.webkit.org/show_bug.cgi?id=206863
+        <rdar://problem/58776993>
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/EditingBehavior.h:
+        (WebCore::EditingBehavior::shouldSelectOnContextualMenuClick const):
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::shouldUseMouseEventsForSelection):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::canMouseDownStartSelect):
+        (WebCore::canMouseDownStartSelect): Deleted.
+        * page/EventHandler.h:
+        Disable WebCore's mouse-event-driven selection mechanisms on macCatalyst,
+        where we use a UITextInteraction-driven selection instead. Otherwise,
+        they conflict with each other in a chaotic fashion.
+
 2020-01-28  Sihui Liu  <sihui_...@apple.com>
 
         IndexedDB: speed up index records deletion

Modified: trunk/Source/WebCore/editing/EditingBehavior.h (255321 => 255322)


--- trunk/Source/WebCore/editing/EditingBehavior.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebCore/editing/EditingBehavior.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -60,7 +60,7 @@
     bool shouldAlwaysGrowSelectionWhenExtendingToBoundary() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
 
     // On Mac, when processing a contextual click, the object being clicked upon should be selected.
-    bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
+    bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; }
 
     // On Linux, should be able to get and insert spelling suggestions without selecting the misspelled word.
     bool shouldAllowSpellingSuggestionsWithoutSelection() const

Modified: trunk/Source/WebCore/page/ChromeClient.h (255321 => 255322)


--- trunk/Source/WebCore/page/ChromeClient.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebCore/page/ChromeClient.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -193,6 +193,8 @@
     virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
     virtual bool supportsSettingCursor() { return true; }
 
+    virtual bool shouldUseMouseEventsForSelection() { return true; }
+
     virtual FloatSize screenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
     virtual FloatSize availableScreenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
     virtual FloatSize overrideScreenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }

Modified: trunk/Source/WebCore/page/EventHandler.cpp (255321 => 255322)


--- trunk/Source/WebCore/page/EventHandler.cpp	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2020-01-29 00:23:03 UTC (rev 255322)
@@ -731,8 +731,13 @@
     return handled;
 }
 
-static inline bool canMouseDownStartSelect(Node* node)
+bool EventHandler::canMouseDownStartSelect(Node* node)
 {
+    if (Page* page = m_frame.page()) {
+        if (!page->chrome().client().shouldUseMouseEventsForSelection())
+            return false;
+    }
+    
     if (!node || !node->renderer())
         return true;
 

Modified: trunk/Source/WebCore/page/EventHandler.h (255321 => 255322)


--- trunk/Source/WebCore/page/EventHandler.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebCore/page/EventHandler.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -500,6 +500,8 @@
 
     bool shouldSendMouseEventsToInactiveWindows() const;
 
+    bool canMouseDownStartSelect(Node*);
+
     Frame& m_frame;
 
     bool m_mousePressed { false };

Modified: trunk/Source/WebKit/ChangeLog (255321 => 255322)


--- trunk/Source/WebKit/ChangeLog	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/ChangeLog	2020-01-29 00:23:03 UTC (rev 255322)
@@ -1,3 +1,40 @@
+2020-01-28  Tim Horton  <timothy_hor...@apple.com>
+
+        macCatalyst: Triple clicking to select a sentence results in an empty selection
+        https://bugs.webkit.org/show_bug.cgi?id=206863
+        <rdar://problem/58776993>
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+        (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]):
+        * UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
+        * UIProcess/API/mac/WKWebViewTestingMac.mm:
+        (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): Deleted.
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::handleProcessSwapOrExit):
+        (WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents): Deleted.
+        (WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
+        (WebKit::WebViewImpl::flushPendingMouseEventCallbacks): Deleted.
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::doAfterProcessingAllPendingMouseEvents):
+        (WebKit::WebPageProxy::didFinishProcessingAllPendingMouseEvents):
+        (WebKit::WebPageProxy::flushPendingMouseEventCallbacks):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
+        Move "doAfterProcessingAllPendingMouseEvents" to WebPage instead of WebViewImpl,
+        so it can be used on all platforms. Expose it via WKWebView.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        (WebKit::WebChromeClient::shouldUseMouseEventsForSelection):
+
 2020-01-28  Andres Gonzalez  <andresg...@apple.com>
 
         Fix for crash in AppKit accessibility.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -59,6 +59,8 @@
 @property (nonatomic, readonly) BOOL _hasServiceWorkerForegroundActivityForTesting;
 - (void)_setAssertionStateForTesting:(int)state;
 
+- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action;
+
 + (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier;
 + (void)_clearApplicationBundleIdentifierTestingOverride;
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -203,6 +203,13 @@
 #endif
 }
 
+- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action
+{
+    _page->doAfterProcessingAllPendingMouseEvents([action = "" {
+        action();
+    });
+}
+
 + (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier
 {
     WebCore::setApplicationBundleIdentifier(String(bundleIdentifier));

Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -156,8 +156,6 @@
     void isPlayingAudioWillChange() final { }
     void isPlayingAudioDidChange() final { }
 
-    void didFinishProcessingAllPendingMouseEvents() final { }
-
     void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
 
 #if ENABLE(VIDEO) && USE(GSTREAMER)

Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -50,7 +50,6 @@
 
 - (void)_setHeaderBannerHeight:(int)height;
 - (void)_setFooterBannerHeight:(int)height;
-- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -101,11 +101,6 @@
     _page->setFooterBannerHeightForTesting(height);
 }
 
-- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action
-{
-    _impl->doAfterProcessingAllPendingMouseEvents(action);
-}
-
 - (NSMenu *)_activeMenu
 {
     // FIXME: Only the DOM paste access menu is supported for now. In the future, it could be

Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -158,8 +158,6 @@
     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
 #endif
 
-    void didFinishProcessingAllPendingMouseEvents() final { }
-
     IPC::Attachment hostFileDescriptor() final;
     void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -569,9 +569,6 @@
 
     void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
 
-    void doAfterProcessingAllPendingMouseEvents(dispatch_block_t action);
-    void didFinishProcessingAllPendingMouseEvents();
-
 #if HAVE(TOUCH_BAR)
     NSTouchBar *makeTouchBar();
     void updateTouchBar();
@@ -795,7 +792,6 @@
     // that has been already sent to WebCore.
     RetainPtr<NSEvent> m_keyDownEventBeingResent;
     Vector<WebCore::KeypressCommand>* m_collectedKeypressCommands { nullptr };
-    Vector<BlockPtr<void()>> m_callbackHandlersAfterProcessingPendingMouseEvents;
 
     String m_lastStringForCandidateRequest;
     NSInteger m_lastCandidateRequestSequenceNumber;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -1462,7 +1462,6 @@
     notifyInputContextAboutDiscardedComposition();
 
     updateRemoteAccessibilityRegistration(false);
-    flushPendingMouseEventCallbacks();
 
     handleDOMPasteRequestWithResult(WebCore::DOMPasteAccessResponse::DeniedForGesture);
 }
@@ -3400,29 +3399,6 @@
     m_page->handleAcceptedCandidate(textCheckingResultFromNSTextCheckingResult(acceptedCandidate));
 }
 
-void WebViewImpl::doAfterProcessingAllPendingMouseEvents(dispatch_block_t action)
-{
-    if (!m_page->isProcessingMouseEvents()) {
-        action();
-        return;
-    }
-
-    m_callbackHandlersAfterProcessingPendingMouseEvents.append(makeBlockPtr(action));
-}
-
-void WebViewImpl::didFinishProcessingAllPendingMouseEvents()
-{
-    flushPendingMouseEventCallbacks();
-}
-
-void WebViewImpl::flushPendingMouseEventCallbacks()
-{
-    for (auto& callback : m_callbackHandlersAfterProcessingPendingMouseEvents)
-        callback();
-
-    m_callbackHandlersAfterProcessingPendingMouseEvents.clear();
-}
-
 void WebViewImpl::preferencesDidChange()
 {
     BOOL needsViewFrameInWindowCoordinates = m_page->preferences().pluginsEnabled();

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -459,8 +459,6 @@
     virtual void didHandleAcceptedCandidate() = 0;
 #endif
 
-    virtual void didFinishProcessingAllPendingMouseEvents() = 0;
-
     virtual void videoControlsManagerDidChange() { }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-01-29 00:23:03 UTC (rev 255322)
@@ -2489,6 +2489,29 @@
     send(Messages::WebPage::MouseEvent(event));
 }
 
+void WebPageProxy::doAfterProcessingAllPendingMouseEvents(WTF::Function<void ()>&& action)
+{
+    if (!isProcessingMouseEvents()) {
+        action();
+        return;
+    }
+
+    m_callbackHandlersAfterProcessingPendingMouseEvents.append(WTFMove(action));
+}
+
+void WebPageProxy::didFinishProcessingAllPendingMouseEvents()
+{
+    flushPendingMouseEventCallbacks();
+}
+
+void WebPageProxy::flushPendingMouseEventCallbacks()
+{
+    for (auto& callback : m_callbackHandlersAfterProcessingPendingMouseEvents)
+        callback();
+
+    m_callbackHandlersAfterProcessingPendingMouseEvents.clear();
+}
+
 #if MERGE_WHEEL_EVENTS
 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
 {
@@ -6681,7 +6704,7 @@
         } else {
             if (auto* automationSession = process().processPool().automationSession())
                 automationSession->mouseEventsFlushedForPage(*this);
-            pageClient().didFinishProcessingAllPendingMouseEvents();
+            didFinishProcessingAllPendingMouseEvents();
         }
 
         break;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -889,6 +889,10 @@
     void processNextQueuedMouseEvent();
     void handleMouseEvent(const NativeWebMouseEvent&);
 
+    void doAfterProcessingAllPendingMouseEvents(WTF::Function<void ()>&&);
+    void didFinishProcessingAllPendingMouseEvents();
+    void flushPendingMouseEventCallbacks();
+
     void handleWheelEvent(const NativeWebWheelEvent&);
 
     bool isProcessingKeyboardEvents() const;
@@ -2438,6 +2442,7 @@
 #if ENABLE(MAC_GESTURE_EVENTS)
     Deque<NativeWebGestureEvent> m_gestureEventQueue;
 #endif
+    Vector<WTF::Function<void ()>> m_callbackHandlersAfterProcessingPendingMouseEvents;
 
 #if ENABLE(TOUCH_EVENTS)
     struct TouchEventTracking {

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -248,8 +248,6 @@
 
     void handleAutocorrectionContext(const WebAutocorrectionContext&) final;
 
-    void didFinishProcessingAllPendingMouseEvents() final { }
-
 #if HAVE(PENCILKIT)
     RetainPtr<WKDrawingView> createDrawingView(WebCore::GraphicsLayer::EmbeddedViewID) override;
 #endif

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -250,8 +250,6 @@
     NSView *inspectorAttachmentView() override;
     _WKRemoteObjectRegistry *remoteObjectRegistry() override;
 
-    void didFinishProcessingAllPendingMouseEvents() final;
-
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     WebCore::WebMediaSessionManager& mediaSessionManager() override;
 #endif

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -919,11 +919,6 @@
     return m_impl->remoteObjectRegistry();
 }
 
-void PageClientImpl::didFinishProcessingAllPendingMouseEvents()
-{
-    m_impl->didFinishProcessingAllPendingMouseEvents();
-}
-
 void PageClientImpl::didRestoreScrollPosition()
 {
     m_impl->didRestoreScrollPosition();

Modified: trunk/Source/WebKit/UIProcess/win/PageClientImpl.h (255321 => 255322)


--- trunk/Source/WebKit/UIProcess/win/PageClientImpl.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/UIProcess/win/PageClientImpl.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -146,8 +146,6 @@
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
 
-    void didFinishProcessingAllPendingMouseEvents() final { }
-
     void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
 
     // Members of PageClientImpl class

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (255321 => 255322)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2020-01-29 00:23:03 UTC (rev 255322)
@@ -181,6 +181,8 @@
     void associateEditableImageWithAttachment(WebCore::GraphicsLayer::EmbeddedViewID, const String& attachmentID) final;
     void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
     void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
+
+    bool shouldUseMouseEventsForSelection() final;
 #endif
 
 #if ENABLE(ORIENTATION_EVENTS)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (255321 => 255322)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -181,6 +181,16 @@
 #endif
 }
 
+bool WebChromeClient::shouldUseMouseEventsForSelection()
+{
+    // In macCatalyst, despite getting mouse events, we still want UITextInteraction and friends to own selection gestures.
+#if HAVE(HOVER_GESTURE_RECOGNIZER)
+    return false;
+#else
+    return true;
+#endif
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/ChangeLog (255321 => 255322)


--- trunk/Tools/ChangeLog	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Tools/ChangeLog	2020-01-29 00:23:03 UTC (rev 255322)
@@ -1,3 +1,25 @@
+2020-01-28  Tim Horton  <timothy_hor...@apple.com>
+
+        macCatalyst: Triple clicking to select a sentence results in an empty selection
+        https://bugs.webkit.org/show_bug.cgi?id=206863
+        <rdar://problem/58776993>
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm: Added.
+        (-[WKTestingEvent locationInView:]):
+        (-[WKTestingEvent _setButtonMask:]):
+        (-[WKTestingEvent _buttonMask]):
+        (-[WKTestingTouch locationInView:]):
+        (-[WKTestingTouch setTapCount:]):
+        (-[WKTestingTouch tapCount]):
+        (mouseGesture):
+        (TEST):
+        Add a test ensuring that simply plumbing mouse events to WebCore
+        does not result in a selection change in macCatalyst (because UIKit
+        will handle the selection change itself, instead).
+
 2020-01-28  Jonathan Bedard  <jbed...@apple.com>
 
         TestWebKitAPI: Conditionalize QuickLook tests on USE(QUICK_LOOK)

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (255321 => 255322)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-01-29 00:22:17 UTC (rev 255321)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-01-29 00:23:03 UTC (rev 255322)
@@ -127,6 +127,7 @@
 		2D00065F1C1F589A0088E6A7 /* WKPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D00065D1C1F58940088E6A7 /* WKPDFView.mm */; };
 		2D01D06E23218FEE0039AA3A /* WKWebViewPrintFormatter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */; };
 		2D08E9372267D0F4002518DA /* ReparentWebViewTimeout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */; };
+		2D116E1323E0CB3A00208900 /* MacCatalystMouseSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */; };
 		2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */; };
 		2D2BEB2D22324E5F005544CA /* RequestTextInputContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */; };
 		2D2D13B3229F408B005068AF /* DeviceManagementRestrictions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2D13B2229F408B005068AF /* DeviceManagementRestrictions.mm */; };
@@ -1654,6 +1655,7 @@
 		2D00065D1C1F58940088E6A7 /* WKPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFView.mm; sourceTree = "<group>"; };
 		2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
 		2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ReparentWebViewTimeout.mm; sourceTree = "<group>"; };
+		2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacCatalystMouseSupport.mm; sourceTree = "<group>"; };
 		2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeferredViewInWindowStateChange.mm; path = WebKit/DeferredViewInWindowStateChange.mm; sourceTree = "<group>"; };
 		2D1C04A51D76298B000A6816 /* TestNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestNavigationDelegate.h; path = cocoa/TestNavigationDelegate.h; sourceTree = "<group>"; };
 		2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestNavigationDelegate.mm; path = cocoa/TestNavigationDelegate.mm; sourceTree = "<group>"; };
@@ -2969,6 +2971,7 @@
 				46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */,
 				8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */,
 				7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */,
+				2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */,
 				07CC7DFD2266330800E39181 /* MediaBufferingPolicy.mm */,
 				51BE9E652376089500B4E117 /* MediaType.mm */,
 				5165FE03201EE617009F7EC3 /* MessagePortProviders.mm */,
@@ -4812,6 +4815,7 @@
 				7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */,
 				6BF4A683239ED4CD00E2F45B /* LoggedInStatus.cpp in Sources */,
 				076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */,
+				2D116E1323E0CB3A00208900 /* MacCatalystMouseSupport.mm in Sources */,
 				CE1866491F72E8F100A0CAB6 /* MarkedText.cpp in Sources */,
 				07CC7DFE2266330900E39181 /* MediaBufferingPolicy.mm in Sources */,
 				CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm (0 => 255322)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm	2020-01-29 00:23:03 UTC (rev 255322)
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MACCATALYST)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import "UIKitSPI.h"
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivateForTesting.h>
+#import <WebKit/WebKit.h>
+#import <wtf/RetainPtr.h>
+
+@interface WKMouseGestureRecognizer : UIGestureRecognizer
+- (void)_hoverEntered:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
+- (void)_hoverExited:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
+- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
+@end
+
+@interface WKContentView ()
+- (void)_mouseGestureRecognizerChanged:(WKMouseGestureRecognizer *)gestureRecognizer;
+@end
+
+@interface WKTestingEvent : UIEvent
+@end
+
+@implementation WKTestingEvent {
+    UIEventButtonMask _buttonMask;
+}
+
+- (CGPoint)locationInView:(UIView *)view
+{
+    return CGPointMake(10, 10);
+}
+
+- (void)_setButtonMask:(UIEventButtonMask)buttonMask
+{
+    _buttonMask = buttonMask;
+}
+
+- (UIEventButtonMask)_buttonMask
+{
+    return _buttonMask;
+}
+
+@end
+
+@interface WKTestingTouch : UITouch
+@end
+
+@implementation WKTestingTouch {
+    NSUInteger _tapCount;
+}
+
+- (CGPoint)locationInView:(UIView *)view
+{
+    return CGPointMake(10, 10);
+}
+
+- (void)setTapCount:(NSUInteger)tapCount
+{
+    _tapCount = tapCount;
+}
+
+- (NSUInteger)tapCount
+{
+    return _tapCount;
+}
+
+@end
+
+static WKMouseGestureRecognizer *mouseGesture(UIView *view)
+{
+    for (UIGestureRecognizer *recognizer in view.gestureRecognizers) {
+        if ([recognizer isKindOfClass:NSClassFromString(@"WKMouseGestureRecognizer")])
+            return (WKMouseGestureRecognizer *)recognizer;
+    }
+
+    return nil;
+}
+
+TEST(MacCatalystMouseSupport, DoNotChangeSelectionWithRightClick)
+{
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+    [webView objectByEvaluatingJavaScript:@"document.body.setAttribute('contenteditable','');"];
+
+    auto contentView = [webView wkContentView];
+    auto gesture = mouseGesture(contentView);
+
+    RetainPtr<WKTestingTouch> touch = adoptNS([[WKTestingTouch alloc] init]);
+    RetainPtr<NSSet> touchSet = [NSSet setWithObject:touch.get()];
+
+    RetainPtr<WKTestingEvent> event = adoptNS([[WKTestingEvent alloc] init]);
+
+    [gesture _hoverEntered:touchSet.get() withEvent:event.get()];
+    [contentView _mouseGestureRecognizerChanged:gesture];
+    [touch setTapCount:1];
+    [event _setButtonMask:UIEventButtonMaskSecondary];
+    [gesture touchesBegan:touchSet.get() withEvent:event.get()];
+    [contentView _mouseGestureRecognizerChanged:gesture];
+    [gesture touchesEnded:touchSet.get() withEvent:event.get()];
+    [contentView _mouseGestureRecognizerChanged:gesture];
+
+    __block bool done = false;
+
+    [webView _doAfterProcessingAllPendingMouseEvents:^{
+        NSNumber *result = [webView objectByEvaluatingJavaScript:@"window.getSelection().isCollapsed"];
+        EXPECT_TRUE([result boolValue]);
+        done = true;
+    }];
+
+    TestWebKitAPI::Util::run(&done);
+}
+
+#endif // PLATFORM(MACCATALYST)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to