[GObject bindings] Make EventTarget interface introspectable
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2013 09:08:48 +0000 (09:08 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2013 09:08:48 +0000 (09:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77835

Reviewed by Gustavo Noronha Silva.

Source/WebCore:

Add webkit_dom_event_target_add_event_listener_with_closure and
webkit_dom_event_target_remove_event_listener_with_closure to be
used by GObject instrospection bindings. Instead of receving a
GCallback, which makes the function not introspectable, they
receive a GClosure.

* bindings/gobject/GObjectEventListener.cpp:
(WebCore::GObjectEventListener::GObjectEventListener):
(WebCore::GObjectEventListener::~GObjectEventListener):
(WebCore::GObjectEventListener::gobjectDestroyed):
(WebCore::GObjectEventListener::handleEvent):
(WebCore::GObjectEventListener::operator==):
* bindings/gobject/GObjectEventListener.h:
(WebCore::GObjectEventListener::addEventListener):
(WebCore::GObjectEventListener::removeEventListener):
* bindings/gobject/WebKitDOMEventTarget.cpp:
(webkit_dom_event_target_dispatch_event):
(webkit_dom_event_target_add_event_listener):
(webkit_dom_event_target_remove_event_listener):
(webkit_dom_event_target_add_event_listener_with_closure):
(webkit_dom_event_target_remove_event_listener_with_closure):
* bindings/gobject/WebKitDOMEventTarget.h:
* bindings/scripts/CodeGeneratorGObject.pm:
(GenerateEventTargetIface):
* bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp:
(webkit_dom_test_event_target_dispatch_event):
(webkit_dom_test_event_target_add_event_listener):
(webkit_dom_test_event_target_remove_event_listener):
* bindings/scripts/test/GObject/WebKitDOMTestNode.cpp:
(webkit_dom_test_node_dispatch_event):
(webkit_dom_test_node_add_event_listener):
(webkit_dom_test_node_remove_event_listener):

Source/WTF:

Add support for use GRefPtr with GClosure.

* wtf/gobject/GRefPtr.cpp:
(WTF::refGPtr):
(WTF::derefGPtr):
* wtf/gobject/GRefPtr.h:
* wtf/gobject/GTypedefs.h:

Tools:

* Scripts/webkitpy/style/checker.py: Add exceptions for custom
GObject DOM bindings headers.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157918 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/gobject/GRefPtr.cpp
Source/WTF/wtf/gobject/GRefPtr.h
Source/WTF/wtf/gobject/GTypedefs.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/gobject/GObjectEventListener.cpp
Source/WebCore/bindings/gobject/GObjectEventListener.h
Source/WebCore/bindings/gobject/WebKitDOMEventTarget.cpp
Source/WebCore/bindings/gobject/WebKitDOMEventTarget.h
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.cpp
Tools/ChangeLog
Tools/Scripts/webkitpy/style/checker.py

index 35cb32d..196d0a4 100644 (file)
@@ -1,3 +1,18 @@
+2013-10-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GObject bindings] Make EventTarget interface introspectable
+        https://bugs.webkit.org/show_bug.cgi?id=77835
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add support for use GRefPtr with GClosure.
+
+        * wtf/gobject/GRefPtr.cpp:
+        (WTF::refGPtr):
+        (WTF::derefGPtr):
+        * wtf/gobject/GRefPtr.h:
+        * wtf/gobject/GTypedefs.h:
+
 2013-10-23  Anders Carlsson  <andersca@apple.com>
 
         Remove USE(LOCKFREE_THREADSAFEREFCOUNTED)
index 3931d5a..b6a31ac 100644 (file)
@@ -21,6 +21,7 @@
 
 #if USE(GLIB)
 
+#include <glib-object.h>
 #include <glib.h>
 
 namespace WTF {
@@ -145,6 +146,19 @@ template <> void derefGPtr(GByteArray* ptr)
         g_byte_array_unref(ptr);
 }
 
+template <> GClosure* refGPtr(GClosure* ptr)
+{
+    if (ptr)
+        g_closure_ref(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(GClosure* ptr)
+{
+    if (ptr)
+        g_closure_unref(ptr);
+}
+
 } // namespace WTF
 
 #endif // USE(GLIB)
index e7d8b64..b25b7bb 100644 (file)
@@ -219,6 +219,8 @@ template <> GByteArray* refGPtr(GByteArray*);
 template <> void derefGPtr(GByteArray*);
 template <> GBytes* refGPtr(GBytes*);
 template <> void derefGPtr(GBytes*);
+template <> GClosure* refGPtr(GClosure*);
+template <> void derefGPtr(GClosure*);
 
 template <typename T> inline T* refGPtr(T* ptr)
 {
index 64c3c58..9990792 100644 (file)
@@ -66,6 +66,7 @@ typedef struct _GKeyFile GKeyFile;
 typedef struct _GPtrArray GPtrArray;
 typedef struct _GByteArray GByteArray;
 typedef struct _GBytes GBytes;
+typedef struct _GClosure GClosure;
 
 #if USE(CAIRO)
 typedef struct _cairo_surface cairo_surface_t;
index bca4c1b..f207c06 100644 (file)
@@ -1,3 +1,43 @@
+2013-10-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GObject bindings] Make EventTarget interface introspectable
+        https://bugs.webkit.org/show_bug.cgi?id=77835
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add webkit_dom_event_target_add_event_listener_with_closure and
+        webkit_dom_event_target_remove_event_listener_with_closure to be
+        used by GObject instrospection bindings. Instead of receving a
+        GCallback, which makes the function not introspectable, they
+        receive a GClosure.
+
+        * bindings/gobject/GObjectEventListener.cpp:
+        (WebCore::GObjectEventListener::GObjectEventListener):
+        (WebCore::GObjectEventListener::~GObjectEventListener):
+        (WebCore::GObjectEventListener::gobjectDestroyed):
+        (WebCore::GObjectEventListener::handleEvent):
+        (WebCore::GObjectEventListener::operator==):
+        * bindings/gobject/GObjectEventListener.h:
+        (WebCore::GObjectEventListener::addEventListener):
+        (WebCore::GObjectEventListener::removeEventListener):
+        * bindings/gobject/WebKitDOMEventTarget.cpp:
+        (webkit_dom_event_target_dispatch_event):
+        (webkit_dom_event_target_add_event_listener):
+        (webkit_dom_event_target_remove_event_listener):
+        (webkit_dom_event_target_add_event_listener_with_closure):
+        (webkit_dom_event_target_remove_event_listener_with_closure):
+        * bindings/gobject/WebKitDOMEventTarget.h:
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        (GenerateEventTargetIface):
+        * bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp:
+        (webkit_dom_test_event_target_dispatch_event):
+        (webkit_dom_test_event_target_add_event_listener):
+        (webkit_dom_test_event_target_remove_event_listener):
+        * bindings/scripts/test/GObject/WebKitDOMTestNode.cpp:
+        (webkit_dom_test_node_dispatch_event):
+        (webkit_dom_test_node_add_event_listener):
+        (webkit_dom_test_node_remove_event_listener):
+
 2013-10-14  Sergio Villar Senin  <svillar@igalia.com>
 
         Use a Vector instead of HashSet to computed the orderValues in RenderFlexibleBox
index 024a854..3a39c7e 100644 (file)
 #include "Event.h"
 #include "WebKitDOMEvent.h"
 #include "WebKitDOMEventPrivate.h"
-#include <glib-object.h>
+#include "WebKitDOMEventTarget.h"
 #include <wtf/HashMap.h>
 
 namespace WebCore {
 
-typedef void (*GObjectEventListenerCallback)(GObject*, WebKitDOMEvent*, void*);
-
-GObjectEventListener::GObjectEventListener(GObject* object, EventTarget* target, const char* domEventName, GCallback handler, bool capture, void* userData)
+GObjectEventListener::GObjectEventListener(GObject* target, EventTarget* coreTarget, const char* domEventName, GClosure* handler, bool capture)
     : EventListener(GObjectEventListenerType)
-    , m_object(object)
-    , m_coreTarget(target)
+    , m_target(target)
+    , m_coreTarget(coreTarget)
     , m_domEventName(domEventName)
     , m_handler(handler)
     , m_capture(capture)
-    , m_userData(userData)
 {
     ASSERT(m_coreTarget);
-    g_object_weak_ref(object, reinterpret_cast<GWeakNotify>(GObjectEventListener::gobjectDestroyedCallback), this);
+    if (G_CLOSURE_NEEDS_MARSHAL(m_handler.get()))
+        g_closure_set_marshal(m_handler.get(), g_cclosure_marshal_generic);
+    g_object_weak_ref(m_target, reinterpret_cast<GWeakNotify>(GObjectEventListener::gobjectDestroyedCallback), this);
 }
 
 GObjectEventListener::~GObjectEventListener()
 {
     if (!m_coreTarget)
         return;
-    g_object_weak_unref(m_object, reinterpret_cast<GWeakNotify>(GObjectEventListener::gobjectDestroyedCallback), this);
+    g_object_weak_unref(m_target, reinterpret_cast<GWeakNotify>(GObjectEventListener::gobjectDestroyedCallback), this);
 }
 
 void GObjectEventListener::gobjectDestroyed()
@@ -59,19 +58,29 @@ void GObjectEventListener::gobjectDestroyed()
     EventTarget* target = m_coreTarget;
     m_coreTarget = 0;
     target->removeEventListener(m_domEventName.data(), this, m_capture);
+    m_handler = 0;
 }
 
 void GObjectEventListener::handleEvent(ScriptExecutionContext*, Event* event)
 {
-    WebKitDOMEvent* gobjectEvent = WEBKIT_DOM_EVENT(WebKit::kit(event));
-    reinterpret_cast<GObjectEventListenerCallback>(m_handler)(m_object, gobjectEvent, m_userData);
-    g_object_unref(gobjectEvent);
+    GValue parameters[2] = { G_VALUE_INIT, G_VALUE_INIT };
+    g_value_init(&parameters[0], WEBKIT_TYPE_DOM_EVENT_TARGET);
+    g_value_set_object(&parameters[0], m_target);
+
+    GRefPtr<WebKitDOMEvent> domEvent = adoptGRef(WebKit::kit(event));
+    g_value_init(&parameters[1], WEBKIT_TYPE_DOM_EVENT);
+    g_value_set_object(&parameters[1], domEvent.get());
+
+    g_closure_invoke(m_handler.get(), 0, 2, parameters, NULL);
+    g_value_unset(parameters + 0);
+    g_value_unset(parameters + 1);
 }
 
 bool GObjectEventListener::operator==(const EventListener& listener)
 {
     if (const GObjectEventListener* gobjectEventListener = GObjectEventListener::cast(&listener))
-        return m_object == gobjectEventListener->m_object && m_handler == gobjectEventListener->m_handler;
+        return m_target == gobjectEventListener->m_target
+            && reinterpret_cast<GCClosure*>(m_handler.get())->callback == reinterpret_cast<GCClosure*>(gobjectEventListener->m_handler.get())->callback;
 
     return false;
 }
index 8e84793..58436fd 100644 (file)
 #include "EventListener.h"
 #include "EventTarget.h"
 #include <wtf/RefPtr.h>
+#include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
 typedef struct _GObject GObject;
-typedef void (*GCallback) (void);
+typedef struct _GClosure GClosure;
 
 namespace WebCore {
 
 class GObjectEventListener : public EventListener {
 public:
 
-    static bool addEventListener(GObject* object, EventTarget* target, const char* domEventName, GCallback handler, bool useCapture, void* userData)
+    static bool addEventListener(GObject* target, EventTarget* coreTarget, const char* domEventName, GClosure* handler, bool useCapture)
     {
-        RefPtr<GObjectEventListener> listener(adoptRef(new GObjectEventListener(object, target, domEventName, handler, useCapture, userData)));
-        return target->addEventListener(domEventName, listener.release(), useCapture);
+        RefPtr<GObjectEventListener> listener(adoptRef(new GObjectEventListener(target, coreTarget, domEventName, handler, useCapture)));
+        return coreTarget->addEventListener(domEventName, listener.release(), useCapture);
     }
 
-    static bool removeEventListener(GObject* object, EventTarget* target, const char* domEventName, GCallback handler, bool useCapture)
+    static bool removeEventListener(GObject* target, EventTarget* coreTarget, const char* domEventName, GClosure* handler, bool useCapture)
     {
-        GObjectEventListener key(object, target, domEventName, handler, useCapture, 0);
-        return target->removeEventListener(domEventName, &key, useCapture);
+        GObjectEventListener key(target, coreTarget, domEventName, handler, useCapture);
+        return coreTarget->removeEventListener(domEventName, &key, useCapture);
     }
 
     static void gobjectDestroyedCallback(GObjectEventListener* listener, GObject*)
@@ -59,21 +60,19 @@ public:
     virtual bool operator==(const EventListener& other);
 
 private:
-    GObjectEventListener(GObject*, EventTarget*, const char* domEventName, GCallback handler, bool capture, void* userData);
+    GObjectEventListener(GObject*, EventTarget*, const char* domEventName, GClosure*, bool capture);
     ~GObjectEventListener();
     void gobjectDestroyed();
 
     virtual void handleEvent(ScriptExecutionContext*, Event*);
 
-    GObject* m_object;
-
+    GObject* m_target;
     // We do not need to keep a reference to the m_coreTarget, because
     // we only use it when the GObject and thus the m_coreTarget object is alive.
     EventTarget* m_coreTarget;
     CString m_domEventName;
-    GCallback m_handler;
+    GRefPtr<GClosure> m_handler;
     bool m_capture;
-    void* m_userData;
 };
 } // namespace WebCore
 
index d885b2c..a8fae2a 100644 (file)
@@ -36,6 +36,7 @@
 #include "WebKitDOMEvent.h"
 #include "WebKitDOMEventTargetPrivate.h"
 #include "WebKitDOMPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
 
 typedef WebKitDOMEventTargetIface WebKitDOMEventTargetInterface;
 
@@ -45,42 +46,50 @@ static void webkit_dom_event_target_default_init(WebKitDOMEventTargetIface*)
 {
 }
 
-void webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
+gboolean webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
 {
-    g_return_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target));
-    g_return_if_fail(WEBKIT_DOM_IS_EVENT(event));
-
-    WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
+    g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
+    g_return_val_if_fail(WEBKIT_DOM_IS_EVENT(event), FALSE);
+    g_return_val_if_fail(!error || !*error, FALSE);
 
-    if (iface->dispatch_event)
-        iface->dispatch_event(target, event, error);
+    return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->dispatch_event(target, event, error);
 }
 
