html5/spec Overview.html,1.5335,1.5336

Update of /sources/public/html5/spec
In directory hutz:/tmp/cvs-serv16191

Modified Files:
	Overview.html 
Log Message:
Tidy up how event handlers are defined to line up better with WebIDL and DOM Core (whatwg r6654)

Index: Overview.html
===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.5335
retrieving revision 1.5336
diff -u -d -r1.5335 -r1.5336
--- Overview.html	7 Oct 2011 22:01:40 -0000	1.5335
+++ Overview.html	7 Oct 2011 22:31:39 -0000	1.5336
@@ -50510,13 +50510,14 @@
   list of <a href="#concept-event-listener" title="concept-event-listener">event listeners</a>
   associated with <var title="">T</var> with <i>type</i> set to the
   <dfn id="event-handler-event-type">event handler event type</dfn> corresponding to <var title="">H</var>, <i>capture</i> set to false, and <i>listener</i>
-  set to be an anonymous function that does nothing when the event
-  handler's value is not a <code><a href="#function">Function</a></code> object and <a href="#concept-function-invoke" title="concept-Function-invoke">invokes the <code>Function</code>
-  object</a> associated with the <a href="#event-handlers" title="event handlers">event
-  handler</a> otherwise. <a href="#refsDOMCORE">[DOMCORE]</a></p>
+  set to <a href="#the-event-handler-processing-algorithm">the event handler processing algorithm</a> defined
+  below. <a href="#refsDOMCORE">[DOMCORE]</a></p>
 
   <p class="note">The <i>listener</i> is emphatically <em>not</em> the
-  <a href="#event-handlers" title="event handlers">event handler</a> itself.</p>
+  <a href="#event-handlers" title="event handlers">event handler</a> itself. Every
+  event handler ends up registering the same <i>listener</i>, the
+  algorithm defined below, which takes care of invoking the right
+  callback, and processing the callback's return value.</p>
 
   <p class="note">This only happens the first time the <a href="#event-handlers" title="event handlers">event handler</a>'s value is set. Since
   listeners are called in the order they were registered, the order of
@@ -50552,41 +50553,57 @@
   not influence whether an <a href="#event-handlers" title="event handlers">event
   handler</a> is triggered or not.</p>
 
-  <p>When an <a href="#event-handlers" title="event handlers">event handler</a>'s
-  <code><a href="#function">Function</a></code> object is <dfn id="concept-function-invoke" title="concept-Function-invoke">invoked</dfn>, its <code title="dom-function-call"><a href="#dom-function-call">call()</a></code> callback must be invoked
-  with one argument, set to the <code><a href="#event">Event</a></code> object of the event
-  in question.</p>
+  <p>The <dfn id="the-event-handler-processing-algorithm">the event handler processing algorithm</dfn> for an
+  <a href="#event-handlers" title="event handlers">event handler</a> <var title="">H</var> and an <code><a href="#event">Event</a></code> object <var title="">E</var> is as follows:</p>
 
-  <p>The handler's return value must then be processed as follows:</p>
+  <ol><li><p>If <var title="">H</var>'s value is null, then abort these
+   steps.</li>
 
-  <dl class="switch"><dt>If the event type is <code class="event-mouseover">mouseover</code></dt>
+   <li><p>Let <var title="">callback</var> be <var title="">H</var>'s
+   value, the <code><a href="#function">Function</a></code> object that the <a href="#event-handlers" title="event
+   handlers">event handler</a> was last set to.</li>
 
-   <dd><p>If the return value is a boolean with the value true, then
-   the event must be canceled.</dd>
+   <li><p>Invoke <var title="">callback</var>'s <code title="dom-function-call"><a href="#dom-function-call">call()</a></code> operation with one
+   argument, the value of which is the <code><a href="#event">Event</a></code> object <var title="">E</var>, with the <i title="dfn-callback-this-value">callback this value</i> set to the
+   <var title="">E</var>'s <code title="dom-Event-currentTarget">currentTarget</code>. Let the
+   return value be <var title="">return value</var>. <a href="#refsWEBIDL">[WEBIDL]</a></p>
 
-   <dt>If the event object is a <code><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> object</dt>
+   <li>
 
-   <dd><p>If the return value is a string, and the event object's
-   <code title="dom-BeforeUnloadEvent-returnValue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code>
-   attribute's value is the empty string, then set the <code title="dom-BeforeUnloadEvent-returnValue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code>
-   attribute's value to the return value.</dd>
+   <li>
 
