Define fontName value
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 28 Jun 2011 09:04:03 -0600
changeset 329 6f528b93014b
parent 328 c80d1fc8bafd
child 330 4ab4279f9fae
Define fontName value

No real interop here, but this definition mostly matches WebKit in
practice.
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Mon Jun 27 15:59:30 2011 -0600
+++ b/editcommands.html	Tue Jun 28 09:04:03 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-27-june-2011>Work in Progress &mdash; Last Update 27 June 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-28-june-2011>Work in Progress &mdash; Last Update 28 June 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;[email protected]&gt;
@@ -2151,8 +2151,7 @@
 understand CSS font-family syntax?), so I don't think such usability concerns
 apply. -->
 
-<p><a href=#value>Value</a>: The computed value of the CSS property "font-family" for
-. . .
+<p><a href=#value>Value</a>:
 <!-- Complicated.
 
 IE 9 RC: Always the empty string.  Not very useful.
@@ -2169,6 +2168,17 @@
 I'm just going to punt on this and say it should be the computed value of
 font-family.  I'll leave CSSOM to decide what that means if there are no
 applicable style rules. -->
+<ol>
+  <li>Let <var title="">node</var> be the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a> of the <a href=#active-range>active
+  range</a>.
+
+  <li>If <var title="">node</var> is not an <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>Element</a></code>, set <var title="">node</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>.
+
+  <li>If <var title="">node</var> is not an <code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#element>Element</a></code>, return the empty string.
+
+  <li>Return the <a href=http://www.w3.org/TR/CSS21/cascade.html#computed-value>computed value</a> of "font-family" for <var title="">node</var>.
+</ol>
 
 <p><a href=#relevant-css-property>Relevant CSS property</a>: "font-family"
 
--- a/implementation.js	Mon Jun 27 15:59:30 2011 -0600
+++ b/implementation.js	Tue Jun 28 09:04:03 2011 -0600
@@ -2684,6 +2684,22 @@
 		for (var i = 0; i < nodeList.length; i++) {
 			setNodeValue(nodeList[i], "fontname", value);
 		}
+	}, value: function() {
+		// "Let node be the start node of the active range."
+		var node = getActiveRange().startContainer;
+
+		// "If node is not an Element, set node to its parent."
+		if (node.nodeType != Node.ELEMENT_NODE) {
+			node = node.parentNode;
+		}
+
+		// "If node is not an Element, return the empty string."
+		if (node.nodeType != Node.ELEMENT_NODE) {
+			return "";
+		}
+
+		// "Return the computed value of "font-family" for node."
+		return getComputedStyle(node).fontFamily;
 	}, relevantCssProperty: "fontFamily"
 };
 //@}
--- a/source.html	Mon Jun 27 15:59:30 2011 -0600
+++ b/source.html	Tue Jun 28 09:04:03 2011 -0600
@@ -2127,8 +2127,7 @@
 understand CSS font-family syntax?), so I don't think such usability concerns
 apply. -->
 
-<p><span>Value</span>: The computed value of the CSS property "font-family" for
-. . .
+<p><span>Value</span>:
 <!-- Complicated.
 
 IE 9 RC: Always the empty string.  Not very useful.
@@ -2145,6 +2144,17 @@
 I'm just going to punt on this and say it should be the computed value of
 font-family.  I'll leave CSSOM to decide what that means if there are no
 applicable style rules. -->
+<ol>
+  <li>Let <var>node</var> be the [[startnode]] of the <span>active
+  range</span>.
+
+  <li>If <var>node</var> is not an [[element]], set <var>node</var> to its
+  [[parent]].
+
+  <li>If <var>node</var> is not an [[element]], return the empty string.
+
+  <li>Return the [[compval]] of "font-family" for <var>node</var>.
+</ol>
 
 <p><span>Relevant CSS property</span>: "font-family"
 <!-- @} -->
--- a/tests.js	Mon Jun 27 15:59:30 2011 -0600
+++ b/tests.js	Tue Jun 28 09:04:03 2011 -0600
@@ -545,6 +545,12 @@
 		'foo<span style="font-family: sans-serif">b[a]r</span>baz',
 		'foo<span style="font-family: monospace">[bar]</span>baz',
 		'foo<span style="font-family: monospace">b[a]r</span>baz',
+
+		'foo<tt contenteditable=false>ba[r</tt>b]az',
+		'fo[o<tt contenteditable=false>b]ar</tt>baz',
+		'foo<tt>{}<br></tt>bar',
+		'foo<tt>{<br></tt>}bar',
+		'foo<tt>{<br></tt>b]ar',
 	],
 	//@}
 	fontsize: [