-gboolean webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData)
+gboolean webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean useCapture, gpointer userData)
 {
 
     g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
     g_return_val_if_fail(eventName, FALSE);
 
-    WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
+    GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(handler, userData, 0));
+    return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->add_event_listener(target, eventName, closure.get(), useCapture);
+}
 
-    if (iface->add_event_listener)
-        return iface->add_event_listener(target, eventName, handler, bubble, userData);
+gboolean webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean useCapture)
+{
+    g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
+    g_return_val_if_fail(eventName, FALSE);
 
-    return FALSE;
+    GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(handler, 0, 0));
+    return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->remove_event_listener(target, eventName, closure.get(), useCapture);
 }
 
-gboolean webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble)
+gboolean webkit_dom_event_target_add_event_listener_with_closure(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
 {
     g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
     g_return_val_if_fail(eventName, FALSE);
+    g_return_val_if_fail(handler, FALSE);
 
-    WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target);
+    return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->add_event_listener(target, eventName, handler, useCapture);
+}
 
-    if (iface->remove_event_listener)
-        return iface->remove_event_listener(target, eventName, handler, bubble);
+gboolean webkit_dom_event_target_remove_event_listener_with_closure(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
+{
+    g_return_val_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target), FALSE);
+    g_return_val_if_fail(eventName, FALSE);
+    g_return_val_if_fail(handler, FALSE);
 
