Tweak outdent algorithm
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 22 May 2011 10:29:54 -0600
changeset 151 ed637dfa594b
parent 150 db7f8b7096f5
child 152 e9727d01a508
Tweak outdent algorithm

This makes the test case
<blockquote><ol><li>foo</li><ol><li>[bar]</li></ol><li>baz</li></ol></blockquote>
behave reasonably.
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Thu May 19 14:38:40 2011 -0600
+++ b/editcommands.html	Sun May 22 10:29:54 2011 -0600
@@ -35,7 +35,7 @@
 <body class=draft>
 <div class=head id=head>
 <h1>HTML Editing Commands</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-19-may-2011>Work in Progress &mdash; Last Update 19 May 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-22-may-2011>Work in Progress &mdash; Last Update 22 May 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;[email protected]&gt;
@@ -3130,12 +3130,15 @@
     <var title="">current ancestor</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>.
   </ol>
 
-  <li>If <var title="">current ancestor</var> is not an <a href=#editable>editable</a>
-  <a href=#potential-indentation-element>potential indentation element</a>, and <var title="">node</var> is an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>
-  or <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>:
-  <!-- This matches IE9 and Firefox 4.0.  When asked to outdent a list wrapped
-  in an indentation element, Chrome 12 dev removes the list instead of the
-  indentation element.  Opera 11.10 seems to remove both. -->
+  <li>If <var title="">node</var> is an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code> or <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>, and either <var title="">current
+  ancestor</var> is not an <a href=#editable>editable</a> <a href=#potential-indentation-element>potential indentation
+  element</a> or <var title="">node</var>'s <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> is an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code> or <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>:
+  <!--
+  When asked to outdent a list wrapped in an indentation element, Chrome 12 dev
+  removes the list instead of the indentation element.  Opera 11.10 seems to
+  remove both.  IE9 and Firefox 4.0 remove the indentation element, as does the
+  spec.
+  -->
 
   <div class=XXX>
   <p>We don't handle a case like
@@ -3155,6 +3158,10 @@
   here.
   -->
 
+  <p class=XXX>What about if node isn't a child of a list, but there's a list
+  ancestor below current ancestor?  Is that even possible given how the
+  block-extend algorithm works?
+
   <ol>
     <li>Unset the <code class=external data-anolis-spec=html title=attr-ol-reversed><a href=http://www.whatwg.org/html/#attr-ol-reversed>reversed</a></code>, <code class=external data-anolis-spec=html title=attr-ol-start><a href=http://www.whatwg.org/html/#attr-ol-start>start</a></code>, and <code class=external data-anolis-spec=html title=attr-ol-type><a href=http://www.whatwg.org/html/#attr-ol-type>type</a></code> attributes of <var title="">node</var>, if any are
     set.
--- a/implementation.js	Thu May 19 14:38:40 2011 -0600
+++ b/implementation.js	Sun May 22 10:29:54 2011 -0600
@@ -3241,11 +3241,12 @@
 		}
 	}
 
-	// "If current ancestor is not an editable potential indentation element,
-	// and node is an ol or ul:"
-	if ((!isEditable(currentAncestor)
-	|| !isPotentialIndentationElement(currentAncestor))
-	&& isHtmlElement(node, ["OL", "UL"])) {
+	// "If node is an ol or ul, and either current ancestor is not an editable
+	// potential indentation element or node's parent is an ol or ul:"
+	if (isHtmlElement(node, ["OL", "UL"])
+	&& (!isEditable(currentAncestor)
+	|| !isPotentialIndentationElement(currentAncestor)
+	|| isHtmlElement(node.parentNode, ["OL", "UL"]))) {
 		// "Unset the reversed, start, and type attributes of node, if any are
 		// set."
 		node.removeAttribute("reversed");
--- a/source.html	Thu May 19 14:38:40 2011 -0600
+++ b/source.html	Sun May 22 10:29:54 2011 -0600
@@ -3177,12 +3177,15 @@
     <var>current ancestor</var> to its [[parent]].
   </ol>
 
-  <li>If <var>current ancestor</var> is not an <span>editable</span>
-  <span>potential indentation element</span>, and <var>node</var> is an [[ol]]
-  or [[ul]]:
-  <!-- This matches IE9 and Firefox 4.0.  When asked to outdent a list wrapped
-  in an indentation element, Chrome 12 dev removes the list instead of the
-  indentation element.  Opera 11.10 seems to remove both. -->
+  <li>If <var>node</var> is an [[ol]] or [[ul]], and either <var>current
+  ancestor</var> is not an <span>editable</span> <span>potential indentation
+  element</span> or <var>node</var>'s [[parent]] is an [[ol]] or [[ul]]:
+  <!--
+  When asked to outdent a list wrapped in an indentation element, Chrome 12 dev
+  removes the list instead of the indentation element.  Opera 11.10 seems to
+  remove both.  IE9 and Firefox 4.0 remove the indentation element, as does the
+  spec.
+  -->
 
   <div class=XXX>
   <p>We don't handle a case like
@@ -3202,6 +3205,10 @@
   here.
   -->
 
+  <p class=XXX>What about if node isn't a child of a list, but there's a list
+  ancestor below current ancestor?  Is that even possible given how the
+  block-extend algorithm works?
+
   <ol>
     <li>Unset the <code data-anolis-spec=html
     title=attr-ol-reversed>reversed</code>, <code data-anolis-spec=html