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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 * This node's text (name) changed. | 256 * This node's text (name) changed. |
257 */ | 257 */ |
258 textChanged, | 258 textChanged, |
259 | 259 |
260 /** | 260 /** |
261 * This node was removed. | 261 * This node was removed. |
262 */ | 262 */ |
263 nodeRemoved | 263 nodeRemoved |
264 }; | 264 }; |
265 | 265 |
| 266 // Where the node's name is from. |
| 267 enum NameFromType { |
| 268 uninitialized, |
| 269 attribute, |
| 270 contents, |
| 271 placeholder, |
| 272 related_element, |
| 273 value |
| 274 }; |
| 275 |
266 dictionary Rect { | 276 dictionary Rect { |
267 long left; | 277 long left; |
268 long top; | 278 long top; |
269 long width; | 279 long width; |
270 long height; | 280 long height; |
271 }; | 281 }; |
272 | 282 |
273 // Arguments for the find() and findAll() methods. | 283 // Arguments for the find() and findAll() methods. |
274 [nocompile, noinline_doc] dictionary FindParams { | 284 [nocompile, noinline_doc] dictionary FindParams { |
275 RoleType? role; | 285 RoleType? role; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 textMarkerChanges, | 361 textMarkerChanges, |
352 allTreeChanges | 362 allTreeChanges |
353 }; | 363 }; |
354 | 364 |
355 // A listener for changes on the <code>AutomationNode</code> tree. | 365 // A listener for changes on the <code>AutomationNode</code> tree. |
356 callback TreeChangeObserver = void(TreeChange treeChange); | 366 callback TreeChangeObserver = void(TreeChange treeChange); |
357 | 367 |
358 // A single node in an Automation tree. | 368 // A single node in an Automation tree. |
359 [nocompile, noinline_doc] dictionary AutomationNode { | 369 [nocompile, noinline_doc] dictionary AutomationNode { |
360 // The root node of the tree containing this AutomationNode. | 370 // The root node of the tree containing this AutomationNode. |
361 AutomationNode root; | 371 AutomationNode? root; |
362 | 372 |
363 // Whether this AutomationNode is a root node. | 373 // Whether this AutomationNode is a root node. |
364 boolean isRootNode; | 374 boolean isRootNode; |
365 | 375 |
366 // The role of this node. | 376 // The role of this node. |
367 automation.RoleType role; | 377 RoleType? role; |
368 | 378 |
369 // The $(ref:automation.StateType)s describing this node. | 379 // The $(ref:automation.StateType)s describing this node. |
370 object state; | 380 // <jsexterns>@type {Object<chrome.automation.StateType, boolean>} |
| 381 // </jsexterns> |
| 382 object? state; |
371 | 383 |
372 // The rendered location (as a bounding box) of this node in global | 384 // The rendered location (as a bounding box) of this node in global |
373 // screen coordinates. | 385 // screen coordinates. |
374 automation.Rect location; | 386 Rect? location; |
375 | 387 |
376 // Computes the bounding box of a subrange of this node in global screen | 388 // Computes the bounding box of a subrange of this node in global screen |
377 // coordinates. Returns the same as |location| if range information | 389 // coordinates. Returns the same as |location| if range information |
378 // is not available. The start and end indices are zero-based offsets | 390 // is not available. The start and end indices are zero-based offsets |
379 // into the node's "name" string attribute. | 391 // into the node's "name" string attribute. |
380 static automation.Rect boundsForRange(long startIndex, long endIndex); | 392 static Rect boundsForRange(long startIndex, long endIndex); |
381 | 393 |
382 // The purpose of the node, other than the role, if any. | 394 // The purpose of the node, other than the role, if any. |
383 DOMString description; | 395 DOMString? description; |
384 | 396 |
385 // The help text for the node, if any. | 397 // The placeholder for this text field, if any. |
386 DOMString help; | 398 DOMString? placeholder; |
387 | 399 |
388 // The accessible name for this node, via the | 400 // The accessible name for this node, via the |
389 // <a href="http://www.w3.org/TR/wai-aria/roles#namecalculation"> | 401 // <a href="http://www.w3.org/TR/wai-aria/roles#namecalculation"> |
390 // Accessible Name Calculation</a> process. | 402 // Accessible Name Calculation</a> process. |
391 DOMString name; | 403 DOMString? name; |
| 404 |
| 405 // The source of the name. |
| 406 NameFromType? nameFrom; |
392 | 407 |
393 // The value for this node: for example the <code>value</code> attribute of | 408 // The value for this node: for example the <code>value</code> attribute of |
394 // an <code><input> element. | 409 // an <code><input> element. |
395 DOMString value; | 410 DOMString? value; |
396 | 411 |
397 // The HTML tag for this element, if this node is an HTML element. | 412 // The HTML tag for this element, if this node is an HTML element. |
398 DOMString htmlTag; | 413 DOMString? htmlTag; |
399 | 414 |
400 // The level of a heading or tree item. | 415 // The level of a heading or tree item. |
401 long hierarchicalLevel; | 416 long? hierarchicalLevel; |
402 | 417 |
403 // The start and end index of each word in an inline text box. | 418 // The start and end index of each word in an inline text box. |
404 long[] wordStarts; | 419 long[]? wordStarts; |
405 long[] wordEnds; | 420 long[]? wordEnds; |
406 | 421 |
407 // The nodes, if any, which this node is specified to control via | 422 // The nodes, if any, which this node is specified to control via |
408 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-control
s"> | 423 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-control
s"> |
409 // <code>aria-controls</code></a>. | 424 // <code>aria-controls</code></a>. |
410 AutomationNode[] controls; | 425 AutomationNode[]? controls; |
411 | 426 |
412 // The nodes, if any, which form a description for this node. | 427 // The nodes, if any, which form a description for this node. |
413 AutomationNode[] describedBy; | 428 AutomationNode[]? describedBy; |
414 | 429 |
415 // The nodes, if any, which may optionally be navigated to after this | 430 // The nodes, if any, which may optionally be navigated to after this |
416 // one. See | 431 // one. See |
417 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-flowto"
> | 432 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-flowto"
> |
418 // <code>aria-flowto</code></a>. | 433 // <code>aria-flowto</code></a>. |
419 AutomationNode[] flowTo; | 434 AutomationNode[]? flowTo; |
420 | 435 |
421 // The nodes, if any, which form a label for this element. Generally, the | 436 // The nodes, if any, which form a label for this element. Generally, the |
422 // text from these elements will also be exposed as the element's accessible | 437 // text from these elements will also be exposed as the element's accessible |
423 // name, via the $(ref:automation.AutomationNode.name) attribute. | 438 // name, via the $(ref:automation.AutomationNode.name) attribute. |
424 AutomationNode[] labelledBy; | 439 AutomationNode[]? labelledBy; |
425 | 440 |
426 // The node referred to by <code>aria-activedescendant</code>, where | 441 // The node referred to by <code>aria-activedescendant</code>, where |
427 // applicable | 442 // applicable |
428 AutomationNode activedescendant; | 443 AutomationNode? activeDescendant; |
429 | 444 |
430 // | 445 // |
431 // Link attributes. | 446 // Link attributes. |
432 // | 447 // |
433 | 448 |
434 // The URL that this link will navigate to. | 449 // The URL that this link will navigate to. |
435 DOMString url; | 450 DOMString? url; |
436 | 451 |
437 // | 452 // |
438 // Document attributes. | 453 // Document attributes. |
439 // | 454 // |
440 | 455 |
441 // The URL of this document. | 456 // The URL of this document. |
442 DOMString docUrl; | 457 DOMString? docUrl; |
443 | 458 |
444 // The title of this document. | 459 // The title of this document. |
445 DOMString docTitle; | 460 DOMString? docTitle; |
446 | 461 |
447 // Whether this document has finished loading. | 462 // Whether this document has finished loading. |
448 boolean docLoaded; | 463 boolean? docLoaded; |
449 | 464 |
450 // The proportion (out of 1.0) that this doc has completed loading. | 465 // The proportion (out of 1.0) that this doc has completed loading. |
451 double docLoadingProgress; | 466 double? docLoadingProgress; |
452 | 467 |
453 // | 468 // |
454 // Scrollable container attributes. | 469 // Scrollable container attributes. |
455 // | 470 // |
456 | 471 |
457 long scrollX; | 472 long? scrollX; |
458 long scrollXMin; | 473 long? scrollXMin; |
459 long scrollXMax; | 474 long? scrollXMax; |
460 long scrollY; | 475 long? scrollY; |
461 long scrollYMin; | 476 long? scrollYMin; |
462 long scrollYMax; | 477 long? scrollYMax; |
463 | 478 |
464 // | 479 // |
465 // Editable text field attributes. | 480 // Editable text field attributes. |
466 // | 481 // |
467 | 482 |
468 // The character index of the start of the selection within this editable | 483 // The character index of the start of the selection within this editable |
469 // text element; -1 if no selection. | 484 // text element; -1 if no selection. |
470 long textSelStart; | 485 long? textSelStart; |
471 | 486 |
472 // The character index of the end of the selection within this editable | 487 // The character index of the end of the selection within this editable |
473 // text element; -1 if no selection. | 488 // text element; -1 if no selection. |
474 long textSelEnd; | 489 long? textSelEnd; |
475 | 490 |
476 // The input type, like email or number. | 491 // The input type, like email or number. |
477 DOMString textInputType; | 492 DOMString? textInputType; |
| 493 |
| 494 // An array of indexes of the break between lines in editable text. |
| 495 long[] lineBreaks; |
| 496 |
| 497 // An array of indexes of the start position of each text marker. |
| 498 long[] markerStarts; |
| 499 |
| 500 // An array of indexes of the end position of each text marker. |
| 501 long[] markerEnds; |
| 502 |
| 503 // An array of numerical types indicating the type of each text marker, |
| 504 // such as a spelling error. |
| 505 long[] markerTypes; |
478 | 506 |
479 // | 507 // |
480 // Tree selection attributes (available on root nodes only) | 508 // Tree selection attributes (available on root nodes only) |
481 // | 509 // |
482 | 510 |
483 // The anchor node of the tree selection, if any. | 511 // The anchor node of the tree selection, if any. |
484 AutomationNode? anchorObject; | 512 AutomationNode? anchorObject; |
485 // The anchor offset of the tree selection, if any. | 513 // The anchor offset of the tree selection, if any. |
486 long? anchorOffset; | 514 long? anchorOffset; |
| 515 // The affinity of the tree selection anchor, if any. |
| 516 DOMString? anchorAffinity; |
487 // The focus node of the tree selection, if any. | 517 // The focus node of the tree selection, if any. |
488 AutomationNode? focusObject; | 518 AutomationNode? focusObject; |
489 // The focus offset of the tree selection, if any. | 519 // The focus offset of the tree selection, if any. |
490 long? focusOffset; | 520 long? focusOffset; |
| 521 // The affinity of the tree selection focus, if any. |
| 522 DOMString? focusAffinity; |
491 | 523 |
492 // | 524 // |
493 // Range attributes. | 525 // Range attributes. |
494 // | 526 // |
495 | 527 |
496 // The current value for this range. | 528 // The current value for this range. |
497 double valueForRange; | 529 double? valueForRange; |
498 | 530 |
499 // The minimum possible value for this range. | 531 // The minimum possible value for this range. |
500 double minValueForRange; | 532 double? minValueForRange; |
501 | 533 |
502 // The maximum possible value for this range. | 534 // The maximum possible value for this range. |
503 double maxValueForRange; | 535 double? maxValueForRange; |
| 536 |
| 537 // |
| 538 // List attributes. |
| 539 // |
| 540 |
| 541 // The 1-based index of an item in a set. |
| 542 long? posInSet; |
| 543 |
| 544 // The number of items in a set; |
| 545 long? setSize; |
504 | 546 |
505 // | 547 // |
506 // Table attributes. | 548 // Table attributes. |
507 // | 549 // |
508 | 550 |
509 // The number of rows in this table. | 551 // The number of rows in this table. |
510 long tableRowCount; | 552 long? tableRowCount; |
511 | 553 |
512 // The number of columns in this table. | 554 // The number of columns in this table. |
513 long tableColumnCount; | 555 long? tableColumnCount; |
514 | 556 |
515 // | 557 // |
516 // Table cell attributes. | 558 // Table cell attributes. |
517 // | 559 // |
518 | 560 |
519 // The zero-based index of the column that this cell is in. | 561 // The zero-based index of the column that this cell is in. |
520 long tableCellColumnIndex; | 562 long? tableCellColumnIndex; |
521 | 563 |
522 // The number of columns that this cell spans (default is 1). | 564 // The number of columns that this cell spans (default is 1). |
523 long tableCellColumnSpan; | 565 long? tableCellColumnSpan; |
524 | 566 |
525 // The zero-based index of the row that this cell is in. | 567 // The zero-based index of the row that this cell is in. |
526 long tableCellRowIndex; | 568 long? tableCellRowIndex; |
527 | 569 |
528 // The number of rows that this cell spans (default is 1). | 570 // The number of rows that this cell spans (default is 1). |
529 long tableCellRowSpan; | 571 long? tableCellRowSpan; |
| 572 |
| 573 // The corresponding column header for this cell. |
| 574 AutomationNode? tableColumnHeader; |
| 575 |
| 576 // The corresponding row header for this cell. |
| 577 AutomationNode? tableRowHeader; |
530 | 578 |
531 // | 579 // |
532 // Live region attributes. | 580 // Live region attributes. |
533 // | 581 // |
534 | 582 |
535 // The type of region if this is the root of a live region. | 583 // The type of region if this is the root of a live region. |
536 // Possible values are 'polite' and 'assertive'. | 584 // Possible values are 'polite' and 'assertive'. |
537 DOMString liveStatus; | 585 DOMString? liveStatus; |
538 | 586 |
539 // The value of aria-relevant for a live region. | 587 // The value of aria-relevant for a live region. |
540 DOMString liveRelevant; | 588 DOMString? liveRelevant; |
541 | 589 |
542 // The value of aria-atomic for a live region. | 590 // The value of aria-atomic for a live region. |
543 boolean liveAtomic; | 591 boolean? liveAtomic; |
544 | 592 |
545 // The value of aria-busy for a live region. | 593 // The value of aria-busy for a live region. |
546 boolean liveBusy; | 594 boolean? liveBusy; |
547 | 595 |
548 // The type of live region if this node is inside a live region. | 596 // The type of live region if this node is inside a live region. |
549 DOMString containerLiveStatus; | 597 DOMString? containerLiveStatus; |
550 | 598 |
551 // The value of aria-relevant if this node is inside a live region. | 599 // The value of aria-relevant if this node is inside a live region. |
552 DOMString containerLiveRelevant; | 600 DOMString? containerLiveRelevant; |
553 | 601 |
554 // The value of aria-atomic if this node is inside a live region. | 602 // The value of aria-atomic if this node is inside a live region. |
555 boolean containerLiveAtomic; | 603 boolean? containerLiveAtomic; |
556 | 604 |
557 // The value of aria-busy if this node is inside a live region. | 605 // The value of aria-busy if this node is inside a live region. |
558 boolean containerLiveBusy; | 606 boolean? containerLiveBusy; |
| 607 |
| 608 // |
| 609 // Miscellaneous attributes. |
| 610 // |
| 611 |
| 612 // A map containing all HTML attributes and their values |
| 613 // <jsexterns>@type {Object<string>}</jsexterns> |
| 614 object? htmlAttributes; |
| 615 |
| 616 // The input type of a text field, such as "text" or "email". |
| 617 DOMString? inputType; |
| 618 |
| 619 // The key that activates this widget. |
| 620 DOMString? accessKey; |
| 621 |
| 622 // The value of the aria-invalid attribute, indicating the error type. |
| 623 DOMString? ariaInvalidValue; |
| 624 |
| 625 // The value of the aria-readonly attribute, if applicable. |
| 626 boolean? ariaReadonly; |
| 627 |
| 628 // The CSS display attribute for this node, if applicable. |
| 629 DOMString? display; |
| 630 |
| 631 // A data url with the contents of this object's image or thumbnail. |
| 632 DOMString? imageDataUrl; |
| 633 |
| 634 // The language code for this subtree. |
| 635 DOMString? language; |
| 636 |
| 637 // If a checkbox or toggle button is in the mixed state. |
| 638 boolean? buttonMixed; |
| 639 |
| 640 // The RGBA foreground color of this subtree, as an integer. |
| 641 long? color; |
| 642 |
| 643 // The RGBA background color of this subtree, as an integer. |
| 644 long? backgroundColor; |
| 645 |
| 646 // The RGBA color of an input element whose value is a color. |
| 647 long? colorValue; |
559 | 648 |
560 // | 649 // |
561 // Walking the tree. | 650 // Walking the tree. |
562 // | 651 // |
563 | 652 |
564 AutomationNode[] children; | 653 AutomationNode[] children; |
565 AutomationNode parent; | 654 AutomationNode? parent; |
566 AutomationNode firstChild; | 655 AutomationNode? firstChild; |
567 AutomationNode lastChild; | 656 AutomationNode? lastChild; |
568 AutomationNode previousSibling; | 657 AutomationNode? previousSibling; |
569 AutomationNode nextSibling; | 658 AutomationNode? nextSibling; |
| 659 AutomationNode? nextOnLine; |
| 660 AutomationNode? previousOnLine; |
570 | 661 |
571 // The index of this node in its parent node's list of children. If this is | 662 // The index of this node in its parent node's list of children. If this is |
572 // the root node, this will be undefined. | 663 // the root node, this will be undefined. |
573 long? indexInParent; | 664 long? indexInParent; |
574 | 665 |
575 // | 666 // |
576 // Actions. | 667 // Actions. |
577 // | 668 // |
578 | 669 |
579 // Does the default action based on this node's role. This is generally | 670 // Does the default action based on this node's role. This is generally |
(...skipping 13 matching lines...) Expand all Loading... |
593 // Scrolls this node to make it visible. | 684 // Scrolls this node to make it visible. |
594 static void makeVisible(); | 685 static void makeVisible(); |
595 | 686 |
596 // Sets selection within a text field. | 687 // Sets selection within a text field. |
597 static void setSelection(long startIndex, long endIndex); | 688 static void setSelection(long startIndex, long endIndex); |
598 | 689 |
599 // Clears focus and sets this node as the starting point for the next | 690 // Clears focus and sets this node as the starting point for the next |
600 // time the user presses Tab or Shift+Tab. | 691 // time the user presses Tab or Shift+Tab. |
601 static void setSequentialFocusNavigationStartingPoint(); | 692 static void setSequentialFocusNavigationStartingPoint(); |
602 | 693 |
| 694 // Show the context menu for this element, as if the user right-clicked. |
| 695 static void showContextMenu(); |
| 696 |
| 697 // Resume playing any media within this tree. |
| 698 static void resumeMedia(); |
| 699 |
| 700 // Start ducking any media within this tree. |
| 701 static void startDuckingMedia(); |
| 702 |
| 703 // Stop ducking any media within this tree. |
| 704 static void stopDuckingMedia(); |
| 705 |
| 706 // Suspend any media playing within this tree. |
| 707 static void suspendMedia(); |
| 708 |
603 // Adds a listener for the given event type and event phase. | 709 // Adds a listener for the given event type and event phase. |
604 static void addEventListener( | 710 static void addEventListener( |
605 EventType eventType, AutomationListener listener, boolean capture); | 711 EventType eventType, AutomationListener listener, boolean capture); |
606 | 712 |
607 // Removes a listener for the given event type and event phase. | 713 // Removes a listener for the given event type and event phase. |
608 static void removeEventListener( | 714 static void removeEventListener( |
609 EventType eventType, AutomationListener listener, boolean capture); | 715 EventType eventType, AutomationListener listener, boolean capture); |
610 | 716 |
611 // Gets the first node in this node's subtree which matches the given CSS | 717 // Gets the first node in this node's subtree which matches the given CSS |
612 // selector and is within the same DOM context. | 718 // selector and is within the same DOM context. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 // Everything in the tree between the two node/offset pairs gets included | 780 // Everything in the tree between the two node/offset pairs gets included |
675 // in the selection. The anchor is where the user started the selection, | 781 // in the selection. The anchor is where the user started the selection, |
676 // while the focus is the point at which the selection gets extended | 782 // while the focus is the point at which the selection gets extended |
677 // e.g. when dragging with a mouse or using the keyboard. For nodes with | 783 // e.g. when dragging with a mouse or using the keyboard. For nodes with |
678 // the role staticText, the offset gives the character offset within | 784 // the role staticText, the offset gives the character offset within |
679 // the value where the selection starts or ends, respectively. | 785 // the value where the selection starts or ends, respectively. |
680 [nocompile] static void setDocumentSelection( | 786 [nocompile] static void setDocumentSelection( |
681 SetDocumentSelectionParams params); | 787 SetDocumentSelectionParams params); |
682 }; | 788 }; |
683 }; | 789 }; |
OLD | NEW |