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