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

2010-08-11 Thread Xan Lopez
On Wed, Aug 11, 2010 at 8:39 AM, Xan Lopez  wrote:
> On Wed, Aug 11, 2010 at 7:51 AM, Darin Adler  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 
#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 
(...)

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
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-11 Thread Xan Lopez
On Wed, Aug 11, 2010 at 5:56 PM, Darin Adler  wrote:
> On Aug 10, 2010, at 11:39 PM, Xan Lopez wrote:
>
>> For the GObject bindings I'm actually exposing the events directly.
>
> This is a new feature, no other binding has this, and you will have to build 
> everything yourself. There’s nothing in IDL files, or in fact anywhere in the 
> project, that lists all the events that might be sent to each class.

As both you and Adam have commented in the thread I don't think this
information is actually needed to build the bindings. Since any event
can be delivered to any EventTarget you have to be quite generic in
how to setup things, at least for GObject. Part of my willingness to
infer that data from the IDL files was to try to avoid being so
generic in the implementation (since it has some drawbacks), but I
think that just ends in an incorrect implementation so I have no
choice but give it up.

Xan
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-11 Thread Darin Adler
On Aug 10, 2010, at 11:39 PM, Xan Lopez wrote:

> For the GObject bindings I'm actually exposing the events directly.

This is a new feature, no other binding has this, and you will have to build 
everything yourself. There’s nothing in IDL files, or in fact anywhere in the 
project, that lists all the events that might be sent to each class.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Xan Lopez
On Wed, Aug 11, 2010 at 7:51 AM, Darin Adler  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).

>
> You mentioned the ended attribute in HTMLMediaElement. This is a boolean 
> attribute, and not an event. It happens to have the same name as an event, 
> but there is no direct connection between the event and the attribute.

Right, I was aware of the distinction. Maybe I failed to express
myself properly here, my only doubt was really why there was no
reference to the event in any IDL file, which has already been
answered.

>
> You asked:
>
>> is it possible to know which Events are defined for each class just from the 
>> IDL files
>
> Events are not defined for classes. The engine can send events to any 
> EventTarget, and the IDL files and the bindings have nothing to say about 
> which events the engine will send to which objects.

Right.

I think the only solution that makes sense for the bindings (at least
the GObject ones, where you *do* have to tell a class which kind of
events/signals it can receive or emit), is to define every possible
type of event in the most basic class that is an EventTarget (say,
Node). In this way you'll be able to connect to the event delivery
signals or manually dispatch and event to any node or any of its
subclasses, both perfectly valid things to do.

Cheers,

Xan

>
>    -- Darin
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Darin Adler
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.

You mentioned the ended attribute in HTMLMediaElement. This is a boolean 
attribute, and not an event. It happens to have the same name as an event, but 
there is no direct connection between the event and the attribute.

You asked:

> is it possible to know which Events are defined for each class just from the 
> IDL files

Events are not defined for classes. The engine can send events to any 
EventTarget, and the IDL files and the bindings have nothing to say about which 
events the engine will send to which objects.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Xan Lopez
On Tue, Aug 10, 2010 at 8:59 PM, Xan Lopez  wrote:
> On Tue, Aug 10, 2010 at 8:32 PM, Adam Barth  wrote:
>> I'm not sure I understand your question.  Every event can happen on
>> every EventTarget.
>
> I mean that an HTMLMediaElement will naturally emit an 'ended' Event
> in some situations, but an HTMLImageElement won't. I see no obvious
> way of knowing that (or other similar facts) from the IDL files.

Answering myself after the trip home, I take it that the answer is
basically that the information I want is not useful when writing the
bindings (since as you say any event can in theory happen in any
target, be it naturally or synthetically), and that I should simply
collect all event classes defined and add them as "this class might
possible receive this event" where appropriate in the class hierarchy?
Another question would be whether we maintain the canonical list
somewhere (perhaps in DOMWindow.idl ) or if we are supposed to
construct it ourselves manually.

>
> Xan
>
>>
>> Adam
>>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Xan Lopez
On Tue, Aug 10, 2010 at 8:32 PM, Adam Barth  wrote:
> I'm not sure I understand your question.  Every event can happen on
> every EventTarget.

I mean that an HTMLMediaElement will naturally emit an 'ended' Event
in some situations, but an HTMLImageElement won't. I see no obvious
way of knowing that (or other similar facts) from the IDL files.

Xan

>
> Adam
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Adam Barth
On Tue, Aug 10, 2010 at 11:26 AM, Xan Lopez  wrote:
> as we all know, when writing DOM bindings on top of WebKit we are
> supposed to use the IDL files it ships as the source of the structure
> and behavior of the DOM. At first I had assumed that to figure out
> which events apply to each type/class it was OK to see which
> EventListeners were defined, and go on from there (ie, if there's a
> onabort defined in Element.idl, Element has an 'abort' Event defined).
> This, though, seems to be not completely accurate in many cases, and
> in others it's downright absent:
>
> Media elements are defined to have, for example, an 'ended' event,
> emitted when the playback has finished. The matching attribute is
> defined in HTMLMediaElement.idl, but the event listener for it is in
> DOMWindow.idl. This was done here
> https://bugs.webkit.org/show_bug.cgi?id=26100 completely on purpose,
> so I assume this is how it's meant to work.
>
> So the question is: is it possible to know which Events are defined
> for each class just from the IDL files, or are we expected to inject
> part of this knowledge ourselves when writing the bindings?

I'm not sure I understand your question.  Every event can happen on
every EventTarget.

Adam
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-08-10 Thread Xan Lopez
Hi,

as we all know, when writing DOM bindings on top of WebKit we are
supposed to use the IDL files it ships as the source of the structure
and behavior of the DOM. At first I had assumed that to figure out
which events apply to each type/class it was OK to see which
EventListeners were defined, and go on from there (ie, if there's a
onabort defined in Element.idl, Element has an 'abort' Event defined).
This, though, seems to be not completely accurate in many cases, and
in others it's downright absent:

Media elements are defined to have, for example, an 'ended' event,
emitted when the playback has finished. The matching attribute is
defined in HTMLMediaElement.idl, but the event listener for it is in
DOMWindow.idl. This was done here
https://bugs.webkit.org/show_bug.cgi?id=26100 completely on purpose,
so I assume this is how it's meant to work.

So the question is: is it possible to know which Events are defined
for each class just from the IDL files, or are we expected to inject
part of this knowledge ourselves when writing the bindings?

Xan
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev