Changeset 183954 in webkit


Ignore:
Timestamp:
May 7, 2015 3:32:07 PM (9 years ago)
Author:
Beth Dakin
Message:

New force-related DOM events should fire in WK1 views
https://bugs.webkit.org/show_bug.cgi?id=144663
-and corresponding-
rdar://problem/20281886

Reviewed by Sam Weinig.

Source/WebCore:

All of the WK1 mouse events need to take the correspondingPressureEvent.

  • page/EventHandler.h:

Make correspondingPressureEvent a part of CurrentEventScope. This is needed to
have accurate pressure information for all of the mouse events in subframes.

  • page/mac/EventHandlerMac.mm:

(WebCore::correspondingPressureEventSlot):
(WebCore::EventHandler::correspondingPressureEvent):
(WebCore::CurrentEventScope::CurrentEventScope):
(WebCore::CurrentEventScope::~CurrentEventScope):

These events don’t have an associated pressure, so send nil for the
correspondingPressureEvent.
(WebCore::EventHandler::wheelEvent):
(WebCore::EventHandler::keyEvent):

Pipe through correspondingPressureEvent.
(WebCore::EventHandler::mouseDown):
(WebCore::EventHandler::mouseDragged):
(WebCore::EventHandler::mouseUp):
(WebCore::EventHandler::mouseMoved):

New function to handle pressure change events.
(WebCore::EventHandler::pressureChange):

Pipe through correspondingPressureEvent.
(WebCore::EventHandler::passMouseMovedEventToScrollbars):
(WebCore::EventHandler::currentPlatformMouseEvent):

Take the correspondingPressureEvent in order to build a PlatformMouseEvent with
the correct pressure information.

  • platform/mac/PlatformEventFactoryMac.h:
  • platform/mac/PlatformEventFactoryMac.mm:

(WebCore::globalPointForEvent):
(WebCore::pointForEvent):
(WebCore::mouseButtonForEvent):
(WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
(WebCore::PlatformEventFactory::createPlatformMouseEvent):

Source/WebKit:

Pass the lastPressureEvent to WebCore.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _updateMouseoverWithEvent:]):
(-[WebHTMLView rightMouseUp:]):
(-[WebHTMLView menuForEvent:]):
(-[WebHTMLView acceptsFirstMouse:]):
(-[WebHTMLView shouldDelayWindowOrderingForEvent:]):
(-[WebHTMLView mouseDown:mouseDown:]):
(-[WebHTMLView mouseDragged:]):
(-[WebHTMLView mouseUp:mouseUp:]):

New NSRespnder method for pressure changes.
(-[WebHTMLView pressureChangeWithEvent:]):

New BOOL _contentPreventsDefault tracks whether the HitTestResult prevented the
default action. Get rid of willHandleMouseDown; now that the gesture recognizer
sets delaysPrimaryMouseButtonEvents to NO, we don’t need this.

  • WebView/WebImmediateActionController.h:
  • WebView/WebImmediateActionController.mm:

(-[WebImmediateActionController _clearImmediateActionState]):

Set all of the immediateActionStages on EventHandler. This is critical to keep
link navigation happening at the right time now that
delaysPrimaryMouseButtonEvents is set to NO.
(-[WebImmediateActionController performHitTestAtPoint:]):
(-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):

Use a dummy animation controller if the content prevents default.
(-[WebImmediateActionController _defaultAnimationController]):
(-[WebImmediateActionController _updateImmediateActionItem]):
(-[WebImmediateActionController webView:willHandleMouseDown:]): Deleted.

Set delaysPrimaryMouseButtonEvents to NO so that we get existing mouse events when
we expect to.

  • WebView/WebView.mm:

(-[WebView _commonInitializationWithFrameName:groupName:]):

Cache the most recent pressure event so that we can send it to WebCore for all of
the mouse events.
(-[WebView _pressureEvent]):
(-[WebView _setPressureEvent:]):

  • WebView/WebViewData.h:
  • WebView/WebViewData.mm:

(-[WebViewPrivate dealloc]):

  • WebView/WebViewInternal.h:

Source/WebKit/mac:

Pass the lastPressureEvent to WebCore.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _updateMouseoverWithEvent:]):
(-[WebHTMLView rightMouseUp:]):
(-[WebHTMLView menuForEvent:]):
(-[WebHTMLView acceptsFirstMouse:]):
(-[WebHTMLView shouldDelayWindowOrderingForEvent:]):
(-[WebHTMLView mouseDown:mouseDown:]):
(-[WebHTMLView mouseDragged:]):
(-[WebHTMLView mouseUp:mouseUp:]):

New NSRespnder method for pressure changes.
(-[WebHTMLView pressureChangeWithEvent:]):

