Add some commented-out algorithm changes
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 21 Mar 2011 12:08:09 -0600
changeset 20 43eb55543101
parent 19 281b2ec74d47
child 21 7b28dc5917ca
Add some commented-out algorithm changes

These would improve neatness a bit, but probably not worth the
complexity.
editcommands.html
source.html
--- a/editcommands.html	Mon Mar 21 12:06:18 2011 -0600
+++ b/editcommands.html	Mon Mar 21 12:08:09 2011 -0600
@@ -27,7 +27,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-18-march-2011>Work in Progress &mdash; Last Update 18 March 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-21-march-2011>Work in Progress &mdash; Last Update 21 March 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;ayg+spec@aryeh.name&gt;
@@ -379,8 +379,9 @@
 children won't change as they're unstyled.  If the element is removed, the
 algorithm will return the list of nodes inserted in its place.
 
-<p class=XXX>This should probably convert, e.g., &lt;font color=red id=foo&gt;
-into &lt;span id=foo&gt; instead of &lt;font id=foo&gt;.
+<!-- If we wanted to be extra-pedantic, we could convert, e.g., <font color=red
+id=foo> into <span id=foo> instead of <font id=foo>, but probably not worth it.
+-->
 
 <ol>
   <li>Let <var title="">element</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element><code class=external data-anolis-spec=domcore>Element</code></a> to be unstyled.
@@ -551,11 +552,70 @@
   element</a>:
 
   <ol>
+    <!-- Handle cases like bolding "bar" in "<i><b>Foo</b></i>bar".
+    Theoretically this algorithm could pointlessly reorganize the DOM in the
+    event of unreasonable style rules, but it's not a big enough deal for us to
+    care, probably. -->
+    <!-- This is probably more complicated than we want, given how likely this
+    is to come up, so I've commented it out for now.
+    <li>Let <var title>candidate</var> be <var title>node</var>'s <code data-anolis-spec=domcore title=dom-Node-previousSibling>previousSibling</code>.
+
+    <li>While <var title>candidate</var> is a <span>simple styling element</span>,
+    and <var title>candidate</var> has exactly one <span data-anolis-spec=domcore title=concept-tree-child>child</span>, and that <span data-anolis-spec=domcore title=concept-tree-child>child</span> is
+    also a <span>simple styling element</span>, and <var title>candidate</var>'s
+    <span>specified style</span> for <var title>property</var> is not <var title>new
+    value</var>, set <var title>candidate</var> to its <span data-anolis-spec=domcore title=concept-tree-child>child</span>.
+
+    <li>If <var title>candidate</var> is a <span>simple styling element</span> whose
+    <span>specified style</span> and computed style for <var title>property</var> are
+    both <var title>new value</var>, and <var title>candidate</var> is not the
+    <code data-anolis-spec=domcore title=dom-Node-previousSibling>previousSibling</code> of <var title>node</var>:
+
+    <ol>
+      <li>While <var title>candidate</var> has <span data-anolis-spec=domcore title=concept-tree-child>children</span>, append the first
+      <span data-anolis-spec=domcore title=concept-tree-child>child</span> of <var title>candidate</var> as the last <span data-anolis-spec=domcore title=concept-tree-child>child</span> of
+      <var title>candidate</var>'s <span data-anolis-spec=domcore title=concept-tree-parent>parent</span>.
+
+      <li>Insert <var title>candidate</var> into <var title>node</var>'s <span data-anolis-spec=domcore title=concept-tree-parent>parent</span> before
+      <var title>node</var>.
+
+      <li>Append the <code data-anolis-spec=domcore title=dom-Node-previousSibling>previousSibling</code> of <var title>candidate</var> as the last
+      <span data-anolis-spec=domcore title=concept-tree-child>child</span> of <var title>candidate</var>.
+    </ol>
+    -->
+
     <li>If <var title="">node</var>'s <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling><code class=external data-anolis-spec=domcore title=dom-Node-previousSibling>previousSibling</code></a> is a <a href=#simple-styling-element>simple styling
     element</a> whose <a href=#specified-style>specified style</a> and computed style for
     <var title="">property</var> are both <var title="">new value</var>, append <var title="">node</var>
     as the last <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 its <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling><code class=external data-anolis-spec=domcore title=dom-Node-previousSibling>previousSibling</code></a> and abort this algorithm.
 