-    return FALSE;
+    return WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target)->remove_event_listener(target, eventName, handler, useCapture);
 }
 
 namespace WebKit {
index 102c946..da3f726 100644 (file)
@@ -36,25 +36,32 @@ struct _WebKitDOMEventTargetIface {
     GTypeInterface gIface;
 
     /* virtual table */
-    void          (* dispatch_event)(WebKitDOMEventTarget *target,
+    gboolean      (* dispatch_event)(WebKitDOMEventTarget *target,
                                      WebKitDOMEvent       *event,
                                      GError              **error);
 
     gboolean      (* add_event_listener)(WebKitDOMEventTarget *target,
                                          const char           *event_name,
-                                         GCallback             handler,
-                                         gboolean              bubble,
-                                         gpointer              user_data);
+                                         GClosure             *handler,
+                                         gboolean              use_capture);
     gboolean      (* remove_event_listener)(WebKitDOMEventTarget *target,
                                             const char           *event_name,
-                                            GCallback             handler,
-                                            gboolean              bubble);
+                                            GClosure             *handler,
+                                            gboolean              use_capture);
 };
 
 
 WEBKIT_API GType     webkit_dom_event_target_get_type(void) G_GNUC_CONST;
 
-WEBKIT_API void      webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget *target,
+/**
+ * webkit_dom_event_target_dispatch_event:
+ * @target: A #WebKitDOMEventTarget
+ * @event: A #WebKitDOMEvent
+ * @error: return location for an error or %NULL
+ *
+ * Returns: a #gboolean
+ */
+WEBKIT_API gboolean  webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget *target,
                                                             WebKitDOMEvent       *event,
                                                             GError              **error);
 
