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