[html5] r1716 - /
whatwg at whatwg.org
whatwg at whatwg.org
Sun Jun 1 03:48:27 PDT 2008
Author: ianh
Date: 2008-06-01 03:48:26 -0700 (Sun, 01 Jun 2008)
New Revision: 1716
Modified:
index
source
Log:
[giow] (2) Define .focus(), .blur(), onfocus, and onblur in a way that doesn't require an infinite loop in the face of a hostile author, and that is better defined in terms of multiple iframes, windows, and orphaned elements. Allow UAs to ignore .blur(). Fix up the mess around the body element having focus.
Modified: index
===================================================================
--- index 2008-05-29 12:12:11 UTC (rev 1715)
+++ index 2008-06-01 10:48:26 UTC (rev 1716)
@@ -25,7 +25,7 @@
<h1 id=html-5>HTML 5</h1>
- <h2 class="no-num no-toc" id=draft>Draft Recommendation — 29 May
+ <h2 class="no-num no-toc" id=draft>Draft Recommendation — 1 June
2008</h2>
<p>You can take part in this work. <a
@@ -7192,20 +7192,7 @@
<h3 id=interaction><span class=secno>3.5 </span><dfn
id=interaction0>Interaction</dfn></h3>
- <!--
-ELEMENT
- attribute long <span title="dom-tabindex">tabIndex</span>;
- void <span title="dom-click">click</span>();
- void <span title="dom-focus">focus</span>();
- void <span title="dom-blur">blur</span>();
- void <span title="dom-scrollIntoView">scrollIntoView</span>();
- void <span title="dom-scrollIntoView">scrollIntoView</span>(in boolean top);
-DOCUMENT
- readonly attribute <span>Element</span> <span title="dom-document-activeElement">activeElement</span>;
- readonly attribute boolean <span title="dom-document-hasFocus">hasFocus</span>;
--->
-
<h4 id=activation><span class=secno>3.5.1 </span>Activation</h4>
<p>The <dfn id=click title=dom-click>click()</dfn> method must <a
@@ -7220,38 +7207,110 @@
tree order, to have one, must have its activation behavior executed.
<h4 id=focus><span class=secno>3.5.2 </span>Focus</h4>
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%20%0A...%3Cform%3E%3Cinput%20name%3Da%20onfocus%3D%22value%2B%3D1%3Bd.name%3D%27a%27%3Bname%3D%27d%27%3Bb.focus()%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22value%2B%3D1%3Bc.focus()%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22value%2B%3D1%3Bd.focus()%22%3E%0A%3Cinput%20name%3Dd%20onfocus%3D%22value%2B%3D1%3Ba.focus()%22%3E -->
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af1%20%27%3Bb.focus()%3Balert(document.activeElement.name)%3Bt.value%2B%3D%27af2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22t.value%2B%3D%27cf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27cf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27cb%20%27%3B%22%3E%0A -->
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%20onload%3D%22document.forms%5B0%5D.a.focus()%22%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onblur%3D%22t.value%2B%3D'ab%20'%3B%20b.focus()%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D'bf1%20'%3Ba.focus()%3Bt.value%2B%3D'bf2%20'%3B%22%20onblur%3D%22t.value%2B%3D'bb%20'%3B%22%3E -->
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%3E...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab1%20%27%3Bb.focus()%3Bt.value%2B%3D%27ab2%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Ba.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E -->
<p>When an element is <em>focused</em>, key events received by the document
- must be targeted at that element. There is always an element focused; in
- the absence of other elements being focused, the document's root element
- is it.
+ must be targeted at that element. There may be no element focused; when no
+ element is focused, key events received by the document must be targetted
+ at <a href="#the-body1">the <code>body</code> element</a>.
- <p>Which element within a document currently has focus is independent of
- whether or not the document itself has the <em>system focus</em>.
+ <p>User agents may track focus for each <a href="#browsing1">browsing
+ context</a> or <code>Document</code> individually, or may support only one
+ focused elment per <a href="#top-level">top-level browsing context</a>
+ — user agents should follow platform conventions in this regard.
- <p>Some focusable elements might take part in <em>sequential focus
- navigation</em>.
+ <p>Which element(s) within a <a href="#top-level">top-level browsing
+ context</a> currently has focus must be independent of whether or not the
+ <a href="#top-level">top-level browsing context</a> itself has the
+ <em>system focus</em>.
<h5 id=focus-management><span class=secno>3.5.2.1. </span>Focus management</h5>
- <p>The <dfn id=focus0 title=dom-focus><code>focus()</code></dfn> and <dfn
- id=blur title=dom-blur><code>blur()</code></dfn> methods must focus and
- unfocus the element respectively, if the element is focusable.
+ <p>The <dfn id=focusing>focusing steps</dfn> are as follows:
- <p>Some elements, most notably <code><a href="#area">area</a></code>, can
- correspond to more than one distinct focusable area. When such an element
- is focused using the <code title=dom-focus><a
- href="#focus0">focus()</a></code> method, the first such region in tree
- order is the one that must be focused.
+ <ol>
+ <li>
+ <p>If focusing the element will remove the focus from another element,
+ then run the <a href="#unfocusing">unfocusing steps</a> for that
+ element.
- <p class=big-issue>Well that clearly needs more.</p>
- <!-- XXX e.g. should the click, focus, blur methods be recursible? -->
+ <li>
+ <p>Make the element the currently focused element in its <a
+ href="#top-level">top-level browsing context</a>.</p>
+ <p>Some elements, most notably <code><a href="#area">area</a></code>, can
+ correspond to more than one distinct focusable area. If a particular
+ area was indicated when the element was focused, then that is the area
+ that must get focus; otherwise, e.g. when using the <code
+ title=dom-focus><a href="#focus0">focus()</a></code> method, the first
+ such region in tree order is the one that must be focused.</p>
+
+ <li>
+ <p><a href="#firing2">Fire a simple event</a> that doesn't bubble called
+ <code title=event-focus>focus</code> at the element.
+ </ol>
+
+ <p>User agents must run the <a href="#focusing">focusing steps</a> for an
+ element whenever the user moves the focus to a <a
+ href="#focusable">focusable</a> element.
+
+ <p>The <dfn id=unfocusing>unfocusing steps</dfn> are as follows:
+
+ <ol><!-- XXX onchange event for input controls -->
+
+ <li>
+ <p>Unfocus the element.
+
+ <li>
+ <p><a href="#firing2">Fire a simple event</a> that doesn't bubble called
+ <code title=event-blur>blur</code> at the element.
+ </ol>
+
+ <p>User agents should run the <a href="#unfocusing">unfocusing steps</a>
+ for an element whenever the user moves the focus away from any <a
+ href="#focusable">focusable</a> element.
+
+ <hr>
+
+ <p>The <dfn id=focus0 title=dom-focus><code>focus()</code></dfn> method,
+ when invoked, must run the following algorithm:
+
+ <ol>
+ <li>
+ <p>If the element is marked as <i><a href="#locked">locked for
+ focus</a></i>, then abort these steps.
+
+ <li>
+ <p>If the element is not <a href="#focusable">focusable</a>, then abort
+ these steps.
+
+ <li>
+ <p>Mark the element as <dfn id=locked>locked for focus</dfn>.
+
+ <li>
+ <p>If the element is not already focused, run the <a
+ href="#focusing">focusing steps</a> for the element.
+
+ <li>
+ <p>Unmark the element as <i><a href="#locked">locked for focus</a></i>.
+ </ol>
+
+ <p>The <dfn id=blur title=dom-blur><code>blur()</code></dfn> method, when
+ invoked, should run the <a href="#unfocusing">unfocusing steps</a> for the
+ element. User agents may selectively or uniformly ignore calls to this
+ method for usability reasons.</p>
+ <!-- XXX define onfocus/onblur behaviour for Window -->
+
+ <hr>
+
<p>The <dfn id=activeelement
title=dom-document-activeElement><code>activeElement</code></dfn>
- attribute must return the element in the document that has focus. If no
- element specifically has focus, this must return <a href="#the-body1">the
- <code>body</code> element</a>.
+ attribute must return the element in the document that is focused. If no
+ element in the <code>Document</code> is focused, this must return <a
+ href="#the-body1">the <code>body</code> element</a>.
<p>The <dfn id=hasfocus
title=dom-document-hasFocus><code>hasFocus</code></dfn> attribute must
@@ -7344,6 +7403,13 @@
</ul>
</dl>
+ <p>An element is <dfn id=focusable>focusable</dfn> if the <code
+ title=attr-tabindex><a href="#tabindex">tabindex</a></code> attribute's
+ definition above defines the element to be focusable <em>and</em> the
+ element is <span>being
+ rendered</span><!-- XXX xref, define display:none as not
+ being rendered, off-screen as being rendered? -->.
+
<p>When an element is focused, the element matches the CSS
<code>:focus</code> pseudo-class and key events are dispatched on that
element in response to keyboard input.
@@ -29917,8 +29983,8 @@
<p><dfn id=firing2 title="fire a simple event">Firing a simple event called
<var title="">e</var></dfn> means that an event with the name <var
title="">e</var>, with no namespace, which does not bubble but is
- cancelable, and which uses the <code>Event</code> interface, must be
- dispatched at the given element.
+ cancelable (unless otherwise stated), and which uses the
+ <code>Event</code> interface, must be dispatched at the given element.
<p><dfn id=firing3 title="fire a show event">Firing a <code
title=event-show>show</code> event</dfn> means <a href="#firing2"
Modified: source
===================================================================
--- source 2008-05-29 12:12:11 UTC (rev 1715)
+++ source 2008-06-01 10:48:26 UTC (rev 1716)
@@ -5638,21 +5638,7 @@
<h3><dfn>Interaction</dfn></h3>
-<!--
-ELEMENT
- attribute long <span title="dom-tabindex">tabIndex</span>;
- void <span title="dom-click">click</span>();
- void <span title="dom-focus">focus</span>();
- void <span title="dom-blur">blur</span>();
- void <span title="dom-scrollIntoView">scrollIntoView</span>();
- void <span title="dom-scrollIntoView">scrollIntoView</span>(in boolean top);
-DOCUMENT
- readonly attribute <span>Element</span> <span title="dom-document-activeElement">activeElement</span>;
- readonly attribute boolean <span title="dom-document-hasFocus">hasFocus</span>;
--->
-
-
<h4>Activation</h4>
<p>The <dfn title="dom-click">click()</dfn> method must <span>fire a
@@ -5667,40 +5653,125 @@
order, to have one, must have its activation behavior executed.</p>
+
<h4>Focus</h4>
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%20%0A...%3Cform%3E%3Cinput%20name%3Da%20onfocus%3D%22value%2B%3D1%3Bd.name%3D%27a%27%3Bname%3D%27d%27%3Bb.focus()%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22value%2B%3D1%3Bc.focus()%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22value%2B%3D1%3Bd.focus()%22%3E%0A%3Cinput%20name%3Dd%20onfocus%3D%22value%2B%3D1%3Ba.focus()%22%3E -->
+
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af1%20%27%3Bb.focus()%3Balert(document.activeElement.name)%3Bt.value%2B%3D%27af2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E%0A%3Cinput%20name%3Dc%20onfocus%3D%22t.value%2B%3D%27cf1%20%27%3Bc.focus()%3Bt.value%2B%3D%27cf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27cb%20%27%3B%22%3E%0A -->
+
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%20onload%3D%22document.forms%5B0%5D.a.focus()%22%3E%0A...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onblur%3D%22t.value%2B%3D'ab%20'%3B%20b.focus()%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D'bf1%20'%3Ba.focus()%3Bt.value%2B%3D'bf2%20'%3B%22%20onblur%3D%22t.value%2B%3D'bb%20'%3B%22%3E -->
+
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cbody%3E...%3Cform%3E%0A%3Ctextarea%20name%3Dt%20cols%3D100%20rows%3D3%3E%3C%2Ftextarea%3E%3Cp%3E%0A%3Cinput%20name%3Da%20onfocus%3D%22t.value%2B%3D%27af%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27ab1%20%27%3Bb.focus()%3Bt.value%2B%3D%27ab2%20%27%3B%22%3E%0A%3Cinput%20name%3Db%20onfocus%3D%22t.value%2B%3D%27bf1%20%27%3Ba.focus()%3Bt.value%2B%3D%27bf2%20%27%3B%22%20onblur%3D%22t.value%2B%3D%27bb%20%27%3B%22%3E -->
+
<p>When an element is <em>focused</em>, key events received by the
- document must be targeted at that element. There is always an
- element focused; in the absence of other elements being focused, the
- document's root element is it.</p>
+ document must be targeted at that element. There may be no element
+ focused; when no element is focused, key events received by the
+ document must be targetted at <span>the <code>body</code>
+ element</span>.</p>
- <p>Which element within a document currently has focus is
- independent of whether or not the document itself has the <em>system
+ <p>User agents may track focus for each <span>browsing
+ context</span> or <code>Document</code> individually, or may support
+ only one focused elment per <span>top-level browsing context</span>
+ — user agents should follow platform conventions in this
+ regard.</p>
+
+ <p>Which element(s) within a <span>top-level browsing context</span>
+ currently has focus must be independent of whether or not the
+ <span>top-level browsing context</span> itself has the <em>system
focus</em>.</p>
- <p>Some focusable elements might take part in <em>sequential focus
- navigation</em>.</p>
-
<h5 id="focus-management">Focus management</h5>
- <p>The <dfn title="dom-focus"><code>focus()</code></dfn> and <dfn
- title="dom-blur"><code>blur()</code></dfn> methods must focus and
- unfocus the element respectively, if the element is focusable.</p>
+ <p>The <dfn>focusing steps</dfn> are as follows:</p>
- <p>Some elements, most notably <code>area</code>, can correspond to
- more than one distinct focusable area. When such an element is
- focused using the <code title="dom-focus">focus()</code> method, the
- first such region in tree order is the one that must be focused.</p>
+ <ol>
- <p class="big-issue">Well that clearly needs more.</p>
- <!-- XXX e.g. should the click, focus, blur methods be recursible? -->
+ <li><p>If focusing the element will remove the focus from another
+ element, then run the <span>unfocusing steps</span> for that
+ element.</p></li>
+ <li>
+
+ <p>Make the element the currently focused element in its
+ <span>top-level browsing context</span>.</p>
+
+ <p>Some elements, most notably <code>area</code>, can correspond
+ to more than one distinct focusable area. If a particular area was
+ indicated when the element was focused, then that is the area that
+ must get focus; otherwise, e.g. when using the <code
+ title="dom-focus">focus()</code> method, the first such region in
+ tree order is the one that must be focused.</p>
+
+ </li>
+
+ <li><p><span>Fire a simple event</span> that doesn't bubble called
+ <code title="event-focus">focus</code> at the element.</p></li>
+
+ </ol>
+
+ <p>User agents must run the <span>focusing steps</span> for an
+ element whenever the user moves the focus to a
+ <span>focusable</span> element.</p>
+
+ <p>The <dfn>unfocusing steps</dfn> are as follows:</p>
+
+ <ol>
+
+ <!-- XXX onchange event for input controls -->
+
+ <li><p>Unfocus the element.</p></li>
+
+ <li><p><span>Fire a simple event</span> that doesn't bubble called
+ <code title="event-blur">blur</code> at the element.</p></li>
+
+ </ol>
+
+ <p>User agents should run the <span>unfocusing steps</span> for an
+ element whenever the user moves the focus away from any
+ <span>focusable</span> element.</p>
+
+ <hr>
+
+ <p>The <dfn title="dom-focus"><code>focus()</code></dfn> method,
+ when invoked, must run the following algorithm:</p>
+
+ <ol>
+
+ <li><p>If the element is marked as <i>locked for focus</i>, then abort
+ these steps.</p></li>
+
+ <li><p>If the element is not <span>focusable</span>, then abort these
+ steps.</p></li>
+
+ <li><p>Mark the element as <dfn>locked for focus</dfn>.</p></li>
+
+ <li><p>If the element is not already focused, run the <span>focusing
+ steps</span> for the element.</p></li>
+
+ <li><p>Unmark the element as <i>locked for focus</i>.</p></li>
+
+ </ol>
+
+ <p>The <dfn title="dom-blur"><code>blur()</code></dfn> method, when
+ invoked, should run the <span>unfocusing steps</span> for the
+ element. User agents may selectively or uniformly ignore calls to
+ this method for usability reasons.</p>
+
+
+
+ <!-- XXX define onfocus/onblur behaviour for Window -->
+
+
+ <hr>
+
+
<p>The <dfn
title="dom-document-activeElement"><code>activeElement</code></dfn>
- attribute must return the element in the document that has focus. If
- no element specifically has focus, this must return <span>the
- <code>body</code> element</span>.</p>
+ attribute must return the element in the document that is
+ focused. If no element in the <code>Document</code> is focused, this
+ must return <span>the <code>body</code> element</span>.</p>
<p>The <dfn
title="dom-document-hasFocus"><code>hasFocus</code></dfn> attribute
@@ -5813,6 +5884,12 @@
</dl>
+ <p>An element is <dfn>focusable</dfn> if the <code
+ title="attr-tabindex">tabindex</code> attribute's definition above
+ defines the element to be focusable <em>and</em> the element is
+ <span>being rendered</span><!-- XXX xref, define display:none as not
+ being rendered, off-screen as being rendered? -->.</p>
+
<p>When an element is focused, the element matches the CSS
<code>:focus</code> pseudo-class and key events are dispatched on
that element in response to keyboard input.</p>
@@ -27622,8 +27699,9 @@
<p><dfn title="fire a simple event">Firing a simple event called
<var title="">e</var></dfn> means that an event with the name <var
title="">e</var>, with no namespace, which does not bubble but is
- cancelable, and which uses the <code>Event</code> interface, must be
- dispatched at the given element.</p>
+ cancelable (unless otherwise stated), and which uses the
+ <code>Event</code> interface, must be dispatched at the given
+ element.</p>
<p><dfn title="fire a show event">Firing a <code
title="event-show">show</code> event</dfn> means <span title="fire a
More information about the Commit-Watchers
mailing list