Skip to content

Commit

Permalink
Refactor Dictation commands to use Macros class.
Browse files Browse the repository at this point in the history
This matches the abstractions in Android Voice Access, where a macro
is something that can check whether it can execute and can execute,
and is independent from Pumpkin or parsed speech results.

In Dictation, a Macro is an abstract class that should be implemented
for each semantic tag / action. Several high-level macros are created
in this change including a RepeatableKeyPressMacro, used to send
the same key press multiple times via an EventGenerator, and an
InputTextViewMacro, which can put text into a text field via the
chrome.input.ime APIs (in InputController).

No functional changes to Dictation commands should result from this
change.

Checking whether a command can be executed in the given context
is mostly left as a TODO.

TEST=DictationCommandsExtensionTest

AX-Relnotes: N/A
Bug: 1247299,1264544
Change-Id: Ied1add45266b8c5ace0a09a685e86022ae93e9dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3265812
Reviewed-by: Akihiro Ota <akihiroota@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/main@{#940578}
  • Loading branch information
Katie Dektar authored and Chromium LUCI CQ committed Nov 11, 2021
1 parent d3abbe7 commit b2d4982
Show file tree
Hide file tree
Showing 10 changed files with 863 additions and 399 deletions.
Expand Up @@ -27,12 +27,17 @@ run_jsbundler("accessibility_common_copied_files") {
"accessibility_common_loader.js",
"autoclick/autoclick.js",
"background.html",
"dictation/commands.js",
"dictation/dictation.js",
"dictation/earcons/audio_end.wav",
"dictation/earcons/audio_initiate.wav",
"dictation/earcons/null_selection.wav",
"dictation/input_controller.js",
"dictation/macros/input_text_view_macro.js",
"dictation/macros/list_commands_macro.js",
"dictation/macros/macro.js",
"dictation/macros/macro_names.js",
"dictation/macros/repeatable_key_press_macro.js",
"dictation/speech_parser.js",
"magnifier/magnifier.js",
]
rewrite_rules = [
Expand Down Expand Up @@ -155,11 +160,25 @@ js_library("dictation_input_controller") {
]
}

js_library("dictation_commands") {
sources = [ "dictation/commands.js" ]
js_library("dictation_macros") {
sources = [
"dictation/macros/input_text_view_macro.js",
"dictation/macros/list_commands_macro.js",
"dictation/macros/macro.js",
"dictation/macros/macro_names.js",
"dictation/macros/repeatable_key_press_macro.js",
]
deps = [
":dictation_input_controller",
"../common:event_generator",
"../common:key_code",
]
externs_list = [ "$externs_path/accessibility_private.js" ]
}

js_library("dictation_commands") {
sources = [ "dictation/speech_parser.js" ]
deps = [
":dictation_input_controller",
":dictation_macros",
]
}

0 comments on commit b2d4982

Please sign in to comment.