Reduce redundant value forcing
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Wed, 21 Sep 2011 11:03:05 -0600
changeset 605 fc58c8a39346
parent 604 3e4ef15b11a2
child 606 e6c392856557
Reduce redundant value forcing

Previously, when setting the selection's value, we would force the value
of every editable effectively contained node. Now we skip any that
aren't allowed children of span, because it's redundant to force their
value. This saves a little work: gentest.html seems to run about 10%
faster (not rigorously tested).
editing.html
implementation.js
source.html
--- a/editing.html	Mon Sep 19 16:09:00 2011 -0600
+++ b/editing.html	Wed Sep 21 11:03:05 2011 -0600
@@ -65,7 +65,7 @@
 <body class=draft>
 <div class=head id=head>
 <h1>HTML Editing APIs</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-19-september-2011>Work in Progress &mdash; Last Update 19 September 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-21-september-2011>Work in Progress &mdash; Last Update 21 September 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;<a href=mailto:ayg@aryeh.name>ayg@aryeh.name</a>&gt;
@@ -3004,7 +3004,12 @@
   <ol>
     <li><a href=#push-down-values>Push down values</a> on <var title="">node</var>.
 
-    <li><a href=#force-the-value>Force the value</a> of <var title="">node</var>.
+    <li>
+    <p class=comments>If the node isn't an allowed child of "span", forcing its
+    value will just force its children's value, which is redundant.  So don't.
+
+    <p>If <var title="">node</var> is an <a href=#allowed-child>allowed child</a> of "span",
+    <a href=#force-the-value>force the value</a> of <var title="">node</var>.
   </ol>
 </ol>
 
--- a/implementation.js	Mon Sep 19 16:09:00 2011 -0600
+++ b/implementation.js	Wed Sep 21 11:03:05 2011 -0600
@@ -2997,8 +2997,10 @@
 		// "Push down values on node."
 		pushDownValues(node, command, newValue);
 
-		// "Force the value of node."
-		forceValue(node, command, newValue);
+		// "If node is an allowed child of span, force the value of node."
+		if (isAllowedChild(node, "span")) {
+			forceValue(node, command, newValue);
+		}
 	});
 }
 
--- a/source.html	Mon Sep 19 16:09:00 2011 -0600
+++ b/source.html	Wed Sep 21 11:03:05 2011 -0600
@@ -3013,7 +3013,12 @@
   <ol>
     <li><span>Push down values</span> on <var>node</var>.
 
-    <li><span>Force the value</span> of <var>node</var>.
+    <li>
+    <p class=comments>If the node isn't an allowed child of "span", forcing its
+    value will just force its children's value, which is redundant.  So don't.
+
+    <p>If <var>node</var> is an <span>allowed child</span> of "span",
+    <span>force the value</span> of <var>node</var>.
   </ol>
 </ol>