[Webkit-unassigned] [Bug 77835] [GObject bindings] Missing scope annotations for add/remove_event_listener

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 10 11:51:48 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=77835


Zan Dobersek <zandobersek at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zandobersek at gmail.com




--- Comment #12 from Zan Dobersek <zandobersek at gmail.com>  2012-02-10 11:51:48 PST ---
I've put some time into investigating this, here are the results:

1)
It seems to me that GObject introspection is bad with GCallbacks being used. I don't know for sure if my blame falls on gi or the pygobject, but it seems that because of GCallback being used, in python, this results with the callback being called with no arguments, despite being triggered as a GObjectEventListenerCallback. I've looked around Gtk+ how this is avoided there and the solution could be to define something like a WebKitDOMEventListenerFunc type of function (basically exporting the GObjectEventListenerCallback) and use it. Because of this callback functions would not need to be wrapped in G_CALLBACK when adding a listener.

2)
As seen in in comments #9 and #10 a solution might be adding a _full version of the function with a GDestroyNotify argument. I'd recommend avoiding that and putting the GDestroyNotify argument into the existing function and accepting a possible NULL value. This would of course cause API break, but I don't really see a need for two separate functions.
I'm not yet very fond of the introspection system, but, at least when using gi in python, it seems that the GDestroyNotify argument is completely ignored. This doesn't really affect the solution apart from an idiomatic point of view, it might not even be a problem, but as of now it bugs me.

3)
After (possibly) adding GDestroyNotify argumnet to add_event_listener, the callback must be properly pointed to its closure via annotations that introspection then picks up. Anthony posted a patch[1] in #webkitgtk+ that does that. I haven't tried it, I rather reordered arguments so that WebKitDOMEventListenerFunc, gpointer to user data and GDestroyNotify were put together at the end of the arguments list - it works as well, but it breaks conformance with how the addEventListener function is defined in DOM. Of course, the use of annotations (as it was done in the patch) is the right way.

4)
All this still leaves webkit_dom_event_target_remove_event_listener unintrospectable. The problem is that introspection demands the callback to be scoped (as it is expected to be used), but this really isn't the situation here - event listeners with that callback are being removed, so the introspection shouldn't really care about the scope. I haven't yet found a way do convince introspection of this, might not even be supported.


[1] http://paste.pocoo.org/show/548725/

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list