--- a/autoimplementation.html Thu Apr 07 15:08:58 2011 -0600
+++ b/autoimplementation.html Thu Apr 07 15:32:58 2011 -0600
@@ -43,6 +43,7 @@
<li><a href=#forecolor>forecolor</a>
<li><a href=#hilitecolor>hilitecolor</a>
<li><a href=#italic>italic</a>
+ <li><a href=#strikethrough>strikethrough</a>
<li><a href=#subscript>subscript</a>
<li><a href=#superscript>superscript</a>
<li><a href=#underline>underline</a>
@@ -144,6 +145,18 @@
<button onclick="addTest('italic', document.querySelector('#italic input').value)">Add test</button>
</div>
+<div id=strikethrough>
+<h1>strikethrough</h1>
+
+<button onclick="runTests('strikethrough')">Run tests</button>
+
+<table border=1><tr><th>Input <th>Spec <th>Browser <th>Same?</table>
+<table border=1><tr><th>Input <th>Spec <th>Browser <th>Same?</table>
+
+<p><label>Enter new test here: <input></label>
+<button onclick="addTest('strikethrough', document.querySelector('#strikethrough input').value)">Add test</button>
+</div>
+
<div id=subscript>
<h1>subscript</h1>
@@ -204,6 +217,7 @@
forecolor: "#FF0000",
hilitecolor: "#FF8888",
italic: null,
+ strikethrough: null,
subscript: null,
superscript: null,
underline: null,
@@ -532,6 +546,28 @@
'foo [bar <i>baz] qoz</i> quz sic',
'foo bar <i>baz [qoz</i> quz] sic',
],
+ strikethrough: [
+ 'foo[bar]baz',
+ 'foo]bar[baz',
+ '{<p><p> <p>foo</p>}',
+ 'foo[bar<b>baz]qoz</b>quz',
+
+ '<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>',
+ '<table><tbody><tr data-start=1 data-end=2><td>foo<td>bar<td>baz</table>',
+ '<table><tbody><tr data-start=0 data-end=2><td>foo<td>bar<td>baz</table>',
+ '<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>',
+ '<table data-start=0 data-end=1><tbody><tr><td>foo<td>bar<td>baz</table>',
+ '{<table><tr><td>foo<td>bar<td>baz</table>}',
+
+ 'foo<s>[bar]</s>baz',
+ 'foo<span style="text-decoration: line-through">[bar]</span>baz',
+ '<s>foo[bar]baz</s>',
+ '<s>foo[b<span style="color:red">ar]ba</span>z</s>',
+ '<s>foo[b<span style="color:red" id=foo>ar]ba</span>z</s>',
+ '<s>foo[b<span style="font-size:3em">ar]ba</span>z</s>',
+ '<s>foo[b<i>ar]ba</i>z</s>',
+ '<p style="text-decoration: line-through">foo[bar]baz</p>',
+ ],
subscript: [
'foo[bar]baz',
'foo]bar[baz',
@@ -662,8 +698,8 @@
}
function addTest(command, test) {
- var doubleTesting = ["backcolor", "bold", "italic", "underline",
- "forecolor", "fontname", "fontsize", "subscript",
+ var doubleTesting = ["backcolor", "bold", "italic", "strikethrough",
+ "underline", "forecolor", "fontname", "fontsize", "subscript",
"superscript"].indexOf(command) != -1;
// I tried to feature-detect styleWithCSS, but it was too much of a pain,
@@ -799,6 +835,7 @@
.replace(/: /g, ":")
.replace(/;? ?"/g, '"')
.replace(/<(\/?)strong/g, '<$1b')
+ .replace(/<(\/?)strike/g, '<$1s')
.replace(/<(\/?)em/g, '<$1i')
.replace(/#[0-9a-fA-F]{6}/g, function(match) { return match.toUpperCase(); });
var normalizedBrowserCell = tr.childNodes[2].childNodes[1].textContent
@@ -806,6 +843,7 @@
.replace(/: /g, ":")
.replace(/;? ?"/g, '"')
.replace(/<(\/?)strong/g, '<$1b')
+ .replace(/<(\/?)strike/g, '<$1s')
.replace(/<(\/?)em/g, '<$1i')
.replace(/#[0-9a-fA-F]{6}/g, function(match) { return match.toUpperCase(); })
.replace(/ class="Apple-style-span"/g, "");
--- a/editcommands.html Thu Apr 07 15:08:58 2011 -0600
+++ b/editcommands.html Thu Apr 07 15:32:58 2011 -0600
@@ -284,6 +284,11 @@
<li>Return "baseline".
</ol>
+ <li>If <var title="">command</var> is "strikethrough", and the "text-decoration"
+ property of <var title="">node</var> or any of its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-ancestor title=concept-tree-ancestor>ancestors</a> computes to
+ a value containing "line-through", return "line-through". Otherwise, return
+ null.
+
<li>If <var title="">command</var> is "underline", and the "text-decoration"
property of <var title="">node</var> or any of its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-ancestor title=concept-tree-ancestor>ancestors</a> computes to
a value containing "underline", return "underline". Otherwise, return
@@ -327,6 +332,19 @@
<li>Return null.
</ol>
+ <li>If <var title="">command</var> is "strikethrough", and <var title="">element</var> has a
+ <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute set, and that attribute sets "text-decoration":
+
+ <ol>
+ <li>If <var title="">element</var>'s <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets "text-decoration" to a
+ value containing "line-through", return "line-through".
+
+ <li>Return null.
+ </ol>
+
+ <li>If <var title="">command</var> is "strikethrough" and <var title="">element</var> is an
+ <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code> element, return "line-through".
+
<li>If <var title="">command</var> is "underline", and <var title="">element</var> has a
<code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute set, and that attribute sets "text-decoration":
@@ -370,7 +388,7 @@
<li>Return null.
</ol>
-<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 span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>,
+<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 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 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>, <code class=external data-anolis-spec=html title=dom-font-color><a href=http://www.whatwg.org/html/#dom-font-color>color</a></code>, <code class=external data-anolis-spec=html title=dom-font-face><a href=http://www.whatwg.org/html/#dom-font-face>face</a></code>, and/or <code class=external data-anolis-spec=html title=dom-font-size><a href=http://www.whatwg.org/html/#dom-font-size>size</a></code>; or an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>
@@ -380,13 +398,13 @@
which at least one of the following holds:
<ul>
- <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <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=font><a href=http://www.whatwg.org/html/#font>font</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 span element"><a href=http://www.whatwg.org/html/#the-span-element>span</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.
+ <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <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=font><a href=http://www.whatwg.org/html/#font>font</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 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.
- <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <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=font><a href=http://www.whatwg.org/html/#font>font</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 span element"><a href=http://www.whatwg.org/html/#the-span-element>span</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 exactly one attribute, which is
- <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, which sets no CSS properties (including invalid or unrecognized
- properties).
+ <li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code>, <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=font><a href=http://www.whatwg.org/html/#font>font</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 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 exactly one attribute,
+ which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, which sets no CSS properties (including invalid or
+ unrecognized properties).
<li>It is an <code class=external data-anolis-spec=html title="the a element"><a href=http://www.whatwg.org/html/#the-a-element>a</a></code> element with exactly one attribute, which is <code class=external data-anolis-spec=html title=attr-hyperlink-href><a href=http://www.whatwg.org/html/#attr-hyperlink-href>href</a></code>.
@@ -401,10 +419,15 @@
<code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets exactly one CSS property
(including invalid or unrecognized properties), which is "font-style".
+ <li>It is an <code class=external data-anolis-spec=html title="the s element"><a href=http://www.whatwg.org/html/#the-s-element>s</a></code> element with exactly one attribute, which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and
+ the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets exactly one CSS property (including invalid or
+ unrecognized properties), which is "text-decoration", which is set to
+ "line-through" or "underline" or "none".
+
<li>It is a <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 exactly one attribute, which is <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and
the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets exactly one CSS property (including invalid or
unrecognized properties), which is "text-decoration", which is set to
- "underline" or "none".
+ "line-through" or "underline" or "none".
<li>It is a <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> or <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> element with exactly one attribute, which is
<code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code>, and the <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute sets exactly one CSS property
@@ -551,6 +574,10 @@
<li>Return <var title="">children</var>.
</ol>
+ <li>If <var title="">command</var> is "strikethrough", and <var title="">element</var> has a
+ <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute that sets "text-decoration" to some value containing
+ "line-through", delete "line-through" from the value.
+
<li>If <var title="">command</var> is "underline", and <var title="">element</var> has a
<code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute that sets "text-decoration" to some value containing
"underline", delete "underline" from the value.
@@ -869,6 +896,14 @@
"italic", let <var title="">new parent</var> be 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("i")</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="">node</var>.
+ <li>If <var title="">command</var> is "strikethrough" and <var title="">new value</var> is
+ "line-through", let <var title="">new parent</var> be 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("s")</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="">node</var>.
+
+ <p class=XXX>Actual UAs use strike, not s, but s is shorter and HTML5 makes
+ strike invalid. I've gone with s for now, but maybe we want to change the
+ spec to require strike.
+
<li>If <var title="">command</var> is "underline" and <var title="">new value</var> is
"underline", let <var title="">new parent</var> be 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("u")</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="">node</var>.
@@ -923,6 +958,11 @@
property</a> for <var title="">command</var> is not null, set that CSS property of
<var title="">new parent</var> to <var title="">new value</var>.
+ <li>If <var title="">command</var> is "strikethrough", and <var title="">new value</var> is
+ "line-through", and the <a href=#effective-value>effective value</a> of "strikethrough" for
+ <var title="">new parent</var> is not "line-through", set the "text-decoration"
+ property of <var title="">new parent</var> to "line-through".
+
<li>If <var title="">command</var> is "underline", and <var title="">new value</var> is
"underline", and the <a href=#effective-value>effective value</a> of "underline" for <var title="">new
parent</var> is not "underline", set the "text-decoration" property of
@@ -941,14 +981,19 @@
<li>Remove <var title="">new parent</var> 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>.
<li>If <var title="">new parent</var> is a <code class=external data-anolis-spec=html title="the span element"><a href=http://www.whatwg.org/html/#the-span-element>span</a></code>, and either <var title="">command</var>
- is "underline" or the <a href=#relevant-css-property>relevant CSS property</a> for
- <var title="">command</var> is not null:
+ is "underline" or <var title="">command</var> is "strikethrough" or the
+ <a href=#relevant-css-property>relevant CSS property</a> for <var title="">command</var> is not null:
<ol>
<li>If the <a href=#relevant-css-property>relevant CSS property</a> for <var title="">command</var> is
not null, set that CSS property of <var title="">node</var> to <var title="">new
value</var>.
+ <li>If <var title="">command</var> is "strikethrough" and <var title="">new value</var> is
+ "line-through", alter the "text-decoration" property of <var title="">node</var>
+ to include "line-through" (preserving "overline" or "underline" if
+ present).
+
<li>If <var title="">command</var> is "underline" and <var title="">new value</var> is
"underline", alter the "text-decoration" property of <var title="">node</var> to
include "underline" (preserving "overline" or "line-through" if present).
@@ -1435,6 +1480,22 @@
<dd><strong>Relevant CSS Property</strong>: "font-style"
+<dt><code title=""><dfn id=command-strikethrough title=command-strikethrough>strikethrough</dfn></code>
+
+<dd><strong>Action</strong>: <a href=#decompose>Decompose</a> the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a>. If the
+state of the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a> for this command is then true, <a href=#set-the-value>set the
+value</a> of each returned <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> to null. Otherwise, <a href=#set-the-value title="set
+the value">set their value</a> to "line-through".
+
+<p class=XXX>Has all the same problems as underline.
+
+<dd><strong>State</strong>: True if every <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code> node that is
+<a href=#effectively-contained>effectively contained</a> in the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a> has <a href=#effective-value>effective
+value</a> "line-through". Otherwise false.
+
+<dd><strong>Value</strong>: Always the empty string.
+
+
<dt><code title=""><dfn id=command-stylewithcss title=command-stylewithcss>styleWithCSS</dfn></code>
<dd><strong>Action</strong>: Convert <var title="">value</var> to a boolean according
--- a/implementation.js Thu Apr 07 15:08:58 2011 -0600
+++ b/implementation.js Thu Apr 07 15:32:58 2011 -0600
@@ -393,12 +393,25 @@
return "baseline";
}
+ // "If command is "strikethrough", and the "text-decoration" property of
+ // node or any of its ancestors computes to a value containing
+ // "line-through", return "line-through". Otherwise, return null."
+ if (command == "strikethrough") {
+ do {
+ if (getComputedStyle(node).textDecoration.indexOf("line-through") != -1) {
+ return "line-through";
+ }
+ node = node.parentNode;
+ } while (node && node.nodeType == Node.ELEMENT_NODE);
+ return null;
+ }
+
// "If command is "underline", and the "text-decoration" property of node
// or any of its ancestors computes to a value containing "underline",
// return "underline". Otherwise, return null."
if (command == "underline") {
do {
- if ((" " + getComputedStyle(node).textDecoration + " ").indexOf(" underline ") != -1) {
+ if (getComputedStyle(node).textDecoration.indexOf("underline") != -1) {
return "underline";
}
node = node.parentNode;
@@ -469,6 +482,28 @@
return null;
}
+ // "If command is "strikethrough", and element has a style attribute set,
+ // and that attribute sets "text-decoration":"
+ if (command == "strikethrough"
+ && element.style.textDecoration != "") {
+ // "If element's style attribute sets "text-decoration" to a value
+ // containing "line-through", return "line-through"."
+ if (element.style.textDecoration.indexOf("line-through") != -1) {
+ return "line-through";
+ }
+
+ // "Return null."
+ return null;
+ }
+
+ // "If command is "strikethrough" and element is a s element, return
+ // "line-through"."
+ if (command == "strikethrough"
+ && isHtmlElement(element)
+ && element.tagName == "S") {
+ return "line-through";
+ }
+
// "If command is "underline", and element has a style attribute set, and
// that attribute sets "text-decoration":"
if (command == "underline"
@@ -541,7 +576,7 @@
return null;
}
-// "A modifiable element is a b, em, i, span, strong, sub, sup, or u element
+// "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
// with no attributes except possibly style and/or href."
@@ -550,7 +585,7 @@
return false;
}
- if (["B", "EM", "I", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) != -1) {
+ if (["B", "EM", "I", "S", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) != -1) {
if (node.attributes.length == 0) {
return true;
}
@@ -603,12 +638,12 @@
}
// Only these elements can possibly be a simple modifiable element.
- if (["A", "B", "EM", "FONT", "I", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) == -1) {
+ if (["A", "B", "EM", "FONT", "I", "S", "SPAN", "STRONG", "SUB", "SUP", "U"].indexOf(node.tagName) == -1) {
return false;
}
- // "It is an a, b, em, font, i, span, strong, sub, sup, or u element with
- // no attributes."
+ // "It is an a, b, em, font, i, s, span, strong, sub, sup, or u element
+ // with no attributes."
if (node.attributes.length == 0) {
return true;
}
@@ -618,8 +653,8 @@
return false;
}
- // "It is an a, b, em, font, i, span, strong, sub, sup, or u element with
- // exactly one attribute, which is style, which sets no CSS properties
+ // "It is an a, b, em, font, i, s, span, strong, sub, sup, or u element
+ // with exactly one attribute, which is style, which sets no CSS properties
// (including invalid or unrecognized properties)."
//
// Not gonna try for invalid or unrecognized.
@@ -664,14 +699,28 @@
return true;
}
+ // "It is an s element with exactly one attribute, which is style, and the
+ // style attribute sets exactly one CSS property (including invalid or
+ // unrecognized properties), which is "text-decoration", which is set to
+ // "line-through" or "underline" or "none"."
+ if (node.tagName == "S"
+ && node.hasAttribute("style")
+ && node.style.length == 1
+ && (node.style.textDecoration == "line-through"
+ || node.style.textDecoration == "underline"
+ || node.style.textDecoration == "none")) {
+ return true;
+ }
+
// "It is a u element with exactly one attribute, which is style, and the
// style attribute sets exactly one CSS property (including invalid or
// unrecognized properties), which is "text-decoration", which is set to
- // "underline" or "none"."
+ // "line-through" or "underline" or "none"."
if (node.tagName == "U"
&& node.hasAttribute("style")
&& node.style.length == 1
- && (node.style.textDecoration == "underline"
+ && (node.style.textDecoration == "line-through"
+ || node.style.textDecoration == "underline"
|| node.style.textDecoration == "none")) {
return true;
}
@@ -859,6 +908,21 @@
return children;
}
+ // "If command is "strikethrough", and element has a style attribute that
+ // sets "text-decoration" to some value containing "line-through", delete
+ // "line-through" from the value."
+ if (command == "strikethrough"
+ && element.style.textDecoration.indexOf("line-through") != -1) {
+ if (element.style.textDecoration == "line-through") {
+ element.style.textDecoration = "";
+ } else {
+ element.style.textDecoration = element.style.textDecoration.replace("line-through", "");
+ }
+ if (element.getAttribute("style") == "") {
+ element.removeAttribute("style");
+ }
+ }
+
// "If command is "underline", and element has a style attribute that sets
// "text-decoration" to some value containing "underline", delete
// "underline" from the value."
@@ -1231,6 +1295,13 @@
newParent = node.ownerDocument.createElement("i");
}
+ // "If command is "strikethrough" and new value is "line-through", let
+ // new parent be the result of calling createElement("s") on the
+ // ownerDocument of node."
+ if (command == "strikethrough" && newValue == "line-through") {
+ newParent = node.ownerDocument.createElement("s");
+ }
+
// "If command is "underline" and new value is "underline", let new
// parent be the result of calling createElement("u") on the
// ownerDocument of node."
@@ -1302,6 +1373,15 @@
newParent.style[property] = newValue;
}
+ // "If command is "strikethrough", and new value is "line-through", and the
+ // effective value of "strikethrough" for new parent is not "line-through",
+ // set the "text-decoration" property of new parent to "line-through"."
+ if (command == "strikethrough"
+ && newValue == "line-through"
+ && getEffectiveValue(newParent, "strikethrough") != "line-through") {
+ newParent.style.textDecoration = "line-through";
+ }
+
// "If command is "underline", and new value is "underline", and the
// effective value of "underline" for new parent is not "underline", set
// the "text-decoration" property of new parent to "underline"."
@@ -1325,16 +1405,30 @@
// "Remove new parent from its parent."
newParent.parentNode.removeChild(newParent);
- // "If new parent is a span, and either command is "underline" or the
- // relevant CSS property for command is not null:"
+ // "If new parent is a span, and either command is "underline" or
+ // command is "strikethrough" or the relevant CSS property for command
+ // is not null:"
if (newParent.tagName == "SPAN"
- && (command == "underline" || property !== null)) {
+ && (command == "underline" || command == "strikethrough" || property !== null)) {
// "If the relevant CSS property for command is not null, set that
// CSS property of node to new value."
if (property !== null) {
node.style[property] = newValue;
}
+ // "If command is "strikethrough" and new value is "line-through",
+ // alter the "text-decoration" property of node to include
+ // "line-through" (preserving "overline" or "underline" if
+ // present)."
+ if (command == "strikethrough" && newValue == "line-through") {
+ if (node.style.textDecoration == ""
+ || node.style.textDecoration == "none") {
+ node.style.textDecoration = "line-through";
+ } else {
+ node.style.textDecoration += " line-through";
+ }
+ }
+
// "If command is "underline" and new value is "underline", alter
// the "text-decoration" property of node to include "underline"
// (preserving "overline" or "line-through" if present)."
@@ -1347,7 +1441,7 @@
}
}
- // "Otherwise:"
+ // "Otherwise:"
} else {
// "Let children be all children of node, omitting any that are
// Elements whose specified value for command is neither null nor
@@ -1559,6 +1653,17 @@
}
break;
+ case "strikethrough":
+ // "Decompose the range. If the state of the range for this command is
+ // then true, set the value of each returned node to null. Otherwise,
+ // set their value to "line-through"."
+ var nodeList = decomposeRange(range);
+ var newValue = getState(command, range) ? null : "line-through";
+ for (var i = 0; i < nodeList.length; i++) {
+ setNodeValue(nodeList[i], command, newValue);
+ }
+ break;
+
case "stylewithcss":
// "Convert value to a boolean according to the algorithm in WebIDL,
// and set the CSS styling flag to the result."
@@ -1659,6 +1764,7 @@
if (command != "bold"
&& command != "italic"
+ && command != "strikethrough"
&& command != "underline"
&& command != "subscript"
&& command != "superscript") {
@@ -1701,6 +1807,13 @@
&& fontStyle !== "oblique") {
return false;
}
+ } else if (command == "strikethrough") {
+ // "True if every Text node that is effectively contained in the
+ // range has effective value "line-through". Otherwise false."
+ var textDecoration = getEffectiveValue(node, command);
+ if (textDecoration !== "line-through") {
+ return false;
+ }
} else if (command == "underline") {
// "True if every Text node that is effectively contained in the
// range has effective value "underline". Otherwise false."
--- a/preprocess Thu Apr 07 15:08:58 2011 -0600
+++ b/preprocess Thu Apr 07 15:32:58 2011 -0600
@@ -52,6 +52,7 @@
'rangemutationrules': '<span data-anolis-spec=domrange>range mutation rules</span>',
'rangeroot': '<span data-anolis-spec=domrange title=concept-range-root>root</span>',
'rangestart': '<span data-anolis-spec=domrange title=concept-range-start>start</span>',
+ 's': '<code data-anolis-spec=html title="the s element">s</code>',
'selection': '<code data-anolis-spec=domrange>Selection</code>',
'sibling': '<span data-anolis-spec=domcore title=concept-tree-sibling>sibling</span>',
'span': '<code data-anolis-spec=html title="the span element">span</code>',
--- a/source.html Thu Apr 07 15:08:58 2011 -0600
+++ b/source.html Thu Apr 07 15:32:58 2011 -0600
@@ -273,6 +273,11 @@
<li>Return "baseline".
</ol>
+ <li>If <var>command</var> is "strikethrough", and the "text-decoration"
+ property of <var>node</var> or any of its [[ancestors]] computes to
+ a value containing "line-through", return "line-through". Otherwise, return
+ null.
+
<li>If <var>command</var> is "underline", and the "text-decoration"
property of <var>node</var> or any of its [[ancestors]] computes to
a value containing "underline", return "underline". Otherwise, return
@@ -316,6 +321,19 @@
<li>Return null.
</ol>
+ <li>If <var>command</var> is "strikethrough", and <var>element</var> has a
+ [[style]] attribute set, and that attribute sets "text-decoration":
+
+ <ol>
+ <li>If <var>element</var>'s [[style]] attribute sets "text-decoration" to a
+ value containing "line-through", return "line-through".
+
+ <li>Return null.
+ </ol>
+
+ <li>If <var>command</var> is "strikethrough" and <var>element</var> is an
+ [[s]] element, return "line-through".
+
<li>If <var>command</var> is "underline", and <var>element</var> has a
[[style]] attribute set, and that attribute sets "text-decoration":
@@ -359,7 +377,7 @@
<li>Return null.
</ol>
-<p>A <dfn>modifiable element</dfn> is a [[b]], [[em]], [[i]], [[span]],
+<p>A <dfn>modifiable element</dfn> 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]], [[fontcolor]], [[fontface]], and/or [[fontsize]]; or an [[a]]
@@ -369,13 +387,13 @@
which at least one of the following holds:
<ul>
- <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[span]], [[strong]],
- [[sub]], [[sup]], or [[u]] element with no attributes.
+ <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[s]], [[span]],
+ [[strong]], [[sub]], [[sup]], or [[u]] element with no attributes.
- <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[span]], [[strong]],
- [[sub]], [[sup]], or [[u]] element with exactly one attribute, which is
- [[style]], which sets no CSS properties (including invalid or unrecognized
- properties).
+ <li>It is an [[a]], [[b]], [[em]], [[font]], [[i]], [[s]], [[span]],
+ [[strong]], [[sub]], [[sup]], or [[u]] element with exactly one attribute,
+ which is [[style]], which sets no CSS properties (including invalid or
+ unrecognized properties).
<li>It is an [[a]] element with exactly one attribute, which is [[href]].
@@ -390,10 +408,15 @@
[[style]], and the [[style]] attribute sets exactly one CSS property
(including invalid or unrecognized properties), which is "font-style".
+ <li>It is an [[s]] element with exactly one attribute, which is [[style]], and
+ the [[style]] attribute sets exactly one CSS property (including invalid or
+ unrecognized properties), which is "text-decoration", which is set to
+ "line-through" or "underline" or "none".
+
<li>It is a [[u]] element with exactly one attribute, which is [[style]], and
the [[style]] attribute sets exactly one CSS property (including invalid or
unrecognized properties), which is "text-decoration", which is set to
- "underline" or "none".
+ "line-through" or "underline" or "none".
<li>It is a [[sub]] or [[sup]] element with exactly one attribute, which is
[[style]], and the [[style]] attribute sets exactly one CSS property
@@ -544,6 +567,10 @@
<li>Return <var>children</var>.
</ol>
+ <li>If <var>command</var> is "strikethrough", and <var>element</var> has a
+ [[style]] attribute that sets "text-decoration" to some value containing
+ "line-through", delete "line-through" from the value.
+
<li>If <var>command</var> is "underline", and <var>element</var> has a
[[style]] attribute that sets "text-decoration" to some value containing
"underline", delete "underline" from the value.
@@ -867,6 +894,16 @@
title=dom-Document-createElement>createElement("i")</code> on the
[[ownerdocument]] of <var>node</var>.
+ <li>If <var>command</var> is "strikethrough" and <var>new value</var> is
+ "line-through", let <var>new parent</var> be the result of calling <code
+ data-anolis-spec=domcore
+ title=dom-Document-createElement>createElement("s")</code> on the
+ [[ownerdocument]] of <var>node</var>.
+
+ <p class=XXX>Actual UAs use strike, not s, but s is shorter and HTML5 makes
+ strike invalid. I've gone with s for now, but maybe we want to change the
+ spec to require strike.
+
<li>If <var>command</var> is "underline" and <var>new value</var> is
"underline", let <var>new parent</var> be the result of calling <code
data-anolis-spec=domcore
@@ -932,6 +969,11 @@
property</span> for <var>command</var> is not null, set that CSS property of
<var>new parent</var> to <var>new value</var>.
+ <li>If <var>command</var> is "strikethrough", and <var>new value</var> is
+ "line-through", and the <span>effective value</span> of "strikethrough" for
+ <var>new parent</var> is not "line-through", set the "text-decoration"
+ property of <var>new parent</var> to "line-through".
+
<li>If <var>command</var> is "underline", and <var>new value</var> is
"underline", and the <span>effective value</span> of "underline" for <var>new
parent</var> is not "underline", set the "text-decoration" property of
@@ -950,14 +992,19 @@
<li>Remove <var>new parent</var> from its [[parent]].
<li>If <var>new parent</var> is a [[span]], and either <var>command</var>
- is "underline" or the <span>relevant CSS property</span> for
- <var>command</var> is not null:
+ is "underline" or <var>command</var> is "strikethrough" or the
+ <span>relevant CSS property</span> for <var>command</var> is not null:
<ol>
<li>If the <span>relevant CSS property</span> for <var>command</var> is
not null, set that CSS property of <var>node</var> to <var>new
value</var>.
+ <li>If <var>command</var> is "strikethrough" and <var>new value</var> is
+ "line-through", alter the "text-decoration" property of <var>node</var>
+ to include "line-through" (preserving "overline" or "underline" if
+ present).
+
<li>If <var>command</var> is "underline" and <var>new value</var> is
"underline", alter the "text-decoration" property of <var>node</var> to
include "underline" (preserving "overline" or "line-through" if present).
@@ -1454,6 +1501,22 @@
<dd><strong>Relevant CSS Property</strong>: "font-style"
+<dt><code title><dfn title=command-strikethrough>strikethrough</dfn></code>
+
+<dd><strong>Action</strong>: <span>Decompose</span> the [[range]]. If the
+state of the [[range]] for this command is then true, <span>set the
+value</span> of each returned [[node]] to null. Otherwise, <span title="set
+the value">set their value</span> to "line-through".
+
+<p class=XXX>Has all the same problems as underline.
+
+<dd><strong>State</strong>: True if every [[text]] node that is
+<span>effectively contained</span> in the [[range]] has <span>effective
+value</span> "line-through". Otherwise false.
+
+<dd><strong>Value</strong>: Always the empty string.
+
+
<dt><code title><dfn title=command-stylewithcss>styleWithCSS</dfn></code>
<dd><strong>Action</strong>: Convert <var>value</var> to a boolean according