83904ad9ad3a61d7bcc115badfb38498e5afcf50
[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 <WebKit2/WKAPICast.h>
30 #include <WebKit2/WKContextSoup.h>
31 #include <WebKit2/WKDownload.h>
32 #include <WebKit2/WKFindOptions.h>
33 #include <WebKit2/WKFullScreenClientGtk.h>
34 #include <WebKit2/WKGeolocationManager.h>
35 #include <WebKit2/WKGeolocationPermissionRequest.h>
36 #include <WebKit2/WKGeolocationPosition.h>
37 #include <WebKit2/WKIconDatabase.h>
38 #include <WebKit2/WKInspector.h>
39 #include <WebKit2/WKInspectorClientGtk.h>
40 #include <WebKit2/WKRetainPtr.h>
41 #include <WebKit2/WKSerializedScriptValue.h>
42 #include <WebKit2/WKSoupRequestManager.h>
43 #include <WebKit2/WKString.h>
44 #include <WebKit2/WKTextChecker.h>
45 #include <WebKit2/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 COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \
54         COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums)
55
56 #define WEBKIT_DEFINE_ASYNC_DATA_STRUCT(structName) \
57 static structName* create##structName() \
58 { \
59     structName* data = g_slice_new0(structName); \
60     new (data) structName(); \
61     return data; \
62 } \
63 static void destroy##structName(structName* data) \
64 { \
65     data->~structName(); \
66     g_slice_free(structName, data); \
67 }
68
69 #define WEBKIT_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, 0, { })
70 #define WEBKIT_DEFINE_ABSTRACT_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, G_TYPE_FLAG_ABSTRACT, { })
71 #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()
72
73 #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()
74 #define _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
75 \
76 static void type_name##_class_init(TypeName##Class* klass); \
77 static gpointer type_name##_parent_class = 0; \
78 static void type_name##_finalize(GObject* object) \
79 { \
80     TypeName* self = (TypeName*)object; \
81     self->priv->~TypeName##Private(); \
82     G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \
83 } \
84 \
85 static void type_name##_class_intern_init(gpointer klass) \
86 { \
87     GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); \
88     g_type_class_add_private(klass, sizeof(TypeName##Private)); \
89     type_name##_parent_class = g_type_class_peek_parent(klass); \
90     type_name##_class_init((TypeName##Class*)klass); \
91     gObjectClass->finalize = type_name##_finalize; \
92 } \
93 \
94 static void type_name##_init(TypeName* self) \
95 { \
96     TypeName##Private* priv = G_TYPE_INSTANCE_GET_PRIVATE(self, type_name##_get_type(), TypeName##Private); \
97     self->priv = priv; \
98     new (priv) TypeName##Private(); \
99 }\
100 GType type_name##_get_type(void) \
101 { \
102     static volatile gsize g_define_type_id__volatile = 0; \
103     if (g_once_init_enter(&g_define_type_id__volatile)) { \
104         GType g_define_type_id = \
105             g_type_register_static_simple( \
106                 TYPE_PARENT, \
107                 g_intern_static_string(#TypeName), \
108                 sizeof(TypeName##Class), \
109                 (GClassInitFunc)type_name##_class_intern_init, \
110                 sizeof(TypeName), \
111                 (GInstanceInitFunc)type_name##_init, \
112                 (GTypeFlags)flags); \
113         // Custom code follows.
114 #define _WEBKIT_DEFINE_TYPE_EXTENDED_END() \
115         g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); \
116     } \
117     return g_define_type_id__volatile; \
118 } // Closes type_name##_get_type().
119
120 unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
121 unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton);
122
123 enum SnapshotRegion {
124     SnapshotRegionVisible,
125     SnapshotRegionFullDocument
126 };
127
128 #endif // WebKitPrivate_h