--- a/editcommands.html Tue Jun 14 12:45:15 2011 -0600
+++ b/editcommands.html Tue Jun 14 12:58:44 2011 -0600
@@ -5127,6 +5127,19 @@
the same as <var title="">range</var>'s, and whose <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-end title=concept-range-end>end</a> is
(<var title="">container</var>, <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-node-length title=concept-node-length>length</a> of <var title="">container</var>).
+ <!-- We don't want the start to be just inside a node, because if it is,
+ we'll leave behind an empty element either in the new or old container.
+ Clearly we don't want the start point to get any higher than the container
+ itself, though. -->
+ <li>While <var title="">new line range</var>'s <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-offset title=concept-boundary-point-offset>offset</a> is zero and its
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a> is not <var title="">container</var>, set its <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> to
+ (<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> of <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a>, <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-indexof title=concept-indexof>index</a> of <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a>).
+
+ <li>While <var title="">new line range</var>'s <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-offset title=concept-boundary-point-offset>offset</a> is the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-node-length title=concept-node-length>length</a>
+ of its <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a> and its <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a> is not <var title="">container</var>, set
+ its <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> to (<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> of <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a>, 1 + <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-indexof title=concept-indexof>index</a> of
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a>).
+
<li>Let <var title="">end of line</var> be true if <var title="">new line range</var> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#contained title=contained>contains</a> either nothing or a
single <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, and false otherwise.
--- a/implementation.js Tue Jun 14 12:45:15 2011 -0600
+++ b/implementation.js Tue Jun 14 12:58:44 2011 -0600
@@ -3975,6 +3975,22 @@
newLineRange.setStart(range.startContainer, range.startOffset);
newLineRange.setEnd(container, getNodeLength(container));
+ // "While new line range's start offset is zero and its start node is
+ // not container, set its start to (parent of start node, index of
+ // start node)."
+ while (newLineRange.startOffset == 0
+ && newLineRange.startContainer != container) {
+ newLineRange.setStart(newLineRange.startContainer.parentNode, getNodeIndex(newLineRange.startContainer));
+ }
+
+ // "While new line range's start offset is the length of its start node
+ // and its start node is not container, set its start to (parent of
+ // start node, 1 + index of start node)."
+ while (newLineRange.startOffset == getNodeLength(newLineRange.startContainer)
+ && newLineRange.startContainer != container) {
+ newLineRange.setStart(newLineRange.startContainer.parentNode, 1 + getNodeIndex(newLineRange.startContainer));
+ }
+
// "Let end of line be true if new line range contains either nothing
// or a single br, and false otherwise."
var containedInNewLineRange = collectContainedNodes(newLineRange);
--- a/source.html Tue Jun 14 12:45:15 2011 -0600
+++ b/source.html Tue Jun 14 12:58:44 2011 -0600
@@ -5147,6 +5147,19 @@
the same as <var>range</var>'s, and whose [[rangeend]] is
(<var>container</var>, [[nodelength]] of <var>container</var>).
+ <!-- We don't want the start to be just inside a node, because if it is,
+ we'll leave behind an empty element either in the new or old container.
+ Clearly we don't want the start point to get any higher than the container
+ itself, though. -->
+ <li>While <var>new line range</var>'s [[startoffset]] is zero and its
+ [[startnode]] is not <var>container</var>, set its [[rangestart]] to
+ ([[parent]] of [[startnode]], [[index]] of [[startnode]]).
+
+ <li>While <var>new line range</var>'s [[startoffset]] is the [[nodelength]]
+ of its [[startnode]] and its [[startnode]] is not <var>container</var>, set
+ its [[rangestart]] to ([[parent]] of [[startnode]], 1 + [[index]] of
+ [[startnode]]).
+
<li>Let <var>end of line</var> be true if <var>new line range</var> <span
data-anolis-spec=domrange title=contained>contains</span> either nothing or a
single [[br]], and false otherwise.
--- a/tests.js Tue Jun 14 12:45:15 2011 -0600
+++ b/tests.js Tue Jun 14 12:58:44 2011 -0600
@@ -1366,11 +1366,13 @@
'<b>foo[]bar</b>',
'<b>foo[]bar</b>baz',
'<b>foo[]</b>bar',
+ 'foo<b>[]bar</b>',
'<b>foo[]</b><i>bar</i>',
'<b id=x class=y>foo[]bar</b>',
'<i><b>foo[]bar</b>baz</i>',
'<p><b>foo[]bar</b></p>',
+ '<p><b>[]foo</b></p>',
'<p><b id=x class=y>foo[]bar</b></p>',
'<div><b>foo[]bar</b></div>'
],