Fix a couple of fontSize bugs
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Fri, 16 Sep 2011 12:43:38 -0600
changeset 586 3c450adef205
parent 585 12706b7f7471
child 587 846e125a5e07
Fix a couple of fontSize bugs

One typo (missing brackets in implementation) and one thinko (assuming
value override is suitable for passing as value argument to
execCommand).
conformancetest/data.js
editing.html
implementation.js
source.html
--- a/conformancetest/data.js	Fri Sep 16 13:33:19 2011 -0600
+++ b/conformancetest/data.js	Fri Sep 16 12:43:38 2011 -0600
@@ -9461,11 +9461,11 @@
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<sub><font size=2>[bar]</font></sub>baz",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub>a[]</sub>baz",
+	"foo<sub><font size=\"2\">a[]</font></sub>baz",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<font size=2><sub>[bar]</sub></font>baz",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub><font size=\"1\">a[]</font></sub>baz",
+	"foo<font size=\"2\"><sub>a[]</sub></font>baz",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<sub><font size=3>[bar]</font></sub>baz",
 	[["stylewithcss","false"],["inserttext","a"]],
@@ -9473,7 +9473,7 @@
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<font size=3><sub>[bar]</sub></font>baz",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub>a[]</sub>baz",
+	"foo<font size=\"3\"><sub>a[]</sub></font>baz",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["[foo<b>bar]</b>baz",
 	[["stylewithcss","false"],["inserttext","a"]],
@@ -9637,11 +9637,11 @@
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<sub><font size=2>[bar</font></sub>baz]",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub>a[]</sub>",
+	"foo<sub><font size=\"2\">a[]</font></sub>",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<font size=2><sub>[bar</sub></font>baz]",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub><font size=\"1\">a[]</font></sub>",
+	"foo<font size=\"2\"><sub>a[]</sub></font>",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<sub><font size=3>[bar</font></sub>baz]",
 	[["stylewithcss","false"],["inserttext","a"]],
@@ -9649,7 +9649,7 @@
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["foo<font size=3><sub>[bar</sub></font>baz]",
 	[["stylewithcss","false"],["inserttext","a"]],
-	"foo<sub>a[]</sub>",
+	"foo<font size=\"3\"><sub>a[]</sub></font>",
 	{"stylewithcss":[null,false,null,null,false,null],"inserttext":[null,null,null,null,null,null]}],
 ["<blockquote><font color=blue>[foo]</font></blockquote>",
 	[["stylewithcss","false"],["inserttext","a"]],
--- a/editing.html	Fri Sep 16 13:33:19 2011 -0600
+++ b/editing.html	Fri Sep 16 12:43:38 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-15-september-2011>Work in Progress &mdash; Last Update 15 September 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-16-september-2011>Work in Progress &mdash; Last Update 16 September 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;<a href=mailto:[email protected]>[email protected]</a>&gt;
@@ -4483,7 +4483,7 @@
     <li>
     <p class=comments>This special case is needed because <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=14067">createLink has no
     value</a>.
-    
+
     <p>Otherwise, if <var title="">override</var> is a string; and <var title="">command</var>
     is "createLink"; and either there is a <a href=#value-override>value override</a> for
     "createLink" that is not equal to <var title="">override</var>, or there is no
@@ -4492,13 +4492,23 @@
     <var title="">override</var>: call <code title=execCommand()><a href=#execcommand()>execCommand("createLink", false,
     <var title="">override</var>)</a></code>.
 
-    <li>Otherwise, if <var title="">override</var> is a string; and <var title="">command</var>
-    is "fontSize"; and either there is a <a href=#value-override>value override</a> for
+    <li>
+    <p class=comments>The override will be some CSS value, so we have to
+    convert it to a legacy font size.
+
+    <p>Otherwise, if <var title="">override</var> is a string; and <var title="">command</var> is
+    "fontSize"; and either there is a <a href=#value-override>value override</a> for
     "fontSize" that is not equal to <var title="">override</var>, or there is no
     <a href=#value-override>value override</a> for "fontSize" and <var title="">node</var>'s
     <a href=#effective-command-value>effective command value</a> for "fontSize" is not
-    <a href=#loosely-equivalent-values title="loosely equivalent values">loosely equivalent</a> to <var title="">override</var>: call
-    <code title=execCommand()><a href=#execcommand()>execCommand("fontSize", false, <var title="">override</var>)</a></code>.
+    <a href=#loosely-equivalent-values title="loosely equivalent values">loosely equivalent</a> to <var title="">override</var>:
+
+    <ol>
+      <li>Convert <var title="">override</var> to an integer number of pixels, and set
+      <var title="">override</var> to the <a href=#legacy-font-size-for>legacy font size for</a> the result.
+
+      <li>Call <code title=execCommand()><a href=#execcommand()>execCommand("fontSize", false, <var title="">override</var>)</a></code>.
+    </ol>
 
     <li>Otherwise, continue this loop from the beginning.
 
--- a/implementation.js	Fri Sep 16 13:33:19 2011 -0600
+++ b/implementation.js	Fri Sep 16 12:43:38 2011 -0600
@@ -4248,7 +4248,7 @@
 
 	// "Add ("fontSize", node's effective command value for "fontSize") to
 	// overrides."
-	overrides.push("fontsize", getEffectiveCommandValue(node, "fontsize"));
+	overrides.push(["fontsize", getEffectiveCommandValue(node, "fontsize")]);
 
 	// "Return overrides."
 	return overrides;
@@ -4307,8 +4307,7 @@
 			// and either there is a value override for "fontSize" that is not
 			// equal to override, or there is no value override for "fontSize"
 			// and node's effective command value for "fontSize" is not loosely
-			// equivalent to override: call execCommand("fontSize", false,
-			// override)."
+			// equivalent to override:"
 			} else if (typeof override == "string"
 			&& command == "fontsize"
 			&& (
@@ -4320,6 +4319,11 @@
 					&& !areLooselyEquivalentValues(command, getEffectiveCommandValue(node, "fontsize"), override)
 				)
 			)) {
+				// "Convert override to an integer number of pixels, and set
+				// override to the legacy font size for the result."
+				override = getLegacyFontSize(override);
+
+				// "Call execCommand("fontSize", false, override)."
 				myExecCommand("fontsize", false, override);
 
 			// "Otherwise, continue this loop from the beginning."
--- a/source.html	Fri Sep 16 13:33:19 2011 -0600
+++ b/source.html	Fri Sep 16 12:43:38 2011 -0600
@@ -4509,7 +4509,7 @@
     <p class=comments>This special case is needed because <a
     href=http://www.w3.org/Bugs/Public/show_bug.cgi?id=14067>createLink has no
     value</a>.
-    
+
     <p>Otherwise, if <var>override</var> is a string; and <var>command</var>
     is "createLink"; and either there is a <span>value override</span> for
     "createLink" that is not equal to <var>override</var>, or there is no
@@ -4518,13 +4518,23 @@
     <var>override</var>: call [[execcommand|"createLink", false,
     <var>override</var>]].
 
-    <li>Otherwise, if <var>override</var> is a string; and <var>command</var>
-    is "fontSize"; and either there is a <span>value override</span> for
+    <li>
+    <p class=comments>The override will be some CSS value, so we have to
+    convert it to a legacy font size.
+
+    <p>Otherwise, if <var>override</var> is a string; and <var>command</var> is
+    "fontSize"; and either there is a <span>value override</span> for
     "fontSize" that is not equal to <var>override</var>, or there is no
     <span>value override</span> for "fontSize" and <var>node</var>'s
     <span>effective command value</span> for "fontSize" is not
-    [[looselyequivalent]] to <var>override</var>: call
-    [[execcommand|"fontSize", false, <var>override</var>]].
+    [[looselyequivalent]] to <var>override</var>:
+
+    <ol>
+      <li>Convert <var>override</var> to an integer number of pixels, and set
+      <var>override</var> to the <span>legacy font size for</span> the result.
+
+      <li>Call [[execcommand|"fontSize", false, <var>override</var>]].
+    </ol>
 
     <li>Otherwise, continue this loop from the beginning.