Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5847)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js

Issue 2694903010: AX checked state changes (Closed)
Patch Set: Fix compiler error Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
index 45720681c6992464733303b54d62854abd3e0f93..2dc20113b2ec92d8a54c91cfec7c9d7d5d2c3c9a 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -723,6 +723,21 @@ Output.forceModeForNextSpeechUtterance = function(mode) {
Output.forceModeForNextSpeechUtterance_ = mode;
};
+/**
+ * For a given automation property, return true if the the value
David Tseng 2017/03/13 18:10:54 nit: remove dup the
aleventhal 2017/04/19 19:29:32 Done.
+ * represents something 'truthy', e.g.: for checked:
+ * 'true'|'mixed' -> true
+ * 'false'|undefined -> false
+ */
+Output.isTruthy = function(node, attrib) {
+ switch(attrib) {
+ case 'checked':
+ return node.checked && node.checked !== 'false';
+ default:
+ return node[attrib] !== undefined || node.state[attrib];
+ }
+};
+
Output.prototype = {
/**
* @return {boolean} True if there's any speech that will be output.
@@ -1155,20 +1170,16 @@ Output.prototype = {
}
} else if (token == 'checked') {
var msg;
- var ariaChecked = node.htmlAttributes['aria-checked'];
- switch (ariaChecked) {
+ switch (node.checked) {
case 'mixed':
- msg = 'aria_checked_mixed';
+ msg = 'checked_mixed';
break;
case 'true':
- msg = 'aria_checked_true';
- break;
- case 'false':
- msg = 'aria_checked_false';
+ msg = 'checked_true';
break;
default:
- msg = node.state[StateType.CHECKED] ?
- 'aria_checked_true' : 'aria_checked_false';
+ msg = 'checked_false';
+ break;
}
this.format_(node, '@' + msg, buff);
} else if (token == 'state') {
@@ -1300,7 +1311,7 @@ Output.prototype = {
if (token == 'if') {
var cond = tree.firstChild;
var attrib = cond.value.slice(1);
- if (node[attrib] !== undefined || node.state[attrib])
+ if (Output.isTruthy(node, attrib))
this.format_(node, cond.nextSibling, buff);
else
this.format_(node, cond.nextSibling.nextSibling, buff);

Powered by Google App Engine
This is Rietveld 408576698