Changeset 163749 in webkit


Ignore:
Timestamp:
Feb 9, 2014 2:55:50 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

.: [GTK] Enable touch features
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

  • Source/autotools/SetupWebKitFeatures.m4:
  • Source/cmake/OptionsGTK.cmake: set ENABLE_TOUCH_EVENTS to 1 if building with GTK+.

Source/WebCore: [GTK] Add touch-events related code to build
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

Tests in fast/events/touch have been enabled on GTK+ now that touch
support is implemented, and thus all expected bits are there.

  • platform/gtk/GtkTouchContextHelper.cpp:
  • platform/gtk/GtkTouchContextHelper.h: Add helper object to track all touchpoints, handy

when creating WebTouchEvents.

  • GNUmakefile.list.am:
  • PlatformGTK.cmake:
  • bindings/gobject/GNUmakefile.am: Add touch related code and idls to build, those are

necessary now that GTK+ implements touch events.

Source/WebKit/gtk: [GTK] Allow building with touch events enabled
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

Even though WebKit1 GTK code doesn't implement touch events,
Fix build if ENABLE_TOUCH_EVENTS is present for WK2.

  • WebCoreSupport/ChromeClientGtk.h:

(WebKit::ChromeClient::needTouchEvents): Add empty stub

Source/WebKit2: [GTK] Implement support touch events
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

In GTK+ >= 3.4.0, GdkEventTouch is available to inform about multitouch events. Use these to implement
touch events on this platform. If a touch is left unhandled and is the "pointer emulating" one, mouse
events will be generated as a fallback.

  • GNUmakefile.list.am:
  • PlatformGTK.cmake:
  • Shared/gtk/NativeWebTouchEventGtk.cpp:
  • Shared/NativeWebTouchEvent.h:

(WebKit::NativeWebTouchEvent::nativeEvent):
(WebKit::NativeWebTouchEvent::touchContext): Add GTK+ implementation of NativeWebTouchEvent.

  • Shared/gtk/WebEventFactory.cpp:

(WebKit::touchPhaseFromEvents):
(WebKit::WebEventFactory::createWebTouchEvent): Add methods to generate WebTouchEvents out
of GdkEventTouch events, a GtkTouchContextHelper object is used to hold information about all current
touches, in order to build information about all individual touchpoints.

  • Shared/gtk/WebEventFactory.h:
  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::doneWithTouchEvent): Implement pointer emulation. If a touch event was unhandled
in DOM and pertains to the touch sequence that emulates pointer events. The event gets transformed to its
mouse event counterpart and handled by the widget again.

  • UIProcess/API/gtk/PageClientImpl.h:
  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseRealize): Listen for touch events
(webkitWebViewBaseTouchEvent):
(webkit_web_view_base_class_init): Add implementation for the touch_events() handler, this merely
lets the pageProxy handle the NativeWebTouchEvent we create to wrap the GdkEvent received.

Tools: [GTK] Enable touch features
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

  • WebKitTestRunner/EventSenderProxy.h:
  • WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:

(WTR::updateEventCoordinates):
(WTR::EventSenderProxy::createTouchEvent):
(WTR::EventSenderProxy::addTouchPoint):
(WTR::EventSenderProxy::updateTouchPoint):
(WTR::EventSenderProxy::sendUpdatedTouchEvents):
(WTR::EventSenderProxy::setTouchPointRadius):
(WTR::EventSenderProxy::setTouchModifier): Implement touch event proxying.

LayoutTests: [GTK] Enable touch features
https://bugs.webkit.org/show_bug.cgi?id=98931

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-09
Reviewed by Carlos Garcia Campos.

  • platform/gtk/TestExpectations: remove fast/events/touch
  • platform/gtk-wk2/TestExpectations: Add new expectations on

fast/events/touch events.