@@ -63,14 +70,15 @@ WEBKIT_API void      webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget
  * @target: A #WebKitDOMEventTarget
  * @event_name: A #gchar
  * @handler: (scope async): A #GCallback
- * @bubble: A #gboolean
+ * @use_capture: A #gboolean
  * @user_data: A #gpointer
  *
+ * Returns: a #gboolean
  */
 WEBKIT_API gboolean  webkit_dom_event_target_add_event_listener(WebKitDOMEventTarget *target,
                                                                 const char           *event_name,
                                                                 GCallback             handler,
-                                                                gboolean              bubble,
+                                                                gboolean              use_capture,
                                                                 gpointer              user_data);
 
 /**
@@ -78,13 +86,53 @@ WEBKIT_API gboolean  webkit_dom_event_target_add_event_listener(WebKitDOMEventTa
  * @target: A #WebKitDOMEventTarget
  * @event_name: A #gchar
  * @handler: (scope call): A #GCallback
- * @bubble: A #gboolean
+ * @use_capture: A #gboolean
  *
+ * Returns: a #gboolean
  */
 WEBKIT_API gboolean  webkit_dom_event_target_remove_event_listener(WebKitDOMEventTarget *target,
                                                                    const char           *event_name,
                                                                    GCallback             handler,
-                                                                   gboolean              bubble);
+                                                                   gboolean              use_capture);
+
+/**
+ * webkit_dom_event_target_add_event_listener_with_closure:
+ * @target: A #WebKitDOMEventTarget
+ * @event_name: A #gchar
+ * @handler: A #GClosure
+ * @use_capture: A #gboolean
+ *
+ * Version of webkit_dom_event_target_add_event_listener() using a closure
+ * instead of a callbacks for easier binding in other languages.
+ *
+ * Returns: a #gboolean
+ *
+ * Rename to: webkit_dom_event_target_add_event_listener
+ */
+WEBKIT_API gboolean webkit_dom_event_target_add_event_listener_with_closure(WebKitDOMEventTarget *target,
+                                                                            const char           *event_name,
+                                                                            GClosure             *handler,
+                                                                            gboolean              use_capture);
+
+/**
+ * webkit_dom_event_target_remove_event_listener_with_closure:
+ * @target: A #WebKitDOMEventTarget
+ * @event_name: A #gchar
+ * @handler: A #GClosure
+ * @use_capture: A #gboolean
+ *
+ * Version of webkit_dom_event_target_remove_event_listener() using a closure
+ * instead of a callbacks for easier binding in other languages.
+ *
+ * Returns: a #gboolean
+ *
+ * Rename to: webkit_dom_event_target_remove_event_listener
+ */
+WEBKIT_API gboolean webkit_dom_event_target_remove_event_listener_with_closure(WebKitDOMEventTarget *target,
+                                                                               const char           *event_name,
+                                                                               GClosure             *handler,
+                                                                               gboolean              use_capture);
+
 
 G_END_DECLS
 
