Minor adjustments
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 23 Jun 2011 11:01:19 -0600
changeset 311 9495a6858c2f
parent 310 0278f12af2f4
child 312 99fc7f229637
Minor adjustments
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Wed Jun 22 13:42:55 2011 -0600
+++ b/editcommands.html	Thu Jun 23 11:01:19 2011 -0600
@@ -38,7 +38,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-22-june-2011>Work in Progress &mdash; Last Update 22 June 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-23-june-2011>Work in Progress &mdash; Last Update 23 June 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;ayg+spec@aryeh.name&gt;
@@ -285,11 +285,10 @@
   worried about throwing nodes away and recreating them multiple times or
   things like that, as long as it produces the correct result.
 
-  <li>I need to pay more attention to whitespace-only nodes.  In most cases
-  these will have no visual effect, but they'll make many algorithms behave
-  differently: decomposing a range, block-extending, etc.  In at least some
-  cases, it's not even possible for the cursor to wind up in them, so maybe we
-  don't need to bother marking them up or anything.
+  <li>I need to pay more attention to invisible nodes.  These will have no
+  visual effect, but they'll make many algorithms behave differently:
+  decomposing a range, block-extending, etc.  Also, need to improve the
+  definition to include things like whitespace-only nodes.
 
   <li>Tim Down <a href=http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-May/031655.html>points
   out</a> that browsers have special behavior for formatting commands when the
--- a/implementation.js	Wed Jun 22 13:42:55 2011 -0600
+++ b/implementation.js	Thu Jun 23 11:01:19 2011 -0600
@@ -676,11 +676,17 @@
 	}
 	var space = document.createTextNode("\u200b");
 	var origHeight = ref.offsetHeight;
+	if (origHeight == 0) {
+		throw "isCollapsedLineBreak: original height is zero, bug?";
+	}
 	br.parentNode.insertBefore(space, br.nextSibling);
 	var finalHeight = ref.offsetHeight;
 	space.parentNode.removeChild(space);
 
-	return origHeight != finalHeight;
+	// Allow some leeway in case the zwsp didn't create a whole new line, but
+	// only made an existing line slightly higher.  Firefox 6.0a2 shows this
+	// behavior when the first line is bold.
+	return origHeight < finalHeight - 5;
 }
 
 // "An extraneous line break is a br that has no visual effect, in that
@@ -702,6 +708,9 @@
 	}
 	var style = br.hasAttribute("style") ? br.getAttribute("style") : null;
 	var origHeight = ref.offsetHeight;
+	if (origHeight == 0) {
+		throw "isExtraneousLineBreak: original height is zero, bug?";
+	}
 	br.setAttribute("style", "display:none");
 	var finalHeight = ref.offsetHeight;
 	if (style === null) {
--- a/source.html	Wed Jun 22 13:42:55 2011 -0600
+++ b/source.html	Thu Jun 23 11:01:19 2011 -0600
@@ -221,11 +221,10 @@
   worried about throwing nodes away and recreating them multiple times or
   things like that, as long as it produces the correct result.
 
-  <li>I need to pay more attention to whitespace-only nodes.  In most cases
-  these will have no visual effect, but they'll make many algorithms behave
-  differently: decomposing a range, block-extending, etc.  In at least some
-  cases, it's not even possible for the cursor to wind up in them, so maybe we
-  don't need to bother marking them up or anything.
+  <li>I need to pay more attention to invisible nodes.  These will have no
+  visual effect, but they'll make many algorithms behave differently:
+  decomposing a range, block-extending, etc.  Also, need to improve the
+  definition to include things like whitespace-only nodes.
 
   <li>Tim Down <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-May/031655.html">points
   out</a> that browsers have special behavior for formatting commands when the
--- a/tests.js	Wed Jun 22 13:42:55 2011 -0600
+++ b/tests.js	Thu Jun 23 11:01:19 2011 -0600
@@ -274,6 +274,7 @@
 		'<span>foo</span>{}<span>bar</span>',
 		'<span>foo[</span><span>]bar</span>',
 		'foo<span style=display:none>bar</span>[]baz',
+		'foo<script>bar</script>[]baz',
 		'fo&ouml;[]bar',
 		'foo&#x308;[]bar',
 
@@ -913,6 +914,7 @@
 		'<span>foo</span>{}<span>bar</span>',
 		'<span>foo[</span><span>]bar</span>',
 		'foo[]<span style=display:none>bar</span>baz',
+		'foo[]<script>bar</script>baz',
 		'fo[]&ouml;bar',
 		'fo[]o&#x308;bar',
 
@@ -1764,6 +1766,7 @@
 
 		'<xmp>foo[]bar</xmp>',
 		'<script>foo[]bar</script>baz',
+		'<div style=display:none>foo[]bar</div>baz',
 
 		'<ol><li>{}<br></li></ol>',
 		'foo<ol><li>{}<br></li></ol>',