W3C home > Mailing lists > Public > public-html-diffs@w3.org > October 2011

hixie: Clarify the outline algorithm to indicate that it only applies to sectioning content and sectioning root elements. (whatwg r6677)

From: poot <cvsmail@w3.org>
Date: Wed, 12 Oct 2011 18:45:50 -0400
To: public-html-diffs@w3.org
Message-Id: <E1RE7Yc-0004we-HS@jay.w3.org>
hixie: Clarify the outline algorithm to indicate that it only applies to
sectioning content and sectioning root elements. (whatwg r6677)

http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.5354&r2=1.5355&f=h
http://html5.org/tools/web-apps-tracker?from=6676&to=6677

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.5354
retrieving revision 1.5355
diff -u -d -r1.5354 -r1.5355
--- Overview.html	12 Oct 2011 19:49:55 -0000	1.5354
+++ Overview.html	12 Oct 2011 22:45:14 -0000	1.5355
@@ -14916,9 +14916,11 @@
 
    <li>
 
-    <p>As you walk over the DOM in <a href="#tree-order">tree order</a>, trigger
-    the first relevant step below for each element as you enter and
-    exit it.</p>
+    <p>As you walk over the DOM in <a href="#tree-order">tree order</a>, starting
+    with the <a href="#sectioning-content">sectioning content</a> element or
+    <a href="#sectioning-root">sectioning root</a> element at the root of the subtree
+    for which an outline is to be created, trigger the first relevant
+    step below for each element as you enter and exit it.</p>
 
     <dl class="switch"><dt>If you are exiting an element and that element is the element
      at the top of the stack</dt>
@@ -15015,8 +15017,11 @@
 
      <dd>
 
-      <p class="note">The <var title="">current outlinee</var> is
-      the element being exited.</p>
+      <p class="note">The <var title="">current outlinee</var> is the
+      element being exited, and it is the <a href="#sectioning-content">sectioning
+      content</a> element or a <a href="#sectioning-root">sectioning root</a> element
+      at the root of the subtree for which an outline is being
+      generated.</p>
 
       <p>Let <var title="">current section</var> be the first <a href="#concept-section" title="concept-section">section</a> in the
       <a href="#outline">outline</a> of the <var title="">current outlinee</var>
@@ -15028,11 +15033,6 @@
      </dd>
 
 
-     <dt>If the <var title="">current outlinee</var> is null</dt>
-
-     <dd><p>Do nothing.</dd>
-
-
      <dt>When entering a <a href="#heading-content">heading content</a> element</dt>
 
      <dd>
@@ -15082,29 +15082,22 @@
 
     </dl><p id="associatedSection">In addition, whenever you exit a node,
     after doing the steps above, if the node is not associated with a
-    <a href="#concept-section" title="concept-section">section</a> yet and <var title="">current section</var> is not null, associate the node
-    with the <a href="#concept-section" title="concept-section">section</a> <var title="">current section</var>.</p>
+    <a href="#concept-section" title="concept-section">section</a> yet, associate the
+    node with the <a href="#concept-section" title="concept-section">section</a> <var title="">current section</var>.</p>
 
    </li>
 
-   <li><p>If the <var title="">current outlinee</var> is null,
-   then there was no <a href="#sectioning-content">sectioning content</a> element or
-   <a href="#sectioning-root">sectioning root</a> element in the DOM. There is no
-   <a href="#outline">outline</a>. Abort these steps.</li>
-
-   <li><p>Associate any nodes that were not associated with a <a href="#concept-section" title="concept-section">section</a> in the steps above with <var title="">current outlinee</var> as their section.</li>
-
    <li><p>Associate all nodes with the heading of the <a href="#concept-section" title="concept-section">section</a> with which they are
    associated, if any.</li>
 
-   <li><p>If <var title="">current outlinee</var> is <a href="#the-body-element-0">the body
-   element</a>, then the outline created for that element is the
-   <a href="#outline">outline</a> of the entire document.</li>
-
   </ol><p>The tree of sections created by the algorithm above, or a proper
   subset thereof, must be used when generating document outlines, for
   example when generating tables of contents.</p>
 
+  <p>The outline created for <a href="#the-body-element-0">the body element</a> of a
+  <code><a href="#document">Document</a></code> is the <a href="#outline">outline</a> of the entire
+  document.</p>
+
   <p>When creating an interactive table of contents, entries should
   jump the user to the relevant <a href="#sectioning-content">sectioning content</a>
   element, if the <a href="#concept-section" title="concept-section">section</a> was
@@ -15164,8 +15157,10 @@
 
    <p>The following JavaScript function shows how the tree walk could
    be implemented. The <var title="">root</var> argument is the root
-   of the tree to walk, and the <var title="">enter</var> and <var title="">exit</var> arguments are callbacks that are called with
-   the nodes as they are entered and exited. <a href="#refsECMA262">[ECMA262]</a></p>
+   of the tree to walk (either a <a href="#sectioning-content">sectioning content</a>
+   element or a <a href="#sectioning-root">sectioning root</a> element), and the <var title="">enter</var> and <var title="">exit</var> arguments are
+   callbacks that are called with the nodes as they are entered and
+   exited. <a href="#refsECMA262">[ECMA262]</a></p>
 
    <pre>function (root, enter, exit) {
   var node = root;
@@ -15177,14 +15172,14 @@
     }
     while (node) {
       exit(node);
-      if (node.nextSibling) {
+      if (node == root) {
+        node = null;
+      } else if (node.nextSibling) {
         node = node.nextSibling;
         continue start;
-      }
-      if (node == root)
-        node = null;
-      else
+      } else {
         node = node.parentNode;
+      }
     }
   }
 }</pre>
Received on Wednesday, 12 October 2011 22:45:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 12 October 2011 22:45:59 GMT