--- a/editcommands.html Wed Jun 29 15:56:26 2011 -0600
+++ b/editcommands.html Wed Jun 29 16:21:41 2011 -0600
@@ -1215,15 +1215,6 @@
if they're effectively contained: it might be that the new node created by
splitText() is returned. -->
-<p>An <dfn id=unwrappable-node>unwrappable node</dfn> is an <a href=#html-element>HTML element</a> which may not
-be used where only <a class=external data-anolis-spec=html href=http://www.whatwg.org/html/#phrasing-content>phrasing content</a> is expected (not counting unknown or
-obsolete elements, which cannot be used at all); or any <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>Element</a></code> whose
-display property computes to something other than "inline", "inline-block", or
-"inline-table"; or any <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> that is not <a href=#editable>editable</a>.
-
-<p class=XXX>Probably want to redefine unwrappable node in terms of allowed
-children or something.
-
<p>A <dfn id=modifiable-element>modifiable element</dfn> is a <code class=external data-anolis-spec=html title="the b element"><a href=http://www.whatwg.org/html/#the-b-element>b</a></code>, <code class=external data-anolis-spec=html title="the em element"><a href=http://www.whatwg.org/html/#the-em-element>em</a></code>, <code class=external data-anolis-spec=html title="the i element"><a href=http://www.whatwg.org/html/#the-i-element>i</a></code>, <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code>, <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>,
<code class=external data-anolis-spec=html title="the strike element"><a href=http://www.whatwg.org/html/#the-strike-element>strike</a></code>, <code class=external data-anolis-spec=html title="the strong element"><a href=http://www.whatwg.org/html/#the-strong-element>strong</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sub</a></code>, <code class=external data-anolis-spec=html title="the sub and sup elements"><a href=http://www.whatwg.org/html/#the-sub-and-sup-elements>sup</a></code>, or <code class=external data-anolis-spec=html title="the u element"><a href=http://www.whatwg.org/html/#the-u-element>u</a></code> element with no attributes
except possibly <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>; or a <code class=external data-anolis-spec=html title=font><a href=http://www.whatwg.org/html/#font>font</a></code> element with no attributes except
@@ -1780,7 +1771,7 @@
<li>If <var title="">new value</var> is null, abort this algorithm.
<li>If <var title="">node</var> is an <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>Element</a></code>, <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code>, or <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#comment>Comment</a></code> node, and
- is not an <a href=#unwrappable-node>unwrappable node</a>:
+ is an <a href=#allowed-child>allowed child</a> of "span":
<ol>
<!-- Even if the value matches, we stick it in a preceding sibling if
@@ -1811,7 +1802,7 @@
<li>If the <a href=#effective-value>effective value</a> of <var title="">command</var> is <var title="">new
value</var> on <var title="">node</var>, abort this algorithm.
- <li>If <var title="">node</var> is an <a href=#unwrappable-node>unwrappable node</a>:
+ <li>If <var title="">node</var> is not an <a href=#allowed-child>allowed child</a> of "span":
<ol>
<li>Let <var title="">children</var> be all <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> of <var title="">node</var>,
@@ -2077,11 +2068,11 @@
often we'll style several consecutive siblings in succession. In that case,
the element created for the first can be reused for the later ones.
-<p>This last step works a bit differently if the node is an <a href=#unwrappable-node>unwrappable
-node</a>. In that case, wrapping it in a simple styling element would
-make the document less conforming than it already was. Instead, we recursively
-force style on its children. The recursion will terminate when we hit a node
-that's wrappable, or when there are no further descendants.
+<p>This last step works a bit differently if the node isn't an <a href=#allowed-child>allowed
+child</a> of "span". In that case, wrapping it in a simple styling element
+would make the document less conforming than it already was. Instead, we
+recursively force style on its children. The recursion will terminate when we
+hit a node that's wrappable, or when there are no further descendants.
<p>After all this, the node is guaranteed to have the style we want, barring
bugs in the algorithm or the two exceptions noted earlier (!important style
--- a/implementation.js Wed Jun 29 15:56:26 2011 -0600
+++ b/implementation.js Wed Jun 29 16:21:41 2011 -0600
@@ -1475,45 +1475,6 @@
return nodeList;
}
-// "An unwrappable node is an HTML element which may not be used where only
-// phrasing content is expected (not counting unknown or obsolete elements,
-// which cannot be used at all); or any Element whose display property computes
-// to something other than "inline", "inline-block", or "inline-table"; or any
-// node that is not editable."
-//
-// I don't bother implementing this exactly, just well enough for testing.
-function isUnwrappableNode(node) {
- if (!node) {
- return false;
- }
-
- if (!isEditable(node)) {
- return true;
- }
-
- if (node.nodeType != Node.ELEMENT_NODE) {
- return false;
- }
-
- var display = getComputedStyle(node).display;
- if (display != "inline"
- && display != "inline-block"
- && display != "inline-table") {
- return true;
- }
-
- if (!isHtmlElement(node)) {
- return false;
- }
-
- return [
- "h1", "h2", "h3", "h4", "h5", "h6", "p", "hr", "pre", "blockquote",
- "ol", "ul", "li", "dl", "dt", "dd", "div", "table", "caption",
- "colgroup", "col", "tbody", "thead", "tfoot", "tr", "th", "td",
- "address"
- ].indexOf(node.tagName.toLowerCase()) != -1;
-}
-
// "A modifiable element is a b, em, i, s, span, strong, sub, sup, or u element
// with no attributes except possibly style; or a font element with no
// attributes except possibly style, color, face, and/or size; or an a element
@@ -2350,13 +2311,13 @@
return;
}
- // "If node is an Element, Text, Comment, or ProcessingInstruction node,
- // and is not an unwrappable node:"
+ // "If node is an Element, Text, or Comment node, and is an allowed child
+ // of "span":"
if ((node.nodeType == Node.ELEMENT_NODE
|| node.nodeType == Node.TEXT_NODE
|| node.nodeType == Node.COMMENT_NODE
|| node.nodeType == Node.PROCESSING_INSTRUCTION_NODE)
- && !isUnwrappableNode(node)) {
+ && isAllowedChild(node, "span")) {
// "Reorder modifiable descendants of node's previousSibling."
reorderModifiableDescendants(node.previousSibling, command, newValue);
@@ -2383,8 +2344,8 @@
return;
}
- // "If node is an unwrappable node:"
- if (isUnwrappableNode(node)) {
+ // "If node is not an allowed child of "span":"
+ if (!isAllowedChild(node, "span")) {
// "Let children be all children of node, omitting any that are
// Elements whose specified value for command is neither null nor
// equal to new value."
--- a/source.html Wed Jun 29 15:56:26 2011 -0600
+++ b/source.html Wed Jun 29 16:21:41 2011 -0600
@@ -1171,15 +1171,6 @@
if they're effectively contained: it might be that the new node created by
splitText() is returned. -->
-<p>An <dfn>unwrappable node</dfn> is an <span>HTML element</span> which may not
-be used where only [[phrasingcontent]] is expected (not counting unknown or
-obsolete elements, which cannot be used at all); or any [[element]] whose
-display property computes to something other than "inline", "inline-block", or
-"inline-table"; or any [[node]] that is not <span>editable</span>.
-
-<p class=XXX>Probably want to redefine unwrappable node in terms of allowed
-children or something.
-
<p>A <dfn>modifiable element</dfn> is a [[b]], [[em]], [[i]], [[s]], [[span]],
[[strike]], [[strong]], [[sub]], [[sup]], or [[u]] element with no attributes
except possibly [[style]]; or a [[font]] element with no attributes except
@@ -1741,7 +1732,7 @@
<li>If <var>new value</var> is null, abort this algorithm.
<li>If <var>node</var> is an [[element]], [[text]], or [[comment]] node, and
- is not an <span>unwrappable node</span>:
+ is an <span>allowed child</span> of "span":
<ol>
<!-- Even if the value matches, we stick it in a preceding sibling if
@@ -1772,7 +1763,7 @@
<li>If the <span>effective value</span> of <var>command</var> is <var>new
value</var> on <var>node</var>, abort this algorithm.
- <li>If <var>node</var> is an <span>unwrappable node</span>:
+ <li>If <var>node</var> is not an <span>allowed child</span> of "span":
<ol>
<li>Let <var>children</var> be all [[children]] of <var>node</var>,
@@ -2056,11 +2047,11 @@
often we'll style several consecutive siblings in succession. In that case,
the element created for the first can be reused for the later ones.
-<p>This last step works a bit differently if the node is an <span>unwrappable
-node</span>. In that case, wrapping it in a simple styling element would
-make the document less conforming than it already was. Instead, we recursively
-force style on its children. The recursion will terminate when we hit a node
-that's wrappable, or when there are no further descendants.
+<p>This last step works a bit differently if the node isn't an <span>allowed
+child</span> of "span". In that case, wrapping it in a simple styling element
+would make the document less conforming than it already was. Instead, we
+recursively force style on its children. The recursion will terminate when we
+hit a node that's wrappable, or when there are no further descendants.
<p>After all this, the node is guaranteed to have the style we want, barring
bugs in the algorithm or the two exceptions noted earlier (!important style
--- a/tests.js Wed Jun 29 15:56:26 2011 -0600
+++ b/tests.js Wed Jun 29 16:21:41 2011 -0600
@@ -1022,7 +1022,6 @@
['<p>', '<xmp>[foo]</xmp>'],
['<div>', '<xmp>[foo]</xmp>'],
- // For queryCommandIndeterm() and queryCommandValue()
'<div><ol><li>[foo]</ol></div>',
'<div><table><tr><td>[foo]</table></div>',
'<p>[foo<h1>bar]</h1>',