New BOOL _contentPreventsDefault tracks whether the HitTestResult prevented the
default action. Get rid of willHandleMouseDown; now that the gesture recognizer
sets delaysPrimaryMouseButtonEvents to NO, we don’t need this.

  • WebView/WebImmediateActionController.h:
  • WebView/WebImmediateActionController.mm:

(-[WebImmediateActionController _clearImmediateActionState]):

Set all of the immediateActionStages on EventHandler. This is critical to keep
link navigation happening at the right time now that
delaysPrimaryMouseButtonEvents is set to NO.
(-[WebImmediateActionController performHitTestAtPoint:]):
(-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):

Use a dummy animation controller if the content prevents default.
(-[WebImmediateActionController _defaultAnimationController]):
(-[WebImmediateActionController _updateImmediateActionItem]):
(-[WebImmediateActionController webView:willHandleMouseDown:]): Deleted.

Set delaysPrimaryMouseButtonEvents to NO so that we get existing mouse events when
we expect to.

  • WebView/WebView.mm:

(-[WebView _commonInitializationWithFrameName:groupName:]):

Cache the most recent pressure event so that we can send it to WebCore for all of
the mouse events.
(-[WebView _pressureEvent]):
(-[WebView _setPressureEvent:]):

  • WebView/WebViewData.h:
  • WebView/WebViewData.mm:

(-[WebViewPrivate dealloc]):

  • WebView/WebViewInternal.h:

Tools:

PlatformEventFactory::createPlatformMouseEvent() takes the last pressure event
now. Just send nil.

  • TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:

