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 { |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 [nocompile, noinline_doc] dictionary AutomationNode { | 310 [nocompile, noinline_doc] dictionary AutomationNode { |
311 // The root node of the tree containing this AutomationNode. | 311 // The root node of the tree containing this AutomationNode. |
312 AutomationNode root; | 312 AutomationNode root; |
313 | 313 |
314 // Whether this AutomationNode is root node. | 314 // Whether this AutomationNode is root node. |
315 boolean isRootNode; | 315 boolean isRootNode; |
316 | 316 |
317 // The role of this node. | 317 // The role of this node. |
318 automation.RoleType role; | 318 automation.RoleType role; |
319 | 319 |
320 // TODO(aboxhall): expose states as mixins instead | |
321 | |
322 // The $(ref:automation.StateType)s describing this node. | 320 // The $(ref:automation.StateType)s describing this node. |
323 object state; | 321 object state; |
324 | 322 |
325 // The rendered location (as a bounding box) of this node within the frame. | 323 // The rendered location (as a bounding box) of this node within the frame. |
326 automation.Rect location; | 324 automation.Rect location; |
327 | 325 |
328 // The purpose of the node, other than the role, if any. | 326 // The purpose of the node, other than the role, if any. |
329 DOMString description; | 327 DOMString description; |
330 | 328 |
331 // The help text for the node, if any. | 329 // The help text for the node, if any. |
(...skipping 30 matching lines...) Expand all Loading... | |
362 // one. See | 360 // one. See |
363 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-flowto" > | 361 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-flowto" > |
364 // <code>aria-flowto</code></a>. | 362 // <code>aria-flowto</code></a>. |
365 AutomationNode[] flowTo; | 363 AutomationNode[] flowTo; |
366 | 364 |
367 // The nodes, if any, which form a label for this element. Generally, the | 365 // The nodes, if any, which form a label for this element. Generally, the |
368 // text from these elements will also be exposed as the element's accessible | 366 // text from these elements will also be exposed as the element's accessible |
369 // name, via the $(ref:automation.AutomationNode.name) attribute. | 367 // name, via the $(ref:automation.AutomationNode.name) attribute. |
370 AutomationNode[] labelledBy; | 368 AutomationNode[] labelledBy; |
371 | 369 |
372 // The nodes, if any, which are to be considered children of this node but | |
373 // are not children in the DOM tree. | |
374 AutomationNode[] owns; | |
375 | |
376 // TODO(aboxhall): Make this private? | |
377 | |
378 // A collection of this node's other attributes. | |
379 object? attributes; | |
380 | |
381 // The index of this node in its parent node's list of children. If this is | |
382 // the root node, this will be undefined. | |
383 long? indexInParent; | |
384 | |
385 AutomationNode[] children; | |
386 AutomationNode parent; | |
387 AutomationNode firstChild; | |
388 AutomationNode lastChild; | |
389 AutomationNode previousSibling; | |
390 AutomationNode nextSibling; | |
391 | |
392 // Does the default action based on this node's role. This is generally | |
393 // the same action that would result from clicking the node such as | |
394 // expanding a treeitem, toggling a checkbox, selecting a radiobutton, | |
395 // or activating a button. | |
396 static void doDefault(); | |
397 | |
398 // Places focus on this node. | |
399 static void focus(); | |
400 | |
401 // Scrolls this node to make it visible. | |
402 static void makeVisible(); | |
403 | |
404 // Sets selection within a text field. | |
405 static void setSelection(long startIndex, long endIndex); | |
406 | |
407 // Adds a listener for the given event type and event phase. | |
408 static void addEventListener( | |
409 EventType eventType, AutomationListener listener, boolean capture); | |
410 | |
411 // Removes a listener for the given event type and event phase. | |
412 static void removeEventListener( | |
413 EventType eventType, AutomationListener listener, boolean capture); | |
414 | |
415 // Gets the first node in this node's subtree which matches the given CSS | |
416 // selector and is within the same DOM context. | |
417 // | |
418 // If this node doesn't correspond directly with an HTML node in the DOM, | |
419 // querySelector will be run on this node's nearest HTML node ancestor. Note | |
420 // that this may result in the query returning a node which is not a | |
421 // descendant of this node. | |
422 // | |
423 // If the selector matches a node which doesn't directly correspond to an | |
424 // automation node (for example an element within an ARIA widget, where the | |
425 // ARIA widget forms one node of the automation tree, or an element which | |
426 // is hidden from accessibility via hiding it using CSS or using | |
427 // aria-hidden), this will return the nearest ancestor which does correspond | |
428 // to an automation node. | |
429 static void domQuerySelector(DOMString selector, QueryCallback callback); | |
430 | |
431 // Finds the first AutomationNode in this node's subtree which matches the | |
432 // given search parameters. | |
433 static AutomationNode find(FindParams params); | |
434 | |
435 // Finds all the AutomationNodes in this node's subtree which matches the | |
436 // given search parameters. | |
437 static AutomationNode[] findAll(FindParams params); | |
438 | |
439 // Returns whether this node matches the given $(ref:automation.FindParams). | |
440 static boolean matches(FindParams params); | |
441 }; | |
442 | |
443 dictionary ActiveDescendantMixin { | |
444 // The node referred to by <code>aria-activedescendant</code>, where | 370 // The node referred to by <code>aria-activedescendant</code>, where |
445 // applicable | 371 // applicable |
446 AutomationNode activedescendant; | 372 AutomationNode activedescendant; |
447 }; | |
448 | 373 |
449 // Attributes which are mixed in to an AutomationNode if it is a link. | 374 // |
450 dictionary LinkMixins { | 375 // Link attributes. |
451 // TODO(aboxhall): Add visited state | 376 // |
452 | 377 |
453 // The URL that this link will navigate to. | 378 // The URL that this link will navigate to. |
454 DOMString url; | 379 DOMString url; |
455 }; | |
456 | 380 |
457 // Attributes which are mixed in to an AutomationNode if it is a document. | 381 // |
458 dictionary DocumentMixins { | 382 // Document attributes. |
383 // | |
384 | |
459 // The URL of this document. | 385 // The URL of this document. |
460 DOMString docUrl; | 386 DOMString docUrl; |
461 | 387 |
462 // The title of this document. | 388 // The title of this document. |
463 DOMString docTitle; | 389 DOMString docTitle; |
464 | 390 |
465 // Whether this document has finished loading. | 391 // Whether this document has finished loading. |
466 boolean docLoaded; | 392 boolean docLoaded; |
467 | 393 |
468 // The proportion (out of 1.0) that this doc has completed loading. | 394 // The proportion (out of 1.0) that this doc has completed loading. |
469 double docLoadingProgress; | 395 double docLoadingProgress; |
470 }; | |
471 | 396 |
472 // TODO(aboxhall): document ScrollableMixins (e.g. what is scrollXMin? is it | 397 // |
473 // ever not 0?) | 398 // Scrollable container attributes. |
399 // | |
474 | 400 |
475 // Attributes which are mixed in to an AutomationNode if it is scrollable. | |
476 dictionary ScrollableMixins { | |
477 long scrollX; | 401 long scrollX; |
478 long scrollXMin; | 402 long scrollXMin; |
479 long scrollXMax; | 403 long scrollXMax; |
480 long scrollY; | 404 long scrollY; |
481 long scrollYMin; | 405 long scrollYMin; |
482 long scrollYMax; | 406 long scrollYMax; |
483 }; | |
484 | 407 |
485 // Attributes which are mixed in to an AutomationNode if it is editable text. | 408 // |
486 dictionary EditableTextMixins { | 409 // Editable text field attributes. |
410 // | |
411 | |
487 // The character index of the start of the selection within this editable | 412 // The character index of the start of the selection within this editable |
488 // text element; -1 if no selection. | 413 // text element; -1 if no selection. |
489 long textSelStart; | 414 long textSelStart; |
490 | 415 |
491 // The character index of the end of the selection within this editable | 416 // The character index of the end of the selection within this editable |
492 // text element; -1 if no selection. | 417 // text element; -1 if no selection. |
493 long textSelEnd; | 418 long textSelEnd; |
494 | 419 |
495 // The input type, like email or number. | 420 // The input type, like email or number. |
496 DOMString textInputType; | 421 DOMString textInputType; |
497 }; | |
498 | 422 |
499 // Attributes which are mixed in to an AutomationNode if it is a range. | 423 // |
500 dictionary RangeMixins { | 424 // Range attributes. |
425 // | |
426 | |
501 // The current value for this range. | 427 // The current value for this range. |
502 double valueForRange; | 428 double valueForRange; |
503 | 429 |
504 // The minimum possible value for this range. | 430 // The minimum possible value for this range. |
505 double minValueForRange; | 431 double minValueForRange; |
506 | 432 |
507 // The maximum possible value for this range. | 433 // The maximum possible value for this range. |
508 double maxValueForRange; | 434 double maxValueForRange; |
509 }; | |
510 | 435 |
511 // TODO(aboxhall): live region mixins. | 436 // |
437 // Table attributes. | |
438 // | |
512 | 439 |
513 // Attributes which are mixed in to an AutomationNode if it is a table. | |
514 dictionary TableMixins { | |
515 // The number of rows in this table. | 440 // The number of rows in this table. |
516 long tableRowCount; | 441 long tableRowCount; |
517 | 442 |
518 // The number of columns in this table. | 443 // The number of columns in this table. |
519 long tableColumnCount; | 444 long tableColumnCount; |
520 }; | |
521 | 445 |
522 // Attributes which are mixed in to an AutomationNode if it is a table cell. | 446 // |
523 dictionary TableCellMixins { | 447 // Table cell attributes. |
448 // | |
449 | |
524 // The zero-based index of the column that this cell is in. | 450 // The zero-based index of the column that this cell is in. |
525 long tableCellColumnIndex; | 451 long tableCellColumnIndex; |
526 | 452 |
527 // The number of columns that this cell spans (default is 1). | 453 // The number of columns that this cell spans (default is 1). |
528 long tableCellColumnSpan; | 454 long tableCellColumnSpan; |
529 | 455 |
530 // The zero-based index of the row that this cell is in. | 456 // The zero-based index of the row that this cell is in. |
531 long tableCellRowIndex; | 457 long tableCellRowIndex; |
532 | 458 |
533 // The number of rows that this cell spans (default is 1). | 459 // The number of rows that this cell spans (default is 1). |
534 long tableCellRowSpan; | 460 long tableCellRowSpan; |
461 | |
462 // | |
463 // Walking the tree. | |
464 // | |
465 | |
466 AutomationNode[] children; | |
467 AutomationNode parent; | |
468 AutomationNode firstChild; | |
469 AutomationNode lastChild; | |
470 AutomationNode previousSibling; | |
471 AutomationNode nextSibling; | |
472 | |
473 // The index of this node in its parent node's list of children. If this is | |
474 // the root node, this will be undefined. | |
475 long? indexInParent; | |
476 | |
477 // | |
478 // Actions. | |
479 // | |
480 | |
481 // Does the default action based on this node's role. This is generally | |
482 // the same action that would result from clicking the node such as | |
483 // expanding a treeitem, toggling a checkbox, selecting a radiobutton, | |
484 // or activating a button. | |
485 static void doDefault(); | |
aboxhall
2015/06/11 15:05:38
Once again I wish Rietveld did move detection. Any
dmazzoni
2015/06/11 19:09:11
The change was just to take all of the mixins and
| |
486 | |
487 // Places focus on this node. | |
488 static void focus(); | |
489 | |
490 // Scrolls this node to make it visible. | |
491 static void makeVisible(); | |
492 | |
493 // Sets selection within a text field. | |
494 static void setSelection(long startIndex, long endIndex); | |
495 | |
496 // Adds a listener for the given event type and event phase. | |
David Tseng
2015/06/10 15:56:31
Rebase?
dmazzoni
2015/06/11 19:09:11
What's wrong with this line? I think it's still co
| |
497 static void addEventListener( | |
498 EventType eventType, AutomationListener listener, boolean capture); | |
499 | |
500 // Removes a listener for the given event type and event phase. | |
501 static void removeEventListener( | |
502 EventType eventType, AutomationListener listener, boolean capture); | |
503 | |
504 // Gets the first node in this node's subtree which matches the given CSS | |
505 // selector and is within the same DOM context. | |
506 // | |
507 // If this node doesn't correspond directly with an HTML node in the DOM, | |
508 // querySelector will be run on this node's nearest HTML node ancestor. Note | |
509 // that this may result in the query returning a node which is not a | |
510 // descendant of this node. | |
511 // | |
512 // If the selector matches a node which doesn't directly correspond to an | |
513 // automation node (for example an element within an ARIA widget, where the | |
514 // ARIA widget forms one node of the automation tree, or an element which | |
515 // is hidden from accessibility via hiding it using CSS or using | |
516 // aria-hidden), this will return the nearest ancestor which does correspond | |
517 // to an automation node. | |
518 static void domQuerySelector(DOMString selector, QueryCallback callback); | |
519 | |
520 // Finds the first AutomationNode in this node's subtree which matches the | |
521 // given search parameters. | |
522 static AutomationNode find(FindParams params); | |
523 | |
524 // Finds all the AutomationNodes in this node's subtree which matches the | |
525 // given search parameters. | |
526 static AutomationNode[] findAll(FindParams params); | |
527 | |
528 // Returns whether this node matches the given $(ref:automation.FindParams). | |
529 static boolean matches(FindParams params); | |
535 }; | 530 }; |
536 | 531 |
537 // Called when the <code>AutomationNode</code> for the page is available. | 532 // Called when the <code>AutomationNode</code> for the page is available. |
538 callback RootCallback = void(AutomationNode rootNode); | 533 callback RootCallback = void(AutomationNode rootNode); |
539 | 534 |
540 interface Functions { | 535 interface Functions { |
541 // Get the automation tree for the tab with the given tabId, or the current | 536 // Get the automation tree for the tab with the given tabId, or the current |
542 // tab if no tabID is given, enabling automation if necessary. Returns a | 537 // tab if no tabID is given, enabling automation if necessary. Returns a |
543 // tree with a placeholder root node; listen for the "loadComplete" event to | 538 // tree with a placeholder root node; listen for the "loadComplete" event to |
544 // get a notification that the tree has fully loaded (the previous root node | 539 // get a notification that the tree has fully loaded (the previous root node |
545 // reference will stop working at or before this point). | 540 // reference will stop working at or before this point). |
546 [nocompile] static void getTree(optional long tabId, RootCallback callback); | 541 [nocompile] static void getTree(optional long tabId, RootCallback callback); |
547 | 542 |
548 // Get the automation tree for the whole desktop which consists of all on | 543 // Get the automation tree for the whole desktop which consists of all on |
549 // screen views. Note this API is currently only supported on Chrome OS. | 544 // screen views. Note this API is currently only supported on Chrome OS. |
550 [nocompile] static void getDesktop(RootCallback callback); | 545 [nocompile] static void getDesktop(RootCallback callback); |
551 | 546 |
552 // Add a tree change observer. Tree change observers are static/global, they | 547 // Add a tree change observer. Tree change observers are static/global, they |
553 // listen to changes across all trees. | 548 // listen to changes across all trees. |
554 [nocompile] static void addTreeChangeObserver( | 549 [nocompile] static void addTreeChangeObserver( |
555 TreeChangeObserver observer); | 550 TreeChangeObserver observer); |
556 | 551 |
557 // Remove a tree change observer. | 552 // Remove a tree change observer. |
558 [nocompile] static void removeTreeChangeObserver( | 553 [nocompile] static void removeTreeChangeObserver( |
559 TreeChangeObserver observer); | 554 TreeChangeObserver observer); |
560 }; | 555 }; |
561 }; | 556 }; |
OLD | NEW |