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