Resolve XXX
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 12 Jul 2011 14:26:22 -0600
changeset 400 b3d61e8688c6
parent 399 3f2d1b0bf985
child 401 f00446ef68a6
Resolve XXX

Also clean up some code while I'm there.
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Tue Jul 12 14:16:24 2011 -0600
+++ b/editcommands.html	Tue Jul 12 14:26:22 2011 -0600
@@ -5335,13 +5335,12 @@
   <!--
   At the beginning of an indented block, outdent it, similar to a list item.
   Browsers don't do this, word processors do.
+
+  Note: this copy-pastes from the outdent command action.
   -->
   <li>If <var title="">offset</var> is zero, and <var title="">node</var> has an
-  <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#ancestor-container title="ancestor container">ancestor container</a> that is both an <a href=#indentation-element>indentation element</a> and a
-  <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-descendant title=concept-tree-descendant>descendant</a> of <var title="">start node</var>:
-
-  <p class=XXX>This copy-pastes from the outdent command action.  I'm also not
-  totally sure it's correct.
+  <a href=#editable>editable</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#ancestor-container title="ancestor container">ancestor container</a> <a href=#in-the-same-editing-host>in the same editing
+  host</a> that's an <a href=#indentation-element>indentation element</a>:
 
   <ol>
     <li><a href=#block-extend>Block-extend</a> the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range title=concept-range>range</a> whose <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> and
--- a/implementation.js	Tue Jul 12 14:16:24 2011 -0600
+++ b/implementation.js	Tue Jul 12 14:26:22 2011 -0600
@@ -5554,21 +5554,14 @@
 			}
 		}
 
-		// "If offset is zero, and node has an ancestor container that is both
-		// an indentation element and a descendant of start node:"
-		var outdentableAncestor = false;
-		for (
-			var ancestor = node;
-			isDescendant(ancestor, startNode);
-			ancestor = ancestor.parentNode
-		) {
-			if (isIndentationElement(ancestor)) {
-				outdentableAncestor = true;
-				break;
-			}
-		}
+		// "If offset is zero, and node has an editable ancestor container in
+		// the same editing host that's an indentation element:"
 		if (offset == 0
-		&& outdentableAncestor) {
+		&& getAncestors(node).concat(node).filter(function(ancestor) {
+			return isEditable(ancestor)
+				&& inSameEditingHost(ancestor, node)
+				&& isIndentationElement(ancestor);
+		}).length) {
 			// "Block-extend the range whose start and end are both (node, 0),
 			// and let new range be the result."
 			var newRange = document.createRange();
--- a/source.html	Tue Jul 12 14:16:24 2011 -0600
+++ b/source.html	Tue Jul 12 14:26:22 2011 -0600
@@ -5328,13 +5328,12 @@
   <!--
   At the beginning of an indented block, outdent it, similar to a list item.
   Browsers don't do this, word processors do.
+
+  Note: this copy-pastes from the outdent command action.
   -->
   <li>If <var>offset</var> is zero, and <var>node</var> has an
-  [[ancestorcontainer]] that is both an <span>indentation element</span> and a
-  [[descendant]] of <var>start node</var>:
-
-  <p class=XXX>This copy-pastes from the outdent command action.  I'm also not
-  totally sure it's correct.
+  <span>editable</span> [[ancestorcontainer]] <span>in the same editing
+  host</span> that's an <span>indentation element</span>:
 
   <ol>
     <li><span>Block-extend</span> the [[range]] whose [[rangestart]] and