Re: [WebIDL] Simplify callbacks

On Tue, 08 Nov 2011 13:23:13 -0700, David Flanagan <>  
> On 11/8/11 6:47 AM, Anne van Kesteren wrote:
>> addEventListener(DOMString type, Callback(Event)? listener, optional  
>> boolean capture)
> How about Callback means [Callback=FunctionOnly].  I.e.: you have to  
> pass a function.  New interfaces could use this.
> And EventCallback means [Callback] EventListener.  I.e. you can pass a  
> function or any object with a handleEvent() method.  Legacy APIs (and  
> new Event apis) can use that.
> Some other thoughts:
> - If these are going to be parameterized with the argument type, it  
> seems like the WebIDL precedent is angle brackets as in  
> sequence<DOMString>.

What do you mean here?

> - If parameterized, will multiple arguments be supported?  What about  
> return values? Seems to me that that requires a lot of new specification  
> in WebIDL and new functionality to add to IDL parsing tools, etc.

Given that callbacks are implemented by authors I do not think we need  
annotations for return values. Multiple arguments works with the syntax I  
proposed. Note also that I omitted naming the arguments for the callback  
as we do not use that in specifications either.

> - If these are going to be types defined by WebIDL itself, precedent is  
> that they should start with a lowercase letter or be prefixed with DOM.   
> (Hmm. "callback" could be the function only version and "DOMCallback"  
> could be the legacy version that supports handleEvent() methods...)

Ah yes. callback() works for me. If we want to move forward with  
FunctionOnly callback could mean that and we could have legacycallback()  
for the one that also has accepts objects with handleEvent(). Would  
definitely make sense to me.

Anne van Kesteren

Received on Wednesday, 9 November 2011 16:23:30 UTC