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