0f8908cf8735f2125bdd7f8ed320aff149bf9987
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / gtk / WebKitPrivate.h
1 /*
2  * Copyright (C) 2011 Igalia S.L.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef WebKitPrivate_h
27 #define WebKitPrivate_h
28
29 #include "WebKitNavigationAction.h"
30 #include <WebKit/WKAPICast.h>
31 #include <WebKit/WKDownload.h>
32 #include <WebKit/WKFindOptions.h>
33 #include <WebKit/WKFullScreenClientGtk.h>
34 #include <WebKit/WKGeolocationManager.h>
35 #include <WebKit/WKGeolocationPermissionRequest.h>
36 #include <WebKit/WKGeolocationPosition.h>
37 #include <WebKit/WKIconDatabase.h>
38 #include <WebKit/WKInspector.h>
39 #include <WebKit/WKInspectorClientGtk.h>
40 #include <WebKit/WKRetainPtr.h>
41 #include <WebKit/WKSerializedScriptValue.h>
42 #include <WebKit/WKSoupCustomProtocolRequestManager.h>
43 #include <WebKit/WKString.h>
44 #include <WebKit/WKUserMediaPermissionRequest.h>
45 #include <WebKit/WebKit2_C.h>
46 #include <glib.h>
47 #include <wtf/Assertions.h>
48
49 #define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))
50 #define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))
51 #define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))
52
53 #define WEBKIT_DEFINE_ASYNC_DATA_STRUCT(structName) \
54 static structName* create##structName() \
55 { \
56     structName* data = g_slice_new0(structName); \
57     new (data) structName(); \
58     return data; \
59 } \
60 static void destroy##structName(structName* data) \
61 { \
62     data->~structName(); \
63     g_slice_free(structName, data); \
64 }
65
66 #define WEBKIT_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, 0, { })
67 #define WEBKIT_DEFINE_ABSTRACT_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, G_TYPE_FLAG_ABSTRACT, { })
68 #define WEBKIT_DEFINE_TYPE_WITH_CODE(TypeName, type_name, TYPE_PARENT, Code) _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, 0) {Code;} _WEBKIT_DEFINE_TYPE_EXTENDED_END()
69
70 #define _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, Code) _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) {Code;} _WEBKIT_DEFINE_TYPE_EXTENDED_END()
71 #define _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
72 \
73 static void type_name##_class_init(TypeName##Class* klass); \
74 static gpointer type_name##_parent_class = 0; \
75 static void type_name##_finalize(GObject* object) \
76 { \
77     TypeName* self = (TypeName*)object; \
78     self->priv->~TypeName##Private(); \
79     G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \
80 } \
81 \
82 static void type_name##_class_intern_init(gpointer klass) \
83 { \
84     GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); \
85     g_type_class_add_private(klass, sizeof(TypeName##Private)); \
86     type_name##_parent_class = g_type_class_peek_parent(klass); \
87     type_name##_class_init((TypeName##Class*)klass); \
88     gObjectClass->finalize = type_name##_finalize; \
89 } \
90 \
91 static void type_name##_init(TypeName* self) \
92 { \
93     TypeName##Private* priv = G_TYPE_INSTANCE_GET_PRIVATE(self, type_name##_get_type(), TypeName##Private); \
94     self->priv = priv; \
95     new (priv) TypeName##Private(); \
96 }\
97 GType type_name##_get_type(void) \
98 { \
99     static volatile gsize g_define_type_id__volatile = 0; \
100     if (g_once_init_enter(&g_define_type_id__volatile)) { \
101         GType g_define_type_id = \
102             g_type_register_static_simple( \
103                 TYPE_PARENT, \
104                 g_intern_static_string(#TypeName), \
105                 sizeof(TypeName##Class), \
106                 (GClassInitFunc)type_name##_class_intern_init, \
107                 sizeof(TypeName), \
108                 (GInstanceInitFunc)type_name##_init, \
109                 (GTypeFlags)flags); \
110         // Custom code follows.
111 #define _WEBKIT_DEFINE_TYPE_EXTENDED_END() \
112         g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); \
113     } \
114     return g_define_type_id__volatile; \
115 } // Closes type_name##_get_type().
116
117 unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
118 unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton);
119 unsigned toGdkModifiers(WebKit::WebEvent::Modifiers);
120 WebKitNavigationType toWebKitNavigationType(WebCore::NavigationType);
121 unsigned toWebKitMouseButton(WebKit::WebMouseEvent::Button);
122 unsigned toWebKitError(unsigned webCoreError);
123 unsigned toWebCoreError(unsigned webKitError);
124
125 enum SnapshotRegion {
126     SnapshotRegionVisible,
127     SnapshotRegionFullDocument
128 };
129
130 #endif // WebKitPrivate_h