Location:
trunk
Files:
28 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r163701 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Enable touch features
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * Source/autotools/SetupWebKitFeatures.m4:
     9        * Source/cmake/OptionsGTK.cmake: set ENABLE_TOUCH_EVENTS to 1 if building with GTK+.
     10
    1112014-02-06  Andreas Kling  <akling@apple.com>
    212
  • trunk/LayoutTests/ChangeLog

    r163742 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Enable touch features
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * platform/gtk/TestExpectations: remove fast/events/touch
     9        * platform/gtk-wk2/TestExpectations: Add new expectations on
     10        fast/events/touch events.
     11
    1122014-02-08  Brady Eidson  <beidson@apple.com>
    213
  • trunk/LayoutTests/platform/gtk-wk1/TestExpectations

    r162963 r163749  
    258258Bug(GTK) http/tests/download [ Failure ]
    259259
     260# Touch support only implemented in WK2
     261fast/events/touch [ Skip ]
     262
    260263#////////////////////////////////////////////////////////////////////////////////////////
    261264# End of Tests failing
  • trunk/LayoutTests/platform/gtk-wk2/TestExpectations

    r163619 r163749  
    186186webkit.org/b/120401 fast/events [ Skip ]
    187187webkit.org/b/120401 editing/selection [ Skip ]
     188
     189# Tests in the gesture folder exercise IOS-specific code, non appliable to GTK+
     190fast/events/touch/gesture [ Skip ]
     191
     192# These tests rely on touch event grouping, which X11/GTK+ doesn't do by design
     193webkit.org/b/128172 fast/events/touch/basic-multi-touch-events-limited.html [ Failure ]
     194webkit.org/b/128172 fast/events/touch/basic-multi-touch-events.html [ Failure ]
     195webkit.org/b/128172 fast/events/touch/touch-input-element-change-documents.html [ Failure ]
     196webkit.org/b/128172 fast/events/touch/frame-hover-update.html [ Failure ]
     197webkit.org/b/128172 fast/events/touch/multi-touch-grouped-targets.html [ Timeout Failure ]
     198webkit.org/b/128172 fast/events/touch/multi-touch-inside-nested-iframes.html [ Timeout ]
     199webkit.org/b/128172 fast/events/touch/multi-touch-inside-iframes.html [ Timeout ]
     200webkit.org/b/128172 fast/events/touch/basic-single-touch-events.html [ Timeout ]
     201webkit.org/b/128172 fast/events/touch/page-scaled-touch-gesture-click.html [ Timeout ]
     202webkit.org/b/128172 fast/events/touch/touch-target.html [ Timeout ]
     203webkit.org/b/128172 fast/events/touch/touch-target-limited.html [ Timeout ]
     204webkit.org/b/128172 fast/events/touch/send-oncancel-event.html [ Timeout ]
    188205
    189206#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r163620 r163749  
    153153webkit.org/b/61140 fast/notifications [ Skip ]
    154154webkit.org/b/61140 http/tests/notifications [ Skip ]
    155 
    156 # These tests require touch support.
    157 webkit.org/b/98931 fast/events/touch [ Skip ]
    158155
    159156# StorageTracker is not enabled.
  • trunk/Source/WebCore/ChangeLog

    r163747 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Add touch-events related code to build
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Tests in fast/events/touch have been enabled on GTK+ now that touch
     9        support is implemented, and thus all expected bits are there.
     10
     11        * platform/gtk/GtkTouchContextHelper.cpp:
     12        * platform/gtk/GtkTouchContextHelper.h: Add helper object to track all touchpoints, handy
     13        when creating WebTouchEvents.
     14        * GNUmakefile.list.am:
     15        * PlatformGTK.cmake:
     16        * bindings/gobject/GNUmakefile.am: Add touch related code and idls to build, those are
     17        necessary now that GTK+ implements touch events.
     18
    1192014-02-09  Zan Dobersek  <zdobersek@igalia.com>
    220
  • trunk/Source/WebCore/GNUmakefile.list.am

    r163649 r163749  
    29982998        Source/WebCore/dom/TextNodeTraversal.h \
    29992999        Source/WebCore/dom/Text.h \
     3000        Source/WebCore/dom/Touch.cpp \
    30003001        Source/WebCore/dom/Touch.h \
     3002        Source/WebCore/dom/TouchEvent.cpp \
    30013003        Source/WebCore/dom/TouchEvent.h \
     3004        Source/WebCore/dom/TouchList.cpp \
    30023005        Source/WebCore/dom/TouchList.h \
    30033006        Source/WebCore/dom/TransformSource.h \
     
    61796182        Source/WebCore/platform/gtk/GtkPopupMenu.cpp \
    61806183        Source/WebCore/platform/gtk/GtkPopupMenu.h \
     6184        Source/WebCore/platform/gtk/GtkTouchContextHelper.cpp \
     6185        Source/WebCore/platform/gtk/GtkTouchContextHelper.h \
    61816186        Source/WebCore/platform/gtk/GtkUtilities.cpp \
    61826187        Source/WebCore/platform/gtk/GtkUtilities.h \
  • trunk/Source/WebCore/PlatformGTK.cmake

    r163687 r163749  
    203203    platform/gtk/GtkPluginWidget.cpp
    204204    platform/gtk/GtkPopupMenu.cpp
     205    platform/gtk/GtkTouchContextHelper.cpp
    205206    platform/gtk/GtkUtilities.cpp
    206207    platform/gtk/GtkVersioning.c
     
    530531        dom/ShadowRoot.idl
    531532        dom/Text.idl
     533        dom/Touch.idl
    532534        dom/TreeWalker.idl
    533535        dom/UIEvent.idl
  • trunk/Source/WebCore/bindings/gobject/GNUmakefile.am

    r163440 r163749  
    263263        DerivedSources/webkitdom/WebKitDOMText.cpp \
    264264        DerivedSources/webkitdom/WebKitDOMTextPrivate.h \
     265        DerivedSources/webkitdom/WebKitDOMTouch.cpp \
     266        DerivedSources/webkitdom/WebKitDOMTouchPrivate.h \
    265267        DerivedSources/webkitdom/WebKitDOMTimeRanges.cpp \
    266268        DerivedSources/webkitdom/WebKitDOMTimeRangesPrivate.h \
     
    324326        DerivedSources/webkitdom/WebKitDOMRange.h \
    325327        DerivedSources/webkitdom/WebKitDOMText.h \
     328        DerivedSources/webkitdom/WebKitDOMTouch.h \
    326329        DerivedSources/webkitdom/WebKitDOMTreeWalker.h \
    327330        DerivedSources/webkitdom/WebKitDOMUIEvent.h \
  • trunk/Source/WebCore/bindings/gobject/webkitdom.symbols

    r161111 r163749  
    105105WebKitDOMXPathExpression* webkit_dom_document_create_expression(WebKitDOMDocument*, const gchar*, WebKitDOMXPathNSResolver*, GError**)
    106106WebKitDOMXPathNSResolver* webkit_dom_document_create_ns_resolver(WebKitDOMDocument*, WebKitDOMNode*)
     107WebKitDOMTouch* webkit_dom_document_create_touch(WebKitDOMDocument*, WebKitDOMDOMWindow*, WebKitDOMEventTarget*, glong, glong, glong, glong, glong, glong, glong, gfloat, gfloat, GError**)
    107108WebKitDOMXPathResult* webkit_dom_document_evaluate(WebKitDOMDocument*, const gchar*, WebKitDOMNode*, WebKitDOMXPathNSResolver*, gushort, WebKitDOMXPathResult*, GError**)
    108109gboolean webkit_dom_document_exec_command(WebKitDOMDocument*, const gchar*, gboolean, const gchar*)
     
    16631664glong webkit_dom_wheel_event_get_wheel_delta(WebKitDOMWheelEvent*)
    16641665gboolean webkit_dom_wheel_event_get_webkit_direction_inverted_from_device(WebKitDOMWheelEvent*)
     1666WebKitDOMEventTarget* webkit_dom_touch_get_target(WebKitDOMTouch*)
     1667gfloat webkit_dom_touch_get_webkit_force(WebKitDOMTouch*)
     1668gfloat webkit_dom_touch_get_webkit_rotation_angle(WebKitDOMTouch*)
     1669glong webkit_dom_touch_get_client_x(WebKitDOMTouch*)
     1670glong webkit_dom_touch_get_client_y(WebKitDOMTouch*)
     1671glong webkit_dom_touch_get_page_x(WebKitDOMTouch*)
     1672glong webkit_dom_touch_get_page_y(WebKitDOMTouch*)
     1673glong webkit_dom_touch_get_screen_x(WebKitDOMTouch*)
     1674glong webkit_dom_touch_get_screen_y(WebKitDOMTouch*)
     1675glong webkit_dom_touch_get_webkit_radius_x(WebKitDOMTouch*)
     1676glong webkit_dom_touch_get_webkit_radius_y(WebKitDOMTouch*)
     1677gulong webkit_dom_touch_get_identifier(WebKitDOMTouch*)
    16651678gchar* webkit_dom_audio_track_get_id(WebKitDOMAudioTrack*)
    16661679gchar* webkit_dom_audio_track_get_kind(WebKitDOMAudioTrack*)
  • trunk/Source/WebCore/platform/gtk/GtkTouchContextHelper.cpp

    r163748 r163749  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
    3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
     2 * Copyright (C) 2013 Carlos Garnacho <carlosg@gnome.org>
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2524 */
    2625
    27 #ifndef WebEventFactory_h
    28 #define WebEventFactory_h
     26#include "config.h"
     27#include "GtkTouchContextHelper.h"
    2928
    30 #include "WebEvent.h"
    31 #include <WebCore/CompositionResults.h>
     29#include <gtk/gtk.h>
    3230
    33 typedef union _GdkEvent GdkEvent;
     31namespace WebCore {
    3432
    35 namespace WebKit {
     33bool GtkTouchContextHelper::handleEvent(GdkEvent* touchEvent)
     34{
     35#ifndef GTK_API_VERSION_2
     36    uint32_t sequence = GPOINTER_TO_UINT(gdk_event_get_event_sequence(touchEvent));
    3637
    37 class WebEventFactory {
    38 public:
    39     static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
    40     static WebWheelEvent createWebWheelEvent(const GdkEvent*);
    41     static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
    42 };
     38    switch (touchEvent->type) {
     39    case GDK_TOUCH_BEGIN: {
     40        ASSERT(m_touchEvents.contains(sequence));
     41        GUniquePtr<GdkEvent> event(gdk_event_copy(touchEvent));
     42        m_touchEvents.add(sequence, std::move(event));
     43        break;
     44    }
     45    case GDK_TOUCH_UPDATE: {
     46        auto it = m_touchEvents.find(sequence);
     47        ASSERT(it != m_touchEvents.end());
     48        it->value.reset(gdk_event_copy(touchEvent));
     49        break;
     50    }
     51    case GDK_TOUCH_END:
     52        ASSERT(m_touchEvents.contains(sequence));
     53        m_touchEvents.remove(sequence);
     54        break;
     55    default:
     56        return false;
     57    }
     58#endif // GTK_API_VERSION_2
    4359
    44 } // namespace WebKit
     60    return true;
     61}
    4562
    46 #endif // WebEventFactory_h
     63} // namespace WebCore
  • trunk/Source/WebCore/platform/gtk/GtkTouchContextHelper.h

    r163748 r163749  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
    3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
     2 * Copyright (C) 2013 Carlos Garnacho <carlosg@gnome.org>
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2524 */
    2625
    27 #ifndef WebEventFactory_h
    28 #define WebEventFactory_h
     26#ifndef GtkTouchContextHelper_h
     27#define GtkTouchContextHelper_h
    2928
    30 #include "WebEvent.h"
    31 #include <WebCore/CompositionResults.h>
     29#include "GUniquePtrGtk.h"
     30#include <wtf/HashMap.h>
     31#include <wtf/Noncopyable.h>
    3232
    33 typedef union _GdkEvent GdkEvent;
     33namespace WebCore {
    3434
    35 namespace WebKit {
     35typedef HashMap<uint32_t, GUniquePtr<GdkEvent>> TouchEventsMap;
    3636
    37 class WebEventFactory {
     37class GtkTouchContextHelper {
     38    WTF_MAKE_NONCOPYABLE(GtkTouchContextHelper);
    3839public:
    39     static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
    40     static WebWheelEvent createWebWheelEvent(const GdkEvent*);
    41     static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
     40    GtkTouchContextHelper() { };
     41    bool handleEvent(GdkEvent*);
     42    const TouchEventsMap& touchEvents() const { return m_touchEvents; };
     43
     44private:
     45    TouchEventsMap m_touchEvents;
    4246};
    4347
    44 } // namespace WebKit
     48} // namespace WebCore
    4549
    46 #endif // WebEventFactory_h
     50#endif
  • trunk/Source/WebKit/gtk/ChangeLog

    r163739 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Allow building with touch events enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Even though WebKit1 GTK code doesn't implement touch events,
     9        Fix build if ENABLE_TOUCH_EVENTS is present for WK2.
     10
     11        * WebCoreSupport/ChromeClientGtk.h:
     12        (WebKit::ChromeClient::needTouchEvents): Add empty stub
     13
    1142014-02-08  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h

    r163724 r163749  
    142142
    143143        virtual void numWheelEventHandlersChanged(unsigned) { }
     144        virtual void needTouchEvents(bool) { }
    144145
    145146        virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*);
  • trunk/Source/WebKit2/ChangeLog

    r163748 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Implement support touch events
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        In GTK+ >= 3.4.0, GdkEventTouch is available to inform about multitouch events. Use these to implement
     9        touch events on this platform. If a touch is left unhandled and is the "pointer emulating" one, mouse
     10        events will be generated as a fallback.
     11
     12        * GNUmakefile.list.am:
     13        * PlatformGTK.cmake:
     14        * Shared/gtk/NativeWebTouchEventGtk.cpp:
     15        * Shared/NativeWebTouchEvent.h:
     16        (WebKit::NativeWebTouchEvent::nativeEvent):
     17        (WebKit::NativeWebTouchEvent::touchContext): Add GTK+ implementation of NativeWebTouchEvent.
     18        * Shared/gtk/WebEventFactory.cpp:
     19        (WebKit::touchPhaseFromEvents):
     20        (WebKit::WebEventFactory::createWebTouchEvent): Add methods to generate WebTouchEvents out
     21        of GdkEventTouch events, a GtkTouchContextHelper object is used to hold information about all current
     22        touches, in order to build information about all individual touchpoints.
     23        * Shared/gtk/WebEventFactory.h:
     24        * UIProcess/API/gtk/PageClientImpl.cpp:
     25        (WebKit::PageClientImpl::doneWithTouchEvent): Implement pointer emulation. If a touch event was unhandled
     26        in DOM and pertains to the touch sequence that emulates pointer events. The event gets transformed to its
     27        mouse event counterpart and handled by the widget again.
     28        * UIProcess/API/gtk/PageClientImpl.h:
     29        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     30        (webkitWebViewBaseRealize): Listen for touch events
     31        (webkitWebViewBaseTouchEvent):
     32        (webkit_web_view_base_class_init): Add implementation for the touch_events() handler, this merely
     33        lets the pageProxy handle the NativeWebTouchEvent we create to wrap the GdkEvent received.
     34
    1352014-02-09  Commit Queue  <commit-queue@webkit.org>
    236
  • trunk/Source/WebKit2/GNUmakefile.list.am

    r163521 r163749  
    385385        Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \
    386386        Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp \
     387        Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp \
    387388        Source/WebKit2/Shared/gtk/NativeWebWheelEventGtk.cpp \
    388389        Source/WebKit2/Shared/gtk/PrintInfoGtk.cpp \
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r163155 r163749  
    5757    Shared/gtk/NativeWebKeyboardEventGtk.cpp
    5858    Shared/gtk/NativeWebMouseEventGtk.cpp
     59    Shared/gtk/NativeWebTouchEventGtk.cpp
    5960    Shared/gtk/NativeWebWheelEventGtk.cpp
    6061    Shared/gtk/PrintInfoGtk.cpp
     
    566567        Shared/WebKit2Initialize.cpp
    567568        Shared/WebMouseEvent.cpp
     569        Shared/WebPlatformTouchPoint.cpp
     570        Shared/WebTouchEvent.cpp
    568571        Shared/WebWheelEvent.cpp
    569572
     
    584587        Shared/gtk/NativeWebKeyboardEventGtk.cpp
    585588        Shared/gtk/NativeWebMouseEventGtk.cpp
     589        Shared/gtk/NativeWebTouchEventGtk.cpp
    586590        Shared/gtk/NativeWebWheelEventGtk.cpp
    587591        Shared/gtk/ProcessExecutablePathGtk.cpp
  • trunk/Source/WebKit2/Shared/NativeWebTouchEvent.h

    r159985 r163749  
    3232#include <wtf/RetainPtr.h>
    3333OBJC_CLASS UIWebTouchEventsGestureRecognizer;
    34 #endif // PLATFORM(IOS)
    35 
    36 #if PLATFORM(EFL)
     34#elif PLATFORM(GTK)
     35#include <WebCore/GUniquePtrGtk.h>
     36#include <WebCore/GtkTouchContextHelper.h>
     37#elif PLATFORM(EFL)
    3738#include "EwkTouchEvent.h"
    3839#include <WebCore/AffineTransform.h>
     
    4748    explicit NativeWebTouchEvent(UIWebTouchEventsGestureRecognizer *);
    4849    const UIWebTouchEventsGestureRecognizer* nativeEvent() const { return m_nativeEvent.get(); }
    49 #endif
    50 #if PLATFORM(EFL)
     50#elif PLATFORM(GTK)
     51    NativeWebTouchEvent(const NativeWebTouchEvent&);
     52    NativeWebTouchEvent(GdkEvent*, WebCore::GtkTouchContextHelper&);
     53    const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
     54    const WebCore::GtkTouchContextHelper& touchContext() const { return m_touchContext; }
     55#elif PLATFORM(EFL)
    5156    NativeWebTouchEvent(EwkTouchEvent*, const WebCore::AffineTransform&);
    5257    const EwkTouchEvent* nativeEvent() const { return m_nativeEvent.get(); }
     
    5661#if PLATFORM(IOS)
    5762    RetainPtr<UIWebTouchEventsGestureRecognizer> m_nativeEvent;
    58 #endif
    59 #if PLATFORM(EFL)
     63#elif PLATFORM(GTK)
     64    GUniquePtr<GdkEvent> m_nativeEvent;
     65    const WebCore::GtkTouchContextHelper& m_touchContext;
     66#elif PLATFORM(EFL)
    6067    RefPtr<EwkTouchEvent> m_nativeEvent;
    6168#endif
  • trunk/Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp

    r163748 r163749  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
    3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
     2 * Copyright (C) 2013 Carlos Garnacho <carlosg@gnome.org>
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2524 */
    2625
    27 #ifndef WebEventFactory_h
    28 #define WebEventFactory_h
     26#include "config.h"
     27#include "NativeWebTouchEvent.h"
    2928
    30 #include "WebEvent.h"
    31 #include <WebCore/CompositionResults.h>
    32 
    33 typedef union _GdkEvent GdkEvent;
     29#include "WebEventFactory.h"
     30#include <gdk/gdk.h>
    3431
    3532namespace WebKit {
    3633
    37 class WebEventFactory {
    38 public:
    39     static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
    40     static WebWheelEvent createWebWheelEvent(const GdkEvent*);
    41     static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
    42 };
     34NativeWebTouchEvent::NativeWebTouchEvent(GdkEvent* event, WebCore::GtkTouchContextHelper& context)
     35    : WebTouchEvent(WebEventFactory::createWebTouchEvent(event, context))
     36    , m_nativeEvent(gdk_event_copy(event))
     37    , m_touchContext(context)
     38{
     39}
     40
     41NativeWebTouchEvent::NativeWebTouchEvent(const NativeWebTouchEvent& event)
     42    : WebTouchEvent(WebEventFactory::createWebTouchEvent(event.nativeEvent(), event.touchContext()))
     43    , m_nativeEvent(gdk_event_copy(event.nativeEvent()))
     44    , m_touchContext(event.touchContext())
     45{
     46}
    4347
    4448} // namespace WebKit
    45 
    46 #endif // WebEventFactory_h
  • trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp

    r147137 r163749  
    3535#include <gdk/gdk.h>
    3636#include <gdk/gdkkeysyms.h>
     37#include <gtk/gtk.h>
    3738#include <wtf/ASCIICType.h>
    3839
     
    204205}
    205206
     207#ifndef GTK_API_VERSION_2
     208static WebPlatformTouchPoint::TouchPointState touchPhaseFromEvents(const GdkEvent* current, const GdkEvent* event)
     209{
     210    if (gdk_event_get_event_sequence(current) != gdk_event_get_event_sequence(event))
     211        return WebPlatformTouchPoint::TouchStationary;
     212
     213    switch (current->type) {
     214    case GDK_TOUCH_UPDATE:
     215        return WebPlatformTouchPoint::TouchMoved;
     216    case GDK_TOUCH_BEGIN:
     217        return WebPlatformTouchPoint::TouchPressed;
     218    case GDK_TOUCH_END:
     219        return WebPlatformTouchPoint::TouchReleased;
     220    default:
     221        return WebPlatformTouchPoint::TouchStationary;
     222    }
     223}
     224
     225static void appendTouchEvent(Vector<WebPlatformTouchPoint>& touchPointList, const GdkEvent* event, WebPlatformTouchPoint::TouchPointState state)
     226{
     227    uint32_t identifier = GPOINTER_TO_UINT(gdk_event_get_event_sequence(event));
     228
     229    gdouble x, y;
     230    gdk_event_get_coords(event, &x, &y);
     231
     232    gdouble xRoot, yRoot;
     233    gdk_event_get_root_coords(event, &xRoot, &yRoot);
     234
     235    WebPlatformTouchPoint touchPoint(identifier, state, IntPoint(xRoot, yRoot), IntPoint(x, y));
     236    touchPointList.uncheckedAppend(touchPoint);
     237}
     238#endif // GTK_API_VERSION_2
     239
     240WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, const WebCore::GtkTouchContextHelper& touchContext)
     241{
     242#ifndef GTK_API_VERSION_2
     243    WebEvent::Type type = WebEvent::NoType;
     244    const auto& touchEvents = touchContext.touchEvents();
     245    int numEvents = touchEvents.size();
     246
     247    switch (event->type) {
     248    case GDK_TOUCH_BEGIN:
     249        type = WebEvent::TouchStart;
     250        break;
     251    case GDK_TOUCH_UPDATE:
     252        type = WebEvent::TouchMove;
     253        break;
     254    case GDK_TOUCH_END:
     255        type = WebEvent::TouchEnd;
     256        ++numEvents;
     257        break;
     258    default:
     259        ASSERT_NOT_REACHED();
     260    }
     261
     262    Vector<WebPlatformTouchPoint> touchPointList;
     263    touchPointList.reserveInitialCapacity(numEvents);
     264
     265    for (auto it = touchEvents.begin(); it != touchEvents.end(); ++it)
     266        appendTouchEvent(touchPointList, it->value.get(), touchPhaseFromEvents(it->value.get(), event));
     267
     268    // Touch was already removed from the GtkTouchContextHelper, add it here.
     269    if (event->type == GDK_TOUCH_END)
     270        appendTouchEvent(touchPointList, event, WebPlatformTouchPoint::TouchReleased);
     271
     272    return WebTouchEvent(type, touchPointList, modifiersForEvent(event), gdk_event_get_time(event));
     273#else
     274    return WebTouchEvent();
     275#endif // GTK_API_VERSION_2
     276}
     277
    206278} // namespace WebKit
  • trunk/Source/WebKit2/Shared/gtk/WebEventFactory.h

    r138544 r163749  
    3030#include "WebEvent.h"
    3131#include <WebCore/CompositionResults.h>
     32#include <WebCore/GtkTouchContextHelper.h>
    3233
    3334typedef union _GdkEvent GdkEvent;
     
    4041    static WebWheelEvent createWebWheelEvent(const GdkEvent*);
    4142    static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
     43    static WebTouchEvent createWebTouchEvent(const GdkEvent*, const WebCore::GtkTouchContextHelper&);
    4244};
    4345
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r163116 r163749  
    328328#endif // ENABLE(FULLSCREEN_API)
    329329
     330void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
     331{
     332    if (wasEventHandled)
     333        return;
     334
     335    // Emulate pointer events if unhandled.
     336    const GdkEvent* touchEvent = event.nativeEvent();
     337
     338    if (!touchEvent->touch.emulating_pointer)
     339        return;
     340
     341    GUniquePtr<GdkEvent> pointerEvent;
     342
     343    if (touchEvent->type == GDK_TOUCH_UPDATE) {
     344        pointerEvent.reset(gdk_event_new(GDK_MOTION_NOTIFY));
     345        pointerEvent->motion.time = touchEvent->touch.time;
     346        pointerEvent->motion.x = touchEvent->touch.x;
     347        pointerEvent->motion.y = touchEvent->touch.y;
     348        pointerEvent->motion.x_root = touchEvent->touch.x_root;
     349        pointerEvent->motion.y_root = touchEvent->touch.y_root;
     350        pointerEvent->motion.state = touchEvent->touch.state | GDK_BUTTON1_MASK;
     351    } else {
     352        switch (touchEvent->type) {
     353        case GDK_TOUCH_END:
     354            pointerEvent.reset(gdk_event_new(GDK_BUTTON_RELEASE));
     355            pointerEvent->button.state = touchEvent->touch.state | GDK_BUTTON1_MASK;
     356            break;
     357        case GDK_TOUCH_BEGIN:
     358            pointerEvent.reset(gdk_event_new(GDK_BUTTON_PRESS));
     359            break;
     360        default:
     361            ASSERT_NOT_REACHED();
     362        }
     363
     364        pointerEvent->button.button = 1;
     365        pointerEvent->button.time = touchEvent->touch.time;
     366        pointerEvent->button.x = touchEvent->touch.x;
     367        pointerEvent->button.y = touchEvent->touch.y;
     368        pointerEvent->button.x_root = touchEvent->touch.x_root;
     369        pointerEvent->button.y_root = touchEvent->touch.y_root;
     370    }
     371
     372    gdk_event_set_device(pointerEvent.get(), gdk_event_get_device(touchEvent));
     373    gdk_event_set_source_device(pointerEvent.get(), gdk_event_get_source_device(touchEvent));
     374    pointerEvent->any.window = GDK_WINDOW(g_object_ref(touchEvent->any.window));
     375    pointerEvent->any.send_event = TRUE;
     376
     377    gtk_widget_event(m_viewWidget, pointerEvent.get());
     378}
     379
    330380} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

    r163116 r163749  
    120120#endif
    121121
     122    virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override;
     123
    122124    // Members of PageClientImpl class
    123125    GtkWidget* m_viewWidget;
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r163708 r163749  
    5454#include <WebCore/GtkClickCounter.h>
    5555#include <WebCore/GtkDragAndDropHelper.h>
     56#include <WebCore/GtkTouchContextHelper.h>
    5657#include <WebCore/GtkUtilities.h>
    5758#include <WebCore/GtkVersioning.h>
     
    111112    WebContextMenuProxyGtk* activeContextMenuProxy;
    112113    WebViewBaseInputMethodFilter inputMethodFilter;
     114    GtkTouchContextHelper touchContext;
    113115
    114116    GtkWindow* toplevelOnScreenWindow;
     
    273275        | GDK_BUTTON1_MOTION_MASK
    274276        | GDK_BUTTON2_MOTION_MASK
    275         | GDK_BUTTON3_MOTION_MASK;
     277        | GDK_BUTTON3_MOTION_MASK
     278        | GDK_TOUCH_MASK;
    276279
    277280    gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
     
    709712
    710713    priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */));
     714
     715    return TRUE;
     716}
     717
     718static gboolean webkitWebViewBaseTouchEvent(GtkWidget* widget, GdkEventTouch* event)
     719{
     720    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
     721
     722    if (priv->authenticationDialog)
     723        return TRUE;
     724
     725    priv->touchContext.handleEvent(reinterpret_cast<GdkEvent*>(event));
     726    priv->pageProxy->handleTouchEvent(NativeWebTouchEvent(reinterpret_cast<GdkEvent*>(event), priv->touchContext));
    711727
    712728    return TRUE;
     
    897913    widgetClass->scroll_event = webkitWebViewBaseScrollEvent;
    898914    widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent;
     915    widgetClass->touch_event = webkitWebViewBaseTouchEvent;
    899916    widgetClass->query_tooltip = webkitWebViewBaseQueryTooltip;
    900917#if ENABLE(DRAG_SUPPORT)
  • trunk/Source/autotools/SetupWebKitFeatures.m4

    r163483 r163749  
    160160    ENABLE_SATURATED_LAYOUT_ARITHMETIC=1\
    161161    ENABLE_TEXT_AUTOSIZING=0 \
    162     ENABLE_TOUCH_EVENTS=0 \
     162    ENABLE_TOUCH_EVENTS=1 \
    163163    ENABLE_TOUCH_ICON_LOADING=0 \
    164164    ENABLE_USER_TIMING=0 \
  • trunk/Source/cmake/OptionsGTK.cmake

    r163440 r163749  
    6767WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
    6868WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT ON)
    69 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS OFF)
     69WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
    7070WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL ON)
    7171WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION OFF)
  • trunk/Tools/ChangeLog

    r163743 r163749  
     12014-02-09  Carlos Garnacho  <carlosg@gnome.org>
     2
     3        [GTK] Enable touch features
     4        https://bugs.webkit.org/show_bug.cgi?id=98931
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * WebKitTestRunner/EventSenderProxy.h:
     9        * WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
     10        (WTR::updateEventCoordinates):
     11        (WTR::EventSenderProxy::createTouchEvent):
     12        (WTR::EventSenderProxy::addTouchPoint):
     13        (WTR::EventSenderProxy::updateTouchPoint):
     14        (WTR::EventSenderProxy::sendUpdatedTouchEvents):
     15        (WTR::EventSenderProxy::setTouchPointRadius):
     16        (WTR::EventSenderProxy::setTouchModifier): Implement touch event proxying.
     17
    1182014-02-08  Andreas Kling  <akling@apple.com>
    219
  • trunk/Tools/DumpRenderTree/gtk/EventSender.cpp

    r162599 r163749  
    913913}
    914914
     915static JSValueRef clearTouchPointsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     916{
     917    return JSValueMakeUndefined(context);
     918}
     919
    915920static JSStaticFunction staticFunctions[] = {
    916921    { "mouseScrollBy", mouseScrollByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/Scripts/webkitperl/FeatureList.pm

    r163483 r163749  
    427427
    428428    { option => "touch-events", desc => "Toggle Touch Events support",
    429       define => "ENABLE_TOUCH_EVENTS", default => (isIOSWebKit() || isEfl()), value => \$touchEventsSupport },
     429      define => "ENABLE_TOUCH_EVENTS", default => (isIOSWebKit() || isEfl() || isGtk()), value => \$touchEventsSupport },
    430430
    431431    { option => "touch-slider", desc => "Toggle Touch Slider support",
  • trunk/Tools/WebKitTestRunner/EventSenderProxy.h

    r156797 r163749  
    2929
    3030#include <wtf/Deque.h>
     31#include <wtf/HashMap.h>
     32#include <wtf/Vector.h>
    3133
    3234#if PLATFORM(GTK)
     35#include <WebCore/GUniquePtrGtk.h>
    3336#include <gdk/gdk.h>
     37#include <wtf/HashSet.h>
    3438#elif PLATFORM(EFL)
    3539#include <WebKit2/EWebKit2.h>
     
    9195    void sendOrQueueEvent(GdkEvent*);
    9296    GdkEvent* createMouseButtonEvent(GdkEventType, unsigned button, WKEventModifiers);
     97    GUniquePtr<GdkEvent> createTouchEvent(GdkEventType, int id);
     98    void sendUpdatedTouchEvents();
    9399#elif PLATFORM(EFL)
    94100    void sendOrQueueEvent(const WTREvent&);
     
    111117    Deque<WTREventQueueItem> m_eventQueue;
    112118    unsigned m_mouseButtonCurrentlyDown;
     119    Vector<GUniquePtr<GdkEvent>> m_touchEvents;
     120    HashSet<int> m_updatedTouchEvents;
    113121#elif PLATFORM(EFL)
    114122    Deque<WTREvent> m_eventQueue;
  • trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp

    r163373 r163749  
    3434#include "EventSenderProxy.h"
    3535
     36#include "NotImplemented.h"
    3637#include "PlatformWebView.h"
    3738#include "TestController.h"
     
    442443}
    443444
     445void updateEventCoordinates(GdkEvent* touchEvent, int x, int y)
     446{
     447    touchEvent->touch.x = x;
     448    touchEvent->touch.y = y;
     449
     450    int xRoot, yRoot;
     451    gdk_window_get_root_coords(touchEvent->touch.window, x, y, &xRoot, &yRoot);
     452    touchEvent->touch.x_root = xRoot;
     453    touchEvent->touch.y_root = yRoot;
     454}
     455
     456GUniquePtr<GdkEvent> EventSenderProxy::createTouchEvent(GdkEventType eventType, int id)
     457{
     458    GUniquePtr<GdkEvent> touchEvent(gdk_event_new(eventType));
     459
     460    touchEvent->touch.sequence = static_cast<GdkEventSequence*>(GINT_TO_POINTER(id));
     461    touchEvent->touch.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView()));
     462    g_object_ref(touchEvent->touch.window);
     463    gdk_event_set_device(touchEvent.get(), gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(touchEvent->button.window))));
     464    touchEvent->touch.time = GDK_CURRENT_TIME;
     465
     466    return touchEvent;
     467}
     468
     469void EventSenderProxy::addTouchPoint(int x, int y)
     470{
     471    // Touch ID is array index plus one, so 0 is skipped.
     472    GUniquePtr<GdkEvent> event = createTouchEvent(static_cast<GdkEventType>(GDK_TOUCH_BEGIN), m_touchEvents.size() + 1);
     473    updateEventCoordinates(event.get(), x, y);
     474    m_touchEvents.append(std::move(event));
     475    m_updatedTouchEvents.add(GPOINTER_TO_INT(event->touch.sequence));
     476}
     477
     478void EventSenderProxy::updateTouchPoint(int index, int x, int y)
     479{
     480    ASSERT(index >= 0 && index < m_touchEvents.size());
     481
     482    const auto& event = m_touchEvents[index];
     483    ASSERT(event);
     484
     485    event->type = GDK_TOUCH_UPDATE;
     486    updateEventCoordinates(event.get(), x, y);
     487    m_updatedTouchEvents.add(GPOINTER_TO_INT(event->touch.sequence));
     488}
     489
     490void EventSenderProxy::sendUpdatedTouchEvents()
     491{
     492    for (auto id : m_updatedTouchEvents)
     493        sendOrQueueEvent(gdk_event_copy(m_touchEvents[id - 1].get()));
     494
     495    m_updatedTouchEvents.clear();
     496}
     497
     498void EventSenderProxy::touchStart()
     499{
     500    sendUpdatedTouchEvents();
     501}
     502
     503void EventSenderProxy::touchMove()
     504{
     505    sendUpdatedTouchEvents();
     506}
     507
     508void EventSenderProxy::touchEnd()
     509{
     510    sendUpdatedTouchEvents();
     511}
     512
     513void EventSenderProxy::touchCancel()
     514{
     515    notImplemented();
     516}
     517
     518void EventSenderProxy::clearTouchPoints()
     519{
     520    m_updatedTouchEvents.clear();
     521    m_touchEvents.clear();
     522}
     523
     524void EventSenderProxy::releaseTouchPoint(int index)
     525{
     526    ASSERT(index >= 0 && index < m_touchEvents.size());
     527
     528    const auto& event = m_touchEvents[index];
     529    event->type = GDK_TOUCH_END;
     530    m_updatedTouchEvents.add(GPOINTER_TO_INT(event->touch.sequence));
     531}
     532
     533void EventSenderProxy::cancelTouchPoint(int index)
     534{
     535    notImplemented();
     536}
     537
     538void EventSenderProxy::setTouchPointRadius(int radiusX, int radiusY)
     539{
     540    notImplemented();
     541}
     542
     543void EventSenderProxy::setTouchModifier(WKEventModifiers modifier, bool enable)
     544{
     545    guint state = webkitModifiersToGDKModifiers(modifier);
     546
     547    for (const auto& event : m_touchEvents) {
     548        if (event->type == GDK_TOUCH_END)
     549            continue;
     550
     551        if (enable)
     552            event->touch.state |= state;
     553        else
     554            event->touch.state &= ~(state);
     555
     556        m_updatedTouchEvents.add(GPOINTER_TO_INT(event->touch.sequence));
     557    }
     558}
     559
     560
    444561} // namespace WTR
Note: See TracChangeset for help on using the changeset viewer.