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
3// found in the LICENSE file.
4
5// The <code>chrome.automation</code> API allows developers to access the
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
8// used to programmatically interact with a page by examining names, roles, and
9// states, listening for events, and performing actions on nodes.
10[nocompile] namespace automation {
11  // Keep the following enums in sync with 'ui/accessibility/ax_enums.mojom'.
12  // They are kept here purely for extension docs generation.
13
14  // Possible events fired on an $(ref:automation.AutomationNode).
15  enum EventType {
16    accessKeyChanged,
17    activeDescendantChanged,
18    alert,
19    ariaAttributeChanged,
20    atomicChanged,
21    autoCompleteChanged,
22    autocorrectionOccured,
23    blur,
24    busyChanged,
25    checkedStateChanged,
26    childrenChanged,
27    classNameChanged,
28    clicked,
29    collapsed,
30    controlsChanged,
31    describedByChanged,
32    descriptionChanged,
33    documentSelectionChanged,
34    documentTitleChanged,
35    dropeffectChanged,
36    editableTextChanged,
37    enabledChanged,
38    endOfTest,
39    expanded,
40    expandedChanged,
41    flowFromChanged,
42    flowToChanged,
43    focus,
44    focusAfterMenuClose,
45    focusChanged,
46    focusContext,
47    grabbedChanged,
48    haspopupChanged,
49    hide,
50    hierarchicalLevelChanged,
51    hitTestResult,
52    hover,
53    ignoredChanged,
54    imageAnnotationChanged,
55    imageFrameUpdated,
56    invalidStatusChanged,
57    keyShortcutsChanged,
58    labeledByChanged,
59    languageChanged,
60    layoutComplete,
61    layoutInvalidated,   // fired when aria-busy goes false
62    liveRegionChanged,
63    liveRegionCreated,
64    liveRegionNodeChanged,  // fired on a node within a live region.
65    liveRelevantChanged,
66    liveStatusChanged,
67    loadComplete,
68    loadStart,
69    locationChanged,
70    mediaStartedPlaying,
71    mediaStoppedPlaying,
72    menuEnd,
73    menuItemSelected,
74    menuListItemSelected,
75    menuListValueChanged,
76    menuPopupEnd,
77    menuPopupStart,
78    menuStart,
79    mouseCanceled,
80    mouseDragged,
81    mouseMoved,
82    mousePressed,
83    mouseReleased,
84    multilineStateChanged,
85    multiselectableStateChanged,
86    nameChanged,
87    objectAttributeChanged,
88    otherAttributeChanged,
89    parentChanged,
90    placeholderChanged,
91    portalActivated,
92    positionInSetChanged,
93    rangeValueChanged,
94    rangeValueMaxChanged,
95    rangeValueMinChanged,
96    rangeValueStepChanged,
97    readonlyChanged,
98    relatedNodeChanged,
99    requiredStateChanged,
100    roleChanged,
101    rowCollapsed,
102    rowCountChanged,
103    rowExpanded,
104    scrollHorizontalPositionChanged,
105    scrollPositionChanged,
106    scrollVerticalPositionChanged,
107    scrolledToAnchor,
108    selectedChanged,
109    selectedChildrenChanged,
110    selectedValueChanged,
111    selection,
112    selectionAdd,
113    selectionInTextFieldChanged,
114    selectionRemove,
115    setSizeChanged,
116    show,
117    sortChanged,
118    stateChanged,
119    subtreeCreated,
120    textAttributeChanged,
121    textSelectionChanged,  // Deprecated.
122    textChanged,
123    tooltipClosed,
124    tooltipOpened,
125    treeChanged,
126    valueInTextFieldChanged,
127    valueChanged,  // Deprecated.
128    windowActivated,
129    windowDeactivated,
130    windowVisibilityChanged
131  };
132
133  // Describes the purpose of an $(ref:automation.AutomationNode).
134  enum RoleType {
135    abbr,
136    alert,
137    alertDialog,
138    anchor,
139    application,
140    article,
141    audio,
142    banner,
143    blockquote,
144    button,
145    canvas,
146    caption,
147    caret,
148    cell,
149    checkBox,
150    client,
151    code,
152    colorWell,
153    column,
154    columnHeader,
155    comboBoxGrouping,
156    comboBoxMenuButton,
157    comment,
158    complementary,
159    contentDeletion,
160    contentInsertion,
161    contentInfo,
162    date,
163    dateTime,
164    definition,
165    descriptionList,
166    descriptionListDetail,
167    descriptionListTerm,
168    desktop,
169    details,
170    dialog,
171    directory,
172    disclosureTriangle,
173    // --------------------------------------------------------------
174    // DPub Roles:
175    // https://www.w3.org/TR/dpub-aam-1.0/#mapping_role_table
176    docAbstract,
177    docAcknowledgments,
178    docAfterword,
179    docAppendix,
180    docBackLink,
181    docBiblioEntry,
182    docBibliography,
183    docBiblioRef,
184    docChapter,
185    docColophon,
186    docConclusion,
187    docCover,
188    docCredit,
189    docCredits,
190    docDedication,
191    docEndnote,
192    docEndnotes,
193    docEpigraph,
194    docEpilogue,
195    docErrata,
196    docExample,
197    docFootnote,
198    docForeword,
199    docGlossary,
200    docGlossRef,
201    docIndex,
202    docIntroduction,
203    docNoteRef,
204    docNotice,
205    docPageBreak,
206    docPageFooter,
207    docPageHeader,
208    docPageList,
209    docPart,
210    docPreface,
211    docPrologue,
212    docPullquote,
213    docQna,
214    docSubtitle,
215    docTip,
216    docToc,
217    // End DPub roles.
218    // --------------------------------------------------------------
219    document,
220    embeddedObject,
221    emphasis,
222    feed,
223    figcaption,
224    figure,
225    footer,
226    footerAsNonLandmark,
227    form,
228    genericContainer,
229    // --------------------------------------------------------------
230    // ARIA Graphics module roles:
231    // https://rawgit.com/w3c/graphics-aam/master/#mapping_role_table
232    graphicsDocument,
233    graphicsObject,
234    graphicsSymbol,
235    // End ARIA Graphics module roles.
236    // --------------------------------------------------------------
237    grid,
238    group,
239    header,
240    headerAsNonLandmark,
241    heading,
242    iframe,
243    iframePresentational,
244    ignored,
245    image,
246    imageMap,
247    imeCandidate,
248    inlineTextBox,
249    inputTime,
250    keyboard,
251    labelText,
252    layoutTable,
253    layoutTableCell,
254    layoutTableRow,
255    legend,
256    lineBreak,
257    link,
258    list,
259    listBox,
260    listBoxOption,
261    listGrid,  // Native
262    listItem,
263    listMarker,
264    log,
265    main,
266    mark,
267    marquee,
268    math,
269    menu,
270    menuBar,
271    menuItem,
272    menuItemCheckBox,
273    menuItemRadio,
274    menuListOption,
275    menuListPopup,
276    meter,
277    navigation,
278    note,
279    pane,
280    paragraph,
281    pdfActionableHighlight, // PDF specific highlight role.
282    pluginObject,
283    popUpButton,
284    portal,
285    pre,
286    presentational,
287    progressIndicator,
288    radioButton,
289    radioGroup,
290    region,
291    rootWebArea,
292    row,
293    rowGroup,
294    rowHeader,
295    ruby,
296    rubyAnnotation,
297    scrollBar,
298    scrollView,
299    search,
300    searchBox,
301    section,
302    slider,
303    sliderThumb,
304    spinButton,
305    splitter,
306    staticText,
307    status,
308    strong,
309    suggestion,
310    svgRoot,
311    switch,
312    tab,
313    tabList,
314    tabPanel,
315    table,
316    tableHeaderContainer,
317    term,
318    textField,
319    textFieldWithComboBox,
320    time,
321    timer,
322    titleBar,
323    toggleButton,
324    toolbar,
325    tooltip,
326    tree,
327    treeGrid,
328    treeItem,
329    unknown,
330    video,
331    webArea,
332    webView,
333    window
334  };
335
336  // Describes characteristics of an $(ref:automation.AutomationNode).
337  enum StateType {
338    autofillAvailable,
339    collapsed,
340    default,
341    editable,
342    expanded,
343    focusable,
344    focused,
345    horizontal,
346    hovered,
347    ignored,
348    invisible,
349    linked,
350    multiline,
351    multiselectable,
352    offscreen,
353    protected,
354    required,
355    richlyEditable,
356    vertical,
357    visited
358  };
359
360  // All possible actions that can be performed on automation nodes.
361  enum ActionType {
362    annotatePageImages,
363    blur,
364    clearAccessibilityFocus,
365    collapse,
366    customAction,
367    decrement,
368    doDefault,
369    expand,
370    focus,
371    getImageData,
372    getTextLocation,
373    hideTooltip,
374    hitTest,
375    increment,
376    internalInvalidateTree,
377    loadInlineTextBoxes,
378    replaceSelectedText,
379    scrollBackward,
380    scrollDown,
381    scrollForward,
382    scrollLeft,
383    scrollRight,
384    scrollUp,
385    scrollToMakeVisible,
386    scrollToPoint,
387    setAccessibilityFocus,
388    setScrollOffset,
389    setSelection,
390    setSequentialFocusNavigationStartingPoint,
391    setValue,
392    showContextMenu,
393    signalEndOfTest,
394    showTooltip
395  };
396
397  // Possible changes to the automation tree. For any given atomic change
398  // to the tree, each node that's added, removed, or changed, will appear
399  // in exactly one TreeChange, with one of these types.
400  //
401  // nodeCreated means that this node was added to the tree and its parent is
402  // new as well, so it's just one node in a new subtree that was added.
403  enum TreeChangeType {
404    /**
405     * This node was added to the tree and its parent is new as well,
406     * so it's just one node in a new subtree that was added.
407     */
408    nodeCreated,
409
410    /**
411     * This node was added to the tree but its parent was already in the
412     * tree, so it's possibly the root of a new subtree - it does not mean
413     * that it necessarily has children.
414     */
415    subtreeCreated,
416
417    /**
418     * This node changed.
419     */
420    nodeChanged,
421
422    /**
423     * This node's text (name) changed.
424     */
425    textChanged,
426
427    /**
428     * This node was removed.
429     */
430    nodeRemoved,
431    /**
432     * This subtree has finished an update.
433     */
434    subtreeUpdateEnd
435  };
436
437  // Where the node's name is from.
438  enum NameFromType {
439    uninitialized,
440    attribute,
441    attributeExplicitlyEmpty,
442    caption,
443    contents,
444    placeholder,
445    relatedElement,
446    title,
447    value
448  };
449
450  enum DescriptionFromType {
451    uninitialized,
452    attribute,
453    contents,
454    relatedElement,
455    title
456  };
457
458  // The input restriction for a object -- even non-controls can be disabled.
459  enum Restriction {
460    disabled,
461    readOnly
462  };
463
464  // Indicates the availability and type of interactive popup element
465  enum HasPopup {
466    true,
467    menu,
468    listbox,
469    tree,
470    grid,
471    dialog
472  };
473
474  // Describes possible actions when performing a do default action.
475  enum DefaultActionVerb {
476    activate,
477    check,
478    click,
479    clickAncestor,
480    jump,
481    open,
482    press,
483    select,
484    uncheck
485};
486
487  // Types of markers on text. See <code>AutomationNode.markerTypes</code>.
488enum MarkerType {
489  spelling,
490  grammar,
491  textMatch,
492  activeSuggestion,
493  suggestion
494};
495
496// The following three enums are associated with an $(ref:automation.AutomationIntent).
497
498// A command associated with an $(ref:automation.AutomationIntent).
499enum IntentCommandType {
500  clearSelection,
501  delete,
502  dictate,
503  extendSelection,
504  format,
505  history,
506  insert,
507  marker,
508  moveSelection,
509  setSelection
510};
511
512// The type of an input event associated with an $(ref:automation.AutomationIntent). It describes an edit
513// command, e.g. IntentCommandType.insert, in more detail.
514enum IntentInputEventType {
515  // Insertion.
516  insertText,
517  insertLineBreak,
518  insertParagraph,
519  insertOrderedList,
520  insertUnorderedList,
521  insertHorizontalRule,
522  insertFromPaste,
523  insertFromDrop,
524  insertFromYank,
525  insertTranspose,
526  insertReplacementText,
527  insertCompositionText,
528  // Deletion.
529  deleteWordBackward,
530  deleteWordForward,
531  deleteSoftLineBackward,
532  deleteSoftLineForward,
533  deleteHardLineBackward,
534  deleteHardLineForward,
535  deleteContentBackward,
536  deleteContentForward,
537  deleteByCut,
538  deleteByDrag,
539  // History.
540  historyUndo,
541  historyRedo,
542  // Formatting.
543  formatBold,
544  formatItalic,
545  formatUnderline,
546  formatStrikeThrough,
547  formatSuperscript,
548  formatSubscript,
549  formatJustifyCenter,
550  formatJustifyFull,
551  formatJustifyRight,
552  formatJustifyLeft,
553  formatIndent,
554  formatOutdent,
555  formatRemove,
556  formatSetBlockTextDirection
557};
558
559// A text boundary associated with an $(ref:automation.AutomationIntent).
560enum IntentTextBoundaryType {
561  character,
562  format,
563  lineEnd,
564  lineStart,
565  lineStartOrEnd,
566  object,
567  pageEnd,
568  pageStart,
569  pageStartOrEnd,
570  paragraphEnd,
571  paragraphStart,
572  paragraphStartOrEnd,
573  sentenceEnd,
574  sentenceStart,
575  sentenceStartOrEnd,
576  webPage,
577  wordEnd,
578  wordStart,
579  wordStartOrEnd
580};
581
582// A move direction associated with an $(ref:automation.AutomationIntent).
583enum IntentMoveDirectionType {
584  backward,
585  forward
586};
587
588// A sort applied to a table row or column header.
589enum SortDirectionType {
590  unsorted,
591  ascending,
592  descending,
593  other
594};
595
596  dictionary Rect {
597    long left;
598    long top;
599    long width;
600    long height;
601  };
602
603  // Arguments for the find() and findAll() methods.
604  [nocompile, noinline_doc] dictionary FindParams {
605    RoleType? role;
606
607    // A map of $(ref:automation.StateType) to boolean, indicating for each
608    // state whether it should be set or not. For example:
609    // <code>{ StateType.disabled: false }</code> would only match if
610    // <code>StateType.disabled</code> was <em>not</em> present in the node's
611    // <code>state</code> object.
612    object? state;
613
614    // A map of attribute name to expected value, for example
615    // <code>{ name: 'Root directory', checkbox_mixed: true }</code>.
616    // String attribute values may be specified as a regex, for example
617    // <code>{ name: /stralia$/</code> }</code>.
618    // Unless specifying a regex, the expected value must be an exact match
619    // in type and value for the actual value. Thus, the type of expected value
620    // must be one of:
621    // <ul>
622    // <li>string</li>
623    // <li>integer</li>
624    // <li>float</li>
625    // <li>boolean</li>
626    // </ul>
627    object? attributes;
628  };
629
630  // Arguments for the setDocumentSelection() function.
631  [nocompile, noinline_doc] dictionary SetDocumentSelectionParams {
632    // The node where the selection begins.
633    [instanceOf=AutomationNode] object anchorObject;
634
635    // The offset in the anchor node where the selection begins.
636    long anchorOffset;
637
638    // The node where the selection ends.
639    [instanceOf=AutomationNode] object focusObject;
640
641    // The offset within the focus node where the selection ends.
642    long focusOffset;
643  };
644
645  // Called when the result for a <code>query</code> is available.
646  callback QueryCallback = void(AutomationNode node);
647
648  [nocompile, noinline_doc] dictionary AutomationIntent {
649    // A command associated with this AutomationIntent.
650    IntentCommandType command;
651
652    // A text boundary associated with this AutomationIntent.
653    IntentTextBoundaryType textBoundary;
654
655    // A move direction associated with this AutomationIntent.
656    IntentMoveDirectionType moveDirection;
657  };
658
659  // An event in the Automation tree.
660  [nocompile, noinline_doc] dictionary AutomationEvent {
661    // The $(ref:automation.AutomationNode) to which the event was targeted.
662    AutomationNode target;
663
664    // The type of the event.
665    EventType type;
666
667    // The source of this event.
668    DOMString eventFrom;
669
670    // Any mouse coordinates associated with this event.
671    long mouseX;
672    long mouseY;
673
674    // A list of $(ref:automation.AutomationIntent)s associated with this event.
675    AutomationIntent[] intents;
676
677    // Stops this event from further processing except for any remaining
678    // listeners on $(ref:automation.AutomationEvent.target).
679    static void stopPropagation();
680  };
681
682  // A listener for events on an <code>AutomationNode</code>.
683  callback AutomationListener = void(AutomationEvent event);
684
685  // A change to the Automation tree.
686  [nocompile, noinline_doc] dictionary TreeChange {
687    // The $(ref:automation.AutomationNode) that changed.
688    AutomationNode target;
689
690    // The type of change.
691    TreeChangeType type;
692  };
693
694  // Possible tree changes to listen to using addTreeChangeObserver.
695  // Note that listening to all tree changes can be expensive.
696  enum TreeChangeObserverFilter {
697    noTreeChanges,
698    liveRegionTreeChanges,
699    textMarkerChanges,
700    allTreeChanges
701  };
702
703  // A listener for changes on the <code>AutomationNode</code> tree.
704  callback TreeChangeObserver = void(TreeChange treeChange);
705
706  // Callback called for actions with a response.
707  callback PerformActionCallback = void(boolean result);
708  callback PerformActionCallbackWithNode = void(AutomationNode node);
709  callback BoundsForRangeCallback = void(Rect bounds);
710
711      [nocompile, noinline_doc] dictionary CustomAction {
712    long id;
713    DOMString description;
714  };
715
716  // The string which the indices are relative to is not included in this
717  // structure. See documentation on $(ref:languageAnnotationForStringAttribute)
718  // for details on how to associate this object with a string.
719  // Also, the start and end indices always point to the first code unit of a
720  // valid code-point.
721    [nocompile, noinline_doc] dictionary LanguageSpan {
722    // Inclusive start index of substring that contains language.
723    long startIndex;
724    // Exclusive end index of substring that contains language.
725    long endIndex;
726    // Detected language for substring.
727    DOMString language;
728    // Probability that language is correct.
729    double probability;
730  };
731
732    // A marker associated with an AutomationNode.
733  [nocompile, noinline_doc] dictionary Marker {
734    // The start offset within the text of the associated node.
735    long startOffset;
736
737    // The end offset within the text of the associated node.
738    long endOffset;
739
740    // A mapping of MarkerType to true or undefined indicating the marker types
741    // for this marker.
742    object flags;
743  };
744
745  // A position in the automation tree.
746  // See ui/accessibility/ax_position.h for documentation. All members need to
747  // be kept in sync with
748  // extensions/renderer/api/automation/automation_position.h.
749  // Some members there are kept private and not represented here.
750  [nocompile, noinline_doc] dictionary AutomationPosition {
751
752    AutomationNode? node;
753    long childIndex;
754    long textOffset;
755    DOMString affinity;
756
757    static boolean isNullPosition();
758    static boolean isTreePosition();
759    static boolean isTextPosition();
760    static boolean isLeafTextPosition();
761    static boolean atStartOfAnchor();
762    static boolean atEndOfAnchor();
763    static boolean atStartOfWord();
764    static boolean atEndOfWord();
765    static boolean atStartOfLine();
766    static boolean atEndOfLine();
767    static boolean atStartOfParagraph();
768    static boolean atEndOfParagraph();
769    static boolean atStartOfPage();
770    static boolean atEndOfPage();
771    static boolean atStartOfFormat();
772    static boolean atEndOfFormat();
773    static boolean atStartOfDocument();
774    static boolean atEndOfDocument();
775    static void asTreePosition();
776    static void asTextPosition();
777    static void asLeafTextPosition();
778    static void moveToPositionAtStartOfAnchor();
779    static void moveToPositionAtEndOfAnchor();
780    static void moveToPositionAtStartOfDocument();
781    static void moveToPositionAtEndOfDocument();
782    static void moveToParentPosition();
783    static void moveToNextLeafTreePosition();
784    static void moveToPreviousLeafTreePosition();
785    static void moveToNextLeafTextPosition();
786    static void moveToPreviousLeafTextPosition();
787    static void moveToNextCharacterPosition();
788    static void moveToPreviousCharacterPosition();
789    static void moveToNextWordStartPosition();
790    static void moveToPreviousWordStartPosition();
791    static void moveToNextWordEndPosition();
792    static void moveToPreviousWordEndPosition();
793    static void moveToNextLineStartPosition();
794    static void moveToPreviousLineStartPosition();
795    static void moveToNextLineEndPosition();
796    static void moveToPreviousLineEndPosition();
797    static void moveToPreviousFormatStartPosition();
798    static void moveToNextFormatEndPosition();
799    static void moveToNextParagraphStartPosition();
800    static void moveToPreviousParagraphStartPosition();
801    static void moveToNextParagraphEndPosition();
802    static void moveToPreviousParagraphEndPosition();
803    static void moveToNextPageStartPosition();
804    static void moveToPreviousPageStartPosition();
805    static void moveToNextPageEndPosition();
806    static void moveToPreviousPageEndPosition();
807    static void moveToNextAnchorPosition();
808    static void moveToPreviousAnchorPosition();
809    static long maxTextOffset();
810    static boolean isInLineBreak();
811    static boolean isInTextObject();
812    static boolean isInWhiteSpace();
813    static boolean isValid();
814    static DOMString getText();
815  };
816
817  // A single node in an Automation tree.
818  [nocompile, noinline_doc] dictionary AutomationNode {
819    // The root node of the tree containing this AutomationNode.
820    AutomationNode? root;
821
822    // Whether this AutomationNode is a root node.
823    boolean isRootNode;
824
825    // The role of this node.
826    RoleType? role;
827
828    // The $(ref:automation.StateType)s describing this node.
829    // <jsexterns>@type {Object<chrome.automation.StateType, boolean>}
830    // </jsexterns>
831    object? state;
832
833    // The rendered location (as a bounding box) of this node in global
834    // screen coordinates.
835    Rect? location;
836
837    // Determines the location of the text within the node specified by
838    // |startIndex| and |endIndex|, inclusively. Invokes |callback| with the
839    // bounding rectangle, in screen coordinates. |callback| can be invoked
840    // either synchronously or asynchronously. The bounds are clipped to
841    // ancestors.
842    static void boundsForRange(long startIndex, long endIndex,
843        BoundsForRangeCallback callback);
844
845    // Determines the location of the text within the node specified by
846    // |startIndex| and |endIndex|, inclusively. Invokes |callback| with the
847    // bounding rectangle, in screen coordinates. |callback| can be invoked
848    // either synchronously or asynchronously. The bounds are not clipped to
849    // ancestors.
850    static void unclippedBoundsForRange(long startIndex, long endIndex,
851        BoundsForRangeCallback callback);
852
853    // The location (as a bounding box) of this node in global screen
854    // coordinates without applying any clipping from ancestors.
855    Rect? unclippedLocation;
856
857    // The purpose of the node, other than the role, if any.
858    DOMString? description;
859
860    // Description of the state of the checkbox.
861    // Used only when the node is checkable.
862    DOMString? checkedStateDescription;
863
864    // The placeholder for this text field, if any.
865    DOMString? placeholder;
866
867    // The role description for this node.
868    DOMString? roleDescription;
869
870    // The accessible name for this node, via the
871    // <a href="http://www.w3.org/TR/wai-aria/#namecalculation">
872    // Accessible Name Calculation</a> process.
873    DOMString? name;
874
875    // The tooltip of the node, if any.
876    DOMString? tooltip;
877
878    // The source of the name.
879    NameFromType? nameFrom;
880
881    // The image annotation for image nodes, which may be a human-readable
882    // string that is the contextualized annotation or a status string related
883    // to annotations.
884    DOMString? imageAnnotation;
885
886    // The value for this node: for example the <code>value</code> attribute of
887    // an <code>&lt;input&gt; element.
888    DOMString? value;
889
890    // The HTML tag for this element, if this node is an HTML element.
891    DOMString? htmlTag;
892
893    // The level of a heading or tree item.
894    long? hierarchicalLevel;
895
896    // The start and end index of each word in an inline text box.
897    long[]? wordStarts;
898    long[]? wordEnds;
899
900    // The start index of each word within the node's name. This is different
901    // from wordStarts because it is not restricted to inline text boxes and can
902    // be used for any type of element.
903    long[]? nonInlineTextWordStarts;
904
905    // The end index of each word within the node's name. This is different
906    // from wordEnds because it is not restricted to inline text boxes and can
907    // be used for any type of element.
908    long[]? nonInlineTextWordEnds;
909
910    // The nodes, if any, which this node is specified to control via
911    // <a href="http://www.w3.org/TR/wai-aria/#aria-controls">
912    // <code>aria-controls</code></a>.
913    AutomationNode[]? controls;
914
915    // The nodes, if any, which form a description for this node.
916    AutomationNode[]? describedBy;
917
918    // The nodes, if any, which may optionally be navigated to after this
919    // one. See
920    // <a href="http://www.w3.org/TR/wai-aria/#aria-flowto">
921    // <code>aria-flowto</code></a>.
922    AutomationNode[]? flowTo;
923
924    // The nodes, if any, which form a label for this element. Generally, the
925    // text from these elements will also be exposed as the element's accessible
926    // name, via the $(ref:automation.AutomationNode.name) attribute.
927    AutomationNode[]? labelledBy;
928
929    // The node referred to by <code>aria-activedescendant</code>, where
930    // applicable
931    AutomationNode? activeDescendant;
932
933    // Reverse relationship for active descendant.
934    AutomationNode[]? activeDescendantFor;
935
936    // The target of an in-page link.
937    AutomationNode? inPageLinkTarget;
938
939    // A node that provides more details about the current node.
940    AutomationNode[]? details;
941
942    // A node that provides an error message for a current node.
943    AutomationNode? errorMessage;
944
945    // Reverse relationship for details.
946    AutomationNode[]? detailsFor;
947
948    // Reverse relationship for errorMessage.
949    AutomationNode[]? errorMessageFor;
950
951    // Reverse relationship for controls.
952    AutomationNode[]? controlledBy;
953
954    // Reverse relationship for describedBy.
955    AutomationNode[]? descriptionFor;
956
957    // Reverse relationship for flowTo.
958    AutomationNode[]? flowFrom;
959
960    // Reverse relationship for labelledBy.
961    AutomationNode[]? labelFor;
962
963    // The column header nodes for a table cell.
964    AutomationNode[]? tableCellColumnHeaders;
965
966    // The row header nodes for a table cell.
967    AutomationNode[]? tableCellRowHeaders;
968
969    // An array of standard actions available on this node.
970    ActionType[]? standardActions;
971
972    // An array of custom actions.
973    CustomAction[]? customActions;
974
975    // The action taken by calling <code>doDefault</code>.
976    DefaultActionVerb? defaultActionVerb;
977
978    //
979    // Link attributes.
980    //
981
982    // The URL that this link will navigate to.
983    DOMString? url;
984
985    //
986    // Document attributes.
987    //
988
989    // The URL of this document.
990    DOMString? docUrl;
991
992    // The title of this document.
993    DOMString? docTitle;
994
995    // Whether this document has finished loading.
996    boolean? docLoaded;
997
998    // The proportion (out of 1.0) that this doc has completed loading.
999    double? docLoadingProgress;
1000
1001    //
1002    // Scrollable container attributes.
1003    //
1004
1005    long? scrollX;
1006    long? scrollXMin;
1007    long? scrollXMax;
1008    long? scrollY;
1009    long? scrollYMin;
1010    long? scrollYMax;
1011
1012    // Indicates whether this node is scrollable.
1013    boolean? scrollable;
1014
1015    //
1016    // Editable text field attributes.
1017    //
1018
1019    // The character index of the start of the selection within this editable
1020    // text element; -1 if no selection.
1021    long? textSelStart;
1022
1023    // The character index of the end of the selection within this editable
1024    // text element; -1 if no selection.
1025    long? textSelEnd;
1026
1027    // The input type, like email or number.
1028    DOMString? textInputType;
1029
1030    // An array of Marker objects for this node.
1031    Marker[]? markers;
1032
1033    //
1034    // Tree selection attributes (available on root nodes only)
1035    //
1036
1037    // If a selection is present, whether the anchor of the selection comes
1038    // after its focus in the accessibility tree.
1039    boolean? isSelectionBackward;
1040    // The anchor node of the tree selection, if any.
1041    AutomationNode? anchorObject;
1042    // The anchor offset of the tree selection, if any.
1043    long? anchorOffset;
1044    // The affinity of the tree selection anchor, if any.
1045    DOMString? anchorAffinity;
1046    // The focus node of the tree selection, if any.
1047    AutomationNode? focusObject;
1048    // The focus offset of the tree selection, if any.
1049    long? focusOffset;
1050    // The affinity of the tree selection focus, if any.
1051    DOMString? focusAffinity;
1052
1053    // The selection start node of the tree selection, if any.
1054    AutomationNode? selectionStartObject;
1055    // The selection start offset of the tree selection, if any.
1056    long? selectionStartOffset;
1057    // The affinity of the tree selection start, if any.
1058    DOMString? selectionStartAffinity;
1059    // The selection end node of the tree selection, if any.
1060    AutomationNode? selectionEndObject;
1061    // The selection end offset of the tree selection, if any.
1062    long? selectionEndOffset;
1063    // The affinity of the tree selection end, if any.
1064    DOMString? selectionEndAffinity;
1065
1066    // Indicates that the node is marked user-select:none
1067    boolean? notUserSelectableStyle;
1068
1069    //
1070    // Range attributes.
1071    //
1072
1073    // The current value for this range.
1074    double? valueForRange;
1075
1076    // The minimum possible value for this range.
1077    double? minValueForRange;
1078
1079    // The maximum possible value for this range.
1080    double? maxValueForRange;
1081
1082    //
1083    // List attributes.
1084    //
1085
1086    // The 1-based index of an item in a set.
1087    long? posInSet;
1088
1089    // The number of items in a set;
1090    long? setSize;
1091
1092    //
1093    // Table attributes.
1094    //
1095
1096    // The number of rows in this table as specified in the DOM.
1097    long? tableRowCount;
1098
1099    // The number of rows in this table as specified by the page author.
1100    long? ariaRowCount;
1101
1102    // The number of columns in this table as specified in the DOM.
1103    long? tableColumnCount;
1104
1105    // The number of columns in this table as specified by the page author.
1106    long? ariaColumnCount;
1107
1108    //
1109    // Table cell attributes.
1110    //
1111
1112    // The zero-based index of the column that this cell is in as specified in
1113    // the DOM.
1114    long? tableCellColumnIndex;
1115
1116    // The ARIA column index as specified by the page author.
1117    long? tableCellAriaColumnIndex;
1118
1119    // The number of columns that this cell spans (default is 1).
1120    long? tableCellColumnSpan;
1121
1122    // The zero-based index of the row that this cell is in as specified in the
1123    // DOM.
1124    long? tableCellRowIndex;
1125
1126    // The ARIA row index as specified by the page author.
1127    long? tableCellAriaRowIndex;
1128
1129    // The number of rows that this cell spans (default is 1).
1130    long? tableCellRowSpan;
1131
1132    // The corresponding column header for this cell.
1133    AutomationNode? tableColumnHeader;
1134
1135    // The corresponding row header for this cell.
1136    AutomationNode? tableRowHeader;
1137
1138    // The column index of this column node.
1139    long? tableColumnIndex;
1140
1141    // The row index of this row node.
1142    long? tableRowIndex;
1143
1144    //
1145    // Live region attributes.
1146    //
1147
1148    // The type of region if this is the root of a live region.
1149    // Possible values are 'polite' and 'assertive'.
1150    DOMString? liveStatus;
1151
1152    // The value of aria-relevant for a live region.
1153    DOMString? liveRelevant;
1154
1155    // The value of aria-atomic for a live region.
1156    boolean? liveAtomic;
1157
1158    // The value of aria-busy for a live region or any other element.
1159    boolean? busy;
1160
1161    // The type of live region if this node is inside a live region.
1162    DOMString? containerLiveStatus;
1163
1164    // The value of aria-relevant if this node is inside a live region.
1165    DOMString? containerLiveRelevant;
1166
1167    // The value of aria-atomic if this node is inside a live region.
1168    boolean? containerLiveAtomic;
1169
1170    // The value of aria-busy if this node is inside a live region.
1171    boolean? containerLiveBusy;
1172
1173    //
1174    // Miscellaneous attributes.
1175    //
1176
1177    // Aria auto complete.
1178    DOMString? autoComplete;
1179
1180    // The name of the programmatic backing object.
1181    DOMString? className;
1182
1183    // Marks this subtree as modal.
1184    boolean? modal;
1185
1186    // A map containing all HTML attributes and their values
1187    // <jsexterns>@type {Object<string>}</jsexterns>
1188    object? htmlAttributes;
1189
1190    // The input type of a text field, such as "text" or "email".
1191    DOMString? inputType;
1192
1193    // The key that activates this widget.
1194    DOMString? accessKey;
1195
1196    // The value of the aria-invalid attribute, indicating the error type.
1197    DOMString? ariaInvalidValue;
1198
1199    // The CSS display attribute for this node, if applicable.
1200    DOMString? display;
1201
1202    // A data url with the contents of this object's image or thumbnail.
1203    DOMString? imageDataUrl;
1204
1205    // The author-provided language code for this subtree.
1206    DOMString? language;
1207
1208    // The detected language code for this subtree.
1209    DOMString? detectedLanguage;
1210
1211    // Indicates the availability and type of interactive popup element
1212    // true - the popup is a menu
1213    // menu - the popup is a menu
1214    // listbox - the popup is a listbox
1215    // tree - the popup is a tree
1216    // grid - the popup is a grid
1217    // dialog - the popup is a dialog
1218    DOMString? hasPopup;
1219
1220    // Input restriction, if any, such as readonly or disabled:
1221    // undefined - enabled control or other object that is not disabled
1222    // Restriction.DISABLED - disallows input in itself + any descendants
1223    // Restriction.READONLY - allow focus/selection but not input
1224    DOMString? restriction;
1225
1226    // Tri-state describing checkbox or radio button:
1227    // 'false' | 'true' | 'mixed'
1228    DOMString? checked;
1229
1230    // The inner html of this element. Only populated for math content.
1231    DOMString? innerHtml;
1232
1233    // The RGBA foreground color of this subtree, as an integer.
1234    long? color;
1235
1236    // The RGBA background color of this subtree, as an integer.
1237    long? backgroundColor;
1238
1239    // The RGBA color of an input element whose value is a color.
1240    long? colorValue;
1241
1242    // Indicates node text is subscript.
1243    boolean subscript;
1244
1245    // Indicates node text is superscript.
1246    boolean superscript;
1247
1248    // Indicates node text is bold.
1249    boolean bold;
1250
1251    // Indicates node text is italic.
1252    boolean italic;
1253
1254    // Indicates node text is underline.
1255    boolean underline;
1256
1257    // Indicates node text is line through.
1258    boolean lineThrough;
1259
1260    // Indicates whether this node is selected, unselected, or neither.
1261    boolean? selected;
1262
1263    // Indicates the font size of this node.
1264    long? fontSize;
1265
1266    // Indicates the font family.
1267    DOMString fontFamily;
1268
1269    // Indicates whether this is a root of an editable subtree.
1270    boolean editableRoot;
1271
1272    //
1273    // Walking the tree.
1274    //
1275
1276    AutomationNode[] children;
1277    AutomationNode? parent;
1278    AutomationNode? firstChild;
1279    AutomationNode? lastChild;
1280    AutomationNode? previousSibling;
1281    AutomationNode? nextSibling;
1282    AutomationNode? previousOnLine;
1283    AutomationNode? nextOnLine;
1284    AutomationNode? previousFocus;
1285    AutomationNode? nextFocus;
1286
1287    // The index of this node in its parent node's list of children. If this is
1288    // the root node, this will be undefined.
1289    long? indexInParent;
1290
1291    // The sort direction of this node.
1292    SortDirectionType sortDirection;
1293
1294    //
1295    // Actions.
1296    //
1297
1298    // Does the default action based on this node's role. This is generally
1299    // the same action that would result from clicking the node such as
1300    // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
1301    // or activating a button.
1302    static void doDefault();
1303
1304    // Places focus on this node.
1305    static void focus();
1306
1307    // Request a data url for the contents of an image, optionally
1308    // resized.  Pass zero for maxWidth and/or maxHeight for the
1309    // original size.
1310    static void getImageData(long maxWidth, long maxHeight);
1311
1312    // Does a hit test of the given global screen coordinates, and fires
1313    // eventToFire on the resulting object.
1314    static void hitTest(
1315        long x,
1316        long y,
1317        EventType eventToFire);
1318
1319    // Does a $(ref:automation.AutomationNode.hitTest), and receives a callback
1320    // with the resulting hit node.
1321    static void hitTestWithReply(
1322        long x,
1323        long y,
1324        PerformActionCallbackWithNode callback);
1325
1326    // Scrolls this node to make it visible.
1327    static void makeVisible();
1328
1329    // Performs custom action.
1330    static void performCustomAction(long customActionId);
1331
1332    // Convenience method to perform a standard action supported by this node.
1333    // For actions requiring additional arguments, call the specific binding
1334    // e.g. <code>setSelection</code>.
1335    static void performStandardAction(ActionType actionType);
1336
1337    // Replaces the selected text within a text field.
1338    static void replaceSelectedText(DOMString value);
1339
1340    // Sets accessibility focus. Accessibility focus is the node on which an
1341    // extension tracks a user's focus. This may be conveyed through a focus
1342    // ring or or speech output by the extension. Automation will dispatch more
1343    // events to the accessibility focus such as location changes.
1344    static void setAccessibilityFocus();
1345
1346    // Sets selection within a text field.
1347    static void setSelection(long startIndex, long endIndex);
1348
1349    // Clears focus and sets this node as the starting point for the next
1350    // time the user presses Tab or Shift+Tab.
1351    static void setSequentialFocusNavigationStartingPoint();
1352
1353    // Sets the value of a text field.
1354    static void setValue(DOMString value);
1355
1356    // Show the context menu for this element, as if the user right-clicked.
1357    static void showContextMenu();
1358
1359    // Resume playing any media within this tree.
1360    static void resumeMedia();
1361
1362    // Start ducking any media within this tree.
1363    static void startDuckingMedia();
1364
1365    // Stop ducking any media within this tree.
1366    static void stopDuckingMedia();
1367
1368    // Suspend any media playing within this tree.
1369    static void suspendMedia();
1370
1371    // Scrolls this scrollable container backward.
1372    static void scrollBackward(optional PerformActionCallback callback);
1373
1374    // Scrolls this scrollable container forward.
1375    static void scrollForward(optional PerformActionCallback callback);
1376
1377    // Scrolls this scrollable container up.
1378    static void scrollUp(optional PerformActionCallback callback);
1379
1380    // Scrolls this scrollable container down.
1381    static void scrollDown(optional PerformActionCallback callback);
1382
1383    // Scrolls this scrollable container left.
1384    static void scrollLeft(optional PerformActionCallback callback);
1385
1386    // Scrolls this scrollable container right.
1387    static void scrollRight(optional PerformActionCallback callback);
1388
1389    // Scrolls this scrollable container to the given point.
1390    static void scrollToPoint(long x, long y);
1391
1392    // Sets this scrollable container's scroll offset.
1393    static void setScrollOffset(long x, long y);
1394
1395    // Adds a listener for the given event type and event phase.
1396    static void addEventListener(
1397        EventType eventType, AutomationListener listener, boolean capture);
1398
1399    // Removes a listener for the given event type and event phase.
1400    static void removeEventListener(
1401        EventType eventType, AutomationListener listener, boolean capture);
1402
1403    // Gets the first node in this node's subtree which matches the given CSS
1404    // selector and is within the same DOM context.
1405    //
1406    // If this node doesn't correspond directly with an HTML node in the DOM,
1407    // querySelector will be run on this node's nearest HTML node ancestor. Note
1408    // that this may result in the query returning a node which is not a
1409    // descendant of this node.
1410    //
1411    // If the selector matches a node which doesn't directly correspond to an
1412    // automation node (for example an element within an ARIA widget, where the
1413    // ARIA widget forms one node of the automation tree, or an element which
1414    // is hidden from accessibility via hiding it using CSS or using
1415    // aria-hidden), this will return the nearest ancestor which does correspond
1416    // to an automation node.
1417    static void domQuerySelector(DOMString selector, QueryCallback callback);
1418
1419    // Finds the first AutomationNode in this node's subtree which matches the
1420    // given search parameters.
1421    static AutomationNode find(FindParams params);
1422
1423    // Finds all the AutomationNodes in this node's subtree which matches the
1424    // given search parameters.
1425    static AutomationNode[] findAll(FindParams params);
1426
1427    // Returns whether this node matches the given $(ref:automation.FindParams).
1428    static boolean matches(FindParams params);
1429
1430    static AutomationNode getNextTextMatch(
1431        DOMString searchStr, boolean backward);
1432
1433    // Returns the detected languages for the provided string attribute as an
1434    // array of LanguageSpan objects. There are several guarantees about the
1435    // format of the LanguageSpan array:
1436    // 1. Is either empty or contains LanguageSpans that cover all indices in
1437    // the associated string attribute value.
1438    // 2. Is sorted by increasing startIndex (those with smaller startIndex
1439    // appear first).
1440    // 3. LanguageSpans are non-overlapping and contain exactly one language.
1441    static LanguageSpan[] languageAnnotationForStringAttribute(
1442        DOMString attribute);
1443
1444    // Creates a position object backed by Chrome's accessibility position support.
1445    static AutomationPosition createPosition(long offset, optional boolean isUpstream);
1446  };
1447
1448  // Called when the <code>AutomationNode</code> for the page is available.
1449  callback RootCallback = void(AutomationNode rootNode);
1450
1451  // Called with the <code>AutomationNode</code> that currently has focus.
1452  callback FocusCallback = void(AutomationNode focusedNode);
1453
1454  // Called with the <code>AutomationNode</code> that currently has
1455  // accessibility focus.
1456  callback AccessibilityFocusCallback = void(AutomationNode focusedNode);
1457
1458  interface Functions {
1459    // Get the automation tree for the tab with the given tabId, or the current
1460    // tab if no tabID is given, enabling automation if necessary. Returns a
1461    // tree with a placeholder root node; listen for the "loadComplete" event to
1462    // get a notification that the tree has fully loaded (the previous root node
1463    // reference will stop working at or before this point).
1464    [nocompile] static void getTree(optional long tabId,
1465                                    optional RootCallback callback);
1466
1467    // Get the automation tree for the whole desktop which consists of all on
1468    // screen views. Note this API is currently only supported on Chrome OS.
1469    [nocompile] static void getDesktop(RootCallback callback);
1470
1471    // Get the automation node that currently has focus, globally. Will return
1472    // null if none of the nodes in any loaded trees have focus.
1473    [nocompile] static void getFocus(FocusCallback callback);
1474
1475    // Get the automation node that currently has accessibility focus, globally.
1476    // Will return null if none of the nodes in any loaded trees have
1477    // accessibility focus.
1478    [nocompile] static void getAccessibilityFocus(
1479        AccessibilityFocusCallback callback);
1480
1481    // Add a tree change observer. Tree change observers are static/global, they
1482    // listen to changes across all trees. Pass a filter to determine what
1483    // specific tree changes to listen to, and note that listnening to all
1484    // tree changes can be expensive.
1485    [nocompile] static void addTreeChangeObserver(
1486        TreeChangeObserverFilter filter, TreeChangeObserver observer);
1487
1488    // Remove a tree change observer.
1489    [nocompile] static void removeTreeChangeObserver(
1490        TreeChangeObserver observer);
1491
1492    // Sets the selection in a tree. This creates a selection in a single
1493    // tree (anchorObject and focusObject must have the same root).
1494    // Everything in the tree between the two node/offset pairs gets included
1495    // in the selection. The anchor is where the user started the selection,
1496    // while the focus is the point at which the selection gets extended
1497    // e.g. when dragging with a mouse or using the keyboard. For nodes with
1498    // the role staticText, the offset gives the character offset within
1499    // the value where the selection starts or ends, respectively.
1500    [nocompile] static void setDocumentSelection(
1501        SetDocumentSelectionParams params);
1502  };
1503};
1504