Commit f8cf3f48 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Add a command to get language info for a node.

The new command is [Search + P + L], which prints the current node's
detected and author-provided languages to the console. This is strictly
a debugging feature and only works when one (or more) of the following
flags have been enabled:

enable-experimental-accessibility-chromevox-language-switching
enable-experimental-accessibility-language-detection
enable-experimental-accessibility-language-detection-dynamic

Bug: 1067739
Relnotes: N/A
Change-Id: Id645fde857dd5d0b7b9aa5cf6242d6aaec903e55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109255
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarChris Hall <chrishall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756889}
parent 0c17ecc3
......@@ -34,6 +34,9 @@ const StateType = chrome.automation.StateType;
/** @private {boolean} */
CommandHandler.incognito_ = !!chrome.runtime.getManifest()['incognito'];
/** @private {boolean} */
CommandHandler.languageLoggingEnabled_ = false;
/**
* Handles toggling sticky mode when encountering editables.
* @private {!SmartStickyMode}
......@@ -1059,6 +1062,29 @@ CommandHandler.onCommand = function(command) {
.send();
}
return false;
case 'logLanguageInformationForCurrentNode': {
if (!CommandHandler.languageLoggingEnabled_) {
return false;
}
const node = ChromeVoxState.instance.currentRange.start.node;
const outString = `
Language information for node
Name: ${node.name}
Detected language: ${node.detectedLanguage || 'None'}
Author language: ${node.language || 'None'}
`;
new Output()
.withString(outString)
.withQueueMode(QueueMode.CATEGORY_FLUSH)
.go();
const annotation = node.languageAnnotationForStringAttribute('name');
const logString = outString.concat(`Language spans:
${JSON.stringify(annotation)}`);
console.error(logString);
LogStore.getInstance().writeTextLog(logString, LogStore.LogType.TEXT);
}
return false;
default:
return true;
}
......@@ -1430,6 +1456,27 @@ CommandHandler.init = function() {
});
}
});
chrome.commandLinePrivate.hasSwitch(
'enable-experimental-accessibility-chromevox-language-switching',
(enabled) => {
if (enabled) {
CommandHandler.languageLoggingEnabled_ = true;
}
});
chrome.commandLinePrivate.hasSwitch(
'enable-experimental-accessibility-language-detection', (enabled) => {
if (enabled) {
CommandHandler.languageLoggingEnabled_ = true;
}
});
chrome.commandLinePrivate.hasSwitch(
'enable-experimental-accessibility-language-detection-dynamic',
(enabled) => {
if (enabled) {
CommandHandler.languageLoggingEnabled_ = true;
}
});
};
}); // goog.scope
......@@ -1065,6 +1065,15 @@
"keyCode": [65, 79]
}
}
},
{
"command": "logLanguageInformationForCurrentNode",
"sequence": {
"cvoxModifier": true,
"keys": {
"keyCode": [80, 76]
}
}
}
]
}
......@@ -170,6 +170,7 @@ LogStore.LogType = {
BRAILLE_RULE: 'brailleRule',
EARCON: 'earcon',
EVENT: 'event',
TEXT: 'text',
TREE: 'tree',
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment