Allow deleting non-active ranges
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 06 Jun 2011 15:19:17 -0600
changeset 235 a2e02a210ef7
parent 234 28b09cd8c691
child 236 cd5324fd83c5
Allow deleting non-active ranges
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Mon Jun 06 15:08:36 2011 -0600
+++ b/editcommands.html	Mon Jun 06 15:19:17 2011 -0600
@@ -931,7 +931,7 @@
   <li>Return <var title="">new parent</var>.
 </ol>
 
-<p>To <dfn id=delete-the-selection>delete the selection</dfn>:
+<p>To <dfn id=delete-the-contents>delete the contents</dfn> of a <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a> <var title="">range</var>:
 
 <p class=XXX>I'm uncertain about the use of prohibited paragraph children here.
 I'm using it mostly because it's convenient and seems relatively sensible.  If
@@ -944,8 +944,6 @@
 the table itself.
 
 <ol>
-  <li>Let <var title="">range</var> be the <a href=#active-range>active range</a>.
-
   <li>If <var title="">range</var> is null, abort these steps and do nothing.
 
   <li>Let <var title="">start node</var>, <var title="">start offset</var>, <var title="">end node</var>,
@@ -2431,8 +2429,8 @@
 <p><a href=#action>Action</a>:
 
 <ol>
-  <li>If the <a href=#active-range>active range</a> is not <code class=external data-anolis-spec=domrange title=dom-Range-collapsed><a href=http://html5.org/specs/dom-range.html#dom-range-collapsed>collapsed</a></code>, <a href=#delete-the-selection>delete the selection</a>
-  and abort these steps.
+  <li>If the <a href=#active-range>active range</a> is not <code class=external data-anolis-spec=domrange title=dom-Range-collapsed><a href=http://html5.org/specs/dom-range.html#dom-range-collapsed>collapsed</a></code>, <a href=#delete-the-contents>delete the contents</a>
+  of the <a href=#active-range>active range</a> and abort these steps.
 
   <p class=XXX>Maybe we sometimes want to do the following even if it isn't
   collapsed?  WebKit seems to do some normalization on the range before
@@ -2728,7 +2726,7 @@
 <p><a href=#action>Action</a>:
 
 <ol>
-  <li><a href=#delete-the-selection>Delete the selection</a>.
+  <li><a href=#delete-the-contents>Delete the contents</a> of the <a href=#active-range>active range</a>.
 
   <li>Let <var title="">frag</var> be the result of calling <code class=external data-anolis-spec=domps title=dom-Range-createContextualFragment><a href=http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragment>createContextualFragment(<var title="">value</var>)</a></code>
   on the <a href=#active-range>active range</a>.
@@ -2767,7 +2765,7 @@
 
   <li>Let <var title="">range</var> be the <a href=#active-range>active range</a>.
 
-  <li><a href=#delete-the-selection>Delete the selection</a>.
+  <li><a href=#delete-the-contents>Delete the contents</a> of the <a href=#active-range>active range</a>.
 
   <li>Let <var title="">img</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("img")</a></code> on the
   <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
@@ -4680,7 +4678,7 @@
 <p><a href=#action>Action</a>:
 
 <ol>
-  <li><a href=#delete-the-selection>Delete the selection</a>.
+  <li><a href=#delete-the-contents>Delete the contents</a> of the <a href=#active-range>active range</a>.
 
   <li>Let <var title="">range</var> be the <a href=#active-range>active range</a>.
 
--- a/implementation.js	Mon Jun 06 15:08:36 2011 -0600
+++ b/implementation.js	Mon Jun 06 15:19:17 2011 -0600
@@ -767,10 +767,7 @@
 	return null;
 }
 
-function deleteSelection() {
-	// "Let range be the active range."
-	var range = globalRange;
-
+function deleteContents(range) {
 	// "If range is null, abort these steps and do nothing."
 	if (!range) {
 		return;
@@ -3111,10 +3108,10 @@
 		break;
 
 		case "delete":
-		// "If the active range is not collapsed, delete the selection and
-		// abort these steps."
+		// "If the active range is not collapsed, delete the contents of the
+		// active range and abort these steps."
 		if (!range.collapsed) {
-			deleteSelection();
+			deleteContents(range);
 			return;
 		}
 		break;
@@ -3401,8 +3398,8 @@
 		break;
 
 		case "inserthtml":
-		// "Delete the selection."
-		deleteSelection();
+		// "Delete the contents of the active range."
+		deleteContents(range);
 
 		// "Let frag be the result of calling createContextualFragment(value)
 		// on the active range."
@@ -3436,8 +3433,8 @@
 			return;
 		}
 
-		// "Delete the selection."
-		deleteSelection();
+		// "Delete the contents of the active range."
+		deleteContents(activeRange);
 
 		// "Let img be the result of calling createElement("img") on the
 		// context object."
@@ -3473,8 +3470,8 @@
 		break;
 
 		case "insertparagraph":
-		// "Delete the selection."
-		deleteSelection();
+		// "Delete the contents of the active range."
+		deleteContents(activeRange);
 
 		// "Let node and offset be range's start node and offset."
 		var node = range.startContainer;
--- a/source.html	Mon Jun 06 15:08:36 2011 -0600
+++ b/source.html	Mon Jun 06 15:19:17 2011 -0600
@@ -891,7 +891,7 @@
   <li>Return <var>new parent</var>.
 </ol>
 
-<p>To <dfn>delete the selection</dfn>:
+<p>To <dfn>delete the contents</dfn> of a [[range]] <var>range</var>:
 
 <p class=XXX>I'm uncertain about the use of prohibited paragraph children here.
 I'm using it mostly because it's convenient and seems relatively sensible.  If
@@ -904,8 +904,6 @@
 the table itself.
 
 <ol>
-  <li>Let <var>range</var> be the <span>active range</span>.
-
   <li>If <var>range</var> is null, abort these steps and do nothing.
 
   <li>Let <var>start node</var>, <var>start offset</var>, <var>end node</var>,
@@ -2416,8 +2414,8 @@
 
 <ol>
   <li>If the <span>active range</span> is not <code data-anolis-spec=domrange
-  title=dom-Range-collapsed>collapsed</code>, <span>delete the selection</span>
-  and abort these steps.
+  title=dom-Range-collapsed>collapsed</code>, <span>delete the contents</span>
+  of the <span>active range</span> and abort these steps.
 
   <p class=XXX>Maybe we sometimes want to do the following even if it isn't
   collapsed?  WebKit seems to do some normalization on the range before
@@ -2713,7 +2711,7 @@
 <p><span>Action</span>:
 
 <ol>
-  <li><span>Delete the selection</span>.
+  <li><span>Delete the contents</span> of the <span>active range</span>.
 
   <li>Let <var>frag</var> be the result of calling <code data-anolis-spec=domps
   title=dom-Range-createContextualFragment>createContextualFragment(<var>value</var>)</code>
@@ -2753,7 +2751,7 @@
 
   <li>Let <var>range</var> be the <span>active range</span>.
 
-  <li><span>Delete the selection</span>.
+  <li><span>Delete the contents</span> of the <span>active range</span>.
 
   <li>Let <var>img</var> be the result of calling <code
   data-anolis-spec=domcore
@@ -4703,7 +4701,7 @@
 <p><span>Action</span>:
 
 <ol>
-  <li><span>Delete the selection</span>.
+  <li><span>Delete the contents</span> of the <span>active range</span>.
 
   <li>Let <var>range</var> be the <span>active range</span>.