index 3567167..9d708f7 100644 (file)
@@ -1380,32 +1380,33 @@ sub GenerateEventTargetIface {
     $implIncludes{"WebKitDOMEventTarget.h"} = 1;
     $implIncludes{"WebKitDOMEventPrivate.h"} = 1;
 
-    push(@cBodyProperties, "static void webkit_dom_${decamelize}_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)\n{\n");
+    push(@cBodyProperties, "static gboolean webkit_dom_${decamelize}_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)\n{\n");
     push(@cBodyProperties, "#if ${conditionalString}\n") if $conditionalString;
     push(@cBodyProperties, "    WebCore::Event* coreEvent = WebKit::core(event);\n");
     push(@cBodyProperties, "    WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject);\n\n");
     push(@cBodyProperties, "    WebCore::ExceptionCode ec = 0;\n");
-    push(@cBodyProperties, "    coreTarget->dispatchEvent(coreEvent, ec);\n");
+    push(@cBodyProperties, "    gboolean result = coreTarget->dispatchEvent(coreEvent, ec);\n");
     push(@cBodyProperties, "    if (ec) {\n        WebCore::ExceptionCodeDescription description(ec);\n");
     push(@cBodyProperties, "        g_set_error_literal(error, g_quark_from_string(\"WEBKIT_DOM\"), description.code, description.name);\n    }\n");
+    push(@cBodyProperties, "    return result;\n");
     push(@cBodyProperties, "#else\n") if $conditionalString;
     push(@cBodyProperties, @conditionalWarn) if scalar(@conditionalWarn);
-    push(@cBodyProperties, "#endif // ${conditionalString}\n") if $conditionalString;
+    push(@cBodyProperties, "    return false;\n#endif // ${conditionalString}\n") if $conditionalString;
     push(@cBodyProperties, "}\n\n");
 
-    push(@cBodyProperties, "static gboolean webkit_dom_${decamelize}_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData)\n{\n");
+    push(@cBodyProperties, "static gboolean webkit_dom_${decamelize}_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)\n{\n");
     push(@cBodyProperties, "#if ${conditionalString}\n") if $conditionalString;
     push(@cBodyProperties, "    WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject);\n");
-    push(@cBodyProperties, "    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble, userData);\n");
+    push(@cBodyProperties, "    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);\n");
     push(@cBodyProperties, "#else\n") if $conditionalString;
     push(@cBodyProperties, @conditionalWarn) if scalar(@conditionalWarn);
     push(@cBodyProperties, "    return false;\n#endif // ${conditionalString}\n") if $conditionalString;
     push(@cBodyProperties, "}\n\n");
 
-    push(@cBodyProperties, "static gboolean webkit_dom_${decamelize}_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble)\n{\n");
+    push(@cBodyProperties, "static gboolean webkit_dom_${decamelize}_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)\n{\n");
     push(@cBodyProperties, "#if ${conditionalString}\n") if $conditionalString;
     push(@cBodyProperties, "    WebCore::${interfaceName}* coreTarget = static_cast<WebCore::${interfaceName}*>(WEBKIT_DOM_OBJECT(target)->coreObject);\n");
-    push(@cBodyProperties, "    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble);\n");
+    push(@cBodyProperties, "    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);\n");
     push(@cBodyProperties, "#else\n") if $conditionalString;
     push(@cBodyProperties, @conditionalWarn) if scalar(@conditionalWarn);
     push(@cBodyProperties, "    return false;\n#endif // ${conditionalString}\n") if $conditionalString;
index 62cd04c..3719fba 100644 (file)
@@ -68,29 +68,30 @@ WebKitDOMTestEventTarget* wrapTestEventTarget(WebCore::TestEventTarget* coreObje
 
 } // namespace WebKit
 
-static void webkit_dom_test_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
+static gboolean webkit_dom_test_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
 {
     WebCore::Event* coreEvent = WebKit::core(event);
     WebCore::TestEventTarget* coreTarget = static_cast<WebCore::TestEventTarget*>(WEBKIT_DOM_OBJECT(target)->coreObject);
 
     WebCore::ExceptionCode ec = 0;
-    coreTarget->dispatchEvent(coreEvent, ec);
+    gboolean result = coreTarget->dispatchEvent(coreEvent, ec);
     if (ec) {
         WebCore::ExceptionCodeDescription description(ec);
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name);
     }
+    return result;
 }
 