-   <dt>Otherwise</dt>
+    <p>Process <var title="">return value</var> as follows:</p>
 
-   <dd><p>If the return value is a boolean with the value false, then
-   the event must be canceled.</dd>
+    <dl class="switch"><dt>If the event type is <code class="event-mouseover">mouseover</code></dt>
 
-  </dl></div><hr><p>The <code><a href="#function">Function</a></code> interface represents a function in the
-  scripting language being used. It is represented in IDL as
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value true, then cancel the event.</dd>
+
+     <dt>If the <code><a href="#event">Event</a></code> object <var title="">E</var> is a
+     <code><a href="#beforeunloadevent">BeforeUnloadEvent</a></code> object</dt>
+
+     <dd><p>If <var title="">return value</var> is a string, and the
+     <code><a href="#event">Event</a></code> object <var title="">E</var>'s <code title="dom-BeforeUnloadEvent-returnValue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code>
+     attribute's value is the empty string, then set the <code title="dom-BeforeUnloadEvent-returnValue"><a href="#dom-beforeunloadevent-returnvalue">returnValue</a></code>
+     attribute's value to <var title="">return value</var>.</dd>
+
+     <dt>Otherwise</dt>
+
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value false, then cancel the event.</dd>
+
+     
+
+    </dl></li>
+
+  </ol></div><hr><p>The <code><a href="#function">Function</a></code> interface represents a function in the
+  scripting language being used. It is represented in Web IDL as
   follows:<pre class="idl">[Callback=FunctionOnly, NoInterfaceObject]
 interface <dfn id="function">Function</dfn> {
   any <a href="#dom-function-call" title="dom-function-call">call</a>(any... arguments);
 };</pre><p>The <dfn id="dom-function-call" title="dom-function-call"><code>call(...)</code></dfn>
   method is the object's callback.<p class="note">In JavaScript, any <code title="">Function</code>
-  object implements this interface.<p>If the <code><a href="#function">Function</a></code> object is a JavaScript <code title="">Function</code>, then when it is invoked by the user agent,
-  the user agent must set the <var title="">thisArg</var> (as defined
-  by ECMAScript edition 5 section 10.4.3 Entering Function Code) to
-  the <a href="#event-handlers" title="event handlers">event handler</a>'s object. <a href="#refsECMA262">[ECMA262]</a><div class="example">
+  object implements this interface.<div class="example">
 
    <p>For example, the following document fragment:</p>
 
@@ -50596,11 +50613,13 @@
    and an alert saying "<code title="">[object&nbsp;HTMLBodyElement]</code>" whenever the user
    clicks something in the page.</p>
 
-  </div><p>The return value of the function affects whether the event is
-  canceled or not: <span class="impl">as described above,</span> if
-  the return value is false, the event is canceled (except for <code class="event-mouseover">mouseover</code> events, where the return
-  value has to be true to cancel the event). With <code title="event-beforeunload">beforeunload</code> events, the value is
-  instead used to determine the message to show the user.<h5 id="event-handlers-on-elements-document-objects-and-window-objects"><span class="secno">6.1.6.2 </span>Event handlers on elements, <code><a href="#document">Document</a></code> objects, and <code><a href="#window">Window</a></code> objects</h5><p>The following are the <a href="#event-handlers">event handlers</a> (and their
+  </div><p class="note">The return value of the function affects whether the
+  event is canceled or not: <span class="impl">as described
+  above,</span> if the return value is false, the event is canceled
+  (except for <code class="event-mouseover">mouseover</code> events,
+  where the return value has to be true to cancel the event). With
+  <code title="event-beforeunload">beforeunload</code> events, the
+  value is instead used to determine the message to show the user.<h5 id="event-handlers-on-elements-document-objects-and-window-objects"><span class="secno">6.1.6.2 </span>Event handlers on elements, <code><a href="#document">Document</a></code> objects, and <code><a href="#window">Window</a></code> objects</h5><p>The following are the <a href="#event-handlers">event handlers</a> (and their
   corresponding <a href="#event-handler-event-type" title="event handler event type">event handler
   event types</a>) <span class="impl">that must be</span> supported
   by all <a href="#html-elements">HTML elements</a>, as both content attributes and

Received on Friday, 7 October 2011 22:31:49 UTC