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 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 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 "DOMObjectCache.h" |
35 | #include <WebCore/EventTarget.h> |
36 | #include "WebKitDOMEvent.h" |
37 | #include "WebKitDOMEventTargetPrivate.h" |
38 | #include "WebKitDOMPrivate.h" |
39 | #include <wtf/glib/GRefPtr.h> |
40 | |
41 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
42 | |
43 | typedef WebKitDOMEventTargetIface WebKitDOMEventTargetInterface; |
44 | |
45 | G_DEFINE_INTERFACE(WebKitDOMEventTarget, webkit_dom_event_target, G_TYPE_OBJECT) |
46 | |
47 | static void webkit_dom_event_target_default_init(WebKitDOMEventTargetIface*) |
48 | { |
49 | } |
50 | |
51 | gboolean webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error) |
52 | { |
53 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE); |
54 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT(event), FALSE); |
55 | g_return_val_if_fail(!error || !*error, FALSE); |
56 | |
57 | return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->dispatch_event(target, event, error); |
58 | } |
59 | |
60 | gboolean webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean useCapture, gpointer userData) |
61 | { |
62 | |
63 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE); |
64 | g_return_val_if_fail(eventName, FALSE); |
65 | |
66 | GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(handler, userData, 0)); |
67 | return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->add_event_listener(target, eventName, closure.get(), useCapture); |
68 | } |
69 | |
70 | gboolean webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean useCapture) |
71 | { |
72 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE); |
73 | g_return_val_if_fail(eventName, FALSE); |
74 | |
75 | GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(handler, 0, 0)); |
76 | return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->remove_event_listener(target, eventName, closure.get(), useCapture); |
77 | } |
78 | |
79 | gboolean webkit_dom_event_target_add_event_listener_with_closure(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture) |
80 | { |
81 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE); |
82 | g_return_val_if_fail(eventName, FALSE); |
83 | g_return_val_if_fail(handler, FALSE); |
84 | |
85 | return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->add_event_listener(target, eventName, handler, useCapture); |
86 | } |
87 | |
88 | gboolean webkit_dom_event_target_remove_event_listener_with_closure(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture) |
89 | { |
90 | g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE); |
91 | g_return_val_if_fail(eventName, FALSE); |
92 | g_return_val_if_fail(handler, FALSE); |
93 | |
94 | return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->remove_event_listener(target, eventName, handler, useCapture); |
95 | } |
96 | |
97 | namespace WebKit { |
98 | |
99 | WebKitDOMEventTarget* kit(WebCore::EventTarget* obj) |
100 | { |
101 | if (!obj) |
102 | return 0; |
103 | |
104 | if (gpointer ret = DOMObjectCache::get(obj)) |
105 | return WEBKIT_DOM_EVENT_TARGET(ret); |
106 | |
107 | return wrap(obj); |
108 | } |
109 | |
110 | WebCore::EventTarget* core(WebKitDOMEventTarget* request) |
111 | { |
112 | return request ? static_cast<WebCore::EventTarget*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; |
113 | } |
114 | |
115 | } // namespace WebKit |
116 | |
117 | G_GNUC_END_IGNORE_DEPRECATIONS; |
118 | |