Define indeterm for hiliteColor
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 28 Jun 2011 15:39:29 -0600
changeset 341 b83b7d617b9b
parent 340 b2c785beb965
child 342 c056a604c764
Define indeterm for hiliteColor
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Tue Jun 28 15:29:19 2011 -0600
+++ b/editcommands.html	Tue Jun 28 15:39:29 2011 -0600
@@ -2521,6 +2521,13 @@
   value</a> of each returned <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> to <var title="">value</var>.
 </ol>
 
+<p><a href=#indeterminate-flag>Indeterminate flag</a>: True if among <a href=#editable>editable</a>
+<code class=external data-anolis-spec=domcore><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code> nodes that are <a href=#effectively-contained>effectively contained</a> in the <a href=#active-range>active
+range</a>, there are two that have distinct <a href=#effective-value title="effective
+value">effective values</a>.  Otherwise false.
+<!-- This follows no one.  Firefox 6.0a2 and Chrome 14 dev both always return
+false.  However, it makes sense. -->
+
 <p><a href=#value>Value</a>: The <a href=#effective-value>effective value</a> of the <a href=#active-range>active
 range</a>'s <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>.
 
--- a/implementation.js	Tue Jun 28 15:29:19 2011 -0600
+++ b/implementation.js	Tue Jun 28 15:39:29 2011 -0600
@@ -2975,6 +2975,17 @@
 		for (var i = 0; i < nodeList.length; i++) {
 			setNodeValue(nodeList[i], "hilitecolor", value);
 		}
+	}, indeterm: function() {
+		// "True if among editable Text nodes that are effectively contained in
+		// the active range, there are two that have distinct effective values.
+		// Otherwise false."
+		return collectAllEffectivelyContainedNodes(getActiveRange(), function(node) {
+			return isEditable(node) && node.nodeType == Node.TEXT_NODE;
+		}).map(function(node) {
+			return getEffectiveValue(node, "hilitecolor");
+		}).filter(function(value, i, arr) {
+			return arr.slice(0, i).indexOf(value) == -1;
+		}).length >= 2;
 	}, value: function() {
 		// "The effective value of the active range's start node."
 		//
--- a/source.html	Tue Jun 28 15:29:19 2011 -0600
+++ b/source.html	Tue Jun 28 15:39:29 2011 -0600
@@ -2497,6 +2497,13 @@
   value</span> of each returned [[node]] to <var>value</var>.
 </ol>
 
+<p><span>Indeterminate flag</span>: True if among <span>editable</span>
+[[text]] nodes that are <span>effectively contained</span> in the <span>active
+range</span>, there are two that have distinct <span title="effective
+value">effective values</span>.  Otherwise false.
+<!-- This follows no one.  Firefox 6.0a2 and Chrome 14 dev both always return
+false.  However, it makes sense. -->
+
 <p><span>Value</span>: The <span>effective value</span> of the <span>active
 range</span>'s [[startnode]].
 
--- a/tests.js	Tue Jun 28 15:29:19 2011 -0600
+++ b/tests.js	Tue Jun 28 15:39:29 2011 -0600
@@ -1272,6 +1272,19 @@
 		'<p style="background-color: #ff8888">foo<span style="background-color: aqua">b[ar]</span>baz</p>',
 		'<div style="background-color: #ff8888"><p style="background-color: aqua">b[ar]</p></div>',
 		'<span style="display: block; background-color: #ff8888"><span style="display: block; background-color: aqua">b[ar]</span></span>',
+
+		// Tests for queryCommandIndeterm() and queryCommandState()
+		'fo[o<span style=background-color:aqua>b]ar</span>baz',
+		'foo<span style=background-color:aqua>ba[r</span>b]az',
+		'fo[o<span style=background-color:aqua>bar</span>b]az',
+		'foo[<span style=background-color:aqua>b]ar</span>baz',
+		'foo<span style=background-color:aqua>ba[r</span>]baz',
+		'foo[<span style=background-color:aqua>bar</span>]baz',
+		'foo<span style=background-color:aqua>[bar]</span>baz',
+		'foo{<span style=background-color:aqua>bar</span>}baz',
+		'<span style=background-color:aqua>fo[o</span><span style=background-color:lime>b]ar</span>',
+		'<span style=background-color:aqua>fo[o</span><span style=background-color:aqua>b]ar</span>',
+		'<span style=background-color:aqua>fo[o<span style=background-color:transparent>b]ar</span></span>',
 	],
 	//@}
 	indent: [