[webkit-dev] On IDL files, events and writing DOM bindings

Xan Lopez xan at gnome.org
Wed Aug 11 18:42:51 PDT 2010


On Wed, Aug 11, 2010 at 8:39 AM, Xan Lopez <xan at gnome.org> wrote:
> On Wed, Aug 11, 2010 at 7:51 AM, Darin Adler <darin at apple.com> wrote:
>> The bindings do not expose events directly, thus the IDL files don’t show the events. The IDL files only show functions and attributes on the various objects. Events are neither functions nor attributes. For the bindings I am familiar with, there is no list of events and so nothing to be generated from the IDL. The event names, as with tag names, are string constants.
>
> Interesting. For the GObject bindings I'm actually exposing the events
> directly. Eg, you are able to do:
>
> g_signal_connect(image, "click-event", callback, NULL);
>
> and callback will be called when the image is clicked, with an Event
> object as a parameter. The wrapping for the Events comes from the IDL
> file that exists for each type of event (Event.idl and its
> subclasses).

FWIW: after this I wanted to check how can the objc bindings do events
without actually exposing any event object/structure directly, since
it seemed at best tricky to achieve this (eg, you really need access
to some data members of say MouseEvents to make sense of what
happened; if it's not exposed as a class in the API it must be exposed
in some other way).

So checking the code I see some headers in the objc bindings dir where
there are references to headers referring to particular event types:

WebCore/bindings/objc/DOMEvents.h:

(...)
#import <WebCore/DOMEvent.h>
#import <WebCore/DOMEventException.h>
#import <WebCore/DOMEventListener.h>
#import <WebCore/DOMEventTarget.h>
#import <WebCore/DOMKeyboardEvent.h>
#import <WebCore/DOMMouseEvent.h>
#import <WebCore/DOMMutationEvent.h>
#import <WebCore/DOMOverflowEvent.h>
#import <WebCore/DOMUIEvent.h>
#import <WebCore/DOMWheelEvent.h>
(...)

and googling a bit with those names you can see the usual definitions
for things like DOMMouseEvent:
http://google.com/codesearch/p?hl=en#mc67TWYcYcg/WebKit/DOMMouseEvent.h&q=DOMUIEvent.h&d=1

So if all this stuff is exposed in the API I think what I have done in
the GObject bindings is essentially the same, and I'm not really
exploring any new ground. I guess at some point we started talking
about different things, and you meant something else in your answer?

Xan


More information about the webkit-dev mailing list