1/*
2 * Copyright (C) 2012 Samsung Electronics
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef WKAPICastEfl_h
21#define WKAPICastEfl_h
22
23#ifndef WKAPICast_h
24#error "Please #include \"WKAPICast.h\" instead of this file directly."
25#endif
26
27#include <WebCore/TextDirection.h>
28#include <WebKit/WKPopupItem.h>
29
30#if ENABLE(TOUCH_EVENTS)
31#include "WebEvent.h"
32#include <WebKit/WKEventEfl.h>
33#endif
34
35namespace WebKit {
36
37class WebView;
38class WebPopupItemEfl;
39class WebPopupMenuListenerEfl;
40
41WK_ADD_API_MAPPING(WKViewRef, WebView)
42WK_ADD_API_MAPPING(WKPopupItemRef, WebPopupItemEfl)
43WK_ADD_API_MAPPING(WKPopupMenuListenerRef, WebPopupMenuListenerEfl)
44
45#if ENABLE(TOUCH_EVENTS)
46class EwkTouchEvent;
47class EwkTouchPoint;
48
49WK_ADD_API_MAPPING(WKTouchEventRef, EwkTouchEvent)
50WK_ADD_API_MAPPING(WKTouchPointRef, EwkTouchPoint)
51#endif
52
53// Enum conversions.
54inline WKPopupItemTextDirection toAPI(WebCore::TextDirection direction)
55{
56    WKPopupItemTextDirection wkDirection = kWKPopupItemTextDirectionLTR;
57
58    switch (direction) {
59    case WebCore::RTL:
60        wkDirection = kWKPopupItemTextDirectionRTL;
61        break;
62    case WebCore::LTR:
63        wkDirection = kWKPopupItemTextDirectionLTR;
64        break;
65    }
66
67    return wkDirection;
68}
69
70#if ENABLE(TOUCH_EVENTS)
71inline WKEventType toAPI(WebEvent::Type type)
72{
73    switch (type) {
74    case WebEvent::TouchStart:
75        return kWKEventTypeTouchStart;
76    case WebEvent::TouchMove:
77        return kWKEventTypeTouchMove;
78    case WebEvent::TouchEnd:
79        return kWKEventTypeTouchEnd;
80    case WebEvent::TouchCancel:
81        return kWKEventTypeTouchCancel;
82    default:
83        return kWKEventTypeNoType;
84    }
85}
86
87inline WKTouchPointState toAPI(WebPlatformTouchPoint::TouchPointState state)
88{
89    switch (state) {
90    case WebPlatformTouchPoint::TouchReleased:
91        return kWKTouchPointStateTouchReleased;
92    case WebPlatformTouchPoint::TouchPressed:
93        return kWKTouchPointStateTouchPressed;
94    case WebPlatformTouchPoint::TouchMoved:
95        return kWKTouchPointStateTouchMoved;
96    case WebPlatformTouchPoint::TouchStationary:
97        return kWKTouchPointStateTouchStationary;
98    case WebPlatformTouchPoint::TouchCancelled:
99        return kWKTouchPointStateTouchCancelled;
100    }
101
102    ASSERT_NOT_REACHED();
103    return kWKTouchPointStateTouchCancelled;
104}
105#endif
106
107}
108
109#endif // WKAPICastEfl_h
110