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

Re: [WebIDL] Simplify callbacks

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 15 Dec 2011 12:52:13 +1100
Message-ID: <4EE952CD.5050002@mcc.id.au>
To: Anne van Kesteren <annevk@opera.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Cameron McCormack:
>> 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.

Anne van Kesteren:
> http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-nodefilter
> has them (sad face), but I am not really sure how that ends up being
> exposed.

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);

>> 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?  You 
can even rename it from "EventListenerAttribute" to "EventHandler" if 
you wish. :)

   // 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;
Received on Thursday, 15 December 2011 01:52:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC