Changeset 181660 in webkit


Ignore:
Timestamp:
Mar 17, 2015 1:20:48 PM (9 years ago)
Author:
Beth Dakin
Message:

DOM mouse events have weird timing for force clickable elements in Safari 8.0.3 on
10.10.2
https://bugs.webkit.org/show_bug.cgi?id=142700
-and corresponding-
rdar://problem/20165168

Reviewed by Tim Horton.

Source/WebCore:

This patch adds a new enum and member variable so that EventHandler can keep track
of the current immediate action state.

  • page/EventHandler.cpp:

(WebCore::EventHandler::EventHandler):

A new mouse press even is starting. We can re-set m_immediateActionStage to none
unless a Hit Test has already been performed.
(WebCore::EventHandler::handleMousePressEvent):

If an immediate action was completed, then send mouse to the DOM and return early.
This will prevent us from doing our own normal mouseup behaviors such as
navigating to a link that was clicked — we only want to do that if the click was
not used to perform an immediate action.
(WebCore::EventHandler::handleMouseReleaseEvent):

  • page/EventHandler.h:

(WebCore::EventHandler::setImmediateActionStage):

Source/WebKit2:

No need to tell the WKImmediateActionController about mouse down any more since we
are expecting it at the beginning of an immediate action interaction.

  • UIProcess/API/mac/WKView.mm:

(-[WKView mouseDown:]):

Set the delaysPrimaryMouseButtonEvents to NO for the
_immediateActionGestureRecognizer. This will cause AppKit to send up the mouse
events at the expected time.
(-[WKView initWithFrame:processPool:configuration:webView:]):

WebCore::EventHandler now needs to know if an immediate action cancelled or
completed. This plumbs that information down.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::immediateActionDidCancel):
(WebKit::WebPageProxy::immediateActionDidComplete):

  • UIProcess/WebPageProxy.h:
  • UIProcess/mac/WKImmediateActionController.h:
  • UIProcess/mac/WKImmediateActionController.mm:

(-[WKImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
(-[WKImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
(-[WKImmediateActionController wkView:willHandleMouseDown:]): Deleted.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

Call EventHandler::setImmediateActionStage() with the appropriate stage.

  • WebProcess/WebPage/mac/WebPageMac.mm:

(WebKit::WebPage::performActionMenuHitTestAtLocation):
(WebKit::WebPage::immediateActionDidCancel):
(WebKit::WebPage::immediateActionDidComplete):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181658 r181660  
     12015-03-17  Beth Dakin  <bdakin@apple.com>
     2
     3        DOM mouse events have weird timing for force clickable elements in Safari 8.0.3 on
     4        10.10.2
     5        https://bugs.webkit.org/show_bug.cgi?id=142700
     6        -and corresponding-
     7        rdar://problem/20165168
     8
     9        Reviewed by Tim Horton.
     10
     11        This patch adds a new enum and member variable so that EventHandler can keep track
     12        of the current immediate action state.
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::EventHandler):
     15
     16        A new mouse press even is starting. We can re-set m_immediateActionStage to none
     17        unless a Hit Test has already been performed.
     18        (WebCore::EventHandler::handleMousePressEvent):
     19
     20        If an immediate action was completed, then send mouse to the DOM and return early.
     21        This will prevent us from doing our own normal mouseup behaviors such as
     22        navigating to a link that was clicked — we only want to do that if the click was
     23        not used to perform an immediate action.
     24        (WebCore::EventHandler::handleMouseReleaseEvent):
     25        * page/EventHandler.h:
     26        (WebCore::EventHandler::setImmediateActionStage):
     27
    1282015-03-17  Joseph Pecoraro  <pecoraro@apple.com>
    229
  • trunk/Source/WebCore/page/EventHandler.cpp

    r181484 r181660  
    424424    , m_autoHideCursorTimer(*this, &EventHandler::autoHideCursorTimerFired)
    425425#endif
     426    , m_immediateActionStage(ImmediateActionStage::None)
    426427{
    427428}
     
    764765
    765766    m_mouseDown = event.event();
     767
     768    if (m_immediateActionStage != ImmediateActionStage::PerformedHitTest)
     769        m_immediateActionStage = ImmediateActionStage::None;
    766770
    767771    if (event.isOverWidget() && passWidgetMouseDownEventToWidget(event))
     
    20582062        return !dispatchMouseEvent(eventNames().mouseupEvent, m_frameSetBeingResized.get(), true, m_clickCount, platformMouseEvent, false);
    20592063
     2064    // If an immediate action was completed using this series of mouse events, then we should send mouseup to
     2065    // the DOM and return now so that we don't perform our own default behaviors.
     2066    if (m_immediateActionStage == ImmediateActionStage::ActionCompleted) {
     2067        m_immediateActionStage = ImmediateActionStage::None;
     2068        return !dispatchMouseEvent(eventNames().mouseupEvent, m_lastElementUnderMouse.get(), true, m_clickCount, platformMouseEvent, false);
     2069    }
     2070    m_immediateActionStage = ImmediateActionStage::None;
     2071
    20602072    if (m_lastScrollbarUnderMouse) {
    20612073        invalidateClick();
  • trunk/Source/WebCore/page/EventHandler.h

    r181484 r181660  
    118118enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
    119119
     120enum class ImmediateActionStage {
     121    None,
     122    PerformedHitTest,
     123    ActionCancelled,
     124    ActionCompleted
     125};
     126
    120127class EventHandler {
    121128    WTF_MAKE_NONCOPYABLE(EventHandler);
     
    306313    bool isHandlingWheelEvent() const { return m_isHandlingWheelEvent; }
    307314
     315    WEBCORE_EXPORT void setImmediateActionStage(ImmediateActionStage stage) { m_immediateActionStage = stage; }
     316
    308317private:
    309318#if ENABLE(DRAG_SUPPORT)
     
    565574    Timer m_autoHideCursorTimer;
    566575#endif
     576
     577    ImmediateActionStage m_immediateActionStage;
    567578};
    568579
  • trunk/Source/WebKit2/ChangeLog

    r181656 r181660  
     12015-03-17  Beth Dakin  <bdakin@apple.com>
     2
     3        DOM mouse events have weird timing for force clickable elements in Safari 8.0.3 on
     4        10.10.2
     5        https://bugs.webkit.org/show_bug.cgi?id=142700
     6        -and corresponding-
     7        rdar://problem/20165168
     8
     9        Reviewed by Tim Horton.
     10
     11        No need to tell the WKImmediateActionController about mouse down any more since we
     12        are expecting it at the beginning of an immediate action interaction.
     13        * UIProcess/API/mac/WKView.mm:
     14        (-[WKView mouseDown:]):
     15
     16        Set the delaysPrimaryMouseButtonEvents to NO for the
     17        _immediateActionGestureRecognizer. This will cause AppKit to send up the mouse
     18        events at the expected time.
     19        (-[WKView initWithFrame:processPool:configuration:webView:]):
     20
     21        WebCore::EventHandler now needs to know if an immediate action cancelled or
     22        completed. This plumbs that information down.
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::WebPageProxy::immediateActionDidCancel):
     25        (WebKit::WebPageProxy::immediateActionDidComplete):
     26        * UIProcess/WebPageProxy.h:
     27        * UIProcess/mac/WKImmediateActionController.h:
     28        * UIProcess/mac/WKImmediateActionController.mm:
     29        (-[WKImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
     30        (-[WKImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
     31        (-[WKImmediateActionController wkView:willHandleMouseDown:]): Deleted.
     32        * WebProcess/WebPage/WebPage.h:
     33        * WebProcess/WebPage/WebPage.messages.in:
     34
     35        Call EventHandler::setImmediateActionStage() with the appropriate stage.
     36        * WebProcess/WebPage/mac/WebPageMac.mm:
     37        (WebKit::WebPage::performActionMenuHitTestAtLocation):
     38        (WebKit::WebPage::immediateActionDidCancel):
     39        (WebKit::WebPage::immediateActionDidComplete):
     40
    1412015-03-17  Timothy Horton  <timothy_horton@apple.com>
    242
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r181176 r181660  
    12751275#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    12761276    [_data->_actionMenuController wkView:self willHandleMouseDown:event];
    1277     [_data->_immediateActionController wkView:self willHandleMouseDown:event];
    12781277#endif
    12791278    [self mouseDownInternal:event];
     
    36673666        _data->_immediateActionController = adoptNS([[WKImmediateActionController alloc] initWithPage:*_data->_page view:self recognizer:_data->_immediateActionGestureRecognizer.get()]);
    36683667        [_data->_immediateActionGestureRecognizer setDelegate:_data->_immediateActionController.get()];
     3668        [_data->_immediateActionGestureRecognizer setDelaysPrimaryMouseButtonEvents:NO];
    36693669    }
    36703670#endif
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r181423 r181660  
    55665566}
    55675567
     5568void WebPageProxy::immediateActionDidCancel()
     5569{
     5570    m_process->send(Messages::WebPage::ImmediateActionDidCancel(), m_pageID);
     5571}
     5572
     5573void WebPageProxy::immediateActionDidComplete()
     5574{
     5575    m_process->send(Messages::WebPage::ImmediateActionDidComplete(), m_pageID);
     5576}
     5577
    55685578void WebPageProxy::didPerformActionMenuHitTest(const ActionMenuHitTestResult& result, bool forImmediateAction, const UserData& userData)
    55695579{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r181423 r181660  
    986986    void focusAndSelectLastActionMenuHitTestResult();
    987987
     988    void immediateActionDidCancel();
     989    void immediateActionDidComplete();
     990
    988991    void installViewStateChangeCompletionHandler(void(^completionHandler)());
    989992#endif
  • trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h

    r181176 r181660  
    7070- (void)willDestroyView:(WKView *)view;
    7171- (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData;
    72 - (void)wkView:(WKView *)wkView willHandleMouseDown:(NSEvent *)event;
    7372- (void)dismissContentRelativeChildWindows;
    7473- (BOOL)hasActiveImmediateAction;
  • trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm

    r181176 r181660  
    8989}
    9090
    91 - (void)wkView:(WKView *)wkView willHandleMouseDown:(NSEvent *)event
    92 {
    93     [self _clearImmediateActionState];
    94 }
    95 
    9691- (void)_cancelImmediateAction
    9792{
     
    219214        return;
    220215
     216    _page->immediateActionDidCancel();
     217
    221218    [_wkView _cancelImmediateActionAnimation];
    222219
     
    230227    if (immediateActionRecognizer != _immediateActionRecognizer)
    231228        return;
     229
     230    _page->immediateActionDidComplete();
    232231
    233232    [_wkView _completeImmediateActionAnimation];
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r181442 r181660  
    10851085    void selectLastActionMenuRange();
    10861086    void focusAndSelectLastActionMenuHitTestResult();
     1087    void immediateActionDidCancel();
     1088    void immediateActionDidComplete();
    10871089    void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
    10881090
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r181442 r181660  
    406406    SelectLastActionMenuRange()
    407407    FocusAndSelectLastActionMenuHitTestResult()
     408    ImmediateActionDidCancel()
     409    ImmediateActionDidComplete()
    408410    DataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
    409411    DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r181442 r181660  
    10251025    HitTestResult hitTestResult = mainFrame.eventHandler().hitTestResultAtPoint(locationInContentCoordinates);
    10261026
     1027    if (forImmediateAction)
     1028        mainFrame.eventHandler().setImmediateActionStage(ImmediateActionStage::PerformedHitTest);
     1029
    10271030    ActionMenuHitTestResult actionMenuResult;
    10281031    actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
     
    11461149}
    11471150
     1151void WebPage::immediateActionDidCancel()
     1152{
     1153    m_page->mainFrame().eventHandler().setImmediateActionStage(ImmediateActionStage::ActionCancelled);
     1154}
     1155
     1156void WebPage::immediateActionDidComplete()
     1157{
     1158    m_page->mainFrame().eventHandler().setImmediateActionStage(ImmediateActionStage::ActionCompleted);
     1159}
     1160
    11481161void WebPage::dataDetectorsDidPresentUI(PageOverlay::PageOverlayID overlayID)
    11491162{
Note: See TracChangeset for help on using the changeset viewer.