Skip to content

Commit

Permalink
[e] (0) Clarify the outline algorithm to indicate that it only applie…
Browse files Browse the repository at this point in the history
…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 86e93a1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 95 deletions.
55 changes: 25 additions & 30 deletions complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -17989,9 +17989,11 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>

<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>
Expand Down Expand Up @@ -18088,8 +18090,11 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>

<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>
Expand All @@ -18101,11 +18106,6 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>
</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>
Expand Down Expand Up @@ -18155,29 +18155,22 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>

</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
Expand Down Expand Up @@ -18237,8 +18230,10 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>

<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;
Expand All @@ -18250,14 +18245,14 @@ <h5 id=outlines><span class=secno>4.4.11.1 </span>Creating an outline</h5>
}
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>
Expand Down
55 changes: 25 additions & 30 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -17989,9 +17989,11 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;

<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>
Expand Down Expand Up @@ -18088,8 +18090,11 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;

<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>
Expand All @@ -18101,11 +18106,6 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;
</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>
Expand Down Expand Up @@ -18155,29 +18155,22 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;

</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
Expand Down Expand Up @@ -18237,8 +18230,10 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;

<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;
Expand All @@ -18250,14 +18245,14 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p&gt;
}
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>
Expand Down
61 changes: 26 additions & 35 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -19148,9 +19148,11 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>

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

Expand Down Expand Up @@ -19261,8 +19263,11 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>

<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
Expand All @@ -19275,11 +19280,6 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>
</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>
Expand Down Expand Up @@ -19346,36 +19346,26 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>

<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
Expand Down Expand Up @@ -19443,10 +19433,11 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>

<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;
Expand All @@ -19458,14 +19449,14 @@ isn't his only passion. He also enjoys other pleasures.&lt;/p>
}
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>
Expand Down

0 comments on commit 86e93a1

Please sign in to comment.