-static gboolean webkit_dom_test_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData)
+static gboolean webkit_dom_test_event_target_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
 {
     WebCore::TestEventTarget* coreTarget = static_cast<WebCore::TestEventTarget*>(WEBKIT_DOM_OBJECT(target)->coreObject);
-    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble, userData);
+    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
 }
 
-static gboolean webkit_dom_test_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble)
+static gboolean webkit_dom_test_event_target_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
 {
     WebCore::TestEventTarget* coreTarget = static_cast<WebCore::TestEventTarget*>(WEBKIT_DOM_OBJECT(target)->coreObject);
-    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble);
+    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
 }
 
 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
index d7b3029..4446f29 100644 (file)
@@ -56,29 +56,30 @@ WebKitDOMTestNode* wrapTestNode(WebCore::TestNode* coreObject)
 
 } // namespace WebKit
 
-static void webkit_dom_test_node_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
+static gboolean webkit_dom_test_node_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
 {
     WebCore::Event* coreEvent = WebKit::core(event);
     WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject);
 
     WebCore::ExceptionCode ec = 0;
-    coreTarget->dispatchEvent(coreEvent, ec);
+    gboolean result = coreTarget->dispatchEvent(coreEvent, ec);
     if (ec) {
         WebCore::ExceptionCodeDescription description(ec);
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name);
     }
