Re: [WebIDL] Simplify callbacks

On Thu, 15 Dec 2011 02:52:13 +0100, Cameron McCormack <cam@mcc.id.au>  
wrote:
> Luckily that is constants and not attributes, and there is no strict  
> need to have the NodeFilter callback be the same as the interface on  
> which those constants are defined:
>
>    interface NodeFilter {
>      const ...;
>    };
>
>    callback NodeFilterCallback = unsigned short acceptNode(Node node);

Yeah if we can make it that I think that would be great. I'm not really  
sure what the implications are but if everyone thinks this can work lets  
do it.


>>> callback EventListener = void handleEvent(Event evt);
>>> typedef [FunctionOnly] EventListener EventListenerAttribute;
>>> attribute EventListenerAttribute onclick;
>
>> I think we should introduce a native IDL type "eventhandler" so you can
>> write
>>
>> eventhandler onclick;
>>
>> Event handlers are extremely common and worthy of such blessing, in my
>> opinion.
>
> That makes Web IDL have a dependency on DOM Core.  Seems a bit  
> backwards.  Why not just include the typedef in DOM Core itself?

Oh, because of the callback argument. I see. I was hoping we could somehow  
get rid of [FunctionOnly] as it is only needed for this.


>    // This line you need to include anyway in DOM Core, for
>    // addEventListener to use.
>    callback EventListener = void handleEvent(Event evt);
>
>    // So you're just adding this one line:
>    typedef [FunctionOnly] EventListener EventHandler;
>
> And all specs defining event handler properties just do:
>
>    attribute EventHandler onclick;

I guess that is fair enough. Though HTML should include the typedef as  
HTML defines event handler attributes at the moment.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Thursday, 15 December 2011 08:29:59 UTC