(TestWebKitAPI::buildAndPerformTest):

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183953 r183954  
     12015-05-07  Beth Dakin  <bdakin@apple.com>
     2
     3        New force-related DOM events should fire in WK1 views
     4        https://bugs.webkit.org/show_bug.cgi?id=144663
     5        -and corresponding-
     6        rdar://problem/20281886
     7
     8        Reviewed by Sam Weinig.
     9
     10        All of the WK1 mouse events need to take the correspondingPressureEvent.
     11        * page/EventHandler.h:
     12
     13        Make correspondingPressureEvent a part of CurrentEventScope. This is needed to
     14        have accurate pressure information for all of the mouse events in subframes.
     15        * page/mac/EventHandlerMac.mm:
     16        (WebCore::correspondingPressureEventSlot):
     17        (WebCore::EventHandler::correspondingPressureEvent):
     18        (WebCore::CurrentEventScope::CurrentEventScope):
     19        (WebCore::CurrentEventScope::~CurrentEventScope):
     20
     21        These events don’t have an associated pressure, so send nil for the
     22        correspondingPressureEvent.
     23        (WebCore::EventHandler::wheelEvent):
     24        (WebCore::EventHandler::keyEvent):
     25
     26        Pipe through correspondingPressureEvent.
     27        (WebCore::EventHandler::mouseDown):
     28        (WebCore::EventHandler::mouseDragged):
     29        (WebCore::EventHandler::mouseUp):
     30        (WebCore::EventHandler::mouseMoved):
     31
     32        New function to handle pressure change events.
     33        (WebCore::EventHandler::pressureChange):
     34
     35        Pipe through correspondingPressureEvent.
     36        (WebCore::EventHandler::passMouseMovedEventToScrollbars):
     37        (WebCore::EventHandler::currentPlatformMouseEvent):
     38
     39        Take the correspondingPressureEvent in order to build a PlatformMouseEvent with
     40        the correct pressure information.
     41        * platform/mac/PlatformEventFactoryMac.h:
     42        * platform/mac/PlatformEventFactoryMac.mm:
     43        (WebCore::globalPointForEvent):
     44        (WebCore::pointForEvent):
     45        (WebCore::mouseButtonForEvent):
     46        (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
     47        (WebCore::PlatformEventFactory::createPlatformMouseEvent):
     48
    1492015-05-06  Roger Fong  <roger_fong@apple.com>
    250
  • trunk/Source/WebCore/page/EventHandler.h

    r183138 r183954  
    267267#if PLATFORM(COCOA) && defined(__OBJC__)
    268268#if !PLATFORM(IOS)
    269     WEBCORE_EXPORT void mouseDown(NSEvent *);
    270     WEBCORE_EXPORT void mouseDragged(NSEvent *);
    271     WEBCORE_EXPORT void mouseUp(NSEvent *);
    272     WEBCORE_EXPORT void mouseMoved(NSEvent *);
     269    WEBCORE_EXPORT void mouseDown(NSEvent *, NSEvent *correspondingPressureEvent);
     270    WEBCORE_EXPORT void mouseDragged(NSEvent *, NSEvent *correspondingPressureEvent);
     271    WEBCORE_EXPORT void mouseUp(NSEvent *, NSEvent *correspondingPressureEvent);
     272    WEBCORE_EXPORT void mouseMoved(NSEvent *, NSEvent *correspondingPressureEvent);
     273    WEBCORE_EXPORT void pressureChange(NSEvent *, NSEvent* correspondingPressureEvent);
    273274    WEBCORE_EXPORT bool keyEvent(NSEvent *);
    274275    WEBCORE_EXPORT bool wheelEvent(NSEvent *);
     
    286287
    287288#if !PLATFORM(IOS)
    288     WEBCORE_EXPORT void passMouseMovedEventToScrollbars(NSEvent *);
     289    WEBCORE_EXPORT void passMouseMovedEventToScrollbars(NSEvent *, NSEvent* correspondingPressureEvent);
    289290
    290291    WEBCORE_EXPORT void sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent);
     
    295296
    296297    WEBCORE_EXPORT static NSEvent *currentNSEvent();
     298    static NSEvent *correspondingPressureEvent();
    297299#else
    298300    static WebEvent *currentEvent();
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r183595 r183954  
    8282}
    8383
     84static RetainPtr<NSEvent>& correspondingPressureEventSlot()
     85{
     86    static NeverDestroyed<RetainPtr<NSEvent>> event;
     87    return event;
     88}
     89
     90NSEvent *EventHandler::correspondingPressureEvent()
     91{
     92    return correspondingPressureEventSlot().get();
     93}
     94
    8495class CurrentEventScope {
    8596     WTF_MAKE_NONCOPYABLE(CurrentEventScope);
    8697public:
    87     CurrentEventScope(NSEvent *);
     98    CurrentEventScope(NSEvent *, NSEvent *correspondingPressureEvent);
    8899    ~CurrentEventScope();
    89100
     
    93104    RetainPtr<NSEvent> m_event;
    94105#endif
     106    RetainPtr<NSEvent> m_savedPressureEvent;
     107    RetainPtr<NSEvent> m_correspondingPressureEvent;
    95108};
    96109
    97 inline CurrentEventScope::CurrentEventScope(NSEvent *event)
     110inline CurrentEventScope::CurrentEventScope(NSEvent *event, NSEvent *correspondingPressureEvent)
    98111    : m_savedCurrentEvent(currentNSEventSlot())
    99112#ifndef NDEBUG
    100113    , m_event(event)
    101114#endif
     115    , m_savedPressureEvent(correspondingPressureEventSlot())
     116    , m_correspondingPressureEvent(correspondingPressureEvent)
    102117{
    103118    currentNSEventSlot() = event;
     119    correspondingPressureEventSlot() = correspondingPressureEvent;
    104120}
    105121
     
    108124    ASSERT(currentNSEventSlot() == m_event);
    109125    currentNSEventSlot() = m_savedCurrentEvent;
     126    correspondingPressureEventSlot() = m_savedPressureEvent;
    110127}
    111128
     
    116133        return false;
    117134
    118     CurrentEventScope scope(event);
     135    CurrentEventScope scope(event, nil);
    119136    return handleWheelEvent(PlatformEventFactory::createPlatformWheelEvent(event, page->chrome().platformPageClient()));
    120137}
     
    126143    ASSERT([event type] == NSKeyDown || [event type] == NSKeyUp);
    127144
    128     CurrentEventScope scope(event);
     145    CurrentEventScope scope(event, nil);
    129146    return keyEvent(PlatformEventFactory::createPlatformKeyboardEvent(event));
    130147
     
    470487}
    471488
    472 void EventHandler::mouseDown(NSEvent *event)
     489void EventHandler::mouseDown(NSEvent *event, NSEvent *correspondingPressureEvent)
    473490{
    474491    FrameView* v = m_frame.view();
     
    480497    m_mouseDownView = nil;
    481498   
    482     CurrentEventScope scope(event);
     499    CurrentEventScope scope(event, correspondingPressureEvent);
    483500
    484501    handleMousePressEvent(currentPlatformMouseEvent());
     
    487504}
    488505
    489 void EventHandler::mouseDragged(NSEvent *event)
     506void EventHandler::mouseDragged(NSEvent *event, NSEvent *correspondingPressureEvent)
    490507{
    491508    FrameView* v = m_frame.view();
     
    495512    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    496513
    497     CurrentEventScope scope(event);
     514    CurrentEventScope scope(event, correspondingPressureEvent);
    498515    handleMouseMoveEvent(currentPlatformMouseEvent());
    499516
     
    501518}
    502519
    503 void EventHandler::mouseUp(NSEvent *event)
     520void EventHandler::mouseUp(NSEvent *event, NSEvent *correspondingPressureEvent)
    504521{
    505522    FrameView* v = m_frame.view();
     
    509526    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    510527
    511     CurrentEventScope scope(event);
     528    CurrentEventScope scope(event, correspondingPressureEvent);
    512529
    513530    // Our behavior here is a little different that Qt. Qt always sends
     
    596613}
    597614
    598 void EventHandler::mouseMoved(NSEvent *event)
     615void EventHandler::mouseMoved(NSEvent *event, NSEvent* correspondingPressureEvent)
    599616{
    600617    // Reject a mouse moved if the button is down - screws up tracking during autoscroll
     
    604621
    605622    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    606     CurrentEventScope scope(event);
     623    CurrentEventScope scope(event, correspondingPressureEvent);
    607624    mouseMoved(currentPlatformMouseEvent());
    608625    END_BLOCK_OBJC_EXCEPTIONS;
    609626}
    610627
    611 void EventHandler::passMouseMovedEventToScrollbars(NSEvent *event)
     628void EventHandler::pressureChange(NSEvent *event, NSEvent* correspondingPressureEvent)
     629{
     630    if (!m_frame.view() || m_sendingEventToSubview)
     631        return;
     632
     633    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     634    CurrentEventScope scope(event, correspondingPressureEvent);
     635    handleMouseForceEvent(currentPlatformMouseEvent());
     636    END_BLOCK_OBJC_EXCEPTIONS;
     637}
     638
     639void EventHandler::passMouseMovedEventToScrollbars(NSEvent *event, NSEvent* correspondingPressureEvent)
    612640{
    613641    // Reject a mouse moved if the button is down - screws up tracking during autoscroll
     
    617645
    618646    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    619     CurrentEventScope scope(event);
     647    CurrentEventScope scope(event, correspondingPressureEvent);
    620648    passMouseMovedEventToScrollbars(currentPlatformMouseEvent());
    621649    END_BLOCK_OBJC_EXCEPTIONS;
     
    675703    if (Page* page = m_frame.page())
    676704        windowView = page->chrome().platformPageClient();
    677     return PlatformEventFactory::createPlatformMouseEvent(currentNSEvent(), windowView);
     705    return PlatformEventFactory::createPlatformMouseEvent(currentNSEvent(), correspondingPressureEvent(), windowView);
    678706}
    679707
  • trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h

    r173176 r183954  
    3535class PlatformEventFactory {
    3636public:
    37     WEBCORE_EXPORT static PlatformMouseEvent createPlatformMouseEvent(NSEvent *, NSView *windowView);
     37    WEBCORE_EXPORT static PlatformMouseEvent createPlatformMouseEvent(NSEvent *, NSEvent *correspondingPressureEvent, NSView *windowView);
    3838    static PlatformWheelEvent createPlatformWheelEvent(NSEvent *, NSView *windowView);
    3939    WEBCORE_EXPORT static PlatformKeyboardEvent createPlatformKeyboardEvent(NSEvent *);
  • trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm

    r182589 r183954  
    5050{
    5151    switch ([event type]) {
     52#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     53        case NSEventTypePressure:
     54#endif
    5255        case NSLeftMouseDown:
    5356        case NSLeftMouseDragged:
     
    7275{
    7376    switch ([event type]) {
     77#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     78        case NSEventTypePressure:
     79#endif
    7480        case NSLeftMouseDown:
    7581        case NSLeftMouseDragged:
     
    100106{
    101107    switch ([event type]) {
     108#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     109        case NSEventTypePressure:
     110#endif
    102111        case NSLeftMouseDown:
    103112        case NSLeftMouseUp:
     
    412421class PlatformMouseEventBuilder : public PlatformMouseEvent {
    413422public:
    414     PlatformMouseEventBuilder(NSEvent *event, NSView *windowView)
     423    PlatformMouseEventBuilder(NSEvent *event, NSEvent *correspondingPressureEvent, NSView *windowView)
    415424    {
    416425        // PlatformEvent
    417         m_type                              = mouseEventTypeForEvent(event);
    418         m_modifiers                         = modifiersForEvent(event);
    419         m_timestamp                         = eventTimeStampSince1970(event);
     426        m_type = mouseEventTypeForEvent(event);
     427
     428#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     429        BOOL eventIsPressureEvent = [event type] == NSEventTypePressure;
     430        if (eventIsPressureEvent) {
     431            // Since AppKit doesn't send mouse events for force down or force up, we have to use the current pressure
     432            // event and correspondingPressureEvent to detect if this is MouseForceDown, MouseForceUp, or just MouseForceChanged.
     433            if (correspondingPressureEvent.stage == 1 && event.stage == 2)
     434                m_type = PlatformEvent::MouseForceDown;
     435            else if (correspondingPressureEvent.stage == 2 && event.stage == 1)
     436                m_type = PlatformEvent::MouseForceUp;
     437            else
     438                m_type = PlatformEvent::MouseForceChanged;
     439        }
     440#else
     441        UNUSED_PARAM(correspondingPressureEvent);
     442#endif
     443
     444        m_modifiers = modifiersForEvent(event);
     445        m_timestamp = eventTimeStampSince1970(event);
    420446
    421447        // PlatformMouseEvent
    422         m_position                          = pointForEvent(event, windowView);
    423         m_globalPosition                    = globalPointForEvent(event);
    424         m_button                            = mouseButtonForEvent(event);
    425         m_clickCount                        = clickCountForEvent(event);
    426        
     448        m_position = pointForEvent(event, windowView);
     449        m_globalPosition = globalPointForEvent(event);
     450        m_button = mouseButtonForEvent(event);
     451        m_clickCount = clickCountForEvent(event);
     452
     453        m_force = 0;
     454#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     455        int stage = eventIsPressureEvent ? event.stage : correspondingPressureEvent.stage;
     456        double pressure = eventIsPressureEvent ? event.pressure : correspondingPressureEvent.pressure;
     457        m_force = stage < 1 ? pressure : pressure + stage - 1;
     458#endif
     459
    427460        // Mac specific
    428         m_modifierFlags                     = [event modifierFlags];
    429         m_eventNumber                       = [event eventNumber];
    430         m_menuTypeForEvent                  = typeForEvent(event);
     461        m_modifierFlags = [event modifierFlags];
     462        m_eventNumber = [event eventNumber];
     463        m_menuTypeForEvent = typeForEvent(event);
    431464    }
    432465};
    433466
    434 PlatformMouseEvent PlatformEventFactory::createPlatformMouseEvent(NSEvent *event, NSView *windowView)
    435 {
    436     return PlatformMouseEventBuilder(event, windowView);
     467PlatformMouseEvent PlatformEventFactory::createPlatformMouseEvent(NSEvent *event, NSEvent *correspondingPressureEvent, NSView *windowView)
     468{
     469    return PlatformMouseEventBuilder(event, correspondingPressureEvent, windowView);
    437470}
    438471
  • trunk/Source/WebKit/ChangeLog

    r183479 r183954  
     12015-05-07  Beth Dakin  <bdakin@apple.com>
     2
     3        New force-related DOM events should fire in WK1 views
     4        https://bugs.webkit.org/show_bug.cgi?id=144663
     5        -and corresponding-
     6        rdar://problem/20281886
     7
     8        Reviewed by Sam Weinig.
     9
     10        Pass the lastPressureEvent to WebCore.
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _updateMouseoverWithEvent:]):
     13        (-[WebHTMLView rightMouseUp:]):
     14        (-[WebHTMLView menuForEvent:]):
     15        (-[WebHTMLView acceptsFirstMouse:]):
     16        (-[WebHTMLView shouldDelayWindowOrderingForEvent:]):
     17        (-[WebHTMLView mouseDown:mouseDown:]):
     18        (-[WebHTMLView mouseDragged:]):
     19        (-[WebHTMLView mouseUp:mouseUp:]):
     20
     21        New NSRespnder method for pressure changes.
     22        (-[WebHTMLView pressureChangeWithEvent:]):
     23
     24        New BOOL _contentPreventsDefault tracks whether the HitTestResult prevented the
     25        default action. Get rid of willHandleMouseDown; now that the gesture recognizer
     26        sets delaysPrimaryMouseButtonEvents to NO, we don’t need this.
     27        * WebView/WebImmediateActionController.h:
     28        * WebView/WebImmediateActionController.mm:
     29        (-[WebImmediateActionController _clearImmediateActionState]):
     30
     31        Set all of the immediateActionStages on EventHandler. This is critical to keep
     32        link navigation happening at the right time now that
     33        delaysPrimaryMouseButtonEvents is set to NO.
     34        (-[WebImmediateActionController performHitTestAtPoint:]):
     35        (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
     36        (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
     37        (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
     38
     39        Use a dummy animation controller if the content prevents default.
     40        (-[WebImmediateActionController _defaultAnimationController]):
     41        (-[WebImmediateActionController _updateImmediateActionItem]):
     42        (-[WebImmediateActionController webView:willHandleMouseDown:]): Deleted.
     43
     44        Set delaysPrimaryMouseButtonEvents to NO so that we get existing mouse events when
     45        we expect to.
     46        * WebView/WebView.mm:
     47        (-[WebView _commonInitializationWithFrameName:groupName:]):
     48
     49        Cache the most recent pressure event so that we can send it to WebCore for all of
     50        the mouse events.
     51        (-[WebView _pressureEvent]):
     52        (-[WebView _setPressureEvent:]):
     53        * WebView/WebViewData.h:
     54        * WebView/WebViewData.mm:
     55        (-[WebViewPrivate dealloc]):
     56        * WebView/WebViewInternal.h:
     57
    1582015-04-27  Brent Fulgham  <bfulgham@apple.com>
    259
  • trunk/Source/WebKit/mac/ChangeLog

    r183940 r183954  
     12015-05-07  Beth Dakin  <bdakin@apple.com>
     2
     3        New force-related DOM events should fire in WK1 views
     4        https://bugs.webkit.org/show_bug.cgi?id=144663
     5        -and corresponding-
     6        rdar://problem/20281886
     7
     8        Reviewed by Sam Weinig.
     9
     10        Pass the lastPressureEvent to WebCore.
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _updateMouseoverWithEvent:]):
     13        (-[WebHTMLView rightMouseUp:]):
     14        (-[WebHTMLView menuForEvent:]):
     15        (-[WebHTMLView acceptsFirstMouse:]):
     16        (-[WebHTMLView shouldDelayWindowOrderingForEvent:]):
     17        (-[WebHTMLView mouseDown:mouseDown:]):
     18        (-[WebHTMLView mouseDragged:]):
     19        (-[WebHTMLView mouseUp:mouseUp:]):
     20
     21        New NSRespnder method for pressure changes.
     22        (-[WebHTMLView pressureChangeWithEvent:]):
     23
     24        New BOOL _contentPreventsDefault tracks whether the HitTestResult prevented the
     25        default action. Get rid of willHandleMouseDown; now that the gesture recognizer
     26        sets delaysPrimaryMouseButtonEvents to NO, we don’t need this.
     27        * WebView/WebImmediateActionController.h:
     28        * WebView/WebImmediateActionController.mm:
     29        (-[WebImmediateActionController _clearImmediateActionState]):
     30
     31        Set all of the immediateActionStages on EventHandler. This is critical to keep
     32        link navigation happening at the right time now that
     33        delaysPrimaryMouseButtonEvents is set to NO.
     34        (-[WebImmediateActionController performHitTestAtPoint:]):
     35        (-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
     36        (-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
     37        (-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
     38
     39        Use a dummy animation controller if the content prevents default.
     40        (-[WebImmediateActionController _defaultAnimationController]):
     41        (-[WebImmediateActionController _updateImmediateActionItem]):
     42        (-[WebImmediateActionController webView:willHandleMouseDown:]): Deleted.
     43
     44        Set delaysPrimaryMouseButtonEvents to NO so that we get existing mouse events when
     45        we expect to.
     46        * WebView/WebView.mm:
     47        (-[WebView _commonInitializationWithFrameName:groupName:]):
     48
     49        Cache the most recent pressure event so that we can send it to WebCore for all of
     50        the mouse events.
     51        (-[WebView _pressureEvent]):
     52        (-[WebView _setPressureEvent:]):
     53        * WebView/WebViewData.h:
     54        * WebView/WebViewData.mm:
     55        (-[WebViewPrivate dealloc]):
     56        * WebView/WebViewInternal.h:
     57
    1582015-05-05  Myles C. Maxfield  <mmaxfield@apple.com>
    259
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r183871 r183954  
    17691769            eventNumber:0 clickCount:0 pressure:0];
    17701770        if (Frame* lastHitCoreFrame = core([lastHitView _frame]))
    1771             lastHitCoreFrame->eventHandler().mouseMoved(event);
     1771            lastHitCoreFrame->eventHandler().mouseMoved(event, [[self _webView] _pressureEvent]);
    17721772    }
    17731773
     
    17881788#endif
    17891789                ) {
    1790                 coreFrame->eventHandler().mouseMoved(event);
     1790                coreFrame->eventHandler().mouseMoved(event, [[self _webView] _pressureEvent]);
    17911791            } else
    1792                 coreFrame->eventHandler().passMouseMovedEventToScrollbars(event);
     1792                coreFrame->eventHandler().passMouseMovedEventToScrollbars(event, [[self _webView] _pressureEvent]);
    17931793        }
    17941794
     
    33043304
    33053305    if (Frame* coreframe = core([self _frame]))
    3306         coreframe->eventHandler().mouseUp(event);
     3306        coreframe->eventHandler().mouseUp(event, [[self _webView] _pressureEvent]);
    33073307}
    33083308
     
    33493349    _private->handlingMouseDownEvent = YES;
    33503350    page->contextMenuController().clearContextMenu();
    3351     coreFrame->eventHandler().mouseDown(event);
    3352     BOOL handledEvent = coreFrame->eventHandler().sendContextMenuEvent(PlatformEventFactory::createPlatformMouseEvent(event, page->chrome().platformPageClient()));
     3351    coreFrame->eventHandler().mouseDown(event, [[self _webView] _pressureEvent]);
     3352    BOOL handledEvent = coreFrame->eventHandler().sendContextMenuEvent(PlatformEventFactory::createPlatformMouseEvent(event, [[self _webView] _pressureEvent], page->chrome().platformPageClient()));
    33533353    _private->handlingMouseDownEvent = NO;
    33543354
     
    37783778#if ENABLE(DRAG_SUPPORT)
    37793779                if (Page* page = coreFrame->page())
    3780                     result = coreFrame->eventHandler().eventMayStartDrag(PlatformEventFactory::createPlatformMouseEvent(event, page->chrome().platformPageClient()));
     3780                    result = coreFrame->eventHandler().eventMayStartDrag(PlatformEventFactory::createPlatformMouseEvent(event, [[self _webView] _pressureEvent], page->chrome().platformPageClient()));
    37813781#endif
    37823782            } else if ([hitHTMLView _isScrollBarEvent:event])
     
    38053805            if (Frame* coreFrame = core([hitHTMLView _frame])) {
    38063806                if (Page* page = coreFrame->page())
    3807                     result = coreFrame->eventHandler().eventMayStartDrag(PlatformEventFactory::createPlatformMouseEvent(event, page->chrome().platformPageClient()));
     3807                    result = coreFrame->eventHandler().eventMayStartDrag(PlatformEventFactory::createPlatformMouseEvent(event, [[self _webView] _pressureEvent], page->chrome().platformPageClient()));
    38083808            }
    38093809#endif
     
    38423842#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    38433843    [[[self _webView] _actionMenuController] webView:[self _webView] willHandleMouseDown:event];
    3844     [[[self _webView] _immediateActionController] webView:[self _webView] willHandleMouseDown:event];
    38453844#endif
    38463845
     
    38733872            // to start the autoscroll timer if appropriate.
    38743873            if (Frame* coreframe = core([self _frame]))
    3875                 coreframe->eventHandler().mouseDown(event);
     3874                coreframe->eventHandler().mouseDown(event, [[self _webView] _pressureEvent]);
    38763875        }
    38773876    }
     
    39263925        if (Frame* frame = core([self _frame])) {
    39273926            if (Page* page = frame->page())
    3928                 page->mainFrame().eventHandler().mouseDragged(event);
     3927                page->mainFrame().eventHandler().mouseDragged(event, [[self _webView] _pressureEvent]);
    39293928        }
    39303929    }
     
    40654064    [self _stopAutoscrollTimer];
    40664065    if (Frame* frame = core([self _frame])) {
    4067         if (Page* page = frame->page())
     4066        if (Page* page = frame->page()) {
     4067#if PLATFORM(IOS)
    40684068            page->mainFrame().eventHandler().mouseUp(event);
     4069#else
     4070            page->mainFrame().eventHandler().mouseUp(event, [[self _webView] _pressureEvent]);
     4071#endif
     4072        }
    40694073    }
    40704074#if !PLATFORM(IOS)
     
    40814085}
    40824086#endif
     4087
     4088- (void)pressureChangeWithEvent:(NSEvent *)event
     4089{
     4090#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
     4091    NSEvent *lastPressureEvent = [[self _webView] _pressureEvent];
     4092    if (event.phase != NSEventPhaseChanged && event.phase != NSEventPhaseBegan && event.phase != NSEventPhaseEnded)
     4093        return;
     4094
     4095    RefPtr<Frame> coreFrame = core([self _frame]);
     4096    if (!coreFrame)
     4097        return;
     4098
     4099    coreFrame->eventHandler().pressureChange(event, lastPressureEvent);
     4100    [[self _webView] _setPressureEvent:event];
     4101#endif
     4102}
    40834103
    40844104#if !PLATFORM(IOS)
  • trunk/Source/WebKit/mac/WebView/WebImmediateActionController.h

    r179230 r183954  
    4646    BOOL _isShowingTextIndicator;
    4747    BOOL _hasActivatedActionContext;
     48    BOOL _contentPreventsDefault;
    4849}
    4950
     
    5152- (void)webViewClosed;
    5253
    53 - (void)webView:(WebView *)webView willHandleMouseDown:(NSEvent *)event;
    5454- (void)webView:(WebView *)webView didHandleScrollWheel:(NSEvent *)event;
    5555
  • trunk/Source/WebKit/mac/WebView/WebImmediateActionController.mm

    r183517 r183954  
    6565@end
    6666
     67@interface WebAnimationController : NSObject <NSImmediateActionAnimationController> {
     68}
     69@end
     70
     71@implementation WebAnimationController
     72@end
     73
    6774using namespace WebCore;
    6875
     
    95102}
    96103
    97 - (void)webView:(WebView *)webView willHandleMouseDown:(NSEvent *)event
    98 {
    99     [self _clearImmediateActionState];
    100     [_webView _clearTextIndicatorWithAnimation:TextIndicatorDismissalAnimation::FadeOut];
    101 }
    102 
    103104- (void)webView:(WebView *)webView didHandleScrollWheel:(NSEvent *)event
    104105{
     
    137138    _currentActionContext = nil;
    138139    _currentQLPreviewMenuItem = nil;
     140    _contentPreventsDefault = NO;
    139141}
    140142
     
    145147        return;
    146148    _hitTestResult = coreFrame->eventHandler().hitTestResultAtPoint(IntPoint(viewPoint));
     149    coreFrame->eventHandler().setImmediateActionStage(ImmediateActionStage::PerformedHitTest);
     150
     151    if (Element* element = _hitTestResult.innerElement())
     152        _contentPreventsDefault = element->dispatchMouseForceWillBegin();
    147153}
    148154
     
    189195        return;
    190196
     197    Frame* coreFrame = core([[[[_webView _selectedOrMainFrame] frameView] documentView] _frame]);
     198    if (!coreFrame)
     199        return;
     200    coreFrame->eventHandler().setImmediateActionStage(ImmediateActionStage::ActionUpdated);
     201    if (_contentPreventsDefault)
     202        return;
     203
    191204    [_webView _setTextIndicatorAnimationProgress:[immediateActionRecognizer animationProgress]];
    192205}
     
    196209    if (immediateActionRecognizer != _immediateActionRecognizer)
    197210        return;
     211
     212    Frame* coreFrame = core([[[[_webView _selectedOrMainFrame] frameView] documentView] _frame]);
     213    if (coreFrame)
     214        coreFrame->eventHandler().setImmediateActionStage(ImmediateActionStage::ActionCancelled);
    198215
    199216    [_webView _setTextIndicatorAnimationProgress:0];
     
    208225        return;
    209226
     227    Frame* coreFrame = core([[[[_webView _selectedOrMainFrame] frameView] documentView] _frame]);
     228    if (!coreFrame)
     229        return;
     230    coreFrame->eventHandler().setImmediateActionStage(ImmediateActionStage::ActionCompleted);
     231
    210232    [_webView _setTextIndicatorAnimationProgress:1];
    211233    [_webView _setMaintainsInactiveSelection:NO];
     
    216238- (id <NSImmediateActionAnimationController>)_defaultAnimationController
    217239{
     240    if (_contentPreventsDefault) {
     241        RetainPtr<WebAnimationController> dummyController = [[WebAnimationController alloc] init];
     242        return dummyController.get();
     243    }
     244
    218245    NSURL *url = _hitTestResult.absoluteLinkURL();
    219246    NSString *absoluteURLString = [url absoluteString];
     
    266293    id <NSImmediateActionAnimationController> defaultAnimationController = [self _defaultAnimationController];
    267294
     295    if (_contentPreventsDefault) {
     296        [_immediateActionRecognizer setAnimationController:defaultAnimationController];
     297        return;
     298    }
     299
    268300    // Allow clients the opportunity to override the default immediate action.
    269301    id customClientAnimationController = nil;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r183682 r183954  
    911911        _private->immediateActionController = [[WebImmediateActionController alloc] initWithWebView:self recognizer:recognizer.get()];
    912912        [recognizer setDelegate:_private->immediateActionController];
     913        [recognizer setDelaysPrimaryMouseButtonEvents:NO];
    913914    }
    914915#endif
     
    86028603#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    86038604
     8605- (NSEvent *)_pressureEvent
     8606{
     8607    return _private->pressureEvent.get();
     8608}
     8609
     8610- (void)_setPressureEvent:(NSEvent *)event
     8611{
     8612    _private->pressureEvent = event;
     8613}
     8614
    86048615- (void)_setTextIndicator:(TextIndicator&)textIndicator
    86058616{
  • trunk/Source/WebKit/mac/WebView/WebViewData.h

    r183172 r183954  
    176176    BOOL hasInitializedLookupObserver;
    177177    RetainPtr<WebWindowVisibilityObserver> windowVisibilityObserver;
     178    RetainPtr<NSEvent> pressureEvent;
    178179#endif // PLATFORM(MAC)
    179180
  • trunk/Source/WebKit/mac/WebView/WebViewInternal.h

    r183517 r183954  
    270270- (WebImmediateActionController *)_immediateActionController;
    271271#endif
     272- (NSEvent *)_pressureEvent;
     273- (void)_setPressureEvent:(NSEvent *)event;
    272274#endif
    273275
  • trunk/Tools/ChangeLog

    r183945 r183954  
     12015-05-07  Beth Dakin  <bdakin@apple.com>
     2
     3        New force-related DOM events should fire in WK1 views
     4        https://bugs.webkit.org/show_bug.cgi?id=144663
     5        -and corresponding-
     6        rdar://problem/20281886
     7
     8        Reviewed by Sam Weinig.
     9
     10        PlatformEventFactory::createPlatformMouseEvent() takes the last pressure event
     11        now. Just send nil.
     12        * TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:
     13        (TestWebKitAPI::buildAndPerformTest):
     14
    1152015-05-07  Michael Catanzaro  <mcatanzaro@igalia.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm

    r182589 r183954  
    5353                                        pressure:0];
    5454   
    55     auto pme = WebCore::PlatformEventFactory::createPlatformMouseEvent(event, webView.get());
     55    auto pme = WebCore::PlatformEventFactory::createPlatformMouseEvent(event, nil, webView.get());
    5656   
    5757    EXPECT_EQ(expectedButton, pme.button());
Note: See TracChangeset for help on using the changeset viewer.