--- a/autoimplementation.html Tue May 03 11:59:30 2011 -0600
+++ b/autoimplementation.html Tue May 03 12:28:26 2011 -0600
@@ -491,7 +491,7 @@
'foobar<br>[ba]z<p>extra',
'foobar<br><br><br><br>[ba]z<p>extra',
'foo[bar<br>ba]z<p>extra',
- '<div>foo<p>[bar]</div><p>extra',
+ '<div>foo<p>[bar]</p>baz</div><p>extra',
// These mimic existing indentation in various browsers, to see how
// they cope with indenting twice. This is Gecko non-CSS and Opera:
--- a/editcommands.html Tue May 03 11:59:30 2011 -0600
+++ b/editcommands.html Tue May 03 12:28:26 2011 -0600
@@ -622,20 +622,14 @@
node</var> to 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>Otherwise, if the <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>child</a> of <var title="">start node</var> with <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-indexof title=concept-indexof>index</a>
- <var title="">start offset</var> minus one is a <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, or an
- (insert definition here), subtract one from <var title="">start offset</var>.
-
- <p class=XXX>This is wrong if the child we're currently before is a block
- element. We should only decrement if the current and previous children are
- both inline. Also, should I just use <a href=#inline-node>inline node</a> here?
-
- <p class=XXX>The definition should include all inline elements except
- <br>. As elsewhere, we have trouble with the exact definition because
- HTML doesn't classify non-conforming elements, but those are common in
- editing and need to be handled correctly.
+ <var title="">start offset</var> and its <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> are both <a href=#inline-node title="inline node">inline nodes</a> and neither 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>, subtract
+ one from <var title="">start offset</var>.
<!-- IE also includes <br> (at least for the purposes of the indent
command), but this is unlikely to match user expectations. -->
+ <p class=XXX>This is wrong in the presence of comments or display: none or
+ probably other things. Do we care?
+
<li>Otherwise, break from this loop.
</ol>
@@ -652,10 +646,8 @@
node</var> and then set <var title="">end node</var> to 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>Otherwise, if the <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>child</a> of <var title="">end node</var> with <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-indexof title=concept-indexof>index</a>
- <var title="">end offset</var> is a <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, or an (insert
- definition here), add one to <var title="">end offset</var>.
-
- <p class=XXX>Same definition as before.
+ <var title="">end offset</var> and its <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> are both <a href=#inline-node title="inline node">inline nodes</a> and neither 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>, add one to
+ <var title="">end offset</var>.
<li>Otherwise, break from this loop.
</ol>
--- a/implementation.js Tue May 03 11:59:30 2011 -0600
+++ b/implementation.js Tue May 03 12:28:26 2011 -0600
@@ -1133,12 +1133,18 @@
startOffset = 1 + getNodeIndex(startNode);
startNode = startNode.parentNode;
- // "Otherwise, if the child of start node with index start offset
- // minus one is a Text or Comment node, or an (insert definition
- // here), subtract one from start offset."
- } else if (startNode.childNodes[startOffset - 1].nodeType == Node.TEXT_NODE
- || startNode.childNodes[startOffset - 1].nodeType == Node.COMMENT_NODE
- || ["B", "I", "SPAN"].indexOf(startNode.childNodes[startOffset - 1].tagName) != -1) {
+ // "Otherwise, if the child of start node with index start offset and
+ // its previousSibling are both inline nodes and neither is a br,
+ // subtract one from start offset."
+ } else if (isInlineNode(startNode.childNodes[startOffset])
+ && isInlineNode(startNode.childNodes[startOffset].previousSibling)
+ && (
+ !isHtmlElement(startNode.childNodes[startOffset])
+ || startNode.childNodes[startOffset].tagName != "BR"
+ ) && (
+ !isHtmlElement(startNode.childNodes[startOffset].previousSibling)
+ || startNode.childNodes[startOffset].previousSibling.tagName != "BR"
+ )) {
startOffset--;
// "Otherwise, break from this loop."
@@ -1164,12 +1170,18 @@
endOffset = 1 + getNodeIndex(endNode);
endNode = endNode.parentNode;
- // "Otherwise, if the child of end node with index end offset is a
- // Text or Comment node, or an (insert definition here), add one to
- // end offset."
- } else if (endNode.childNodes[endOffset].nodeType == Node.TEXT_NODE
- || endNode.childNodes[endOffset].nodeType == Node.COMMENT_NODE
- || ["B", "I", "SPAN"].indexOf(endNode.childNodes[endOffset].tagName) != -1) {
+ // "Otherwise, if the child of end node with index end offset and its
+ // previousSibling are both inline nodes and neither is a br, add one
+ // to end offset."
+ } else if (isInlineNode(endNode.childNodes[endOffset])
+ && isInlineNode(endNode.childNodes[endOffset].previousSibling)
+ && (
+ !isHtmlElement(endNode.childNodes[endOffset])
+ || endNode.childNodes[endOffset].tagName != "BR"
+ ) && (
+ !isHtmlElement(endNode.childNodes[endOffset].previousSibling)
+ || endNode.childNodes[endOffset].previousSibling.tagName != "BR"
+ )) {
endOffset++;
// "Otherwise, break from this loop."
--- a/source.html Tue May 03 11:59:30 2011 -0600
+++ b/source.html Tue May 03 12:28:26 2011 -0600
@@ -617,20 +617,15 @@
node</var> to its [[parent]].
<li>Otherwise, if the [[child]] of <var>start node</var> with [[index]]
- <var>start offset</var> minus one is a [[text]] or [[comment]] node, or an
- (insert definition here), subtract one from <var>start offset</var>.
-
- <p class=XXX>This is wrong if the child we're currently before is a block
- element. We should only decrement if the current and previous children are
- both inline. Also, should I just use <span>inline node</span> here?
-
- <p class=XXX>The definition should include all inline elements except
- <br>. As elsewhere, we have trouble with the exact definition because
- HTML doesn't classify non-conforming elements, but those are common in
- editing and need to be handled correctly.
+ <var>start offset</var> and its [[previoussibling]] are both <span
+ title="inline node">inline nodes</span> and neither is a [[br]], subtract
+ one from <var>start offset</var>.
<!-- IE also includes <br> (at least for the purposes of the indent
command), but this is unlikely to match user expectations. -->
+ <p class=XXX>This is wrong in the presence of comments or display: none or
+ probably other things. Do we care?
+
<li>Otherwise, break from this loop.
</ol>
@@ -647,10 +642,9 @@
node</var> and then set <var>end node</var> to its [[parent]].
<li>Otherwise, if the [[child]] of <var>end node</var> with [[index]]
- <var>end offset</var> is a [[text]] or [[comment]] node, or an (insert
- definition here), add one to <var>end offset</var>.
-
- <p class=XXX>Same definition as before.
+ <var>end offset</var> and its [[previoussibling]] are both <span
+ title="inline node">inline nodes</span> and neither is a [[br]], add one to
+ <var>end offset</var>.
<li>Otherwise, break from this loop.
</ol>