Changeset 255322 in webkit


Ignore:
Timestamp:
Jan 28, 2020 4:23:03 PM (4 years ago)
Author:
timothy_horton@apple.com
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).

Location:
trunk
Files:
1 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r255318 r255322  
     12020-01-28  Tim Horton  <timothy_horton@apple.com>
     2
     3        macCatalyst: Triple clicking to select a sentence results in an empty selection
     4        https://bugs.webkit.org/show_bug.cgi?id=206863
     5        <rdar://problem/58776993>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * editing/EditingBehavior.h:
     10        (WebCore::EditingBehavior::shouldSelectOnContextualMenuClick const):
     11        * page/ChromeClient.h:
     12        (WebCore::ChromeClient::shouldUseMouseEventsForSelection):
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::canMouseDownStartSelect):
     15        (WebCore::canMouseDownStartSelect): Deleted.
     16        * page/EventHandler.h:
     17        Disable WebCore's mouse-event-driven selection mechanisms on macCatalyst,
     18        where we use a UITextInteraction-driven selection instead. Otherwise,
     19        they conflict with each other in a chaotic fashion.
     20
    1212020-01-28  Sihui Liu  <sihui_liu@apple.com>
    222
  • trunk/Source/WebCore/editing/EditingBehavior.h

    r243124 r255322  
    6161
    6262    // On Mac, when processing a contextual click, the object being clicked upon should be selected.
    63     bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
     63    bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; }
    6464
    6565    // On Linux, should be able to get and insert spelling suggestions without selecting the misspelled word.
  • trunk/Source/WebCore/page/ChromeClient.h

    r253636 r255322  
    194194    virtual bool supportsSettingCursor() { return true; }
    195195
     196    virtual bool shouldUseMouseEventsForSelection() { return true; }
     197
    196198    virtual FloatSize screenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
    197199    virtual FloatSize availableScreenSize() const { return const_cast<ChromeClient&>(*this).windowRect().size(); }
  • trunk/Source/WebCore/page/EventHandler.cpp

    r255128 r255322  
    732732}
    733733
    734 static inline bool canMouseDownStartSelect(Node* node)
    735 {
     734bool EventHandler::canMouseDownStartSelect(Node* node)
     735{
     736    if (Page* page = m_frame.page()) {
     737        if (!page->chrome().client().shouldUseMouseEventsForSelection())
     738            return false;
     739    }
     740   
    736741    if (!node || !node->renderer())
    737742        return true;
  • trunk/Source/WebCore/page/EventHandler.h

    r255128 r255322  
    501501    bool shouldSendMouseEventsToInactiveWindows() const;
    502502
     503    bool canMouseDownStartSelect(Node*);
     504
    503505    Frame& m_frame;
    504506
  • trunk/Source/WebKit/ChangeLog

    r255313 r255322  
     12020-01-28  Tim Horton  <timothy_horton@apple.com>
     2
     3        macCatalyst: Triple clicking to select a sentence results in an empty selection
     4        https://bugs.webkit.org/show_bug.cgi?id=206863
     5        <rdar://problem/58776993>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
     10        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
     11        (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]):
     12        * UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
     13        * UIProcess/API/mac/WKWebViewTestingMac.mm:
     14        (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): Deleted.
     15        * UIProcess/Cocoa/WebViewImpl.h:
     16        * UIProcess/Cocoa/WebViewImpl.mm:
     17        (WebKit::WebViewImpl::handleProcessSwapOrExit):
     18        (WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents): Deleted.
     19        (WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
     20        (WebKit::WebViewImpl::flushPendingMouseEventCallbacks): Deleted.
     21        * UIProcess/PageClient.h:
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::doAfterProcessingAllPendingMouseEvents):
     24        (WebKit::WebPageProxy::didFinishProcessingAllPendingMouseEvents):
     25        (WebKit::WebPageProxy::flushPendingMouseEventCallbacks):
     26        * UIProcess/WebPageProxy.h:
     27        * UIProcess/ios/PageClientImplIOS.h:
     28        * UIProcess/mac/PageClientImplMac.h:
     29        * UIProcess/mac/PageClientImplMac.mm:
     30        (WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents): Deleted.
     31        Move "doAfterProcessingAllPendingMouseEvents" to WebPage instead of WebViewImpl,
     32        so it can be used on all platforms. Expose it via WKWebView.
     33
     34        * WebProcess/WebCoreSupport/WebChromeClient.h:
     35        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
     36        (WebKit::WebChromeClient::shouldUseMouseEventsForSelection):
     37
    1382020-01-28  Andres Gonzalez  <andresg_22@apple.com>
    239
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h

    r255271 r255322  
    6060- (void)_setAssertionStateForTesting:(int)state;
    6161
     62- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action;
     63
    6264+ (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier;
    6365+ (void)_clearApplicationBundleIdentifierTestingOverride;
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm

    r255271 r255322  
    204204}
    205205
     206- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action
     207{
     208    _page->doAfterProcessingAllPendingMouseEvents([action = makeBlockPtr(action)] {
     209        action();
     210    });
     211}
     212
    206213+ (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier
    207214{
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h

    r250645 r255322  
    157157    void isPlayingAudioDidChange() final { }
    158158
    159     void didFinishProcessingAllPendingMouseEvents() final { }
    160 
    161159    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
    162160
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h

    r253465 r255322  
    5151- (void)_setHeaderBannerHeight:(int)height;
    5252- (void)_setFooterBannerHeight:(int)height;
    53 - (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action;
    5453
    5554@end
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm

    r253527 r255322  
    102102}
    103103
    104 - (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action
    105 {
    106     _impl->doAfterProcessingAllPendingMouseEvents(action);
    107 }
    108 
    109104- (NSMenu *)_activeMenu
    110105{
  • trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h

    r254121 r255322  
    159159#endif
    160160
    161     void didFinishProcessingAllPendingMouseEvents() final { }
    162 
    163161    IPC::Attachment hostFileDescriptor() final;
    164162    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r254213 r255322  
    570570    void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
    571571
    572     void doAfterProcessingAllPendingMouseEvents(dispatch_block_t action);
    573     void didFinishProcessingAllPendingMouseEvents();
    574 
    575572#if HAVE(TOUCH_BAR)
    576573    NSTouchBar *makeTouchBar();
     
    796793    RetainPtr<NSEvent> m_keyDownEventBeingResent;
    797794    Vector<WebCore::KeypressCommand>* m_collectedKeypressCommands { nullptr };
    798     Vector<BlockPtr<void()>> m_callbackHandlersAfterProcessingPendingMouseEvents;
    799795
    800796    String m_lastStringForCandidateRequest;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r254312 r255322  
    14631463
    14641464    updateRemoteAccessibilityRegistration(false);
    1465     flushPendingMouseEventCallbacks();
    14661465
    14671466    handleDOMPasteRequestWithResult(WebCore::DOMPasteAccessResponse::DeniedForGesture);
     
    34013400}
    34023401
    3403 void WebViewImpl::doAfterProcessingAllPendingMouseEvents(dispatch_block_t action)
    3404 {
    3405     if (!m_page->isProcessingMouseEvents()) {
    3406         action();
    3407         return;
    3408     }
    3409 
    3410     m_callbackHandlersAfterProcessingPendingMouseEvents.append(makeBlockPtr(action));
    3411 }
    3412 
    3413 void WebViewImpl::didFinishProcessingAllPendingMouseEvents()
    3414 {
    3415     flushPendingMouseEventCallbacks();
    3416 }
    3417 
    3418 void WebViewImpl::flushPendingMouseEventCallbacks()
    3419 {
    3420     for (auto& callback : m_callbackHandlersAfterProcessingPendingMouseEvents)
    3421         callback();
    3422 
    3423     m_callbackHandlersAfterProcessingPendingMouseEvents.clear();
    3424 }
    3425 
    34263402void WebViewImpl::preferencesDidChange()
    34273403{
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r253749 r255322  
    460460#endif
    461461
    462     virtual void didFinishProcessingAllPendingMouseEvents() = 0;
    463 
    464462    virtual void videoControlsManagerDidChange() { }
    465463
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r255135 r255322  
    24902490}
    24912491
     2492void WebPageProxy::doAfterProcessingAllPendingMouseEvents(WTF::Function<void ()>&& action)
     2493{
     2494    if (!isProcessingMouseEvents()) {
     2495        action();
     2496        return;
     2497    }
     2498
     2499    m_callbackHandlersAfterProcessingPendingMouseEvents.append(WTFMove(action));
     2500}
     2501
     2502void WebPageProxy::didFinishProcessingAllPendingMouseEvents()
     2503{
     2504    flushPendingMouseEventCallbacks();
     2505}
     2506
     2507void WebPageProxy::flushPendingMouseEventCallbacks()
     2508{
     2509    for (auto& callback : m_callbackHandlersAfterProcessingPendingMouseEvents)
     2510        callback();
     2511
     2512    m_callbackHandlersAfterProcessingPendingMouseEvents.clear();
     2513}
     2514
    24922515#if MERGE_WHEEL_EVENTS
    24932516static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
     
    66826705            if (auto* automationSession = process().processPool().automationSession())
    66836706                automationSession->mouseEventsFlushedForPage(*this);
    6684             pageClient().didFinishProcessingAllPendingMouseEvents();
     6707            didFinishProcessingAllPendingMouseEvents();
    66856708        }
    66866709
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r255135 r255322  
    890890    void handleMouseEvent(const NativeWebMouseEvent&);
    891891
     892    void doAfterProcessingAllPendingMouseEvents(WTF::Function<void ()>&&);
     893    void didFinishProcessingAllPendingMouseEvents();
     894    void flushPendingMouseEventCallbacks();
     895
    892896    void handleWheelEvent(const NativeWebWheelEvent&);
    893897
     
    24392443    Deque<NativeWebGestureEvent> m_gestureEventQueue;
    24402444#endif
     2445    Vector<WTF::Function<void ()>> m_callbackHandlersAfterProcessingPendingMouseEvents;
    24412446
    24422447#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r254025 r255322  
    249249    void handleAutocorrectionContext(const WebAutocorrectionContext&) final;
    250250
    251     void didFinishProcessingAllPendingMouseEvents() final { }
    252 
    253251#if HAVE(PENCILKIT)
    254252    RetainPtr<WKDrawingView> createDrawingView(WebCore::GraphicsLayer::EmbeddedViewID) override;
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r250973 r255322  
    251251    _WKRemoteObjectRegistry *remoteObjectRegistry() override;
    252252
    253     void didFinishProcessingAllPendingMouseEvents() final;
    254 
    255253#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    256254    WebCore::WebMediaSessionManager& mediaSessionManager() override;
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r253465 r255322  
    920920}
    921921
    922 void PageClientImpl::didFinishProcessingAllPendingMouseEvents()
    923 {
    924     m_impl->didFinishProcessingAllPendingMouseEvents();
    925 }
    926 
    927922void PageClientImpl::didRestoreScrollPosition()
    928923{
  • trunk/Source/WebKit/UIProcess/win/PageClientImpl.h

    r243847 r255322  
    147147    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
    148148
    149     void didFinishProcessingAllPendingMouseEvents() final { }
    150 
    151149    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
    152150
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r253636 r255322  
    182182    void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
    183183    void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
     184
     185    bool shouldUseMouseEventsForSelection() final;
    184186#endif
    185187
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm

    r247926 r255322  
    182182}
    183183
     184bool WebChromeClient::shouldUseMouseEventsForSelection()
     185{
     186    // In macCatalyst, despite getting mouse events, we still want UITextInteraction and friends to own selection gestures.
     187#if HAVE(HOVER_GESTURE_RECOGNIZER)
     188    return false;
     189#else
     190    return true;
     191#endif
     192}
     193
    184194} // namespace WebKit
    185195
  • trunk/Tools/ChangeLog

    r255320 r255322  
     12020-01-28  Tim Horton  <timothy_horton@apple.com>
     2
     3        macCatalyst: Triple clicking to select a sentence results in an empty selection
     4        https://bugs.webkit.org/show_bug.cgi?id=206863
     5        <rdar://problem/58776993>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm: Added.
     11        (-[WKTestingEvent locationInView:]):
     12        (-[WKTestingEvent _setButtonMask:]):
     13        (-[WKTestingEvent _buttonMask]):
     14        (-[WKTestingTouch locationInView:]):
     15        (-[WKTestingTouch setTapCount:]):
     16        (-[WKTestingTouch tapCount]):
     17        (mouseGesture):
     18        (TEST):
     19        Add a test ensuring that simply plumbing mouse events to WebCore
     20        does not result in a selection change in macCatalyst (because UIKit
     21        will handle the selection change itself, instead).
     22
    1232020-01-28  Jonathan Bedard  <jbedard@apple.com>
    224
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r255318 r255322  
    128128                2D01D06E23218FEE0039AA3A /* WKWebViewPrintFormatter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */; };
    129129                2D08E9372267D0F4002518DA /* ReparentWebViewTimeout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */; };
     130                2D116E1323E0CB3A00208900 /* MacCatalystMouseSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */; };
    130131                2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */; };
    131132                2D2BEB2D22324E5F005544CA /* RequestTextInputContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */; };
     
    16551656                2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
    16561657                2D08E9362267D0F3002518DA /* ReparentWebViewTimeout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ReparentWebViewTimeout.mm; sourceTree = "<group>"; };
     1658                2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacCatalystMouseSupport.mm; sourceTree = "<group>"; };
    16571659                2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeferredViewInWindowStateChange.mm; path = WebKit/DeferredViewInWindowStateChange.mm; sourceTree = "<group>"; };
    16581660                2D1C04A51D76298B000A6816 /* TestNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestNavigationDelegate.h; path = cocoa/TestNavigationDelegate.h; sourceTree = "<group>"; };
     
    29702972                                8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */,
    29712973                                7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */,
     2974                                2D116E1223E0CB3900208900 /* MacCatalystMouseSupport.mm */,
    29722975                                07CC7DFD2266330800E39181 /* MediaBufferingPolicy.mm */,
    29732976                                51BE9E652376089500B4E117 /* MediaType.mm */,
     
    48134816                                6BF4A683239ED4CD00E2F45B /* LoggedInStatus.cpp in Sources */,
    48144817                                076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */,
     4818                                2D116E1323E0CB3A00208900 /* MacCatalystMouseSupport.mm in Sources */,
    48154819                                CE1866491F72E8F100A0CAB6 /* MarkedText.cpp in Sources */,
    48164820                                07CC7DFE2266330900E39181 /* MediaBufferingPolicy.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.