/
accessibility_private.clj
189 lines (144 loc) · 8.77 KB
/
accessibility_private.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
(ns chromex.ext.accessibility-private
" * available since Chrome 36"
(:refer-clojure :only [defmacro defn apply declare meta let partial])
(:require [chromex.wrapgen :refer [gen-wrap-helper]]
[chromex.callgen :refer [gen-call-helper gen-tap-all-events-call]]))
(declare api-table)
(declare gen-call)
; -- functions --------------------------------------------------------------------------------------------------------------
(defmacro set-native-accessibility-enabled
"Enables or disables native accessibility support. Once disabled, it is up to the calling extension to provide accessibility
for web contents.
|enabled| - True if native accessibility support should be enabled."
([enabled] (gen-call :function ::set-native-accessibility-enabled &form enabled)))
(defmacro set-focus-ring
"Sets the bounds of the accessibility focus ring.
|rects| - Array of rectangles to draw the accessibility focus ring around.
|color| - CSS-style hex color string beginning with # like #FF9982 or #EEE."
([rects color] (gen-call :function ::set-focus-ring &form rects color))
([rects] `(set-focus-ring ~rects :omit)))
(defmacro set-highlights
"Sets the bounds of the accessibility highlight.
|rects| - Array of rectangles to draw the highlight around.
|color| - CSS-style hex color string beginning with # like #FF9982 or #EEE."
([rects color] (gen-call :function ::set-highlights &form rects color)))
(defmacro set-keyboard-listener
"Sets the calling extension as a listener of all keyboard events optionally allowing the calling extension to
capture/swallow the key event via DOM apis. Returns false via callback when unable to set the listener.
|enabled| - True if the caller wants to listen to key events; false to stop listening to events. Note that there is
only ever one extension listening to key events.
|capture| - True if key events should be swallowed natively and not propagated if preventDefault() gets called by the
extension's background page."
([enabled capture] (gen-call :function ::set-keyboard-listener &form enabled capture)))
(defmacro darken-screen
"Darkens or undarkens the screen.
|enabled| - True to darken screen; false to undarken screen."
([enabled] (gen-call :function ::darken-screen &form enabled)))
(defmacro set-switch-access-keys
"Change the keyboard keys captured by Switch Access.
|key-codes| - The key codes for the keys that will be captured."
([key-codes] (gen-call :function ::set-switch-access-keys &form key-codes)))
(defmacro set-native-chrome-vox-arc-support-for-current-app
"Sets current ARC app to use native ARC support.
|enabled| - True for ChromeVox (native), false for TalkBack."
([enabled] (gen-call :function ::set-native-chrome-vox-arc-support-for-current-app &form enabled)))
(defmacro send-synthetic-key-event
"Sends a fabricated key event.
|key-event| - The event to send."
([key-event] (gen-call :function ::send-synthetic-key-event &form key-event)))
(defmacro on-select-to-speak-state-changed
"Called by the Select-to-Speak extension when Select-to-Speak has changed states, between selecting with the mouse,
speaking, and inactive.
|state| - ?"
([state] (gen-call :function ::on-select-to-speak-state-changed &form state)))
; -- events -----------------------------------------------------------------------------------------------------------------
;
; docs: https://github.com/binaryage/chromex/#tapping-events
(defmacro tap-on-introduce-chrome-vox-events
"Fired whenever ChromeVox should output introduction.
Events will be put on the |channel| with signature [::on-introduce-chrome-vox []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-introduce-chrome-vox &form channel args)))
(defmacro tap-on-accessibility-gesture-events
"Fired when an accessibility gesture is detected by the touch exploration controller.
Events will be put on the |channel| with signature [::on-accessibility-gesture [gesture]] where:
|gesture| - ?
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-accessibility-gesture &form channel args)))
(defmacro tap-on-two-finger-touch-start-events
"Fired when we first detect two fingers are held down, which can be used to toggle spoken feedback on some touch-only
devices.
Events will be put on the |channel| with signature [::on-two-finger-touch-start []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-two-finger-touch-start &form channel args)))
(defmacro tap-on-two-finger-touch-stop-events
"Fired when the user is no longer holding down two fingers (including releasing one, holding down three, or moving them).
Events will be put on the |channel| with signature [::on-two-finger-touch-stop []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-two-finger-touch-stop &form channel args)))
(defmacro tap-on-select-to-speak-state-change-requested-events
"Called when Chrome OS wants to change the Select-to-Speak state, between selecting with the mouse, speaking, and inactive.
Events will be put on the |channel| with signature [::on-select-to-speak-state-change-requested []].
Note: |args| will be passed as additional parameters into Chrome event's .addListener call."
([channel & args] (apply gen-call :event ::on-select-to-speak-state-change-requested &form channel args)))
; -- convenience ------------------------------------------------------------------------------------------------------------
(defmacro tap-all-events
"Taps all valid non-deprecated events in chromex.ext.accessibility-private namespace."
[chan]
(gen-tap-all-events-call api-table (meta &form) chan))
; ---------------------------------------------------------------------------------------------------------------------------
; -- API TABLE --------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------------------
(def api-table
{:namespace "chrome.accessibilityPrivate",
:since "36",
:functions
[{:id ::set-native-accessibility-enabled,
:name "setNativeAccessibilityEnabled",
:params [{:name "enabled", :type "boolean"}]}
{:id ::set-focus-ring,
:name "setFocusRing",
:since "39",
:params
[{:name "rects", :type "[array-of-accessibilityPrivate.ScreenRects]"}
{:name "color", :optional? true, :type "string"}]}
{:id ::set-highlights,
:name "setHighlights",
:since "64",
:params [{:name "rects", :type "[array-of-accessibilityPrivate.ScreenRects]"} {:name "color", :type "string"}]}
{:id ::set-keyboard-listener,
:name "setKeyboardListener",
:since "48",
:params [{:name "enabled", :type "boolean"} {:name "capture", :type "boolean"}]}
{:id ::darken-screen, :name "darkenScreen", :since "59", :params [{:name "enabled", :type "boolean"}]}
{:id ::set-switch-access-keys,
:name "setSwitchAccessKeys",
:since "61",
:params [{:name "key-codes", :type "[array-of-integers]"}]}
{:id ::set-native-chrome-vox-arc-support-for-current-app,
:name "setNativeChromeVoxArcSupportForCurrentApp",
:since "63",
:params [{:name "enabled", :type "boolean"}]}
{:id ::send-synthetic-key-event,
:name "sendSyntheticKeyEvent",
:since "65",
:params [{:name "key-event", :type "accessibilityPrivate.SyntheticKeyboardEvent"}]}
{:id ::on-select-to-speak-state-changed,
:name "onSelectToSpeakStateChanged",
:since "68",
:params [{:name "state", :type "accessibilityPrivate.SelectToSpeakState"}]}],
:events
[{:id ::on-introduce-chrome-vox, :name "onIntroduceChromeVox", :since "42"}
{:id ::on-accessibility-gesture,
:name "onAccessibilityGesture",
:since "52",
:params [{:name "gesture", :type "accessibilityPrivate.Gesture"}]}
{:id ::on-two-finger-touch-start, :name "onTwoFingerTouchStart", :since "59"}
{:id ::on-two-finger-touch-stop, :name "onTwoFingerTouchStop", :since "59"}
{:id ::on-select-to-speak-state-change-requested, :name "onSelectToSpeakStateChangeRequested", :since "68"}]})
; -- helpers ----------------------------------------------------------------------------------------------------------------
; code generation for native API wrapper
(defmacro gen-wrap [kind item-id config & args]
(apply gen-wrap-helper api-table kind item-id config args))
; code generation for API call-site
(def gen-call (partial gen-call-helper api-table))