Changeset 152147 in webkit


Ignore:
Timestamp:
Jun 27, 2013 6:53:32 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Add WK2 C API to handle touch events.
https://bugs.webkit.org/show_bug.cgi?id=108915

Patch by Eunmi Lee <eunmi15.lee@samsung.com> on 2013-06-27
Reviewed by Gyuyoung Kim.

Touch events for our target platforms differ (XInput2, Wayland, Tizen) so
for the EFL port we want to be able to feed events manually.

To keep our current API for desktop EFL/Enlightenment working, we convert
our currently limited EFL events to the new EFL specific C EwkTouchPoint
and EwkTouchEvent type.

EwkTouchPoint and EwkTouchEvent are exposed as WKTouchPointRef and
WKTouchEventRef, so they are opaque in the applications.

The WKViewSendTouchEvent can be used for any use-case (platform/product)
not involving the EFL events.

At the same time we make sure to avoid using WK2 internals in our EFL API
implementation.

  • PlatformEfl.cmake:
  • Shared/API/c/efl/WKBaseEfl.h:
  • Shared/APIObject.h:
  • Shared/NativeWebTouchEvent.h:

(WebKit::NativeWebTouchEvent::nativeEvent):

  • Shared/efl/NativeWebTouchEventEfl.cpp:

(WebKit::NativeWebTouchEvent::NativeWebTouchEvent):

  • Shared/efl/WebEventFactory.cpp:

(WebKit::toWebPlatformTouchPointState):
(WebKit::toWebEventType):
(WebKit::toWebEventModifiers):
(WebKit::WebEventFactory::createWebTouchEvent):

  • Shared/efl/WebEventFactory.h:
  • UIProcess/API/C/efl/WKAPICastEfl.h:
  • UIProcess/API/C/efl/WKEventEfl.cpp: Added.

(WKTouchPointCreate):
(WKTouchEventCreate):

  • UIProcess/API/C/efl/WKEventEfl.h: Added.
  • UIProcess/API/C/efl/WKViewEfl.cpp:

(WKViewSendTouchEvent):

  • UIProcess/API/C/efl/WKViewEfl.h:
  • UIProcess/API/efl/EwkView.cpp:

(toWKTouchPointState):
(toWKEventModifiers):
(EwkView::feedTouchEvent):
(EwkView::feedTouchEvents):

  • UIProcess/efl/EwkTouchEvent.cpp: Added.

(WebKit::EwkTouchEvent::EwkTouchEvent):

  • UIProcess/efl/EwkTouchEvent.h: Added.

(WebKit::EwkTouchEvent::create):
(WebKit::EwkTouchEvent::eventType):
(WebKit::EwkTouchEvent::touchPoints):
(WebKit::EwkTouchEvent::modifiers):
(WebKit::EwkTouchEvent::timestamp):
(WebKit::EwkTouchEvent::type):

  • UIProcess/efl/EwkTouchPoint.cpp: Added.

(WebKit::EwkTouchPoint::EwkTouchPoint):

  • UIProcess/efl/EwkTouchPoint.h: Added.

(WebKit::EwkTouchPoint::create):
(WebKit::EwkTouchPoint::id):
(WebKit::EwkTouchPoint::state):
(WebKit::EwkTouchPoint::screenPosition):
(WebKit::EwkTouchPoint::position):
(WebKit::EwkTouchPoint::radius):
(WebKit::EwkTouchPoint::rotationAngle):
(WebKit::EwkTouchPoint::forceFactor):
(WebKit::EwkTouchPoint::type):

  • UIProcess/efl/WebViewEfl.cpp:

(WebKit::WebViewEfl::sendTouchEvent):

  • UIProcess/efl/WebViewEfl.h:
Location:
trunk/Source/WebKit2
Files:
1 added
14 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r152110 r152147  
     12013-06-27  Eunmi Lee  <eunmi15.lee@samsung.com>
     2
     3        [EFL][WK2] Add WK2 C API to handle touch events.
     4        https://bugs.webkit.org/show_bug.cgi?id=108915
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Touch events for our target platforms differ (XInput2, Wayland, Tizen) so
     9        for the EFL port we want to be able to feed events manually.
     10
     11        To keep our current API for desktop EFL/Enlightenment working, we convert
     12        our currently limited EFL events to the new EFL specific C EwkTouchPoint
     13        and EwkTouchEvent type.
     14
     15        EwkTouchPoint and EwkTouchEvent are exposed as WKTouchPointRef and
     16        WKTouchEventRef, so they are opaque in the applications.
     17
     18        The WKViewSendTouchEvent can be used for any use-case (platform/product)
     19        not involving the EFL events.
     20
     21        At the same time we make sure to avoid using WK2 internals in our EFL API
     22        implementation.
     23
     24        * PlatformEfl.cmake:
     25        * Shared/API/c/efl/WKBaseEfl.h:
     26        * Shared/APIObject.h:
     27        * Shared/NativeWebTouchEvent.h:
     28        (WebKit::NativeWebTouchEvent::nativeEvent):
     29        * Shared/efl/NativeWebTouchEventEfl.cpp:
     30        (WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
     31        * Shared/efl/WebEventFactory.cpp:
     32        (WebKit::toWebPlatformTouchPointState):
     33        (WebKit::toWebEventType):
     34        (WebKit::toWebEventModifiers):
     35        (WebKit::WebEventFactory::createWebTouchEvent):
     36        * Shared/efl/WebEventFactory.h:
     37        * UIProcess/API/C/efl/WKAPICastEfl.h:
     38        * UIProcess/API/C/efl/WKEventEfl.cpp: Added.
     39        (WKTouchPointCreate):
     40        (WKTouchEventCreate):
     41        * UIProcess/API/C/efl/WKEventEfl.h: Added.
     42        * UIProcess/API/C/efl/WKViewEfl.cpp:
     43        (WKViewSendTouchEvent):
     44        * UIProcess/API/C/efl/WKViewEfl.h:
     45        * UIProcess/API/efl/EwkView.cpp:
     46        (toWKTouchPointState):
     47        (toWKEventModifiers):
     48        (EwkView::feedTouchEvent):
     49        (EwkView::feedTouchEvents):
     50        * UIProcess/efl/EwkTouchEvent.cpp: Added.
     51        (WebKit::EwkTouchEvent::EwkTouchEvent):
     52        * UIProcess/efl/EwkTouchEvent.h: Added.
     53        (WebKit::EwkTouchEvent::create):
     54        (WebKit::EwkTouchEvent::eventType):
     55        (WebKit::EwkTouchEvent::touchPoints):
     56        (WebKit::EwkTouchEvent::modifiers):
     57        (WebKit::EwkTouchEvent::timestamp):
     58        (WebKit::EwkTouchEvent::type):
     59        * UIProcess/efl/EwkTouchPoint.cpp: Added.
     60        (WebKit::EwkTouchPoint::EwkTouchPoint):
     61        * UIProcess/efl/EwkTouchPoint.h: Added.
     62        (WebKit::EwkTouchPoint::create):
     63        (WebKit::EwkTouchPoint::id):
     64        (WebKit::EwkTouchPoint::state):
     65        (WebKit::EwkTouchPoint::screenPosition):
     66        (WebKit::EwkTouchPoint::position):
     67        (WebKit::EwkTouchPoint::radius):
     68        (WebKit::EwkTouchPoint::rotationAngle):
     69        (WebKit::EwkTouchPoint::forceFactor):
     70        (WebKit::EwkTouchPoint::type):
     71        * UIProcess/efl/WebViewEfl.cpp:
     72        (WebKit::WebViewEfl::sendTouchEvent):
     73        * UIProcess/efl/WebViewEfl.h:
     74
    1752013-06-27  Csaba Osztrogonác  <ossy@webkit.org>
    276
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r150460 r152147  
    5050    UIProcess/API/C/CoordinatedGraphics/WKView.cpp
    5151
     52    UIProcess/API/C/efl/WKEventEfl.cpp
    5253    UIProcess/API/C/efl/WKPageEfl.cpp
    5354    UIProcess/API/C/efl/WKPopupItem.cpp
     
    105106    UIProcess/efl/ContextMenuClientEfl.cpp
    106107    UIProcess/efl/DownloadManagerEfl.cpp
     108    UIProcess/efl/EwkTouchEvent.cpp
     109    UIProcess/efl/EwkTouchPoint.cpp
    107110    UIProcess/efl/FindClientEfl.cpp
    108111    UIProcess/efl/FormClientEfl.cpp
  • trunk/Source/WebKit2/Shared/API/c/efl/WKBaseEfl.h

    r143275 r152147  
    2828typedef const struct OpaqueWKPopupItem* WKPopupItemRef;
    2929typedef const struct OpaqueWKPopupMenuListener* WKPopupMenuListenerRef;
     30typedef const struct OpaqueWKTouchPoint* WKTouchPointRef;
     31typedef const struct OpaqueWKTouchEvent* WKTouchEventRef;
    3032
    3133#endif /* WKBaseEfl_h */
  • trunk/Source/WebKit2/Shared/APIObject.h

    r149417 r152147  
    138138#if PLATFORM(EFL)
    139139        TypePopupMenuItem,
     140#if ENABLE(TOUCH_EVENTS)
     141        TypeTouchPoint,
     142        TypeTouchEvent,
     143#endif
    140144#endif
    141145    };
  • trunk/Source/WebKit2/Shared/NativeWebTouchEvent.h

    r133012 r152147  
    3232#include <QTouchEvent>
    3333#elif PLATFORM(EFL)
    34 #include "ewk_touch.h"
    35 #include <Evas.h>
     34#include "EwkTouchEvent.h"
    3635#include <WebCore/AffineTransform.h>
     36#include <wtf/RefPtr.h>
    3737#endif
    3838
     
    4444    explicit NativeWebTouchEvent(const QTouchEvent*, const QTransform& fromItemTransform);
    4545#elif PLATFORM(EFL)
    46     NativeWebTouchEvent(Ewk_Touch_Event_Type, const Eina_List*, const Evas_Modifier*, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen, double timestamp);
     46    NativeWebTouchEvent(EwkTouchEvent*, const WebCore::AffineTransform&);
    4747#endif
    4848
    4949#if PLATFORM(QT)
    5050    const QTouchEvent* nativeEvent() const { return &m_nativeEvent; }
     51#elif PLATFORM(EFL)
     52    const EwkTouchEvent* nativeEvent() const { return m_nativeEvent.get(); }
    5153#endif
    5254
     
    5456#if PLATFORM(QT)
    5557    const QTouchEvent m_nativeEvent;
     58#elif PLATFORM(EFL)
     59    RefPtr<EwkTouchEvent> m_nativeEvent;
    5660#endif
    5761};
  • trunk/Source/WebKit2/Shared/efl/NativeWebTouchEventEfl.cpp

    r139287 r152147  
    3333namespace WebKit {
    3434
    35 NativeWebTouchEvent::NativeWebTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen, double timestamp)
    36     : WebTouchEvent(WebEventFactory::createWebTouchEvent(type, points, modifiers, toWebContent, toDeviceScreen, timestamp))
     35NativeWebTouchEvent::NativeWebTouchEvent(EwkTouchEvent* touchEvent, const WebCore::AffineTransform& toWebContent)
     36    : WebTouchEvent(WebEventFactory::createWebTouchEvent(touchEvent, toWebContent))
     37    , m_nativeEvent(touchEvent)
    3738{
    3839}
  • trunk/Source/WebKit2/Shared/efl/WebEventFactory.cpp

    r144898 r152147  
    3232#include <WebCore/Scrollbar.h>
    3333
     34#if ENABLE(TOUCH_EVENTS)
     35#include "EwkTouchEvent.h"
     36#include "EwkTouchPoint.h"
     37#include "ImmutableArray.h"
     38#include "WKAPICast.h"
     39#endif
     40
    3441using namespace WebCore;
    3542
     
    206213
    207214#if ENABLE(TOUCH_EVENTS)
    208 static inline WebEvent::Type typeForTouchEvent(Ewk_Touch_Event_Type type)
    209 {
    210     if (type == EWK_TOUCH_START)
     215static inline WebPlatformTouchPoint::TouchPointState toWebPlatformTouchPointState(WKTouchPointState state)
     216{
     217    switch (state) {
     218    case kWKTouchPointStateTouchReleased:
     219        return WebPlatformTouchPoint::TouchReleased;
     220    case kWKTouchPointStateTouchMoved:
     221        return WebPlatformTouchPoint::TouchMoved;
     222    case kWKTouchPointStateTouchPressed:
     223        return WebPlatformTouchPoint::TouchPressed;
     224    case kWKTouchPointStateTouchStationary:
     225        return WebPlatformTouchPoint::TouchStationary;
     226    case kWKTouchPointStateTouchCancelled:
     227    default:
     228        return WebPlatformTouchPoint::TouchCancelled;
     229    }
     230}
     231
     232static inline WebEvent::Type toWebEventType(WKEventType type)
     233{
     234    switch (type) {
     235    case kWKEventTypeTouchStart:
    211236        return WebEvent::TouchStart;
    212     if (type == EWK_TOUCH_MOVE)
     237    case kWKEventTypeTouchMove:
    213238        return WebEvent::TouchMove;
    214     if (type == EWK_TOUCH_END)
     239    case kWKEventTypeTouchEnd:
    215240        return WebEvent::TouchEnd;
    216     if (type == EWK_TOUCH_CANCEL)
     241    case kWKEventTypeTouchCancel:
    217242        return WebEvent::TouchCancel;
    218 
    219     return WebEvent::NoType;
    220 }
    221 
    222 WebTouchEvent WebEventFactory::createWebTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers, const AffineTransform& toWebContent, const AffineTransform& toDeviceScreen, double timestamp)
    223 {
     243    default:
     244        return WebEvent::NoType;
     245    }
     246
     247}
     248
     249static inline WebEvent::Modifiers toWebEventModifiers(unsigned modifiers)
     250{
     251    unsigned result = 0;
     252
     253    if (modifiers & kWKEventModifiersShiftKey)
     254        result |= WebEvent::ShiftKey;
     255    if (modifiers & kWKEventModifiersControlKey)
     256        result |= WebEvent::ControlKey;
     257    if (modifiers & kWKEventModifiersAltKey)
     258        result |= WebEvent::AltKey;
     259    if (modifiers & kWKEventModifiersMetaKey)
     260        result |= WebEvent::MetaKey;
     261
     262    return static_cast<WebEvent::Modifiers>(result);
     263}
     264
     265WebTouchEvent WebEventFactory::createWebTouchEvent(const EwkTouchEvent* event, const AffineTransform& toWebContent)
     266{
     267    ImmutableArray* touchPointsArray = toImpl(event->touchPoints());
     268    size_t size = touchPointsArray->size();
     269
    224270    Vector<WebPlatformTouchPoint> touchPoints;
    225     touchPoints.reserveInitialCapacity(eina_list_count(points));
    226 
    227     const Eina_List* list;
    228     void* item;
    229     EINA_LIST_FOREACH(points, list, item) {
    230         Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
    231 
    232         WebPlatformTouchPoint::TouchPointState state;
    233         switch (point->state) {
    234         case EVAS_TOUCH_POINT_UP:
    235             state = WebPlatformTouchPoint::TouchReleased;
    236             break;
    237         case EVAS_TOUCH_POINT_MOVE:
    238             state = WebPlatformTouchPoint::TouchMoved;
    239             break;
    240         case EVAS_TOUCH_POINT_DOWN:
    241             state = WebPlatformTouchPoint::TouchPressed;
    242             break;
    243         case EVAS_TOUCH_POINT_STILL:
    244             state = WebPlatformTouchPoint::TouchStationary;
    245             break;
    246         case EVAS_TOUCH_POINT_CANCEL:
    247             state = WebPlatformTouchPoint::TouchCancelled;
    248             break;
    249         default:
    250             ASSERT_NOT_REACHED();
    251             continue;
    252         }
    253 
    254         IntPoint pos(point->x, point->y);
    255         touchPoints.uncheckedAppend(WebPlatformTouchPoint(point->id, state, toDeviceScreen.mapPoint(pos), toWebContent.mapPoint(pos)));
    256     }
    257 
    258     return WebTouchEvent(typeForTouchEvent(type), touchPoints, modifiersForEvent(modifiers), timestamp);
     271    touchPoints.reserveInitialCapacity(size);
     272
     273    for (size_t i = 0; i < size; ++i) {
     274        if (EwkTouchPoint* point = touchPointsArray->at<EwkTouchPoint>(i))
     275            touchPoints.uncheckedAppend(WebPlatformTouchPoint(point->id(), toWebPlatformTouchPointState(point->state()), toIntPoint(point->screenPosition()), toWebContent.mapPoint(toIntPoint(point->position())), toIntSize(point->radius()), point->rotationAngle(), point->forceFactor()));
     276    }
     277
     278    return WebTouchEvent(toWebEventType(event->eventType()), touchPoints, toWebEventModifiers(event->modifiers()), event->timestamp());
    259279}
    260280#endif
  • trunk/Source/WebKit2/Shared/efl/WebEventFactory.h

    r133012 r152147  
    2828
    2929#include "WebEvent.h"
    30 #include "ewk_touch.h"
    3130#include <Evas.h>
    3231#include <WebCore/AffineTransform.h>
    3332
    3433namespace WebKit {
     34
     35#if ENABLE(TOUCH_EVENTS)
     36class EwkTouchEvent;
     37#endif
    3538
    3639class WebEventFactory {
     
    4346    static WebKeyboardEvent createWebKeyboardEvent(const Evas_Event_Key_Up*);
    4447#if ENABLE(TOUCH_EVENTS)
    45     static WebTouchEvent createWebTouchEvent(Ewk_Touch_Event_Type, const Eina_List*, const Evas_Modifier*, const WebCore::AffineTransform&, const WebCore::AffineTransform&, double timestamp);
     48    static WebTouchEvent createWebTouchEvent(const EwkTouchEvent*, const WebCore::AffineTransform&);
    4649#endif
    4750};
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKAPICastEfl.h

    r143275 r152147  
    3838WK_ADD_API_MAPPING(WKPopupMenuListenerRef, WebPopupMenuListenerEfl)
    3939
     40#if ENABLE(TOUCH_EVENTS)
     41class EwkTouchEvent;
     42class EwkTouchPoint;
     43
     44WK_ADD_API_MAPPING(WKTouchEventRef, EwkTouchEvent)
     45WK_ADD_API_MAPPING(WKTouchPointRef, EwkTouchPoint)
     46#endif
     47
    4048// Enum conversions.
    4149inline WKPopupItemTextDirection toAPI(WebCore::TextDirection direction)
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKEventEfl.cpp

    r152144 r152147  
    11/*
    2  * Copyright (C) 2013 Intel Corporation. All rights reserved.
     2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "WKViewEfl.h"
     27#include "WKEventEfl.h"
    2828
    29 #include "EwkView.h"
     29#include "EwkTouchEvent.h"
     30#include "EwkTouchPoint.h"
     31#include "ImmutableArray.h"
    3032#include "WKAPICast.h"
    31 #include "WebViewEfl.h"
    32 #include <WebKit2/WKImageCairo.h>
     33#include "WebEvent.h"
    3334
    3435using namespace WebKit;
    3536
    36 void WKViewPaintToCairoSurface(WKViewRef viewRef, cairo_surface_t* surface)
     37WKTouchPointRef WKTouchPointCreate(int id, WKPoint position, WKPoint screenPosition, WKTouchPointState state, WKSize radius, float rotationAngle, float forceFactor)
    3738{
    38     static_cast<WebViewEfl*>(toImpl(viewRef))->paintToCairoSurface(surface);
     39#if ENABLE(TOUCH_EVENTS)
     40    return toAPI(EwkTouchPoint::create(id, state, screenPosition, position, radius, rotationAngle, forceFactor).leakRef());
     41#else
     42    UNUSED_PARAM(id);
     43    UNUSED_PARAM(position);
     44    UNUSED_PARAM(screenPosition);
     45    UNUSED_PARAM(state);
     46    UNUSED_PARAM(radius);
     47    UNUSED_PARAM(rotationAngle);
     48    UNUSED_PARAM(forceFactor);
     49    return 0;
     50#endif
    3951}
    4052
    41 WKImageRef WKViewCreateSnapshot(WKViewRef viewRef)
     53WKTouchEventRef WKTouchEventCreate(WKEventType type, WKArrayRef wkTouchPoints, WKEventModifiers modifiers, double timestamp)
    4254{
    43     EwkView* ewkView = static_cast<WebViewEfl*>(toImpl(viewRef))->ewkView();
    44     return WKImageCreateFromCairoSurface(ewkView->takeSnapshot().get(), 0 /* options */);
     55#if ENABLE(TOUCH_EVENTS)
     56    return toAPI(EwkTouchEvent::create(type, wkTouchPoints, modifiers, timestamp).leakRef());
     57#else
     58    UNUSED_PARAM(type);
     59    UNUSED_PARAM(wkTouchPoints);
     60    UNUSED_PARAM(modifiers);
     61    UNUSED_PARAM(timestamp);
     62    return 0;
     63#endif
    4564}
    46 
    47 void WKViewSetThemePath(WKViewRef viewRef, WKStringRef theme)
    48 {
    49     static_cast<WebViewEfl*>(toImpl(viewRef))->setThemePath(toImpl(theme)->string());
    50 }
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKEventEfl.h

    r152144 r152147  
    11/*
    2  * Copyright (C) 2013 Intel Corporation. All rights reserved.
     2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
     3 * Copyright (C) 2012-2013 Nokia Corporation and/or its subsidiary(-ies).
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2425 */
    2526
    26 #ifndef WKViewEfl_h
    27 #define WKViewEfl_h
     27#ifndef WKEventEfl_h
     28#define WKEventEfl_h
    2829
    29 #include <WebKit2/WKBase.h>
    30 
    31 typedef struct _cairo_surface cairo_surface_t;
     30#include <WebKit2/WKEvent.h>
     31#include <WebKit2/WKGeometry.h>
    3232
    3333#ifdef __cplusplus
     
    3535#endif
    3636
    37 WK_EXPORT void WKViewPaintToCairoSurface(WKViewRef, cairo_surface_t*);
     37enum WKEventType {
     38    kWKEventTypeNoType = -1,
     39    kWKEventTypeTouchStart,
     40    kWKEventTypeTouchMove,
     41    kWKEventTypeTouchEnd,
     42    kWKEventTypeTouchCancel
     43};
     44typedef enum WKEventType WKEventType;
    3845
    39 WK_EXPORT WKImageRef WKViewCreateSnapshot(WKViewRef);
     46enum WKTouchPointState {
     47    kWKTouchPointStateTouchReleased,
     48    kWKTouchPointStateTouchPressed,
     49    kWKTouchPointStateTouchMoved,
     50    kWKTouchPointStateTouchStationary,
     51    kWKTouchPointStateTouchCancelled
     52};
     53typedef enum WKTouchPointState WKTouchPointState;
    4054
    41 WK_EXPORT void WKViewSetThemePath(WKViewRef, WKStringRef);
     55WK_EXPORT WKTouchPointRef WKTouchPointCreate(int id, WKPoint position, WKPoint screenPosition, WKTouchPointState, WKSize radius, float rotationAngle, float forceFactor);
     56WK_EXPORT WKTouchEventRef WKTouchEventCreate(WKEventType, WKArrayRef, WKEventModifiers, double timestamp);
    4257
    4358#ifdef __cplusplus
     
    4560#endif
    4661
    47 #endif /* WKViewEfl_h */
     62#endif /* WKEventEfl_h */
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.cpp

    r149902 r152147  
    4949    static_cast<WebViewEfl*>(toImpl(viewRef))->setThemePath(toImpl(theme)->string());
    5050}
     51
     52void WKViewSendTouchEvent(WKViewRef viewRef, WKTouchEventRef touchEventRef)
     53{
     54#if ENABLE(TOUCH_EVENTS)
     55    static_cast<WebViewEfl*>(toImpl(viewRef))->sendTouchEvent(toImpl(touchEventRef));
     56#else
     57    UNUSED_PARAM(viewRef);
     58    UNUSED_PARAM(touchEventRef);
     59#endif
     60}
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKViewEfl.h

    r149902 r152147  
    4141WK_EXPORT void WKViewSetThemePath(WKViewRef, WKStringRef);
    4242
     43WK_EXPORT void WKViewSendTouchEvent(WKViewRef, WKTouchEventRef);
     44
    4345#ifdef __cplusplus
    4446}
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp

    r151541 r152147  
    3737#include "SnapshotImageGL.h"
    3838#include "ViewClientEfl.h"
     39#include "WKArray.h"
    3940#include "WKDictionary.h"
     41#include "WKEventEfl.h"
    4042#include "WKGeometry.h"
    4143#include "WKNumber.h"
     
    713715
    714716#if ENABLE(TOUCH_EVENTS)
     717static WKTouchPointState toWKTouchPointState(Evas_Touch_Point_State state)
     718{
     719    switch (state) {
     720    case EVAS_TOUCH_POINT_UP:
     721        return kWKTouchPointStateTouchReleased;
     722    case EVAS_TOUCH_POINT_MOVE:
     723        return kWKTouchPointStateTouchMoved;
     724    case EVAS_TOUCH_POINT_DOWN:
     725        return kWKTouchPointStateTouchPressed;
     726    case EVAS_TOUCH_POINT_STILL:
     727        return kWKTouchPointStateTouchStationary;
     728    case EVAS_TOUCH_POINT_CANCEL:
     729    default:
     730        return kWKTouchPointStateTouchCancelled;
     731    }
     732}
     733
     734static WKEventModifiers toWKEventModifiers(const Evas_Modifier* modifiers)
     735{
     736    WKEventModifiers wkModifiers = 0;
     737    if (evas_key_modifier_is_set(modifiers, "Shift"))
     738        wkModifiers |= kWKEventModifiersShiftKey;
     739    if (evas_key_modifier_is_set(modifiers, "Control"))
     740        wkModifiers |= kWKEventModifiersControlKey;
     741    if (evas_key_modifier_is_set(modifiers, "Alt"))
     742        wkModifiers |= kWKEventModifiersAltKey;
     743    if (evas_key_modifier_is_set(modifiers, "Meta"))
     744        wkModifiers |= kWKEventModifiersMetaKey;
     745
     746    return wkModifiers;
     747}
     748
    715749void EwkView::feedTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
    716750{
    717     page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, webView()->transformFromScene(), transformToScreen(), ecore_time_get()));
     751    unsigned length = eina_list_count(points);
     752    OwnArrayPtr<WKTypeRef> touchPoints = adoptArrayPtr(new WKTypeRef[length]);
     753    for (unsigned i = 0; i < length; ++i) {
     754        Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_nth(points, i));
     755        ASSERT(point);
     756        IntPoint position(point->x, point->y);
     757        touchPoints[i] = WKTouchPointCreate(point->id, toAPI(IntPoint(position)), toAPI(transformToScreen().mapPoint(position)), toWKTouchPointState(point->state), WKSizeMake(0, 0), 0, 1);
     758    }
     759    WKRetainPtr<WKArrayRef> wkTouchPoints(AdoptWK, WKArrayCreateAdoptingValues(touchPoints.get(), length));
     760
     761    WKViewSendTouchEvent(wkView(), adoptWK(WKTouchEventCreate(static_cast<WKEventType>(type), wkTouchPoints.get(), toWKEventModifiers(modifiers), ecore_time_get())).get());
    718762}
    719763
     
    12611305    Ewk_View_Smart_Data* sd = smartData();
    12621306
    1263     unsigned count = evas_touch_point_list_count(sd->base.evas);
    1264     if (!count)
    1265         return;
    1266 
    1267     Eina_List* points = 0;
    1268     for (unsigned i = 0; i < count; ++i) {
    1269         Ewk_Touch_Point* point = new Ewk_Touch_Point;
    1270         point->id = evas_touch_point_list_nth_id_get(sd->base.evas, i);
    1271         evas_touch_point_list_nth_xy_get(sd->base.evas, i, &point->x, &point->y);
    1272         point->state = evas_touch_point_list_nth_state_get(sd->base.evas, i);
    1273         points = eina_list_append(points, point);
    1274     }
    1275 
    1276     feedTouchEvent(type, points, evas_key_modifier_get(sd->base.evas));
    1277 
    1278     void* data;
    1279     EINA_LIST_FREE(points, data)
    1280         delete static_cast<Ewk_Touch_Point*>(data);
     1307    unsigned length = evas_touch_point_list_count(sd->base.evas);
     1308    if (!length)
     1309        return;
     1310
     1311    OwnArrayPtr<WKTypeRef> touchPoints = adoptArrayPtr(new WKTypeRef[length]);
     1312    for (unsigned i = 0; i < length; ++i) {
     1313        int x, y;
     1314        evas_touch_point_list_nth_xy_get(sd->base.evas, i, &x, &y);
     1315        IntPoint position(x, y);
     1316        Evas_Touch_Point_State state = evas_touch_point_list_nth_state_get(sd->base.evas, i);
     1317        int id = evas_touch_point_list_nth_id_get(sd->base.evas, i);
     1318        touchPoints[i] = WKTouchPointCreate(id, toAPI(IntPoint(position)), toAPI(transformToScreen().mapPoint(position)), toWKTouchPointState(state), WKSizeMake(0, 0), 0, 1);
     1319    }
     1320    WKRetainPtr<WKArrayRef> wkTouchPoints(AdoptWK, WKArrayCreateAdoptingValues(touchPoints.get(), length));
     1321
     1322    WKViewSendTouchEvent(wkView(), adoptWK(WKTouchEventCreate(static_cast<WKEventType>(type), wkTouchPoints.get(), toWKEventModifiers(evas_key_modifier_get(sd->base.evas)), ecore_time_get())).get());
    12811323}
    12821324
  • trunk/Source/WebKit2/UIProcess/efl/EwkTouchEvent.cpp

    r152144 r152147  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
     27#include "EwkTouchEvent.h"
    2728
    2829#if ENABLE(TOUCH_EVENTS)
    29 #include "NativeWebTouchEvent.h"
    30 
    31 #include "WebEventFactory.h"
    3230
    3331namespace WebKit {
    3432
    35 NativeWebTouchEvent::NativeWebTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen, double timestamp)
    36     : WebTouchEvent(WebEventFactory::createWebTouchEvent(type, points, modifiers, toWebContent, toDeviceScreen, timestamp))
     33EwkTouchEvent::EwkTouchEvent(WKEventType type, WKArrayRef touchPoints, WKEventModifiers modifiers, double timestamp)
     34    : m_eventType(type)
     35    , m_touchPoints(touchPoints)
     36    , m_modifiers(modifiers)
     37    , m_timestamp(timestamp)
    3738{
    3839}
     
    4041} // namespace WebKit
    4142
    42 #endif
     43#endif // ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebKit2/UIProcess/efl/EwkTouchEvent.h

    r152144 r152147  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
     26#ifndef EwkTouchEvent_h
     27#define EwkTouchEvent_h
    2728
    2829#if ENABLE(TOUCH_EVENTS)
    29 #include "NativeWebTouchEvent.h"
    3030
    31 #include "WebEventFactory.h"
     31#include "APIObject.h"
     32#include "WKArray.h"
     33#include "WKEventEfl.h"
     34#include "WKRetainPtr.h"
     35#include <wtf/PassRefPtr.h>
    3236
    3337namespace WebKit {
    3438
    35 NativeWebTouchEvent::NativeWebTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen, double timestamp)
    36     : WebTouchEvent(WebEventFactory::createWebTouchEvent(type, points, modifiers, toWebContent, toDeviceScreen, timestamp))
    37 {
    38 }
     39class EwkTouchEvent : public APIObject {
     40public:
     41    static const APIObject::Type APIType = TypeTouchEvent;
     42
     43    static PassRefPtr<EwkTouchEvent> create(WKEventType type, WKArrayRef touchPoints, WKEventModifiers modifiers, double timestamp)
     44    {
     45        return adoptRef(new EwkTouchEvent(type, touchPoints, modifiers, timestamp));
     46    }
     47
     48    WKEventType eventType() const { return m_eventType; }
     49    WKArrayRef touchPoints() const { return m_touchPoints.get(); }
     50    WKEventModifiers modifiers() const { return m_modifiers; }
     51    double timestamp() const { return m_timestamp; }
     52
     53private:
     54    EwkTouchEvent(WKEventType, WKArrayRef, WKEventModifiers, double timestamp);
     55
     56    virtual APIObject::Type type() const { return APIType; }
     57
     58    WKEventType m_eventType;
     59    WKRetainPtr<WKArrayRef> m_touchPoints;
     60    WKEventModifiers m_modifiers;
     61    double m_timestamp;
     62};
    3963
    4064} // namespace WebKit
    4165
    42 #endif
     66#endif // ENABLE(TOUCH_EVENTS)
     67
     68#endif /* EwkTouchEvent_h */
  • trunk/Source/WebKit2/UIProcess/efl/EwkTouchPoint.cpp

    r152144 r152147  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
     27#include "EwkTouchPoint.h"
    2728
    2829#if ENABLE(TOUCH_EVENTS)
    29 #include "NativeWebTouchEvent.h"
    30 
    31 #include "WebEventFactory.h"
    3230
    3331namespace WebKit {
    3432
    35 NativeWebTouchEvent::NativeWebTouchEvent(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen, double timestamp)
    36     : WebTouchEvent(WebEventFactory::createWebTouchEvent(type, points, modifiers, toWebContent, toDeviceScreen, timestamp))
     33EwkTouchPoint::EwkTouchPoint(uint32_t id, WKTouchPointState state, const WKPoint& screenPosition, const WKPoint& position, const WKSize& radius, float rotationAngle, float forceFactor)
     34    : m_id(id)
     35    , m_state(state)
     36    , m_screenPosition(screenPosition)
     37    , m_position(position)
     38    , m_radius(radius)
     39    , m_rotationAngle(rotationAngle)
     40    , m_forceFactor(forceFactor)
    3741{
    3842}
     
    4044} // namespace WebKit
    4145
    42 #endif
     46#endif // ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.cpp

    r151414 r152147  
    3838#if ENABLE(FULLSCREEN_API)
    3939#include "WebFullScreenManagerProxy.h"
     40#endif
     41
     42#if ENABLE(TOUCH_EVENTS)
     43#include "EwkTouchEvent.h"
    4044#endif
    4145
     
    113117}
    114118
     119#if ENABLE(TOUCH_EVENTS)
     120void WebViewEfl::sendTouchEvent(EwkTouchEvent* touchEvent)
     121{
     122    ASSERT(touchEvent);
     123    m_page->handleTouchEvent(NativeWebTouchEvent(touchEvent, transformFromScene()));
     124}
     125#endif
     126
    115127} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h

    r151414 r152147  
    3333namespace WebKit {
    3434
     35#if ENABLE(TOUCH_EVENTS)
     36class EwkTouchEvent;
     37#endif
     38
    3539class WebViewEfl : public WebView {
    3640public:
     
    4044    void paintToCairoSurface(cairo_surface_t*);
    4145    void setThemePath(const String&);
     46
     47#if ENABLE(TOUCH_EVENTS)
     48    void sendTouchEvent(EwkTouchEvent*);
     49#endif
    4250
    4351private:
Note: See TracChangeset for help on using the changeset viewer.