Skip to content
Permalink
Browse files

[e] (0) Clarify the outline algorithm to indicate that it only applie…

…s to sectioning content and sectioning root elements.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=13880

git-svn-id: http://svn.whatwg.org/webapps@6677 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 12, 2011
1 parent 1ca3782 commit 86e93a1c0c3561c321a89614653c04a2ae282a32
Showing with 76 additions and 95 deletions.
  1. +25 −30 complete.html
  2. +25 −30 index
  3. +26 −35 source

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

<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>
</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>

</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

<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;
}
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>
55 index

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

<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>
</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>

</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

<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;
}
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>
61 source

<li>

<p>As you walk over the DOM in <span>tree order</span>, trigger
the first relevant step below for each element as you enter and
exit it.</p>
<p>As you walk over the DOM in <span>tree order</span>, starting
with the <span>sectioning content</span> element or
<span>sectioning root</span> 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">


<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 <span>sectioning
content</span> element or a <span>sectioning root</span> 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 <span
title="concept-section">section</span> in the
</dd>


<dt>If the <var title="">current outlinee</var> is null</dt>

<dd><p>Do nothing.</p></dd>


<dt>When entering a <span>heading content</span> element</dt>

<dd>

<p id="associatedSection">In addition, whenever you exit a node,
after doing the steps above, if the node is not associated with a
<span title="concept-section">section</span> yet and <var
title="">current section</var> is not null, associate the node
with the <span title="concept-section">section</span> <var
<span title="concept-section">section</span> yet, associate the
node with the <span title="concept-section">section</span> <var
title="">current section</var>.</p>

</li>

<li><p>If the <var title="">current outlinee</var> is null,
then there was no <span>sectioning content</span> element or
<span>sectioning root</span> element in the DOM. There is no
<span>outline</span>. Abort these steps.</p></li>

<li><p>Associate any nodes that were not associated with a <span
title="concept-section">section</span> in the steps above with <var
title="">current outlinee</var> as their section.</p></li>

<li><p>Associate all nodes with the heading of the <span
title="concept-section">section</span> with which they are
associated, if any.</p></li>

<li><p>If <var title="">current outlinee</var> is <span>the body
element</span>, then the outline created for that element is the
<span>outline</span> of the entire document.</p></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 <span>the body element</span> of a
<code>Document</code> is the <span>outline</span> of the entire
document.</p>

<p>When creating an interactive table of contents, entries should
jump the user to the relevant <span>sectioning content</span>
element, if the <span title="concept-section">section</span> was

<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 <span>sectioning content</span>
element or a <span>sectioning root</span> 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;
}
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>

0 comments on commit 86e93a1

Please sign in to comment.
You can’t perform that action at this time.