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 var AutomationEvent = require('automationEvent').AutomationEvent; | 5 var AutomationEvent = require('automationEvent').AutomationEvent; |
6 var automationInternal = | 6 var automationInternal = |
7 require('binding').Binding.create('automationInternal').generate(); | 7 require('binding').Binding.create('automationInternal').generate(); |
8 var exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
9 var IsInteractPermitted = | 9 var IsInteractPermitted = |
10 requireNative('automationInternal').IsInteractPermitted; | 10 requireNative('automationInternal').IsInteractPermitted; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 /** | 218 /** |
219 * @param {number} axTreeID The id of the accessibility tree. | 219 * @param {number} axTreeID The id of the accessibility tree. |
220 * @param {number} nodeID The id of a node. | 220 * @param {number} nodeID The id of a node. |
221 * @param {string} attr The name of an HTML attribute. | 221 * @param {string} attr The name of an HTML attribute. |
222 * @return {?string} The value of this attribute, or undefined if the tree, | 222 * @return {?string} The value of this attribute, or undefined if the tree, |
223 * node, or attribute wasn't found. | 223 * node, or attribute wasn't found. |
224 */ | 224 */ |
225 var GetHtmlAttribute = requireNative('automationInternal').GetHtmlAttribute; | 225 var GetHtmlAttribute = requireNative('automationInternal').GetHtmlAttribute; |
226 | 226 |
| 227 /** |
| 228 * @param {number} axTreeID The id of the accessibility tree. |
| 229 * @param {number} nodeID The id of a node. |
| 230 * @return {automation.NameFromType} The source of the node's name. |
| 231 */ |
| 232 var GetNameFrom = requireNative('automationInternal').GetNameFrom; |
| 233 |
227 var lastError = require('lastError'); | 234 var lastError = require('lastError'); |
228 var logging = requireNative('logging'); | 235 var logging = requireNative('logging'); |
229 var schema = requireNative('automationInternal').GetSchemaAdditions(); | |
230 var utils = require('utils'); | 236 var utils = require('utils'); |
231 | 237 |
232 /** | 238 /** |
233 * A single node in the Automation tree. | 239 * A single node in the Automation tree. |
234 * @param {AutomationRootNodeImpl} root The root of the tree. | 240 * @param {AutomationRootNodeImpl} root The root of the tree. |
235 * @constructor | 241 * @constructor |
236 */ | 242 */ |
237 function AutomationNodeImpl(root) { | 243 function AutomationNodeImpl(root) { |
238 this.rootImpl = root; | 244 this.rootImpl = root; |
239 this.hostNode_ = null; | 245 this.hostNode_ = null; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 get nextSibling() { | 358 get nextSibling() { |
353 var parent = this.parent; | 359 var parent = this.parent; |
354 if (!parent) | 360 if (!parent) |
355 return undefined; | 361 return undefined; |
356 parent = privates(parent).impl; | 362 parent = privates(parent).impl; |
357 var indexInParent = GetIndexInParent(this.treeID, this.id); | 363 var indexInParent = GetIndexInParent(this.treeID, this.id); |
358 return this.rootImpl.get( | 364 return this.rootImpl.get( |
359 GetChildIDAtIndex(parent.treeID, parent.id, indexInParent + 1)); | 365 GetChildIDAtIndex(parent.treeID, parent.id, indexInParent + 1)); |
360 }, | 366 }, |
361 | 367 |
| 368 get nameFrom() { |
| 369 return GetNameFrom(this.treeID, this.id); |
| 370 }, |
| 371 |
362 doDefault: function() { | 372 doDefault: function() { |
363 this.performAction_('doDefault'); | 373 this.performAction_('doDefault'); |
364 }, | 374 }, |
365 | 375 |
366 focus: function() { | 376 focus: function() { |
367 this.performAction_('focus'); | 377 this.performAction_('focus'); |
368 }, | 378 }, |
369 | 379 |
370 getImageData: function(maxWidth, maxHeight) { | 380 getImageData: function(maxWidth, maxHeight) { |
371 this.performAction_('getImageData', | 381 this.performAction_('getImageData', |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 return false; | 672 return false; |
663 } | 673 } |
664 } | 674 } |
665 } | 675 } |
666 return true; | 676 return true; |
667 } | 677 } |
668 }; | 678 }; |
669 | 679 |
670 var stringAttributes = [ | 680 var stringAttributes = [ |
671 'accessKey', | 681 'accessKey', |
672 'action', | |
673 'ariaInvalidValue', | 682 'ariaInvalidValue', |
674 'autoComplete', | |
675 'containerLiveRelevant', | 683 'containerLiveRelevant', |
676 'containerLiveStatus', | 684 'containerLiveStatus', |
677 'description', | 685 'description', |
678 'display', | 686 'display', |
679 'dropeffect', | |
680 'help', | |
681 'htmlTag', | |
682 'imageDataUrl', | 687 'imageDataUrl', |
683 'language', | 688 'language', |
684 'liveRelevant', | 689 'liveRelevant', |
685 'liveStatus', | 690 'liveStatus', |
686 'name', | 691 'name', |
687 'placeholder', | 692 'placeholder', |
688 'shortcut', | |
689 'textInputType', | 693 'textInputType', |
690 'url', | 694 'url', |
691 'value']; | 695 'value']; |
692 | 696 |
693 var boolAttributes = [ | 697 var boolAttributes = [ |
694 'ariaReadonly', | 698 'ariaReadonly', |
695 'buttonMixed', | 699 'buttonMixed', |
696 'canSetValue', | |
697 'canvasHasFallback', | |
698 'containerLiveAtomic', | 700 'containerLiveAtomic', |
699 'containerLiveBusy', | 701 'containerLiveBusy', |
700 'grabbed', | |
701 'isAxTreeHost', | |
702 'liveAtomic', | 702 'liveAtomic', |
703 'liveBusy', | 703 'liveBusy']; |
704 'updateLocationOnly']; | |
705 | 704 |
706 var intAttributes = [ | 705 var intAttributes = [ |
707 'backgroundColor', | 706 'backgroundColor', |
708 'color', | 707 'color', |
709 'colorValue', | 708 'colorValue', |
710 'descriptionFrom', | |
711 'hierarchicalLevel', | 709 'hierarchicalLevel', |
712 'invalidState', | |
713 'nameFrom', | |
714 'posInSet', | 710 'posInSet', |
715 'scrollX', | 711 'scrollX', |
716 'scrollXMax', | 712 'scrollXMax', |
717 'scrollXMin', | 713 'scrollXMin', |
718 'scrollY', | 714 'scrollY', |
719 'scrollYMax', | 715 'scrollYMax', |
720 'scrollYMin', | 716 'scrollYMin', |
721 'setSize', | 717 'setSize', |
722 'sortDirection', | |
723 'tableCellColumnIndex', | 718 'tableCellColumnIndex', |
724 'tableCellColumnSpan', | 719 'tableCellColumnSpan', |
725 'tableCellRowIndex', | 720 'tableCellRowIndex', |
726 'tableCellRowSpan', | 721 'tableCellRowSpan', |
727 'tableColumnCount', | 722 'tableColumnCount', |
728 'tableColumnIndex', | 723 'tableColumnIndex', |
729 'tableRowCount', | 724 'tableRowCount', |
730 'tableRowIndex', | 725 'tableRowIndex', |
731 'textDirection', | |
732 'textSelEnd', | 726 'textSelEnd', |
733 'textSelStart', | 727 'textSelStart']; |
734 'textStyle']; | |
735 | 728 |
736 var nodeRefAttributes = [ | 729 var nodeRefAttributes = [ |
737 ['activedescendantId', 'activeDescendant'], | 730 ['activedescendantId', 'activeDescendant'], |
738 ['nextOnLineId', 'nextOnLine'], | 731 ['nextOnLineId', 'nextOnLine'], |
739 ['previousOnLineId', 'previousOnLine'], | 732 ['previousOnLineId', 'previousOnLine'], |
740 ['tableColumnHeaderId', 'tableColumnHeader'], | 733 ['tableColumnHeaderId', 'tableColumnHeader'], |
741 ['tableHeaderId', 'tableHeader'], | 734 ['tableHeaderId', 'tableHeader'], |
742 ['tableRowHeaderId', 'tableRowHeader'], | 735 ['tableRowHeaderId', 'tableRowHeader']]; |
743 ['titleUiElement', 'titleUIElement']]; | |
744 | 736 |
745 var intListAttributes = [ | 737 var intListAttributes = [ |
746 'characterOffsets', | |
747 'lineBreaks', | 738 'lineBreaks', |
748 'markerEnds', | 739 'markerEnds', |
749 'markerStarts', | 740 'markerStarts', |
750 'markerTypes', | 741 'markerTypes', |
751 'wordEnds', | 742 'wordEnds', |
752 'wordStarts']; | 743 'wordStarts']; |
753 | 744 |
754 var nodeRefListAttributes = [ | 745 var nodeRefListAttributes = [ |
755 ['cellIds', 'cells'], | |
756 ['controlsIds', 'controls'], | 746 ['controlsIds', 'controls'], |
757 ['describedbyIds', 'describedBy'], | 747 ['describedbyIds', 'describedBy'], |
758 ['flowtoIds', 'flowTo'], | 748 ['flowtoIds', 'flowTo'], |
759 ['labelledbyIds', 'labelledBy'], | 749 ['labelledbyIds', 'labelledBy']]; |
760 ['uniqueCellIds', 'uniqueCells']]; | |
761 | 750 |
762 var floatAttributes = [ | 751 var floatAttributes = [ |
763 'valueForRange', | 752 'valueForRange', |
764 'minValueForRange', | 753 'minValueForRange', |
765 'maxValueForRange', | 754 'maxValueForRange']; |
766 'fontSize']; | |
767 | 755 |
768 var htmlAttributes = [ | 756 var htmlAttributes = [ |
769 ['type', 'inputType']]; | 757 ['type', 'inputType']]; |
770 | 758 |
771 var publicAttributes = []; | 759 var publicAttributes = []; |
772 | 760 |
773 $Array.forEach(stringAttributes, function(attributeName) { | 761 $Array.forEach(stringAttributes, function(attributeName) { |
774 $Array.push(publicAttributes, attributeName); | 762 $Array.push(publicAttributes, attributeName); |
775 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 763 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
776 __proto__: null, | 764 __proto__: null, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 return obj; | 1017 return obj; |
1030 }, | 1018 }, |
1031 | 1019 |
1032 remove: function(id) { | 1020 remove: function(id) { |
1033 if (this.axNodeDataCache_[id]) | 1021 if (this.axNodeDataCache_[id]) |
1034 privates(this.axNodeDataCache_[id]).impl.detach(); | 1022 privates(this.axNodeDataCache_[id]).impl.detach(); |
1035 delete this.axNodeDataCache_[id]; | 1023 delete this.axNodeDataCache_[id]; |
1036 }, | 1024 }, |
1037 | 1025 |
1038 destroy: function() { | 1026 destroy: function() { |
1039 this.dispatchEvent(schema.EventType.destroyed, 'none'); | 1027 this.dispatchEvent('destroyed', 'none'); |
1040 for (var id in this.axNodeDataCache_) | 1028 for (var id in this.axNodeDataCache_) |
1041 this.remove(id); | 1029 this.remove(id); |
1042 this.detach(); | 1030 this.detach(); |
1043 }, | 1031 }, |
1044 | 1032 |
1045 setHostNode(hostNode) { | 1033 setHostNode(hostNode) { |
1046 this.hostNode_ = hostNode; | 1034 this.hostNode_ = hostNode; |
1047 }, | 1035 }, |
1048 | 1036 |
1049 onAccessibilityEvent: function(eventParams) { | 1037 onAccessibilityEvent: function(eventParams) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 'previousSibling', | 1101 'previousSibling', |
1114 'nextSibling', | 1102 'nextSibling', |
1115 'isRootNode', | 1103 'isRootNode', |
1116 'role', | 1104 'role', |
1117 'state', | 1105 'state', |
1118 'location', | 1106 'location', |
1119 'indexInParent', | 1107 'indexInParent', |
1120 'lineStartOffsets', | 1108 'lineStartOffsets', |
1121 'root', | 1109 'root', |
1122 'htmlAttributes', | 1110 'htmlAttributes', |
| 1111 'nameFrom', |
1123 ]), | 1112 ]), |
1124 }); | 1113 }); |
1125 | 1114 |
1126 function AutomationRootNode() { | 1115 function AutomationRootNode() { |
1127 privates(AutomationRootNode).constructPrivate(this, arguments); | 1116 privates(AutomationRootNode).constructPrivate(this, arguments); |
1128 } | 1117 } |
1129 utils.expose(AutomationRootNode, AutomationRootNodeImpl, { | 1118 utils.expose(AutomationRootNode, AutomationRootNodeImpl, { |
1130 superclass: AutomationNode, | 1119 superclass: AutomationNode, |
1131 readonly: [ | 1120 readonly: [ |
1132 'chromeChannel', | 1121 'chromeChannel', |
(...skipping 17 matching lines...) Expand all Loading... |
1150 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { | 1139 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { |
1151 return AutomationRootNodeImpl.getOrCreate(treeID); | 1140 return AutomationRootNodeImpl.getOrCreate(treeID); |
1152 }); | 1141 }); |
1153 | 1142 |
1154 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { | 1143 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { |
1155 AutomationRootNodeImpl.destroy(treeID); | 1144 AutomationRootNodeImpl.destroy(treeID); |
1156 }); | 1145 }); |
1157 | 1146 |
1158 exports.$set('AutomationNode', AutomationNode); | 1147 exports.$set('AutomationNode', AutomationNode); |
1159 exports.$set('AutomationRootNode', AutomationRootNode); | 1148 exports.$set('AutomationRootNode', AutomationRootNode); |
OLD | NEW |