Chromium Code Reviews| 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 t ree, but only exposes |
|
aboxhall
2014/06/17 15:04:19
Need to wrap this to 80 cols.
David Tseng
2014/06/17 19:25:37
Done.
| |
| 7 // representation, analogous to the DOM tree, which represents the | 7 // <em>semantic</em> structure of a page. It can be used to programmatically |
| 8 // <em>semantic</em> structure of a page, and can be used to programmatically | 8 // interact with a page by examining names, roles, and states, listening for |
| 9 // interact with a page. | 9 // 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'. | |
|
aboxhall
2014/06/17 15:04:18
Will this comment end up in the compiled documenta
David Tseng
2014/06/17 19:25:37
Nope; didn't show up in preview python server.
| |
| 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 | |
|
aboxhall
2014/06/17 15:04:18
What happens to these comments when the doc is gen
David Tseng
2014/06/17 19:25:37
They don't seem to be picked up. I can point you t
aboxhall
2014/06/17 20:18:12
No problem, was just curious. I assume we're ok wi
| |
| 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 { |
|
aboxhall
2014/06/17 15:04:18
Why noinline_doc?
David Tseng
2014/06/17 19:25:37
It was inlining the entire definition of Automatio
aboxhall
2014/06/17 20:18:12
Oh! How annoying.
| |
| 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 // Prevent the further bubbling (or capturing) phases of this event. Note |
|
aboxhall
2014/06/17 15:04:19
We should be consistent with either present or imp
David Tseng
2014/06/17 19:25:37
Went with 'Stops' as opposed to 'Prevents' to alig
| |
| 27 // dispatch. | 220 // any remaining listeners on $(ref:EventType.target) will be allowed to |
| 221 // process this event. | |
| 28 static void stopPropagation(); | 222 static void stopPropagation(); |
| 29 }; | 223 }; |
| 30 | 224 |
| 31 // A listener for events on an <code>AutomationNode</code>. | 225 // A listener for events on an <code>AutomationNode</code>. |
| 32 callback AutomationListener = void(AutomationEvent event); | 226 callback AutomationListener = void(AutomationEvent event); |
| 33 | 227 |
| 34 // A single node in an Automation tree. | 228 // A single node in an Automation tree. |
| 35 [nocompile] dictionary AutomationNode { | 229 [nocompile, noinline_doc] dictionary AutomationNode { |
| 36 // The root node of the tree containing this AutomationNode. | 230 // The root node of the tree containing this AutomationNode. |
| 37 AutomationRootNode root; | 231 AutomationRootNode root; |
| 38 | 232 |
| 39 // Whether this AutomationNode is an AutomationRootNode. | 233 // Whether this AutomationNode is an AutomationRootNode. |
| 40 bool isRootNode; | 234 bool isRootNode; |
| 41 | 235 |
| 42 // Unique ID to identify this node. | 236 // Unique ID to identify this node. |
| 43 long id; | 237 long id; |
| 44 | 238 |
| 45 // The role of this node, e.g. button, static text etc. | 239 // The role of this node. |
| 46 DOMString role; | 240 automation.RoleType role; |
| 47 | 241 |
| 48 // The state of this node, e.g. {pressed": true, "inactive": true} etc. | 242 // The $(ref:automation.StateType)s describing this node. |
| 49 object state; | 243 object state; |
| 50 | 244 |
| 51 // The rendered location (as a bounding box) of this node within the frame. | 245 // The rendered location (as a bounding box) of this node within the frame. |
| 52 Rect location; | 246 automation.Rect location; |
| 53 | 247 |
| 54 // A collection of this node's other attributes. | 248 // 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; | 249 object? attributes; |
| 58 | 250 |
| 59 // The index of this node in its parent node's list of children. If this is | 251 // The index of this node in its parent node's list of children. If this is |
| 60 // the root node, this will be undefined. | 252 // the root node, this will be undefined. |
| 61 long? indexInParent; | 253 long? indexInParent; |
| 62 | 254 |
| 63 // Traversal. | 255 static AutomationNode[] children(); |
| 64 static object[] children(); | 256 static AutomationNode parent(); |
| 65 static object parent(); | 257 static AutomationNode firstChild(); |
| 66 static object firstChild(); | 258 static AutomationNode lastChild(); |
| 67 static object lastChild(); | 259 static AutomationNode previousSibling(); |
| 68 static object previousSibling(); | 260 static AutomationNode nextSibling(); |
| 69 static object nextSibling(); | |
| 70 | 261 |
| 71 // Actions. | 262 // Do the default action based on this node's role (e.g. click a button). |
|
aboxhall
2014/06/17 15:04:18
Present tense.
Do we want to expand on this expla
David Tseng
2014/06/17 19:25:37
Done.
| |
| 72 static void doDefault(); | 263 static void doDefault(); |
| 264 | |
| 265 // Places focus on this node. | |
| 73 static void focus(); | 266 static void focus(); |
| 267 | |
| 268 // Scrolls this node to make it visible. | |
| 74 static void makeVisible(); | 269 static void makeVisible(); |
| 270 | |
| 271 // Sets selection within a text field. | |
| 75 static void setSelection(long startIndex, long endIndex); | 272 static void setSelection(long startIndex, long endIndex); |
| 76 | 273 |
| 77 // Events. | 274 // Adds a listener for the given event type and event phase. |
| 78 static void addEventListener( | 275 static void addEventListener( |
| 79 DOMString eventType, AutomationListener listener, bool capture); | 276 EventType eventType, AutomationListener listener, bool capture); |
| 277 | |
| 278 // Removes a listener for the given event type and event phase. | |
| 80 static void removeEventListener( | 279 static void removeEventListener( |
| 81 DOMString eventType, AutomationListener listener, bool capture); | 280 EventType eventType, AutomationListener listener, bool capture); |
| 82 }; | 281 }; |
| 83 | 282 |
| 84 // The root node of the automation tree for a single frame or desktop. | 283 // The root node of the automation tree for a single frame or desktop. |
| 85 // This may be: | 284 // This may be: |
| 86 // <ul> | 285 // <ul> |
| 87 // <li> The desktop | 286 // <li> The desktop |
| 88 // <li> The top frame of a page | 287 // <li> The top frame of a page |
| 89 // <li> A frame or iframe within a page | 288 // <li> A frame or iframe within a page |
| 90 // </ul> | 289 // </ul> |
| 91 // Thus, an <code>AutomationRootNode</code> may be a descendant of one or | 290 // 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 | 291 // more <code>AutomationRootNode</code>s, and in turn have one or more |
| 93 // <code>AutomationRootNode</code>s in its descendants. Thus, the | 292 // <code>AutomationRootNode</code>s in its descendants. Thus, the |
| 94 // <code>root</code> property of the <code>AutomationRootNode</code> will be | 293 // <code>root</code> property of the <code>AutomationRootNode</code> will be |
| 95 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code> | 294 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code> |
| 96 // if this is the top-level <code>AutomationRootNode</code>. | 295 // if this is the top-level <code>AutomationRootNode</code>. |
| 97 // | 296 // |
| 98 // Extends $(ref:automation.AutomationNode). | 297 // Extends $(ref:automation.AutomationNode). |
| 99 [nocompile] dictionary AutomationRootNode { | 298 [nocompile, noinline_doc] dictionary AutomationRootNode { |
| 299 // TODO(aboxhall/dtseng): implement loading. Kept separate to not include | |
|
aboxhall
2014/06/17 15:04:18
When do you think we'll end up doing this? We can
David Tseng
2014/06/17 19:25:36
Not sure when, but I'm fine with it being here; do
aboxhall
2014/06/17 20:18:12
I think we should at least make sure |loaded| alwa
| |
| 300 // in generated docs. | |
| 301 | |
| 100 // Whether this AutomationRootNode is loaded or not. If false, call load() | 302 // Whether this AutomationRootNode is loaded or not. If false, call load() |
| 101 // to get the contents. | 303 // to get the contents. |
| 102 // TODO(aboxhall/dtseng): implement. | |
| 103 bool loaded; | 304 bool loaded; |
| 104 | 305 |
| 105 // Load the accessibility tree for this AutomationRootNode. | 306 // Load the accessibility tree for this AutomationRootNode. |
| 106 // TODO(aboxhall/dtseng): implement. | |
| 107 static void load(RootCallback callback); | 307 static void load(RootCallback callback); |
| 108 }; | 308 }; |
| 109 | 309 |
| 110 // Called when the <code>AutomationRootNode</code> for the page is available. | 310 // Called when the <code>AutomationRootNode</code> for the page is available. |
| 111 callback RootCallback = void(AutomationRootNode rootNode); | 311 callback RootCallback = void(AutomationRootNode rootNode); |
| 112 | 312 |
| 113 interface Functions { | 313 interface Functions { |
| 114 // Get the automation tree for the tab with the given tabId, or the current | 314 // 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 | 315 // 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 | 316 // 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 | 317 // get a notification that the tree has fully loaded (the previous root node |
| 118 // reference will stop working at or before this point). | 318 // reference will stop working at or before this point). |
| 119 [nocompile] static void getTree(optional long tabId, RootCallback callback); | 319 [nocompile] static void getTree(optional long tabId, RootCallback callback); |
| 120 | 320 |
| 121 // Get the automation tree for the desktop. | 321 // Get the automation tree for the whole desktop which consists of all on |
| 322 // screen views. Note this API is currently only supported on Chrome OS. | |
| 122 [nocompile] static void getDesktop(RootCallback callback); | 323 [nocompile] static void getDesktop(RootCallback callback); |
| 123 }; | 324 }; |
| 124 }; | 325 }; |
| OLD | NEW |