W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Re: [WebIDL] Simplify callbacks

From: Anne van Kesteren <annevk@opera.com>
Date: Wed, 14 Dec 2011 11:04:45 +0100
To: "public-script-coord@w3.org" <public-script-coord@w3.org>, "Cameron McCormack" <cam@mcc.id.au>
Message-ID: <op.v6g4x7fp64w2qv@annevk-macbookpro.local>
On Wed, 14 Dec 2011 02:12:23 +0100, Cameron McCormack <cam@mcc.id.au>  
> Anyway, here's a suggestion:
>    callback EventListener = void handleEvent(Event evt);
>    interface EventTarget {
>      void addEventListener(DOMString type, EventListener listener,
>                            bool useCapture);
>    };
> That handles the (by far common case) of [Callback,NoInterfaceObject]  
> being used on an interface with a single operation.  It's an improvement  
> over using "interface" IMO.

Agreed, looks pretty awesome to me!

> Also if someone knows of any interfaces that use a [Callback] with  
> attributes on it, please let me know.  It would simplify matters to drop  
> support for that too.

has them (sad face), but I am not really sure how that ends up being  

> For event listener attributes where they are required to be restricted  
> only to Function objects (that is the case, yes?) we could write
>    callback EventListener = void handleEvent(Event evt);
>    [FunctionOnly] attribute EventListener onclick;
> or
>    callback EventListener = void handleEvent(Event evt);
>    typedef [FunctionOnly] EventListener EventListenerAttribute;
>    attribute EventListenerAttribute onclick;
> to reduce a bit of repetition.

I think we should introduce a native IDL type "eventhandler" so you can  

   eventhandler onclick;

Event handlers are extremely common and worthy of such blessing, in my  

Anne van Kesteren
Received on Wednesday, 14 December 2011 10:05:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC