--- a/editing.html Wed Aug 03 12:48:34 2011 -0600
+++ b/editing.html Wed Aug 03 13:25:59 2011 -0600
@@ -1033,10 +1033,12 @@
<h3 id=wrapping-a-list-of-nodes><span class=secno>6.2 </span>Wrapping a list of nodes</h3>
<p>To <dfn id=wrap>wrap</dfn> a list <var title="">node list</var> of consecutive <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-sibling title=concept-tree-sibling>sibling</a>
-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>, given <dfn id=sibling-criteria>sibling criteria</dfn> and <dfn id=new-parent-instructions>new parent
-instructions</dfn>, run the following algorithm. If not provided,
-<a href=#sibling-criteria>sibling criteria</a> match nothing and <a href=#new-parent-instructions>new parent
-instructions</a> return null.
+<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>, run the following algorithm. In addition to <var title="">node list</var>,
+the algorithm accepts two inputs: an algorithm <var title="">sibling criteria</var> that
+accepts a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> as input and outputs a boolean, and an algorithm <var title="">new
+parent instructions</var> that accepts nothing as input and outputs a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a>
+or null. If not provided, <var title="">sibling criteria</var> returns false and
+<var title="">new parent instructions</var> returns null.
<ol>
<li>If <var title="">node list</var> is empty, or the first member of <var title="">node
@@ -1052,22 +1054,22 @@
is a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, append that <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code> to <var title="">node list</var>.
<li>If the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of the first member of <var title="">node list</var>
- is <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling criteria</a>, let
- <var title="">new parent</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of the first member of
- <var title="">node list</var>.
+ is <a href=#editable>editable</a> and running <var title="">sibling criteria</var> on it
+ returns true, let <var title="">new parent</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of the
+ first member of <var title="">node list</var>.
<li>Otherwise, if the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of <var title="">node
- list</var> is <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling
- criteria</a>, let <var title="">new parent</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last
- member of <var title="">node list</var>.
-
- <li>Otherwise, run the <a href=#new-parent-instructions>new parent instructions</a>, and let <var title="">new
+ list</var> is <a href=#editable>editable</a> and running <var title="">sibling criteria</var>
+ on it returns true, let <var title="">new parent</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the
+ last member of <var title="">node list</var>.
+
+ <li>Otherwise, run <var title="">new parent instructions</var>, and let <var title="">new
parent</var> be the result.
<li>
- <p class=comments>This can only happen if the new parent instructions are run
- and they return null. This can be used to only merge with adjacent siblings,
- in case you don't want to create a new parent if that fails.
+ <p class=comments>This can only happen if <var title="">new parent instructions</var>
+ is run and it returns null. This can be used to only merge with adjacent
+ siblings, in case you don't want to create a new parent if that fails.
<p>If <var title="">new parent</var> is null, abort these steps and return null.
@@ -1170,8 +1172,8 @@
</ol>
<li>
- <p class=comments>This could happen if the new parent instructions returned a
- node whose parent wasn't null.
+ <p class=comments>This could happen if <var title="">new parent instructions</var>
+ returned a node whose parent wasn't null.
<p>If <var title="">original parent</var> is <a href=#editable>editable</a> and has no
<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, remove it from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
@@ -1181,7 +1183,7 @@
them. We want to merge them in this case.
<p>If <var title="">new parent</var>'s <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> is <a href=#editable>editable</a> and
- meets the <a href=#sibling-criteria>sibling criteria</a>:
+ running <var title="">sibling criteria</var> on it returns true:
<ol>
<li>If <var title="">new parent</var> is not an <a href=#inline-node>inline node</a>, but
@@ -1241,7 +1243,7 @@
requirements but should be treated properly. In particular, they can
interfere with serialization (e.g., center cannot descend from p).
- <li> Sometimes users give instructions that have to produce invalid DOMs to
+ <li>Sometimes users give instructions that have to produce invalid DOMs to
get the expected effect, like indenting the first item of a list.
<li>The HTML validity requirements are sometimes quite complicated.
@@ -2123,15 +2125,17 @@
<code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code>.
<li>
- <p class=comments>The new parent instructions are too complicated to
- reasonably feed into the wrap algorithm.
+ <p class=comments>The <var title="">new parent instructions</var> we'd want are too
+ complicated to reasonably feed into the wrap algorithm, so we just let them
+ return null and do the wrapping ourselves if <var title="">sibling criteria</var>
+ didn't return true.
<p><a href=#wrap>Wrap</a> the one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">node</var>,
- with <a href=#sibling-criteria>sibling criteria</a> matching a <a href=#simple-modifiable-element>simple modifiable
- element</a> whose <a href=#specified-command-value>specified command value</a> is <a href=#equivalent-values title="equivalent values">equivalent</a>
- to <var title="">new value</var> and whose <a href=#effective-command-value>effective command value</a> is
- <a href=#loosely-equivalent-values title="loosely equivalent values">loosely equivalent</a> to <var title="">new value</var>, and with <a href=#new-parent-instructions>new parent
- instructions</a> returning null.
+ with <var title="">sibling criteria</var> returning true for a <a href=#simple-modifiable-element>simple
+ modifiable element</a> whose <a href=#specified-command-value>specified command value</a> is
+ <a href=#equivalent-values title="equivalent values">equivalent</a> to <var title="">new value</var> and whose <a href=#effective-command-value>effective command
+ value</a> is <a href=#loosely-equivalent-values title="loosely equivalent values">loosely equivalent</a> to <var title="">new value</var> and false
+ otherwise, and with <var title="">new parent instructions</var> returning null.
</ol>
<li>If the <a href=#effective-command-value>effective command value</a> of <var title="">command</var> is
@@ -3507,10 +3511,11 @@
<ol>
<li>If <var title="">node</var> is a <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/html/#the-dd-element>dd</a></code> or <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/html/#the-dt-element>dt</a></code>, <a href=#wrap>wrap</a> the
- one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">node</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching any <code class=external data-anolis-spec=html title="the dl element"><a href=http://www.whatwg.org/html/#the-dl-element>dl</a></code> with no <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute title=concept-attribute>attributes</a>, and <a href=#new-parent-instructions>new
- parent instructions</a> returning the result of calling
- <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("dl")</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Then abort these steps.
+ one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">node</var>, with <var title="">sibling
+ criteria</var> returning true for any <code class=external data-anolis-spec=html title="the dl element"><a href=http://www.whatwg.org/html/#the-dl-element>dl</a></code> with no <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute title=concept-attribute>attributes</a> and
+ false otherwise, and <var title="">new parent instructions</var> returning the
+ result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("dl")</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Then
+ abort these steps.
<li>If <var title="">node</var> is not a <a href=#prohibited-paragraph-child>prohibited paragraph child</a>,
abort these steps.
@@ -4886,11 +4891,12 @@
HTML5.
</div>
- <p><a href=#wrap>Wrap</a> <var title="">node list</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching only <a href=#html-element title="HTML element">HTML
- elements</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">tag</var> and <a href=#new-parent-instructions>new parent
- instructions</a> returning the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">tag</var>)</a></code> on
- the <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">first node</var>.
+ <p><a href=#wrap>Wrap</a> <var title="">node list</var>, with <var title="">sibling criteria</var>
+ returning true for an <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
+ <var title="">tag</var> and false otherwise, and <var title="">new parent
+ instructions</var> returning the result of calling
+ <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">tag</var>)</a></code> on the <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">first
+ node</var>.
<li>Abort these steps.
</ol>
@@ -4922,11 +4928,11 @@
get it wrong. Just indent on both sides.
</div>
- <p><a href=#wrap>Wrap</a> <var title="">node list</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching any <a href=#simple-indentation-element>simple indentation element</a>, and
- <a href=#new-parent-instructions>new parent instructions</a> to return the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("blockquote")</a></code> on the
- <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">first node</var>. Let <var title="">new parent</var> be the
- result.
+ <p><a href=#wrap>Wrap</a> <var title="">node list</var>, with <var title="">sibling criteria</var>
+ returning true for a <a href=#simple-indentation-element>simple indentation element</a> and false
+ otherwise, and <var title="">new parent instructions</var> returning the result of
+ calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("blockquote")</a></code> on the <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">first
+ node</var>. Let <var title="">new parent</var> be the result.
<li><a href=#fix-disallowed-ancestors>Fix disallowed ancestors</a> of <var title="">new parent</var>.
</ol>
@@ -5654,9 +5660,9 @@
<li><a href=#split-the-parent>Split the parent</a> of <var title="">children</var>.
- <li><a href=#wrap>Wrap</a> <var title="">children</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching any <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
- <var title="">tag name</var>.
+ <li><a href=#wrap>Wrap</a> <var title="">children</var>, with <var title="">sibling
+ criteria</var> returning true for an <a href=#html-element>HTML element</a> with
+ <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">tag name</var> and false otherwise.
<li><a href=#restore-the-values>Restore the values</a> from <var title="">values</var>.
</ol>
@@ -5782,8 +5788,8 @@
<code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member from <var title="">node list</var> and append it
to <var title="">nodes to wrap</var>.
- <li><a href=#wrap>Wrap</a> <var title="">nodes to wrap</var>, with <a href=#new-parent-instructions>new parent
- instructions</a> returning the result of calling
+ <li><a href=#wrap>Wrap</a> <var title="">nodes to wrap</var>, with <var title="">new parent
+ instructions</var> returning the result of calling
<code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("li")</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Append the result to
<var title="">sublist</var>.
</ol>
@@ -5807,21 +5813,21 @@
<li><a href=#split-the-parent>Split the parent</a> of <var title="">sublist</var>.
- <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching any <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
- <var title="">tag name</var>, and <a href=#new-parent-instructions>new parent instructions</a> returning
- the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">tag name</var>)</a></code> on the
- <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
+ <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <var title="">sibling
+ criteria</var> returning true for an <a href=#html-element>HTML element</a> with
+ <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">tag name</var> and false otherwise, and <var title="">new
+ parent instructions</var> returning the result of calling
+ <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">tag name</var>)</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
<li><a href=#restore-the-values>Restore the values</a> from <var title="">values</var>.
<li>Continue this loop from the beginning.
</ol>
- <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with the <a href=#sibling-criteria>sibling
- criteria</a> matching any <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
- <var title="">tag name</var>, and the <a href=#new-parent-instructions>new parent instructions</a> being the
- following:
+ <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <var title="">sibling criteria</var>
+ returning true for an <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">tag
+ name</var> and false otherwise, and <var title="">new parent instructions</var>
+ being the following:
<ol>
<li>
@@ -5832,10 +5838,10 @@
<pre><ol><li>foo</li><ol><li>[bar]</ol></ol></pre>
<p>instead of
<pre><ol><li>foo</ol><blockquote><ol><li>[bar]</ol></blockquote>.</pre>
- <p>We handle the special case in the new parent instructions instead of
- outside because we'd prefer to wind up in a sibling if there is one. We
- handle only previousSibling, not nextSibling, because we really mean for
- this to cover something like
+ <p>We handle the special case in <var title="">new parent instructions</var>
+ instead of outside because we'd prefer to wind up in a sibling if there
+ is one. We handle only previousSibling, not nextSibling, because we
+ really mean for this to cover something like
<pre>[foo<blockquote>bar]</blockquote></pre>
<p>which we'll handle node-by-node. TODO: Maybe we should do this
differently, like just special-case simple indentation elements in an
@@ -5961,9 +5967,9 @@
<var title="">sublist</var>, remove the first member of <var title="">node list</var> and
append it to <var title="">sublist</var>.
- <li><p><a href=#wrap>Wrap</a> <var title="">sublist</var>. <a href=#sibling-criteria>Sibling criteria</a>
- match any <code class=external data-anolis-spec=html title="the div element"><a href=http://www.whatwg.org/html/#the-div-element>div</a></code> that has one or both of the following two attributes, and
- no other attributes:
+ <li><p><a href=#wrap>Wrap</a> <var title="">sublist</var>. <var title="">Sibling criteria</var>
+ returns true for any <code class=external data-anolis-spec=html title="the div element"><a href=http://www.whatwg.org/html/#the-div-element>div</a></code> that has one or both of the following two
+ attributes and no other attributes, and false otherwise:
<ul>
<li>An <code class=external data-anolis-spec=html title=attr-div-align><a href=http://www.whatwg.org/html/#attr-div-align>align</a></code>
@@ -5980,9 +5986,9 @@
browser behaves in this case, but for inline formatting it matches everyone
but Gecko's CSS mode, so I'm just being consistent.
- <p><a href=#new-parent-instructions>New parent instructions</a> are to call <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("div")</a></code>
+ <p><var title="">New parent instructions</var> are to call <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("div")</a></code>
on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>, then set its CSS property "text-align" to
- <var title="">alignment</var>, and return the result.
+ <var title="">alignment</var> and return the result.
</ol>
</ol>
@@ -6553,11 +6559,12 @@
</ol>
<li><a href=#wrap>Wrap</a> <var title="">sublist</var>. If <var title="">value</var> is "div" or
- "p", <a href=#sibling-criteria>sibling criteria</a> match nothing; otherwise they match any
- <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">value</var> and no
- attributes. <a href=#new-parent-instructions>New parent instructions</a> return the result of
- running <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Then
- <a href=#fix-disallowed-ancestors>fix disallowed ancestors</a> of the result.
+ "p", <var title="">sibling criteria</var> returns false; otherwise it returns true
+ for an <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> <var title="">value</var> and no
+ attributes, and false otherwise. <var title="">New parent instructions</var>
+ return the result of running <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on the
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Then <a href=#fix-disallowed-ancestors>fix disallowed ancestors</a> of the
+ result.
</ol>
</ol>
@@ -7421,8 +7428,8 @@
not null and is an <a href=#allowed-child>allowed child</a> of "p", append it to
<var title="">node list</var>.
- <li><a href=#wrap>Wrap</a> <var title="">node list</var>, with <a href=#sibling-criteria>sibling
- criteria</a> matching nothing and <a href=#new-parent-instructions>new parent instructions</a>
+ <li><a href=#wrap>Wrap</a> <var title="">node list</var>, with <var title="">sibling
+ criteria</var> returning false and <var title="">new parent instructions</var>
returning the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">tag</var>)</a></code> on the
<a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Set <var title="">container</var> to the result.
</ol>
--- a/implementation.js Wed Aug 03 12:48:34 2011 -0600
+++ b/implementation.js Wed Aug 03 13:25:59 2011 -0600
@@ -1193,8 +1193,8 @@
//@{
function wrap(nodeList, siblingCriteria, newParentInstructions) {
- // "If not provided, sibling criteria match nothing and new parent
- // instructions return null."
+ // "If not provided, sibling criteria returns false and new parent
+ // instructions returns null."
if (typeof siblingCriteria == "undefined") {
siblingCriteria = function() { return false };
}
@@ -1218,21 +1218,21 @@
}
// "If the previousSibling of the first member of node list is editable and
- // meets the sibling criteria, let new parent be the previousSibling of the
- // first member of node list."
+ // running sibling criteria on it returns true, let new parent be the
+ // previousSibling of the first member of node list."
var newParent;
if (isEditable(nodeList[0].previousSibling)
&& siblingCriteria(nodeList[0].previousSibling)) {
newParent = nodeList[0].previousSibling;
// "Otherwise, if the nextSibling of the last member of node list is
- // editable and meets the sibling criteria, let new parent be the
- // nextSibling of the last member of node list."
+ // editable and running sibling criteria on it returns true, let new parent
+ // be the nextSibling of the last member of node list."
} else if (isEditable(nodeList[nodeList.length - 1].nextSibling)
&& siblingCriteria(nodeList[nodeList.length - 1].nextSibling)) {
newParent = nodeList[nodeList.length - 1].nextSibling;
- // "Otherwise, run the new parent instructions, and let new parent be the
+ // "Otherwise, run new parent instructions, and let new parent be the
// result."
} else {
newParent = newParentInstructions();
@@ -1314,8 +1314,8 @@
originalParent.parentNode.removeChild(originalParent);
}
- // "If new parent's nextSibling is editable and meets the sibling
- // criteria:"
+ // "If new parent's nextSibling is editable and running sibling criteria on
+ // it returns true:"
if (isEditable(newParent.nextSibling)
&& siblingCriteria(newParent.nextSibling)) {
// "If new parent is not an inline node, but new parent's last child
@@ -2527,10 +2527,10 @@
reorderModifiableDescendants(node.nextSibling, command, newValue);
// "Wrap the one-node list consisting of node, with sibling criteria
- // matching a simple modifiable element whose specified command value
- // is equivalent to new value and whose effective command value is
- // loosely equivalent to new value, and with new parent instructions
- // returning null."
+ // returning true for a simple modifiable element whose specified
+ // command value is equivalent to new value and whose effective command
+ // value is loosely equivalent to new value and false otherwise, and
+ // with new parent instructions returning null."
wrap([node],
function(node) {
return isSimpleModifiableElement(node)
@@ -3603,9 +3603,10 @@
})
&& !isHtmlElement(node, defaultSingleLineContainerName)) {
// "If node is a dd or dt, wrap the one-node list consisting of node,
- // with sibling criteria matching any dl with no attributes, and new
- // parent instructions returning the result of calling
- // createElement("dl") on the context object. Then abort these steps."
+ // with sibling criteria returning true for any dl with no attributes
+ // and false otherwise, and new parent instructions returning the
+ // result of calling createElement("dl") on the context object. Then
+ // abort these steps."
if (isHtmlElement(node, ["dd", "dt"])) {
wrap([node],
function(sibling) { return isHtmlElement(sibling, "dl") && !sibling.attributes.length },
@@ -5069,9 +5070,10 @@
// "Let tag be the local name of the parent of first node."
var tag = firstNode.parentNode.tagName;
- // "Wrap node list, with sibling criteria matching only HTML elements
- // with local name tag and new parent instructions returning the result
- // of calling createElement(tag) on the ownerDocument of first node."
+ // "Wrap node list, with sibling criteria returning true for an HTML
+ // element with local name tag and false otherwise, and new parent
+ // instructions returning the result of calling createElement(tag) on
+ // the ownerDocument of first node."
wrap(nodeList,
function(node) { return isHtmlElement(node, tag) },
function() { return firstNode.ownerDocument.createElement(tag) });
@@ -5080,10 +5082,10 @@
return;
}
- // "Wrap node list, with sibling criteria matching any simple indentation
- // element, and new parent instructions to return the result of calling
- // createElement("blockquote") on the ownerDocument of first node. Let new
- // parent be the result."
+ // "Wrap node list, with sibling criteria returning true for a simple
+ // indentation element and false otherwise, and new parent instructions
+ // returning the result of calling createElement("blockquote") on the
+ // ownerDocument of first node. Let new parent be the result."
var newParent = wrap(nodeList,
function(node) { return isSimpleIndentationElement(node) },
function() { return firstNode.ownerDocument.createElement("blockquote") });
@@ -5328,8 +5330,8 @@
// "Split the parent of children."
splitParent(children);
- // "Wrap children, with sibling criteria matching any HTML
- // element with local name tag name."
+ // "Wrap children, with sibling criteria returning true for an
+ // HTML element with local name tag name and false otherwise."
wrap(children, function(node) { return isHtmlElement(node, tagName) });
// "Restore the values from values."
@@ -5454,7 +5456,7 @@
// "Wrap nodes to wrap, with new parent instructions
// returning the result of calling createElement("li") on
- // the context object. Append the result to sublist."
+ // the context object. Append the result to sublist."
sublist.push(wrap(nodesToWrap,
undefined,
function() { return document.createElement("li") }));
@@ -5479,9 +5481,9 @@
// "Split the parent of sublist."
splitParent(sublist);
- // "Wrap sublist, with sibling criteria matching any HTML
- // element with local name tag name, and new parent
- // instructions returning the result of calling
+ // "Wrap sublist, with sibling criteria returning true for an
+ // HTML element with local name tag name and false otherwise,
+ // and new parent instructions returning the result of calling
// createElement(tag name) on the context object."
wrap(sublist,
function(node) { return isHtmlElement(node, tagName) },
@@ -5494,9 +5496,9 @@
continue;
}
- // "Wrap sublist, with the sibling criteria matching any HTML
- // element with local name tag name, and the new parent
- // instructions being the following:"
+ // "Wrap sublist, with sibling criteria returning true for an HTML
+ // element with local name tag name and false otherwise, and new
+ // parent instructions being the following:"
// . . .
// "Fix disallowed ancestors of the previous step's result."
fixDisallowedAncestors(wrap(sublist,
@@ -5624,8 +5626,9 @@
sublist.push(nodeList.shift());
}
- // "Wrap sublist. Sibling criteria match any div that has one or both
- // of the following two attributes, and no other attributes:
+ // "Wrap sublist. Sibling criteria returns true for any div that has
+ // one or both of the following two attributes and no other attributes,
+ // and false otherwise:"
//
// * "An align attribute whose value is an ASCII case-insensitive
// match for alignment.
@@ -5634,7 +5637,7 @@
// "text-align", which is set to alignment.
//
// "New parent instructions are to call createElement("div") on the
- // context object, then set its CSS property "text-align" to alignment,
+ // context object, then set its CSS property "text-align" to alignment
// and return the result."
wrap(sublist,
function(node) {
@@ -6098,11 +6101,12 @@
}
}
- // "Wrap sublist. If value is "div" or "p", sibling criteria match
- // nothing; otherwise they match any HTML element with local name
- // value and no attributes. New parent instructions return the
- // result of running createElement(value) on the context object.
- // Then fix disallowed ancestors of the result."
+ // "Wrap sublist. If value is "div" or "p", sibling criteria
+ // returns false; otherwise it returns true for an HTML element
+ // with local name value and no attributes, and false otherwise.
+ // New parent instructions return the result of running
+ // createElement(value) on the context object. Then fix disallowed
+ // ancestors of the result."
fixDisallowedAncestors(wrap(sublist,
["div", "p"].indexOf(value) == - 1
? function(node) { return isHtmlElement(node, value) && !node.attributes.length }
@@ -6891,9 +6895,9 @@
nodeList.push(nodeList[nodeList.length - 1].nextSibling);
}
- // "Wrap node list, with sibling criteria matching nothing and new
+ // "Wrap node list, with sibling criteria returning false and new
// parent instructions returning the result of calling
- // createElement(tag) on the context object. Set container to the
+ // createElement(tag) on the context object. Set container to the
// result."
container = wrap(nodeList,
function() { return false },
--- a/source.html Wed Aug 03 12:48:34 2011 -0600
+++ b/source.html Wed Aug 03 13:25:59 2011 -0600
@@ -987,10 +987,12 @@
<h3>Wrapping a list of nodes</h3>
<!-- @{ -->
<p>To <dfn>wrap</dfn> a list <var>node list</var> of consecutive [[sibling]]
-[[nodes]], given <dfn>sibling criteria</dfn> and <dfn>new parent
-instructions</dfn>, run the following algorithm. If not provided,
-<span>sibling criteria</span> match nothing and <span>new parent
-instructions</span> return null.
+[[nodes]], run the following algorithm. In addition to <var>node list</var>,
+the algorithm accepts two inputs: an algorithm <var>sibling criteria</var> that
+accepts a [[node]] as input and outputs a boolean, and an algorithm <var>new
+parent instructions</var> that accepts nothing as input and outputs a [[node]]
+or null. If not provided, <var>sibling criteria</var> returns false and
+<var>new parent instructions</var> returns null.
<ol>
<li>If <var>node list</var> is empty, or the first member of <var>node
@@ -1006,22 +1008,22 @@
is a [[br]], append that [[br]] to <var>node list</var>.
<li>If the [[previoussibling]] of the first member of <var>node list</var>
- is <span>editable</span> and meets the <span>sibling criteria</span>, let
- <var>new parent</var> be the [[previoussibling]] of the first member of
- <var>node list</var>.
+ is <span>editable</span> and running <var>sibling criteria</var> on it
+ returns true, let <var>new parent</var> be the [[previoussibling]] of the
+ first member of <var>node list</var>.
<li>Otherwise, if the [[nextsibling]] of the last member of <var>node
- list</var> is <span>editable</span> and meets the <span>sibling
- criteria</span>, let <var>new parent</var> be the [[nextsibling]] of the last
- member of <var>node list</var>.
-
- <li>Otherwise, run the <span>new parent instructions</span>, and let <var>new
+ list</var> is <span>editable</span> and running <var>sibling criteria</var>
+ on it returns true, let <var>new parent</var> be the [[nextsibling]] of the
+ last member of <var>node list</var>.
+
+ <li>Otherwise, run <var>new parent instructions</var>, and let <var>new
parent</var> be the result.
<li>
- <p class=comments>This can only happen if the new parent instructions are run
- and they return null. This can be used to only merge with adjacent siblings,
- in case you don't want to create a new parent if that fails.
+ <p class=comments>This can only happen if <var>new parent instructions</var>
+ is run and it returns null. This can be used to only merge with adjacent
+ siblings, in case you don't want to create a new parent if that fails.
<p>If <var>new parent</var> is null, abort these steps and return null.
@@ -1132,8 +1134,8 @@
</ol>
<li>
- <p class=comments>This could happen if the new parent instructions returned a
- node whose parent wasn't null.
+ <p class=comments>This could happen if <var>new parent instructions</var>
+ returned a node whose parent wasn't null.
<p>If <var>original parent</var> is <span>editable</span> and has no
[[children]], remove it from its [[parent]].
@@ -1143,7 +1145,7 @@
them. We want to merge them in this case.
<p>If <var>new parent</var>'s [[nextsibling]] is <span>editable</span> and
- meets the <span>sibling criteria</span>:
+ running <var>sibling criteria</var> on it returns true:
<ol>
<li>If <var>new parent</var> is not an <span>inline node</span>, but
@@ -1205,7 +1207,7 @@
requirements but should be treated properly. In particular, they can
interfere with serialization (e.g., center cannot descend from p).
- <li> Sometimes users give instructions that have to produce invalid DOMs to
+ <li>Sometimes users give instructions that have to produce invalid DOMs to
get the expected effect, like indenting the first item of a list.
<li>The HTML validity requirements are sometimes quite complicated.
@@ -2095,15 +2097,17 @@
[[nextsibling]].
<li>
- <p class=comments>The new parent instructions are too complicated to
- reasonably feed into the wrap algorithm.
+ <p class=comments>The <var>new parent instructions</var> we'd want are too
+ complicated to reasonably feed into the wrap algorithm, so we just let them
+ return null and do the wrapping ourselves if <var>sibling criteria</var>
+ didn't return true.
<p><span>Wrap</span> the one-[[node]] list consisting of <var>node</var>,
- with <span>sibling criteria</span> matching a <span>simple modifiable
- element</span> whose <span>specified command value</span> is [[equivalent]]
- to <var>new value</var> and whose <span>effective command value</span> is
- [[looselyequivalent]] to <var>new value</var>, and with <span>new parent
- instructions</span> returning null.
+ with <var>sibling criteria</var> returning true for a <span>simple
+ modifiable element</span> whose <span>specified command value</span> is
+ [[equivalent]] to <var>new value</var> and whose <span>effective command
+ value</span> is [[looselyequivalent]] to <var>new value</var> and false
+ otherwise, and with <var>new parent instructions</var> returning null.
</ol>
<li>If the <span>effective command value</span> of <var>command</var> is
@@ -3510,10 +3514,11 @@
<ol>
<li>If <var>node</var> is a [[dd]] or [[dt]], <span>wrap</span> the
- one-[[node]] list consisting of <var>node</var>, with <span>sibling
- criteria</span> matching any [[dl]] with no [[attributes]], and <span>new
- parent instructions</span> returning the result of calling
- [[createelement|"dl"]] on the [[contextobject]]. Then abort these steps.
+ one-[[node]] list consisting of <var>node</var>, with <var>sibling
+ criteria</var> returning true for any [[dl]] with no [[attributes]] and
+ false otherwise, and <var>new parent instructions</var> returning the
+ result of calling [[createelement|"dl"]] on the [[contextobject]]. Then
+ abort these steps.
<li>If <var>node</var> is not a <span>prohibited paragraph child</span>,
abort these steps.
@@ -4903,13 +4908,12 @@
HTML5.
</div>
- <p><span>Wrap</span> <var>node list</var>, with <span>sibling
- criteria</span> matching only <span title="HTML element">HTML
- elements</span> with [[localname]] <var>tag</var> and <span>new parent
- instructions</span> returning the result of calling <code
- data-anolis-spec=domcore
- title=dom-Document-createElement>createElement(<var>tag</var>)</code> on
- the [[ownerdocument]] of <var>first node</var>.
+ <p><span>Wrap</span> <var>node list</var>, with <var>sibling criteria</var>
+ returning true for an <span>HTML element</span> with [[localname]]
+ <var>tag</var> and false otherwise, and <var>new parent
+ instructions</var> returning the result of calling
+ [[createelement|<var>tag</var>]] on the [[ownerdocument]] of <var>first
+ node</var>.
<li>Abort these steps.
</ol>
@@ -4941,13 +4945,11 @@
get it wrong. Just indent on both sides.
</div>
- <p><span>Wrap</span> <var>node list</var>, with <span>sibling
- criteria</span> matching any <span>simple indentation element</span>, and
- <span>new parent instructions</span> to return the result of calling <code
- data-anolis-spec=domcore
- title=dom-Document-createElement>createElement("blockquote")</code> on the
- [[ownerdocument]] of <var>first node</var>. Let <var>new parent</var> be the
- result.
+ <p><span>Wrap</span> <var>node list</var>, with <var>sibling criteria</var>
+ returning true for a <span>simple indentation element</span> and false
+ otherwise, and <var>new parent instructions</var> returning the result of
+ calling [[createelement|"blockquote"]] on the [[ownerdocument]] of <var>first
+ node</var>. Let <var>new parent</var> be the result.
<li><span>Fix disallowed ancestors</span> of <var>new parent</var>.
</ol>
@@ -5679,9 +5681,9 @@
<li><span>Split the parent</span> of <var>children</var>.
- <li><span>Wrap</span> <var>children</var>, with <span>sibling
- criteria</span> matching any <span>HTML element</span> with [[localname]]
- <var>tag name</var>.
+ <li><span>Wrap</span> <var>children</var>, with <var>sibling
+ criteria</var> returning true for an <span>HTML element</span> with
+ [[localname]] <var>tag name</var> and false otherwise.
<li><span>Restore the values</span> from <var>values</var>.
</ol>
@@ -5810,8 +5812,8 @@
[[br]], remove the first member from <var>node list</var> and append it
to <var>nodes to wrap</var>.
- <li><span>Wrap</span> <var>nodes to wrap</var>, with <span>new parent
- instructions</span> returning the result of calling
+ <li><span>Wrap</span> <var>nodes to wrap</var>, with <var>new parent
+ instructions</var> returning the result of calling
[[createelement|"li"]] on the [[contextobject]]. Append the result to
<var>sublist</var>.
</ol>
@@ -5835,21 +5837,21 @@
<li><span>Split the parent</span> of <var>sublist</var>.
- <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
- criteria</span> matching any <span>HTML element</span> with [[localname]]
- <var>tag name</var>, and <span>new parent instructions</span> returning
- the result of calling [[createelement|<var>tag name</var>]] on the
- [[contextobject]].
+ <li><span>Wrap</span> <var>sublist</var>, with <var>sibling
+ criteria</var> returning true for an <span>HTML element</span> with
+ [[localname]] <var>tag name</var> and false otherwise, and <var>new
+ parent instructions</var> returning the result of calling
+ [[createelement|<var>tag name</var>]] on the [[contextobject]].
<li><span>Restore the values</span> from <var>values</var>.
<li>Continue this loop from the beginning.
</ol>
- <li><span>Wrap</span> <var>sublist</var>, with the <span>sibling
- criteria</span> matching any <span>HTML element</span> with [[localname]]
- <var>tag name</var>, and the <span>new parent instructions</span> being the
- following:
+ <li><span>Wrap</span> <var>sublist</var>, with <var>sibling criteria</var>
+ returning true for an <span>HTML element</span> with [[localname]] <var>tag
+ name</var> and false otherwise, and <var>new parent instructions</var>
+ being the following:
<ol>
<li>
@@ -5860,10 +5862,10 @@
<pre><ol><li>foo</li><ol><li>[bar]</ol></ol></pre>
<p>instead of
<pre><ol><li>foo</ol><blockquote><ol><li>[bar]</ol></blockquote>.</pre>
- <p>We handle the special case in the new parent instructions instead of
- outside because we'd prefer to wind up in a sibling if there is one. We
- handle only previousSibling, not nextSibling, because we really mean for
- this to cover something like
+ <p>We handle the special case in <var>new parent instructions</var>
+ instead of outside because we'd prefer to wind up in a sibling if there
+ is one. We handle only previousSibling, not nextSibling, because we
+ really mean for this to cover something like
<pre>[foo<blockquote>bar]</blockquote></pre>
<p>which we'll handle node-by-node. TODO: Maybe we should do this
differently, like just special-case simple indentation elements in an
@@ -5991,9 +5993,9 @@
<var>sublist</var>, remove the first member of <var>node list</var> and
append it to <var>sublist</var>.
- <li><p><span>Wrap</span> <var>sublist</var>. <span>Sibling criteria</span>
- match any [[div]] that has one or both of the following two attributes, and
- no other attributes:
+ <li><p><span>Wrap</span> <var>sublist</var>. <var>Sibling criteria</var>
+ returns true for any [[div]] that has one or both of the following two
+ attributes and no other attributes, and false otherwise:
<ul>
<li>An <code data-anolis-spec=html title=attr-div-align>align</code>
@@ -6010,9 +6012,9 @@
browser behaves in this case, but for inline formatting it matches everyone
but Gecko's CSS mode, so I'm just being consistent.
- <p><span>New parent instructions</span> are to call [[createelement|"div"]]
+ <p><var>New parent instructions</var> are to call [[createelement|"div"]]
on the [[contextobject]], then set its CSS property "text-align" to
- <var>alignment</var>, and return the result.
+ <var>alignment</var> and return the result.
</ol>
</ol>
@@ -6587,11 +6589,12 @@
</ol>
<li><span>Wrap</span> <var>sublist</var>. If <var>value</var> is "div" or
- "p", <span>sibling criteria</span> match nothing; otherwise they match any
- <span>HTML element</span> with [[localname]] <var>value</var> and no
- attributes. <span>New parent instructions</span> return the result of
- running [[createelement|<var>value</var>]] on the [[contextobject]]. Then
- <span>fix disallowed ancestors</span> of the result.
+ "p", <var>sibling criteria</var> returns false; otherwise it returns true
+ for an <span>HTML element</span> with [[localname]] <var>value</var> and no
+ attributes, and false otherwise. <var>New parent instructions</var>
+ return the result of running [[createelement|<var>value</var>]] on the
+ [[contextobject]]. Then <span>fix disallowed ancestors</span> of the
+ result.
</ol>
</ol>
@@ -7459,8 +7462,8 @@
not null and is an <span>allowed child</span> of "p", append it to
<var>node list</var>.
- <li><span>Wrap</span> <var>node list</var>, with <span>sibling
- criteria</span> matching nothing and <span>new parent instructions</span>
+ <li><span>Wrap</span> <var>node list</var>, with <var>sibling
+ criteria</var> returning false and <var>new parent instructions</var>
returning the result of calling [[createelement|<var>tag</var>]] on the
[[contextobject]]. Set <var>container</var> to the result.
</ol>