+    <!--
+    <li>Let <var title>candidate</var> be <var title>node</var>'s <code data-anolis-spec=domcore title=dom-Node-nextSibling>nextSibling</code>.
+
+    <li>While <var title>candidate</var> is a <span>simple styling element</span>,
+    and <var title>candidate</var> has exactly one <span data-anolis-spec=domcore title=concept-tree-child>child</span>, and that <span data-anolis-spec=domcore title=concept-tree-child>child</span> is
+    also a <span>simple styling element</span>, and <var title>candidate</var>'s
+    <span>specified style</span> for <var title>property</var> is not <var title>new
+    value</var>, set <var title>candidate</var> to its <span data-anolis-spec=domcore title=concept-tree-child>child</span>.
+
+    <li>If <var title>candidate</var> is a <span>simple styling element</span> whose
+    <span>specified style</span> and computed style for <var title>property</var> are
+    both <var title>new value</var>, and <var title>candidate</var> is not the
+    <code data-anolis-spec=domcore title=dom-Node-nextSibling>nextSibling</code> of <var title>node</var>:
+
+    <ol>
+      <li>While <var title>candidate</var> has <span data-anolis-spec=domcore title=concept-tree-child>children</span>, append the first
+      <span data-anolis-spec=domcore title=concept-tree-child>child</span> of <var title>candidate</var> as the last <span data-anolis-spec=domcore title=concept-tree-child>child</span> of
+      <var title>candidate</var>'s <span data-anolis-spec=domcore title=concept-tree-parent>parent</span>.
+
+      <li>Insert <var title>candidate</var> into <var title>node</var>'s <span data-anolis-spec=domcore title=concept-tree-parent>parent</span> after
+      <var title>node</var>.
+
+      <li>Append the <code data-anolis-spec=domcore title=dom-Node-nextSibling>nextSibling</code> of <var title>candidate</var> as the last
+      <span data-anolis-spec=domcore title=concept-tree-child>child</span> of <var title>candidate</var>.
+    </ol>
+    -->
+
     <li>If <var title="">node</var>'s <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling><code class=external data-anolis-spec=domcore title=dom-Node-nextSibling>nextSibling</code></a> is a <a href=#simple-styling-element>simple styling
     element</a> whose <a href=#specified-style>specified style</a> and computed style for
     <var title="">property</var> are both <var title="">new value</var>, insert <var title="">node</var>
--- a/source.html	Mon Mar 21 12:06:18 2011 -0600
+++ b/source.html	Mon Mar 21 12:08:09 2011 -0600
@@ -374,8 +374,9 @@
 children won't change as they're unstyled.  If the element is removed, the
 algorithm will return the list of nodes inserted in its place.
 
-<p class=XXX>This should probably convert, e.g., &lt;font color=red id=foo>
-into &lt;span id=foo> instead of &lt;font id=foo>.
+<!-- If we wanted to be extra-pedantic, we could convert, e.g., <font color=red
+id=foo> into <span id=foo> instead of <font id=foo>, but probably not worth it.
+-->
 
 <ol>
   <li>Let <var>element</var> be the [[element]] to be unstyled.
@@ -547,11 +548,70 @@
   element</span>:
 
   <ol>
+    <!-- Handle cases like bolding "bar" in "<i><b>Foo</b></i>bar".
+    Theoretically this algorithm could pointlessly reorganize the DOM in the
+    event of unreasonable style rules, but it's not a big enough deal for us to
+    care, probably. -->
+    <!-- This is probably more complicated than we want, given how likely this
+    is to come up, so I've commented it out for now.
+    <li>Let <var>candidate</var> be <var>node</var>'s [[previoussibling]].
+
+    <li>While <var>candidate</var> is a <span>simple styling element</span>,
+    and <var>candidate</var> has exactly one [[child]], and that [[child]] is
+    also a <span>simple styling element</span>, and <var>candidate</var>'s
+    <span>specified style</span> for <var>property</var> is not <var>new
+    value</var>, set <var>candidate</var> to its [[child]].
+
+    <li>If <var>candidate</var> is a <span>simple styling element</span> whose
+    <span>specified style</span> and computed style for <var>property</var> are
+    both <var>new value</var>, and <var>candidate</var> is not the
+    [[previoussibling]] of <var>node</var>:
+
+    <ol>
+      <li>While <var>candidate</var> has [[children]], append the first
+      [[child]] of <var>candidate</var> as the last [[child]] of
+      <var>candidate</var>'s [[parent]].
+
+      <li>Insert <var>candidate</var> into <var>node</var>'s [[parent]] before
+      <var>node</var>.
+
+      <li>Append the [[previoussibling]] of <var>candidate</var> as the last
+      [[child]] of <var>candidate</var>.
+    </ol>
+    -->
+
     <li>If <var>node</var>'s [[previoussibling]] is a <span>simple styling
     element</span> whose <span>specified style</span> and computed style for
     <var>property</var> are both <var>new value</var>, append <var>node</var>
     as the last [[child]] of its [[previoussibling]] and abort this algorithm.
 
+    <!--
+    <li>Let <var>candidate</var> be <var>node</var>'s [[nextsibling]].
+
+    <li>While <var>candidate</var> is a <span>simple styling element</span>,
+    and <var>candidate</var> has exactly one [[child]], and that [[child]] is
+    also a <span>simple styling element</span>, and <var>candidate</var>'s
+    <span>specified style</span> for <var>property</var> is not <var>new
+    value</var>, set <var>candidate</var> to its [[child]].
+
+    <li>If <var>candidate</var> is a <span>simple styling element</span> whose
+    <span>specified style</span> and computed style for <var>property</var> are
+    both <var>new value</var>, and <var>candidate</var> is not the
+    [[nextsibling]] of <var>node</var>:
+
+    <ol>
+      <li>While <var>candidate</var> has [[children]], append the first
+      [[child]] of <var>candidate</var> as the last [[child]] of
+      <var>candidate</var>'s [[parent]].
+
+      <li>Insert <var>candidate</var> into <var>node</var>'s [[parent]] after
+      <var>node</var>.
+
+      <li>Append the [[nextsibling]] of <var>candidate</var> as the last
+      [[child]] of <var>candidate</var>.
+    </ol>
+    -->
+
     <li>If <var>node</var>'s [[nextsibling]] is a <span>simple styling
     element</span> whose <span>specified style</span> and computed style for
     <var>property</var> are both <var>new value</var>, insert <var>node</var>