Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/renderer/resources/extensions/automation/automation_node.js

Issue 2601333002: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Optional to nullable Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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',
752 'wordStarts'];
753 742
754 var nodeRefListAttributes = [ 743 var nodeRefListAttributes = [
755 ['cellIds', 'cells'],
756 ['controlsIds', 'controls'], 744 ['controlsIds', 'controls'],
757 ['describedbyIds', 'describedBy'], 745 ['describedbyIds', 'describedBy'],
758 ['flowtoIds', 'flowTo'], 746 ['flowtoIds', 'flowTo'],
759 ['labelledbyIds', 'labelledBy'], 747 ['labelledbyIds', 'labelledBy']];
760 ['uniqueCellIds', 'uniqueCells']];
761 748
762 var floatAttributes = [ 749 var floatAttributes = [
763 'valueForRange', 750 'valueForRange',
764 'minValueForRange', 751 'minValueForRange',
765 'maxValueForRange', 752 'maxValueForRange'];
766 'fontSize'];
767 753
768 var htmlAttributes = [ 754 var htmlAttributes = [
769 ['type', 'inputType']]; 755 ['type', 'inputType']];
770 756
771 var publicAttributes = []; 757 var publicAttributes = [];
772 758
773 $Array.forEach(stringAttributes, function(attributeName) { 759 $Array.forEach(stringAttributes, function(attributeName) {
774 $Array.push(publicAttributes, attributeName); 760 $Array.push(publicAttributes, attributeName);
775 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { 761 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
776 __proto__: null, 762 __proto__: null,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 return obj; 1011 return obj;
1026 }, 1012 },
1027 1013
1028 remove: function(id) { 1014 remove: function(id) {
1029 if (this.axNodeDataCache_[id]) 1015 if (this.axNodeDataCache_[id])
1030 privates(this.axNodeDataCache_[id]).impl.detach(); 1016 privates(this.axNodeDataCache_[id]).impl.detach();
1031 delete this.axNodeDataCache_[id]; 1017 delete this.axNodeDataCache_[id];
1032 }, 1018 },
1033 1019
1034 destroy: function() { 1020 destroy: function() {
1035 this.dispatchEvent(schema.EventType.destroyed, 'none'); 1021 this.dispatchEvent('destroyed', 'none');
1036 for (var id in this.axNodeDataCache_) 1022 for (var id in this.axNodeDataCache_)
1037 this.remove(id); 1023 this.remove(id);
1038 this.detach(); 1024 this.detach();
1039 }, 1025 },
1040 1026
1041 setHostNode(hostNode) { 1027 setHostNode(hostNode) {
1042 this.hostNode_ = hostNode; 1028 this.hostNode_ = hostNode;
1043 }, 1029 },
1044 1030
1045 onAccessibilityEvent: function(eventParams) { 1031 onAccessibilityEvent: function(eventParams) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 'previousSibling', 1095 'previousSibling',
1110 'nextSibling', 1096 'nextSibling',
1111 'isRootNode', 1097 'isRootNode',
1112 'role', 1098 'role',
1113 'state', 1099 'state',
1114 'location', 1100 'location',
1115 'indexInParent', 1101 'indexInParent',
1116 'lineStartOffsets', 1102 'lineStartOffsets',
1117 'root', 1103 'root',
1118 'htmlAttributes', 1104 'htmlAttributes',
1105 'nameFrom',
1119 ]), 1106 ]),
1120 }); 1107 });
1121 1108
1122 function AutomationRootNode() { 1109 function AutomationRootNode() {
1123 privates(AutomationRootNode).constructPrivate(this, arguments); 1110 privates(AutomationRootNode).constructPrivate(this, arguments);
1124 } 1111 }
1125 utils.expose(AutomationRootNode, AutomationRootNodeImpl, { 1112 utils.expose(AutomationRootNode, AutomationRootNodeImpl, {
1126 superclass: AutomationNode, 1113 superclass: AutomationNode,
1127 readonly: [ 1114 readonly: [
1128 'docTitle', 1115 'docTitle',
(...skipping 16 matching lines...) Expand all
1145 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { 1132 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) {
1146 return AutomationRootNodeImpl.getOrCreate(treeID); 1133 return AutomationRootNodeImpl.getOrCreate(treeID);
1147 }); 1134 });
1148 1135
1149 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { 1136 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) {
1150 AutomationRootNodeImpl.destroy(treeID); 1137 AutomationRootNodeImpl.destroy(treeID);
1151 }); 1138 });
1152 1139
1153 exports.$set('AutomationNode', AutomationNode); 1140 exports.$set('AutomationNode', AutomationNode);
1154 exports.$set('AutomationRootNode', AutomationRootNode); 1141 exports.$set('AutomationRootNode', AutomationRootNode);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698