Changeset 222855 in webkit


Ignore:
Timestamp:
Oct 4, 2017 10:33:27 AM (6 years ago)
Author:
Adrian Perez de Castro
Message:

[GTK] WebKit2GTK+ does not handle touchmove and touchend events correctly
https://bugs.webkit.org/show_bug.cgi?id=158531

Reviewed by Carlos Alberto Lopez Perez.

Do not bypass WebCore event handling when receiving touch events.

Based on a patch by Andre Moreira Magalhaes <Andre Moreira Magalhaes>.
Thanks to Carlos Garnacho <carlosg@gnome.org> for helping out reviewing the code.

  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::doneWithTouchEvent): Make sure touchend reaches gesture controller if touchbegin evet got to it.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseTouchEvent): Do not invoke gesture controller directly by bypassing WebCore event handling.

  • UIProcess/gtk/GestureController.cpp:

(WebKit::GestureController::reset): Added.
(WebKit::GestureController::handleEvent): Reset gesture controller when touchpadupdate/end is received without touchbegin.
(WebKit::GestureController::Gesture::reset): Added.

  • UIProcess/gtk/GestureController.h:
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r222846 r222855  
     12017-10-04  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [GTK] WebKit2GTK+ does not handle touchmove and touchend events correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=158531
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Do not bypass WebCore event handling when receiving touch events.
     9
     10        Based on a patch by Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk>.
     11        Thanks to Carlos Garnacho <carlosg@gnome.org> for helping out reviewing the code.
     12
     13        * UIProcess/API/gtk/PageClientImpl.cpp:
     14        (WebKit::PageClientImpl::doneWithTouchEvent): Make sure touchend reaches gesture controller if touchbegin evet got to it.
     15        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     16        (webkitWebViewBaseTouchEvent): Do not invoke gesture controller directly by bypassing WebCore event handling.
     17        * UIProcess/gtk/GestureController.cpp:
     18        (WebKit::GestureController::reset): Added.
     19        (WebKit::GestureController::handleEvent): Reset gesture controller when touchpadupdate/end is received without touchbegin.
     20        (WebKit::GestureController::Gesture::reset): Added.
     21        * UIProcess/gtk/GestureController.h:
     22
    1232017-10-04  Michael Catanzaro  <mcatanzaro@igalia.com>
    224
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp

    r218740 r222855  
    343343void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
    344344{
    345     if (wasEventHandled)
    346         return;
     345    const GdkEvent* touchEvent = event.nativeEvent();
    347346
    348347#if HAVE(GTK_GESTURES)
    349348    GestureController& gestureController = webkitWebViewBaseGestureController(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
    350     if (gestureController.handleEvent(event.nativeEvent()))
    351         return;
     349    if (wasEventHandled) {
     350        gestureController.reset();
     351        return;
     352    }
     353    wasEventHandled = gestureController.handleEvent(event.nativeEvent());
    352354#endif
    353355
     356    if (wasEventHandled)
     357        return;
     358
    354359    // Emulate pointer events if unhandled.
    355     const GdkEvent* touchEvent = event.nativeEvent();
    356 
    357360    if (!touchEvent->touch.emulating_pointer)
    358361        return;
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r218332 r222855  
    928928    uint32_t sequence = GPOINTER_TO_UINT(gdk_event_get_event_sequence(touchEvent));
    929929
    930 #if HAVE(GTK_GESTURES)
    931     GestureController& gestureController = webkitWebViewBaseGestureController(webViewBase);
    932     if (gestureController.isProcessingGestures()) {
    933         // If we are already processing gestures is because the WebProcess didn't handle the
    934         // BEGIN touch event, so pass subsequent events to the GestureController.
    935         gestureController.handleEvent(touchEvent);
    936         // Remove the gesture event sequence from the handled touch events
    937         // list to avoid the gesure sequence and a touch sequence of same
    938         // ID to conflict.
    939         priv->touchEvents.remove(sequence);
    940         return TRUE;
    941     }
    942 #endif
    943 
    944930    switch (touchEvent->type) {
    945931    case GDK_TOUCH_BEGIN: {
  • trunk/Source/WebKit/UIProcess/gtk/GestureController.cpp

    r217971 r222855  
    6868}
    6969
     70void GestureController::Gesture::reset()
     71{
     72    gtk_event_controller_reset(GTK_EVENT_CONTROLLER(m_gesture.get()));
     73}
     74
    7075bool GestureController::Gesture::isActive() const
    7176{
  • trunk/Source/WebKit/UIProcess/gtk/GestureController.h

    r217971 r222855  
    5050    bool handleEvent(const GdkEvent*);
    5151
     52    void reset()
     53    {
     54        m_dragGesture.reset();
     55        m_swipeGesture.reset();
     56        m_zoomGesture.reset();
     57    }
     58
    5259private:
    5360    class Gesture {
    5461    public:
     62        void reset();
    5563        bool isActive() const;
    5664        void handleEvent(const GdkEvent*);
Note: See TracChangeset for help on using the changeset viewer.