+    return result;
 }
 
-static gboolean webkit_dom_test_node_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData)
+static gboolean webkit_dom_test_node_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
 {
     WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject);
-    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble, userData);
+    return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
 }
 
-static gboolean webkit_dom_test_node_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble)
+static gboolean webkit_dom_test_node_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
 {
     WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject);
-    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble);
+    return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
 }
 
 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
index 4e69d94..1f11b24 100644 (file)
@@ -1,3 +1,13 @@
+2013-10-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GObject bindings] Make EventTarget interface introspectable
+        https://bugs.webkit.org/show_bug.cgi?id=77835
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * Scripts/webkitpy/style/checker.py: Add exceptions for custom
+        GObject DOM bindings headers.
+
 2013-10-23  Lucas Forschler  <lforschler@apple.com>
 
         Add two more mac bots to the Mavericks Test Queue.
index f23d307..b772658 100644 (file)
@@ -151,6 +151,8 @@ _PATH_RULES_SPECIFIER = [
       # lower-cased, underscore-separated values, whitespace before
       # parens for function calls, and always having variable names.
       # Also, GTK+ allows the use of NULL.
+      "Source/WebCore/bindings/gobject/WebKitDOMCustom.h",
+      "Source/WebCore/bindings/gobject/WebKitDOMEventTarget.h",
       "Source/WebCore/bindings/scripts/test/GObject",
       "Source/WebKit/gtk/webkit/",
       "Tools/DumpRenderTree/gtk/"],
@@ -216,7 +218,7 @@ _PATH_RULES_SPECIFIER = [
     ([# These files define GObjects, which implies some definitions of
       # variables and functions containing underscores.
       "Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp",
-      "Source/WebCore/bindings/gobject/WebKitDOMCustom.h",
+      "Source/WebCore/bindings/gobject/WebKitDOMEventTarget.cpp",
       "Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer1.cpp",
       "Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp",
       "Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp",