1 /*
2 * Copyright (C) 2010 Igalia S.L.
3 *
4 * This file is derived by hand from an automatically generated file.
5 * Keeping it up-to-date could potentially be done by adding
6 * a make_names.pl generator, or by writing a separate
7 * generater which takes JSHTMLElementWrapperFactory.h as input.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "WebKitDOMEventTarget.h"
33
34 #include "EventTarget.h"
35 #include "WebKitDOMEvent.h"
36
37 typedef WebKitDOMEventTargetIface WebKitDOMEventTargetInterface;
38 #if GLIB_CHECK_VERSION(2, 24, 0)
G_DEFINE_INTERFACE(WebKitDOMEventTarget,webkit_dom_event_target,G_TYPE_OBJECT)39 G_DEFINE_INTERFACE(WebKitDOMEventTarget, webkit_dom_event_target, G_TYPE_OBJECT)
40 #else
41 static void webkit_dom_event_target_default_init(WebKitDOMEventTargetIface*);
42
43 GType webkit_dom_event_target_get_type(void)
44 {
45 static volatile gsize typeIdVolatile = 0;
46
47 if (g_once_init_enter(&typeIdVolatile)) {
48 GType typeId = g_type_register_static_simple(G_TYPE_INTERFACE,
49 g_intern_static_string("WebKitDOMEventTarget"),
50 sizeof(WebKitDOMEventTargetInterface),
51 (GClassInitFunc)webkit_dom_event_target_default_init,
52 0,
53 static_cast<GInstanceInitFunc>(0),
54 static_cast<GTypeFlags>(0));
55 g_type_interface_add_prerequisite(typeId, G_TYPE_OBJECT);
56 g_once_init_leave(&typeIdVolatile, typeId);
57 }
58
59 return typeIdVolatile;
60 }
61 #endif
62
63 static void webkit_dom_event_target_default_init(WebKitDOMEventTargetIface*)
64 {
65 }
66
webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget * target,WebKitDOMEvent * event,GError ** error)67 void webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
68 {
69 g_return_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target));
70 g_return_if_fail(WEBKIT_DOM_IS_EVENT(event));
71
72 WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
73
74 if (iface->dispatch_event)
75 iface->dispatch_event(target, event, error);
76 }
77
webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget * target,const char * eventName,GCallback handler,gboolean bubble,gpointer userData)78 gboolean webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData)
79 {
80
81 g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
82 g_return_val_if_fail(eventName, FALSE);
83
84 WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
85
86 if (iface->add_event_listener)
87 return iface->add_event_listener(target, eventName, handler, bubble, userData);
88
89 return FALSE;
90 }
91
webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget * target,const char * eventName,GCallback handler,gboolean bubble)92 gboolean webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble)
93 {
94 g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
95 g_return_val_if_fail(eventName, FALSE);
96
97 WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
98
99 if (iface->remove_event_listener)
100 return iface->remove_event_listener(target, eventName, handler, bubble);
101
102 return FALSE;
103 }
104
105 namespace WebKit {
106
core(WebKitDOMEventTarget * request)107 WebCore::EventTarget* core(WebKitDOMEventTarget* request)
108 {
109 g_return_val_if_fail(request, 0);
110
111 WebCore::EventTarget* coreObject = static_cast<WebCore::EventTarget*>(WEBKIT_DOM_OBJECT(request)->coreObject);
112 g_return_val_if_fail(coreObject, 0);
113
114 return coreObject;
115 }
116
117 } // namespace WebKit
118
119