OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // The <code>chrome.automation</code> API allows developers to access the | 5 // The <code>chrome.automation</code> API allows developers to access the |
6 // automation (accessibility) tree for the browser. This is a tree | 6 // automation (accessibility) tree for the browser. The tree resembles the DOM |
7 // representation, analogous to the DOM tree, which represents the | 7 // tree, but only exposes <em>semantic</em> structure of a page. It can be used |
8 // <em>semantic</em> structure of a page, and can be used to programmatically | 8 // to programmatically interact with a page by examining names, roles, and |
9 // interact with a page. | 9 // states, listening for events, and performing actions on nodes. |
10 [nocompile] namespace automation { | 10 [nocompile] namespace automation { |
11 // Keep the following enums in sync with 'ui/accessibility/ax_enums.idl'. | |
12 // They are kept here purely for extension docs generation. | |
13 | |
14 // Possible events fired on an $(ref:automation.AutomationNode). | |
15 enum EventType { | |
16 activedescendantchanged, | |
17 alert, | |
18 ariaAttributeChanged, | |
19 autocorrectionOccured, | |
20 blur, | |
21 checkedStateChanged, | |
22 childrenChanged, | |
23 focus, | |
24 hide, | |
25 hover, | |
26 invalidStatusChanged, | |
27 layoutComplete, | |
28 liveRegionChanged, | |
29 loadComplete, | |
30 locationChanged, | |
31 menuEnd, | |
32 menuListItemSelected, | |
33 menuListValueChanged, | |
34 menuPopupEnd, | |
35 menuPopupStart, | |
36 menuStart, | |
37 rowCollapsed, | |
38 rowCountChanged, | |
39 rowExpanded, | |
40 scrollPositionChanged, | |
41 scrolledToAnchor, | |
42 selectedChildrenChanged, | |
43 selectedTextChanged, | |
44 selectionChanged, | |
45 show, | |
46 textChanged, | |
47 textInserted, | |
48 textRemoved, | |
49 valueChanged | |
50 }; | |
51 | |
52 // Describes the purpose of an $(ref:automation.AutomationNode). | |
53 enum RoleType { | |
54 alertDialog, | |
55 alert, | |
56 annotation, | |
57 application, | |
58 article, | |
59 banner, | |
60 browser, | |
61 busyIndicator, | |
62 button, | |
63 buttonDropDown, | |
64 canvas, | |
65 cell, | |
66 checkBox, | |
67 client, | |
68 colorWell, | |
69 columnHeader, | |
70 column, | |
71 comboBox, | |
72 complementary, | |
73 contentInfo, | |
74 definition, | |
75 descriptionListDetail, | |
76 descriptionListTerm, | |
77 desktop, | |
78 dialog, | |
79 directory, | |
80 disclosureTriangle, | |
81 div, | |
82 document, | |
83 drawer, | |
84 editableText, | |
85 embeddedObject, | |
86 footer, | |
87 form, | |
88 grid, | |
89 group, | |
90 growArea, | |
91 heading, | |
92 helpTag, | |
93 horizontalRule, | |
94 iframe, | |
95 ignored, | |
96 imageMapLink, | |
97 imageMap, | |
98 image, | |
99 incrementor, | |
100 inlineTextBox, | |
101 labelText, | |
102 legend, | |
103 link, | |
104 listBoxOption, | |
105 listBox, | |
106 listItem, | |
107 listMarker, | |
108 list, | |
109 locationBar, | |
110 log, | |
111 main, | |
112 marquee, | |
113 mathElement, | |
114 math, | |
115 matte, | |
116 menuBar, | |
117 menuButton, | |
118 menuItem, | |
119 menuListOption, | |
120 menuListPopup, | |
121 menu, | |
122 navigation, | |
123 note, | |
124 outline, | |
125 pane, | |
126 paragraph, | |
127 popUpButton, | |
128 presentational, | |
129 progressIndicator, | |
130 radioButton, | |
131 radioGroup, | |
132 region, | |
133 rootWebArea, | |
134 rowHeader, | |
135 row, | |
136 rulerMarker, | |
137 ruler, | |
138 svgRoot, | |
139 scrollArea, | |
140 scrollBar, | |
141 seamlessWebArea, | |
142 search, | |
143 sheet, | |
144 slider, | |
145 sliderThumb, | |
146 spinButtonPart, | |
147 spinButton, | |
148 splitGroup, | |
149 splitter, | |
150 staticText, | |
151 status, | |
152 systemWide, | |
153 tabGroup, | |
154 tabList, | |
155 tabPanel, | |
156 tab, | |
157 tableHeaderContainer, | |
158 table, | |
159 textArea, | |
160 textField, | |
161 timer, | |
162 titleBar, | |
163 toggleButton, | |
164 toolbar, | |
165 treeGrid, | |
166 treeItem, | |
167 tree, | |
168 unknown, | |
169 tooltip, | |
170 valueIndicator, | |
171 webArea, | |
172 window | |
173 }; | |
174 | |
175 // Describes characteristics of an $(ref:automation.AutomationNode). | |
176 enum StateType { | |
177 busy, | |
178 checked, | |
179 collapsed, | |
180 default, | |
181 disabled, // ui/views only | |
182 editable, // ui/views only | |
183 enabled, // content only | |
184 expanded, | |
185 focusable, | |
186 focused, | |
187 haspopup, | |
188 hovered, | |
189 indeterminate, | |
190 invisible, | |
191 linked, | |
192 multiselectable, | |
193 offscreen, | |
194 pressed, | |
195 protected, | |
196 readOnly, | |
197 required, | |
198 selectable, | |
199 selected, | |
200 vertical, | |
201 visited | |
202 }; | |
203 | |
11 dictionary Rect { | 204 dictionary Rect { |
12 long left; | 205 long left; |
13 long top; | 206 long top; |
14 long width; | 207 long width; |
15 long height; | 208 long height; |
16 }; | 209 }; |
17 | 210 |
18 // An event in the Automation tree. | 211 // An event in the Automation tree. |
19 [nocompile] dictionary AutomationEvent { | 212 [nocompile, noinline_doc] dictionary AutomationEvent { |
20 // The $(ref:automation.AutomationNode) to which the event was targeted. | 213 // The $(ref:automation.AutomationNode) to which the event was targeted. |
21 AutomationNode target; | 214 AutomationNode target; |
22 | 215 |
23 // The type of the event. | 216 // The type of the event. |
24 DOMString type; | 217 EventType type; |
25 | 218 |
26 // Prevents all other event listeners from being triggered for this event | 219 // Stops this event from further processing except for any remaining |
27 // dispatch. | 220 // listeners on $(ref:EventType.target). |
28 static void stopPropagation(); | 221 static void stopPropagation(); |
29 }; | 222 }; |
30 | 223 |
31 // A listener for events on an <code>AutomationNode</code>. | 224 // A listener for events on an <code>AutomationNode</code>. |
32 callback AutomationListener = void(AutomationEvent event); | 225 callback AutomationListener = void(AutomationEvent event); |
33 | 226 |
34 // A single node in an Automation tree. | 227 // A single node in an Automation tree. |
35 [nocompile] dictionary AutomationNode { | 228 [nocompile, noinline_doc] dictionary AutomationNode { |
36 // The root node of the tree containing this AutomationNode. | 229 // The root node of the tree containing this AutomationNode. |
37 AutomationRootNode root; | 230 AutomationRootNode root; |
38 | 231 |
39 // Whether this AutomationNode is an AutomationRootNode. | 232 // Whether this AutomationNode is an AutomationRootNode. |
40 bool isRootNode; | 233 bool isRootNode; |
41 | 234 |
42 // Unique ID to identify this node. | 235 // Unique ID to identify this node. |
43 long id; | 236 long id; |
44 | 237 |
45 // The role of this node, e.g. button, static text etc. | 238 // The role of this node. |
46 DOMString role; | 239 automation.RoleType role; |
not at google - send to devlin
2014/06/17 21:10:31
you shouldn't need to namespace these yourself, it
David Tseng
2014/06/17 21:21:46
I know...but if I remove it, and refresh the previ
| |
47 | 240 |
48 // The state of this node, e.g. {pressed": true, "inactive": true} etc. | 241 // The $(ref:automation.StateType)s describing this node. |
49 object state; | 242 object state; |
50 | 243 |
51 // The rendered location (as a bounding box) of this node within the frame. | 244 // The rendered location (as a bounding box) of this node within the frame. |
52 Rect location; | 245 automation.Rect location; |
53 | 246 |
54 // A collection of this node's other attributes. | 247 // A collection of this node's other attributes. |
55 // TODO(aboxhall): Create and use combined list of attributes from | |
56 // AXStringAttribute, AXIntAttribute etc. | |
57 object? attributes; | 248 object? attributes; |
58 | 249 |
59 // The index of this node in its parent node's list of children. If this is | 250 // The index of this node in its parent node's list of children. If this is |
60 // the root node, this will be undefined. | 251 // the root node, this will be undefined. |
61 long? indexInParent; | 252 long? indexInParent; |
62 | 253 |
63 // Traversal. | 254 static AutomationNode[] children(); |
64 static object[] children(); | 255 static AutomationNode parent(); |
65 static object parent(); | 256 static AutomationNode firstChild(); |
66 static object firstChild(); | 257 static AutomationNode lastChild(); |
67 static object lastChild(); | 258 static AutomationNode previousSibling(); |
68 static object previousSibling(); | 259 static AutomationNode nextSibling(); |
69 static object nextSibling(); | |
70 | 260 |
71 // Actions. | 261 // Does the default action based on this node's role. This is generally |
262 // the same action that would result from clicking the node such as | |
263 // expanding a treeitem, toggling a checkbox, selecting a radiobutton, | |
264 // or activating a button. | |
72 static void doDefault(); | 265 static void doDefault(); |
266 | |
267 // Places focus on this node. | |
73 static void focus(); | 268 static void focus(); |
269 | |
270 // Scrolls this node to make it visible. | |
74 static void makeVisible(); | 271 static void makeVisible(); |
272 | |
273 // Sets selection within a text field. | |
75 static void setSelection(long startIndex, long endIndex); | 274 static void setSelection(long startIndex, long endIndex); |
76 | 275 |
77 // Events. | 276 // Adds a listener for the given event type and event phase. |
78 static void addEventListener( | 277 static void addEventListener( |
79 DOMString eventType, AutomationListener listener, bool capture); | 278 EventType eventType, AutomationListener listener, bool capture); |
279 | |
280 // Removes a listener for the given event type and event phase. | |
80 static void removeEventListener( | 281 static void removeEventListener( |
81 DOMString eventType, AutomationListener listener, bool capture); | 282 EventType eventType, AutomationListener listener, bool capture); |
82 }; | 283 }; |
83 | 284 |
84 // The root node of the automation tree for a single frame or desktop. | 285 // The root node of the automation tree for a single frame or desktop. |
85 // This may be: | 286 // This may be: |
86 // <ul> | 287 // <ul> |
87 // <li> The desktop | 288 // <li> The desktop |
88 // <li> The top frame of a page | 289 // <li> The top frame of a page |
89 // <li> A frame or iframe within a page | 290 // <li> A frame or iframe within a page |
90 // </ul> | 291 // </ul> |
91 // Thus, an <code>AutomationRootNode</code> may be a descendant of one or | 292 // Thus, an <code>AutomationRootNode</code> may be a descendant of one or |
92 // more <code>AutomationRootNode</code>s, and in turn have one or more | 293 // more <code>AutomationRootNode</code>s, and in turn have one or more |
93 // <code>AutomationRootNode</code>s in its descendants. Thus, the | 294 // <code>AutomationRootNode</code>s in its descendants. Thus, the |
94 // <code>root</code> property of the <code>AutomationRootNode</code> will be | 295 // <code>root</code> property of the <code>AutomationRootNode</code> will be |
95 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code> | 296 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code> |
96 // if this is the top-level <code>AutomationRootNode</code>. | 297 // if this is the top-level <code>AutomationRootNode</code>. |
97 // | 298 // |
98 // Extends $(ref:automation.AutomationNode). | 299 // Extends $(ref:automation.AutomationNode). |
99 [nocompile] dictionary AutomationRootNode { | 300 [nocompile, noinline_doc] dictionary AutomationRootNode { |
301 // TODO(aboxhall/dtseng): implement loading. Kept separate to not include | |
302 // in generated docs. | |
303 | |
100 // Whether this AutomationRootNode is loaded or not. If false, call load() | 304 // Whether this AutomationRootNode is loaded or not. If false, call load() |
101 // to get the contents. | 305 // to get the contents. |
102 // TODO(aboxhall/dtseng): implement. | |
103 bool loaded; | 306 bool loaded; |
104 | 307 |
105 // Load the accessibility tree for this AutomationRootNode. | 308 // Load the accessibility tree for this AutomationRootNode. |
106 // TODO(aboxhall/dtseng): implement. | |
107 static void load(RootCallback callback); | 309 static void load(RootCallback callback); |
108 }; | 310 }; |
109 | 311 |
110 // Called when the <code>AutomationRootNode</code> for the page is available. | 312 // Called when the <code>AutomationRootNode</code> for the page is available. |
111 callback RootCallback = void(AutomationRootNode rootNode); | 313 callback RootCallback = void(AutomationRootNode rootNode); |
112 | 314 |
113 interface Functions { | 315 interface Functions { |
114 // Get the automation tree for the tab with the given tabId, or the current | 316 // Get the automation tree for the tab with the given tabId, or the current |
115 // tab if no tabID is given, enabling automation if necessary. Returns a | 317 // tab if no tabID is given, enabling automation if necessary. Returns a |
116 // tree with a placeholder root node; listen for the "loadComplete" event to | 318 // tree with a placeholder root node; listen for the "loadComplete" event to |
117 // get a notification that the tree has fully loaded (the previous root node | 319 // get a notification that the tree has fully loaded (the previous root node |
118 // reference will stop working at or before this point). | 320 // reference will stop working at or before this point). |
119 [nocompile] static void getTree(optional long tabId, RootCallback callback); | 321 [nocompile] static void getTree(optional long tabId, RootCallback callback); |
120 | 322 |
121 // Get the automation tree for the desktop. | 323 // Get the automation tree for the whole desktop which consists of all on |
324 // screen views. Note this API is currently only supported on Chrome OS. | |
122 [nocompile] static void getDesktop(RootCallback callback); | 325 [nocompile] static void getDesktop(RootCallback callback); |
123 }; | 326 }; |
124 }; | 327 }; |
OLD | NEW |