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. The tree resembles the DOM | 6 // automation (accessibility) tree for the browser. The tree resembles the DOM |
7 // tree, but only exposes the <em>semantic</em> structure of a page. It can be | 7 // tree, but only exposes the <em>semantic</em> structure of a page. It can be |
8 // used to programmatically interact with a page by examining names, roles, and | 8 // used to programmatically interact with a page by examining names, roles, and |
9 // states, listening for events, and performing actions on nodes. | 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 clicked, | |
24 documentSelectionChanged, | |
25 expandedChanged, | |
26 focus, | |
27 imageFrameUpdated, | |
28 hide, | |
29 hover, | |
30 invalidStatusChanged, | |
31 layoutComplete, | |
32 liveRegionCreated, | |
33 liveRegionChanged, | |
34 loadComplete, | |
35 locationChanged, | |
36 mediaStartedPlaying, | |
37 mediaStoppedPlaying, | |
38 menuEnd, | |
39 menuListItemSelected, | |
40 menuListValueChanged, | |
41 menuPopupEnd, | |
42 menuPopupStart, | |
43 menuStart, | |
44 mouseCanceled, | |
45 mouseDragged, | |
46 mouseMoved, | |
47 mousePressed, | |
48 mouseReleased, | |
49 rowCollapsed, | |
50 rowCountChanged, | |
51 rowExpanded, | |
52 scrollPositionChanged, | |
53 scrolledToAnchor, | |
54 selectedChildrenChanged, | |
55 selection, | |
56 selectionAdd, | |
57 selectionRemove, | |
58 show, | |
59 textChanged, | |
60 textSelectionChanged, | |
61 treeChanged, | |
62 valueChanged | |
63 }; | |
64 | |
65 // Describes the purpose of an $(ref:automation.AutomationNode). | |
66 enum RoleType { | |
67 abbr, | |
68 alertDialog, | |
69 alert, | |
70 annotation, | |
71 application, | |
72 article, | |
73 audio, | |
74 banner, | |
75 blockquote, | |
76 busyIndicator, | |
77 button, | |
78 buttonDropDown, | |
79 canvas, | |
80 caption, | |
81 cell, | |
82 checkBox, | |
83 client, | |
84 colorWell, | |
85 columnHeader, | |
86 column, | |
87 comboBox, | |
88 complementary, | |
89 contentInfo, | |
90 date, | |
91 dateTime, | |
92 definition, | |
93 descriptionListDetail, | |
94 descriptionList, | |
95 descriptionListTerm, | |
96 desktop, | |
97 details, | |
98 dialog, | |
99 directory, | |
100 disclosureTriangle, | |
101 div, | |
102 document, | |
103 embeddedObject, | |
104 figcaption, | |
105 figure, | |
106 footer, | |
107 form, | |
108 grid, | |
109 group, | |
110 heading, | |
111 iframe, | |
112 iframePresentational, | |
113 ignored, | |
114 imageMapLink, | |
115 imageMap, | |
116 image, | |
117 inlineTextBox, | |
118 inputTime, | |
119 labelText, | |
120 legend, | |
121 lineBreak, | |
122 link, | |
123 listBoxOption, | |
124 listBox, | |
125 listItem, | |
126 listMarker, | |
127 list, | |
128 locationBar, | |
129 log, | |
130 main, | |
131 mark, | |
132 marquee, | |
133 math, | |
134 menuBar, | |
135 menuButton, | |
136 menuItem, | |
137 menuItemCheckBox, | |
138 menuItemRadio, | |
139 menuListOption, | |
140 menuListPopup, | |
141 menu, | |
142 meter, | |
143 navigation, | |
144 note, | |
145 outline, | |
146 pane, | |
147 paragraph, | |
148 popUpButton, | |
149 pre, | |
150 presentational, | |
151 progressIndicator, | |
152 radioButton, | |
153 radioGroup, | |
154 region, | |
155 rootWebArea, | |
156 rowHeader, | |
157 row, | |
158 ruby, | |
159 ruler, | |
160 svgRoot, | |
161 scrollArea, | |
162 scrollBar, | |
163 seamlessWebArea, | |
164 search, | |
165 searchBox, | |
166 slider, | |
167 sliderThumb, | |
168 spinButtonPart, | |
169 spinButton, | |
170 splitter, | |
171 staticText, | |
172 status, | |
173 switch, | |
174 tabGroup, | |
175 tabList, | |
176 tabPanel, | |
177 tab, | |
178 tableHeaderContainer, | |
179 table, | |
180 textField, | |
181 time, | |
182 timer, | |
183 titleBar, | |
184 toggleButton, | |
185 toolbar, | |
186 treeGrid, | |
187 treeItem, | |
188 tree, | |
189 unknown, | |
190 tooltip, | |
191 video, | |
192 webArea, | |
193 webView, | |
194 window | |
195 }; | |
196 | |
197 // Describes characteristics of an $(ref:automation.AutomationNode). | |
198 enum StateType { | |
199 busy, | |
200 checked, | |
201 collapsed, | |
202 default, | |
203 disabled, | |
204 editable, | |
205 expanded, | |
206 focusable, | |
207 focused, | |
208 haspopup, | |
209 horizontal, | |
210 hovered, | |
211 invisible, | |
212 linked, | |
213 multiline, | |
214 multiselectable, | |
215 offscreen, | |
216 pressed, | |
217 protected, | |
218 readOnly, | |
219 required, | |
220 richlyEditable, | |
221 selectable, | |
222 selected, | |
223 vertical, | |
224 visited | |
225 }; | |
226 | |
227 // Possible changes to the automation tree. For any given atomic change | 11 // Possible changes to the automation tree. For any given atomic change |
228 // to the tree, each node that's added, removed, or changed, will appear | 12 // to the tree, each node that's added, removed, or changed, will appear |
229 // in exactly one TreeChange, with one of these types. | 13 // in exactly one TreeChange, with one of these types. |
230 // | 14 // |
231 // | 15 // |
232 // nodeCreated means that this node was added to the tree and its parent is | 16 // nodeCreated means that this node was added to the tree and its parent is |
233 // new as well, so it's just one node in a new subtree that was added. | 17 // new as well, so it's just one node in a new subtree that was added. |
234 enum TreeChangeType { | 18 enum TreeChangeType { |
235 /** | 19 /** |
236 * This node was added to the tree and its parent is new as well, | 20 * This node was added to the tree and its parent is new as well, |
(...skipping 26 matching lines...) Expand all Loading... |
263 | 47 |
264 dictionary Rect { | 48 dictionary Rect { |
265 long left; | 49 long left; |
266 long top; | 50 long top; |
267 long width; | 51 long width; |
268 long height; | 52 long height; |
269 }; | 53 }; |
270 | 54 |
271 // Arguments for the find() and findAll() methods. | 55 // Arguments for the find() and findAll() methods. |
272 [nocompile, noinline_doc] dictionary FindParams { | 56 [nocompile, noinline_doc] dictionary FindParams { |
273 RoleType? role; | 57 DOMString? role; |
274 | 58 |
275 // A map of $(ref:automation.StateType) to boolean, indicating for each | 59 // A map of $(DOMString) to boolean, indicating for each |
276 // state whether it should be set or not. For example: | 60 // state whether it should be set or not. For example: |
277 // <code>{ StateType.disabled: false }</code> would only match if | 61 // disabled: false would only match if |
278 // <code>StateType.disabled</code> was <em>not</em> present in the node's | 62 // disabled: false was <em>not</em> present in the node's |
279 // <code>state</code> object. | 63 // <code>state</code> object. |
280 object? state; | 64 object? state; |
281 | 65 |
282 // A map of attribute name to expected value, for example | 66 // A map of attribute name to expected value, for example |
283 // <code>{ name: 'Root directory', checkbox_mixed: true }</code>. | 67 // <code>{ name: 'Root directory', checkbox_mixed: true }</code>. |
284 // String attribute values may be specified as a regex, for example | 68 // String attribute values may be specified as a regex, for example |
285 // <code>{ name: /stralia$/</code> }</code>. | 69 // <code>{ name: /stralia$/</code> }</code>. |
286 // Unless specifying a regex, the expected value must be an exact match | 70 // Unless specifying a regex, the expected value must be an exact match |
287 // in type and value for the actual value. Thus, the type of expected value | 71 // in type and value for the actual value. Thus, the type of expected value |
288 // must be one of: | 72 // must be one of: |
(...skipping 20 matching lines...) Expand all Loading... |
309 | 93 |
310 // Called when the result for a <code>query</code> is available. | 94 // Called when the result for a <code>query</code> is available. |
311 callback QueryCallback = void(AutomationNode node); | 95 callback QueryCallback = void(AutomationNode node); |
312 | 96 |
313 // An event in the Automation tree. | 97 // An event in the Automation tree. |
314 [nocompile, noinline_doc] dictionary AutomationEvent { | 98 [nocompile, noinline_doc] dictionary AutomationEvent { |
315 // The $(ref:automation.AutomationNode) to which the event was targeted. | 99 // The $(ref:automation.AutomationNode) to which the event was targeted. |
316 AutomationNode target; | 100 AutomationNode target; |
317 | 101 |
318 // The type of the event. | 102 // The type of the event. |
319 EventType type; | 103 DOMString type; |
320 | 104 |
321 // The source of this event. | 105 // The source of this event. |
322 DOMString eventFrom; | 106 DOMString eventFrom; |
323 | 107 |
324 long mouseX; | 108 long mouseX; |
325 long mouseY; | 109 long mouseY; |
326 | 110 |
327 // Stops this event from further processing except for any remaining | 111 // Stops this event from further processing except for any remaining |
328 // listeners on $(ref:AutomationEvent.target). | 112 // listeners on $(ref:AutomationEvent.target). |
329 static void stopPropagation(); | 113 static void stopPropagation(); |
(...skipping 25 matching lines...) Expand all Loading... |
355 | 139 |
356 // A single node in an Automation tree. | 140 // A single node in an Automation tree. |
357 [nocompile, noinline_doc] dictionary AutomationNode { | 141 [nocompile, noinline_doc] dictionary AutomationNode { |
358 // The root node of the tree containing this AutomationNode. | 142 // The root node of the tree containing this AutomationNode. |
359 AutomationNode root; | 143 AutomationNode root; |
360 | 144 |
361 // Whether this AutomationNode is a root node. | 145 // Whether this AutomationNode is a root node. |
362 boolean isRootNode; | 146 boolean isRootNode; |
363 | 147 |
364 // The role of this node. | 148 // The role of this node. |
365 automation.RoleType role; | 149 DOMString role; |
366 | 150 |
367 // The $(ref:automation.StateType)s describing this node. | 151 // The states describing this node. |
368 object state; | 152 object state; |
369 | 153 |
370 // The rendered location (as a bounding box) of this node in global | 154 // The rendered location (as a bounding box) of this node in global |
371 // screen coordinates. | 155 // screen coordinates. |
372 automation.Rect location; | 156 automation.Rect location; |
373 | 157 |
374 // Computes the bounding box of a subrange of this node in global screen | 158 // Computes the bounding box of a subrange of this node in global screen |
375 // coordinates. Returns the same as |location| if range information | 159 // coordinates. Returns the same as |location| if range information |
376 // is not available. The start and end indices are zero-based offsets | 160 // is not available. The start and end indices are zero-based offsets |
377 // into the node's "name" string attribute. | 161 // into the node's "name" string attribute. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 377 |
594 // Sets selection within a text field. | 378 // Sets selection within a text field. |
595 static void setSelection(long startIndex, long endIndex); | 379 static void setSelection(long startIndex, long endIndex); |
596 | 380 |
597 // Clears focus and sets this node as the starting point for the next | 381 // Clears focus and sets this node as the starting point for the next |
598 // time the user presses Tab or Shift+Tab. | 382 // time the user presses Tab or Shift+Tab. |
599 static void setSequentialFocusNavigationStartingPoint(); | 383 static void setSequentialFocusNavigationStartingPoint(); |
600 | 384 |
601 // Adds a listener for the given event type and event phase. | 385 // Adds a listener for the given event type and event phase. |
602 static void addEventListener( | 386 static void addEventListener( |
603 EventType eventType, AutomationListener listener, boolean capture); | 387 DOMString eventType, AutomationListener listener, boolean capture); |
604 | 388 |
605 // Removes a listener for the given event type and event phase. | 389 // Removes a listener for the given event type and event phase. |
606 static void removeEventListener( | 390 static void removeEventListener( |
607 EventType eventType, AutomationListener listener, boolean capture); | 391 DOMString eventType, AutomationListener listener, boolean capture); |
608 | 392 |
609 // Gets the first node in this node's subtree which matches the given CSS | 393 // Gets the first node in this node's subtree which matches the given CSS |
610 // selector and is within the same DOM context. | 394 // selector and is within the same DOM context. |
611 // | 395 // |
612 // If this node doesn't correspond directly with an HTML node in the DOM, | 396 // If this node doesn't correspond directly with an HTML node in the DOM, |
613 // querySelector will be run on this node's nearest HTML node ancestor. Note | 397 // querySelector will be run on this node's nearest HTML node ancestor. Note |
614 // that this may result in the query returning a node which is not a | 398 // that this may result in the query returning a node which is not a |
615 // descendant of this node. | 399 // descendant of this node. |
616 // | 400 // |
617 // If the selector matches a node which doesn't directly correspond to an | 401 // If the selector matches a node which doesn't directly correspond to an |
(...skipping 21 matching lines...) Expand all Loading... |
639 | 423 |
640 // Called with the <code>AutomationNode</code> that currently has focus. | 424 // Called with the <code>AutomationNode</code> that currently has focus. |
641 callback FocusCallback = void(AutomationNode focusedNode); | 425 callback FocusCallback = void(AutomationNode focusedNode); |
642 | 426 |
643 interface Functions { | 427 interface Functions { |
644 // Get the automation tree for the tab with the given tabId, or the current | 428 // Get the automation tree for the tab with the given tabId, or the current |
645 // tab if no tabID is given, enabling automation if necessary. Returns a | 429 // tab if no tabID is given, enabling automation if necessary. Returns a |
646 // tree with a placeholder root node; listen for the "loadComplete" event to | 430 // tree with a placeholder root node; listen for the "loadComplete" event to |
647 // get a notification that the tree has fully loaded (the previous root node | 431 // get a notification that the tree has fully loaded (the previous root node |
648 // reference will stop working at or before this point). | 432 // reference will stop working at or before this point). |
649 [nocompile] static void getTree(optional long tabId, RootCallback callback); | 433 [nocompile] static void getTree(long tabId, RootCallback callback); |
650 | 434 |
651 // Get the automation tree for the whole desktop which consists of all on | 435 // Get the automation tree for the whole desktop which consists of all on |
652 // screen views. Note this API is currently only supported on Chrome OS. | 436 // screen views. Note this API is currently only supported on Chrome OS. |
653 [nocompile] static void getDesktop(RootCallback callback); | 437 [nocompile] static void getDesktop(RootCallback callback); |
654 | 438 |
655 // Get the automation node that currently has focus, globally. Will return | 439 // Get the automation node that currently has focus, globally. Will return |
656 // null if none of the nodes in any loaded trees have focus. | 440 // null if none of the nodes in any loaded trees have focus. |
657 [nocompile] static void getFocus(FocusCallback callback); | 441 [nocompile] static void getFocus(FocusCallback callback); |
658 | 442 |
659 // Add a tree change observer. Tree change observers are static/global, they | 443 // Add a tree change observer. Tree change observers are static/global, they |
(...skipping 12 matching lines...) Expand all Loading... |
672 // Everything in the tree between the two node/offset pairs gets included | 456 // Everything in the tree between the two node/offset pairs gets included |
673 // in the selection. The anchor is where the user started the selection, | 457 // in the selection. The anchor is where the user started the selection, |
674 // while the focus is the point at which the selection gets extended | 458 // while the focus is the point at which the selection gets extended |
675 // e.g. when dragging with a mouse or using the keyboard. For nodes with | 459 // e.g. when dragging with a mouse or using the keyboard. For nodes with |
676 // the role staticText, the offset gives the character offset within | 460 // the role staticText, the offset gives the character offset within |
677 // the value where the selection starts or ends, respectively. | 461 // the value where the selection starts or ends, respectively. |
678 [nocompile] static void setDocumentSelection( | 462 [nocompile] static void setDocumentSelection( |
679 SetDocumentSelectionParams params); | 463 SetDocumentSelectionParams params); |
680 }; | 464 }; |
681 }; | 465 }; |
OLD | NEW |