Hypothetical WebIDL block for EventTarget

View: New views
5 Messages — Rating Filter:   Alert me  

Hypothetical WebIDL block for EventTarget

by Travis Leithead-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I realize I'm touching on a controversial topic, but I was wondering what feedback we might get by proposing that the EventTarget interface in DOM Level 3 Events be marked up with WebIDL as follows (I don't imagine controversy on any other interface):
 
[NoInterfaceObject]
interface EventTarget {
  void               addEventListener(in DOMString type,
                                      in EventListener listener,
                                      in boolean useCapture);
  void               removeEventListener(in DOMString type,
                                         in EventListener listener,
                                         in boolean useCapture);
  // Modified in DOM Level 3:
  boolean            dispatchEvent(in Event evt)
                                   raises(EventException,
                                   DOMException);
};

Note, this is different from http://dev.w3.org/2006/webapi/WebIDL/dom/dom2events.idl
The point of contention is whether EventTarget should be bound to an "interface object" in the ECMAScript binding or whether it participates in the mix-in algorithm, however that will end up working (not finalized in WebIDL at the moment).

For reference:

Browser     this.hasOwnProperty("EventTarget")
===============================================
IE8 false
FF3.5 false (but EventTarget.prototype exists)?
Safari4 false
Opera10 false


Re: Hypothetical WebIDL block for EventTarget

by Garrett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 14, 2009 at 12:26 PM, Travis Leithead <travil@...> wrote:

(crossposting to public-script-coord@..., as there is some
crossover of standards).

> I realize I'm touching on a controversial topic, but I was wondering what feedback we might get by proposing that the EventTarget interface in DOM Level 3 Events be marked up with WebIDL as follows (I don't imagine controversy on any other interface):
>
What is controversial?

Can you please clarify the problem that this proposal solves?

[...]

>
> Note, this is different from http://dev.w3.org/2006/webapi/WebIDL/dom/dom2events.idl
> The point of contention is whether EventTarget should be bound to an "interface object" in the ECMAScript binding or whether it participates in the mix-in algorithm, however that will end up working (not finalized in WebIDL at the moment).
>
> For reference:
>

Where is your test code?

> Browser     this.hasOwnProperty("EventTarget")
> ===============================================
> IE8             false
> FF3.5           false (but EventTarget.prototype exists)?
> Safari4 false
> Opera10 false
>

The expectation of a |true| result would be based on on a few preconditions:
  (1) A global EventTarget property
  (2) The global object has Object.prototype in its prototype chain.
  (3) hasOwnProperty checks the both the Window and the WindowProxy.

ECMA-262 r3, s 15.1 states:
| The values of the [[Prototype]] and [[Class]] properties of the
| global object are implementation-dependent.

Off the top of my head, I'll wager that you are wrong about Firefox
3.5 and Safari.

Opera's global object is a bit different, and so event if it does have
a global EventTarget, then - this.hasOwnProperty("EventTarget") -
would probably result in the same false as:

  this.hasOwnProperty("window"); .// false in Opera.

A program would not care about outcome of whatever it is your test expects.

What is the reason for this proposal?

Garrett


Re: Hypothetical WebIDL block for EventTarget

by Maciej Stachowiak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 14, 2009, at 12:26 PM, Travis Leithead wrote:

> I realize I'm touching on a controversial topic, but I was wondering  
> what feedback we might get by proposing that the EventTarget  
> interface in DOM Level 3 Events be marked up with WebIDL as follows  
> (I don't imagine controversy on any other interface):
>
> [NoInterfaceObject]
> interface EventTarget {
>  void               addEventListener(in DOMString type,
>                                      in EventListener listener,
>                                      in boolean useCapture);
>  void               removeEventListener(in DOMString type,
>                                         in EventListener listener,
>                                         in boolean useCapture);
>  // Modified in DOM Level 3:
>  boolean            dispatchEvent(in Event evt)
>                                   raises(EventException,
>                                   DOMException);
> };
>
> Note, this is different from http://dev.w3.org/2006/webapi/WebIDL/dom/dom2events.idl
> The point of contention is whether EventTarget should be bound to an  
> "interface object" in the ECMAScript binding or whether it  
> participates in the mix-in algorithm, however that will end up  
> working (not finalized in WebIDL at the moment).

I think it makes sense that interfaces meant to be used as mixins  
don't produce a prototype object.

> For reference:
>
> Browser     this.hasOwnProperty("EventTarget")

You should use ("EventTarget" in window) as the test. hasOwnProperty  
will miss prototype properties.

> ===============================================
> IE8 false
> FF3.5 false (but EventTarget.prototype exists)?
> Safari4 false
> Opera10 false
>



Re: Hypothetical WebIDL block for EventTarget

by Garrett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 14, 2009 at 1:52 PM, Garrett Smith <dhtmlkitchen@...> wrote:
> On Wed, Oct 14, 2009 at 12:26 PM, Travis Leithead <travil@...> wrote:
>

[snip]

> Where is your test code?
>
>> Browser     this.hasOwnProperty("EventTarget")
>> ===============================================
>> IE8             false
>> FF3.5           false (but EventTarget.prototype exists)?
>> Safari4 false
>> Opera10 false
>>
>
> The expectation of a |true| result would be based on on a few preconditions:
>  (1) A global EventTarget property
>  (2) The global object has Object.prototype in its prototype chain.
>  (3) hasOwnProperty checks the both the Window and the WindowProxy.
>
(as a special behavior of |hasOwnProperty| for Global/WindowProxy object)


Re: Hypothetical WebIDL block for EventTarget

by Anne van Kesteren-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 14 Oct 2009 21:26:43 +0200, Travis Leithead <travil@...>  
wrote:

> I realize I'm touching on a controversial topic, but I was wondering  
> what feedback we might get by proposing that the EventTarget interface  
> in DOM Level 3 Events be marked up with WebIDL as follows (I don't  
> imagine controversy on any other interface):
> [NoInterfaceObject]
> interface EventTarget {
>   void               addEventListener(in DOMString type,
>                                       in EventListener listener,
>                                       in boolean useCapture);
>   void               removeEventListener(in DOMString type,
>                                          in EventListener listener,
>                                          in boolean useCapture);
>   // Modified in DOM Level 3:
>   boolean            dispatchEvent(in Event evt)
>                                    raises(EventException,
>                                    DOMException);
> };

Makes sense to me.


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