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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 var schema = requireNative('automationInternal').GetSchemaAdditions(); | 192 var schema = requireNative('automationInternal').GetSchemaAdditions(); |
193 var utils = require('utils'); | 193 var utils = require('utils'); |
194 | 194 |
195 /** | 195 /** |
196 * A single node in the Automation tree. | 196 * A single node in the Automation tree. |
197 * @param {AutomationRootNodeImpl} root The root of the tree. | 197 * @param {AutomationRootNodeImpl} root The root of the tree. |
198 * @constructor | 198 * @constructor |
199 */ | 199 */ |
200 function AutomationNodeImpl(root) { | 200 function AutomationNodeImpl(root) { |
201 this.rootImpl = root; | 201 this.rootImpl = root; |
202 // Public attributes. No actual data gets set on this object. | 202 this.listeners = {__proto__: null}; |
203 this.listeners = {}; | |
204 } | 203 } |
205 | 204 |
206 AutomationNodeImpl.prototype = { | 205 AutomationNodeImpl.prototype = { |
| 206 __proto__: null, |
207 treeID: -1, | 207 treeID: -1, |
208 id: -1, | 208 id: -1, |
209 role: '', | |
210 state: { busy: true }, | |
211 isRootNode: false, | 209 isRootNode: false, |
212 | 210 |
213 get root() { | 211 get root() { |
214 return this.rootImpl.wrapper; | 212 return this.rootImpl.wrapper; |
215 }, | 213 }, |
216 | 214 |
217 get parent() { | 215 get parent() { |
218 if (this.hostNode_) | 216 if (this.hostNode_) |
219 return this.hostNode_; | 217 return this.hostNode_; |
220 var parentID = GetParentID(this.treeID, this.id); | 218 var parentID = GetParentID(this.treeID, this.id); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 266 |
269 get children() { | 267 get children() { |
270 if (this.childTree) | 268 if (this.childTree) |
271 return [this.childTree]; | 269 return [this.childTree]; |
272 | 270 |
273 var children = []; | 271 var children = []; |
274 var count = GetChildCount(this.treeID, this.id); | 272 var count = GetChildCount(this.treeID, this.id); |
275 for (var i = 0; i < count; ++i) { | 273 for (var i = 0; i < count; ++i) { |
276 var childID = GetChildIDAtIndex(this.treeID, this.id, i); | 274 var childID = GetChildIDAtIndex(this.treeID, this.id, i); |
277 var child = this.rootImpl.get(childID); | 275 var child = this.rootImpl.get(childID); |
278 children.push(child); | 276 $Array.push(children, child); |
279 } | 277 } |
280 return children; | 278 return children; |
281 }, | 279 }, |
282 | 280 |
283 get previousSibling() { | 281 get previousSibling() { |
284 var parent = this.parent; | 282 var parent = this.parent; |
285 var indexInParent = GetIndexInParent(this.treeID, this.id); | 283 var indexInParent = GetIndexInParent(this.treeID, this.id); |
286 if (parent && indexInParent > 0) | 284 if (parent && indexInParent > 0) |
287 return parent.children[indexInParent - 1]; | 285 return parent.children[indexInParent - 1]; |
288 return undefined; | 286 return undefined; |
(...skipping 30 matching lines...) Expand all Loading... |
319 | 317 |
320 showContextMenu: function() { | 318 showContextMenu: function() { |
321 this.performAction_('showContextMenu'); | 319 this.performAction_('showContextMenu'); |
322 }, | 320 }, |
323 | 321 |
324 domQuerySelector: function(selector, callback) { | 322 domQuerySelector: function(selector, callback) { |
325 automationInternal.querySelector( | 323 automationInternal.querySelector( |
326 { treeID: this.rootImpl.treeID, | 324 { treeID: this.rootImpl.treeID, |
327 automationNodeID: this.id, | 325 automationNodeID: this.id, |
328 selector: selector }, | 326 selector: selector }, |
329 this.domQuerySelectorCallback_.bind(this, callback)); | 327 $Function.bind(this.domQuerySelectorCallback_, this, callback)); |
330 }, | 328 }, |
331 | 329 |
332 find: function(params) { | 330 find: function(params) { |
333 return this.findInternal_(params); | 331 return this.findInternal_(params); |
334 }, | 332 }, |
335 | 333 |
336 findAll: function(params) { | 334 findAll: function(params) { |
337 return this.findInternal_(params, []); | 335 return this.findInternal_(params, []); |
338 }, | 336 }, |
339 | 337 |
340 matches: function(params) { | 338 matches: function(params) { |
341 return this.matchInternal_(params); | 339 return this.matchInternal_(params); |
342 }, | 340 }, |
343 | 341 |
344 addEventListener: function(eventType, callback, capture) { | 342 addEventListener: function(eventType, callback, capture) { |
345 this.removeEventListener(eventType, callback); | 343 this.removeEventListener(eventType, callback); |
346 if (!this.listeners[eventType]) | 344 if (!this.listeners[eventType]) |
347 this.listeners[eventType] = []; | 345 this.listeners[eventType] = []; |
348 this.listeners[eventType].push({callback: callback, capture: !!capture}); | 346 $Array.push(this.listeners[eventType], { |
| 347 __proto__: null, |
| 348 callback: callback, |
| 349 capture: !!capture, |
| 350 }); |
349 }, | 351 }, |
350 | 352 |
351 // TODO(dtseng/aboxhall): Check this impl against spec. | 353 // TODO(dtseng/aboxhall): Check this impl against spec. |
352 removeEventListener: function(eventType, callback) { | 354 removeEventListener: function(eventType, callback) { |
353 if (this.listeners[eventType]) { | 355 if (this.listeners[eventType]) { |
354 var listeners = this.listeners[eventType]; | 356 var listeners = this.listeners[eventType]; |
355 for (var i = 0; i < listeners.length; i++) { | 357 for (var i = 0; i < listeners.length; i++) { |
356 if (callback === listeners[i].callback) | 358 if (callback === listeners[i].callback) |
357 listeners.splice(i, 1); | 359 $Array.splice(listeners, i, 1); |
358 } | 360 } |
359 } | 361 } |
360 }, | 362 }, |
361 | 363 |
362 toJSON: function() { | 364 toJSON: function() { |
363 return { treeID: this.treeID, | 365 return { treeID: this.treeID, |
364 id: this.id, | 366 id: this.id, |
365 role: this.role, | 367 role: this.role, |
366 attributes: this.attributes }; | 368 attributes: this.attributes }; |
367 }, | 369 }, |
368 | 370 |
369 dispatchEvent: function(eventType) { | 371 dispatchEvent: function(eventType) { |
370 var path = []; | 372 var path = []; |
371 var parent = this.parent; | 373 var parent = this.parent; |
372 while (parent) { | 374 while (parent) { |
373 path.push(parent); | 375 $Array.push(path, parent); |
374 parent = parent.parent; | 376 parent = parent.parent; |
375 } | 377 } |
376 var event = new AutomationEvent(eventType, this.wrapper); | 378 var event = new AutomationEvent(eventType, this.wrapper); |
377 | 379 |
378 // Dispatch the event through the propagation path in three phases: | 380 // Dispatch the event through the propagation path in three phases: |
379 // - capturing: starting from the root and going down to the target's parent | 381 // - capturing: starting from the root and going down to the target's parent |
380 // - targeting: dispatching the event on the target itself | 382 // - targeting: dispatching the event on the target itself |
381 // - bubbling: starting from the target's parent, going back up to the root. | 383 // - bubbling: starting from the target's parent, going back up to the root. |
382 // At any stage, a listener may call stopPropagation() on the event, which | 384 // At any stage, a listener may call stopPropagation() on the event, which |
383 // will immediately stop event propagation through this path. | 385 // will immediately stop event propagation through this path. |
384 if (this.dispatchEventAtCapturing_(event, path)) { | 386 if (this.dispatchEventAtCapturing_(event, path)) { |
385 if (this.dispatchEventAtTargeting_(event, path)) | 387 if (this.dispatchEventAtTargeting_(event, path)) |
386 this.dispatchEventAtBubbling_(event, path); | 388 this.dispatchEventAtBubbling_(event, path); |
387 } | 389 } |
388 }, | 390 }, |
389 | 391 |
390 toString: function() { | 392 toString: function() { |
391 var parentID = GetParentID(this.treeID, this.id); | 393 var parentID = GetParentID(this.treeID, this.id); |
392 var childTreeID = GetIntAttribute(this.treeID, this.id, 'childTreeId'); | 394 var childTreeID = GetIntAttribute(this.treeID, this.id, 'childTreeId'); |
393 var count = GetChildCount(this.treeID, this.id); | 395 var count = GetChildCount(this.treeID, this.id); |
394 var childIDs = []; | 396 var childIDs = []; |
395 for (var i = 0; i < count; ++i) { | 397 for (var i = 0; i < count; ++i) { |
396 var childID = GetChildIDAtIndex(this.treeID, this.id, i); | 398 var childID = GetChildIDAtIndex(this.treeID, this.id, i); |
397 childIDs.push(childID); | 399 $Array.push(childIDs, childID); |
398 } | 400 } |
399 | 401 |
400 var result = 'node id=' + this.id + | 402 var result = 'node id=' + this.id + |
401 ' role=' + this.role + | 403 ' role=' + this.role + |
402 ' state=' + $JSON.stringify(this.state) + | 404 ' state=' + $JSON.stringify(this.state) + |
403 ' parentID=' + parentID + | 405 ' parentID=' + parentID + |
404 ' childIds=' + $JSON.stringify(childIDs); | 406 ' childIds=' + $JSON.stringify(childIDs); |
405 if (this.hostNode_) { | 407 if (this.hostNode_) { |
406 var hostNodeImpl = privates(this.hostNode_).impl; | 408 var hostNodeImpl = privates(this.hostNode_).impl; |
407 result += ' host treeID=' + hostNodeImpl.treeID + | 409 result += ' host treeID=' + hostNodeImpl.treeID + |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 userCallback(null); | 495 userCallback(null); |
494 } | 496 } |
495 userCallback(resultNode); | 497 userCallback(resultNode); |
496 }, | 498 }, |
497 | 499 |
498 findInternal_: function(params, opt_results) { | 500 findInternal_: function(params, opt_results) { |
499 var result = null; | 501 var result = null; |
500 this.forAllDescendants_(function(node) { | 502 this.forAllDescendants_(function(node) { |
501 if (privates(node).impl.matchInternal_(params)) { | 503 if (privates(node).impl.matchInternal_(params)) { |
502 if (opt_results) | 504 if (opt_results) |
503 opt_results.push(node); | 505 $Array.push(opt_results, node); |
504 else | 506 else |
505 result = node; | 507 result = node; |
506 return !opt_results; | 508 return !opt_results; |
507 } | 509 } |
508 }); | 510 }); |
509 if (opt_results) | 511 if (opt_results) |
510 return opt_results; | 512 return opt_results; |
511 return result; | 513 return result; |
512 }, | 514 }, |
513 | 515 |
514 /** | 516 /** |
515 * Executes a closure for all of this node's descendants, in pre-order. | 517 * Executes a closure for all of this node's descendants, in pre-order. |
516 * Early-outs if the closure returns true. | 518 * Early-outs if the closure returns true. |
517 * @param {Function(AutomationNode):boolean} closure Closure to be executed | 519 * @param {Function(AutomationNode):boolean} closure Closure to be executed |
518 * for each node. Return true to early-out the traversal. | 520 * for each node. Return true to early-out the traversal. |
519 */ | 521 */ |
520 forAllDescendants_: function(closure) { | 522 forAllDescendants_: function(closure) { |
521 var stack = this.wrapper.children.reverse(); | 523 var stack = $Array.reverse(this.wrapper.children); |
522 while (stack.length > 0) { | 524 while (stack.length > 0) { |
523 var node = stack.pop(); | 525 var node = $Array.pop(stack); |
524 if (closure(node)) | 526 if (closure(node)) |
525 return; | 527 return; |
526 | 528 |
527 var children = node.children; | 529 var children = node.children; |
528 for (var i = children.length - 1; i >= 0; i--) | 530 for (var i = children.length - 1; i >= 0; i--) |
529 stack.push(children[i]); | 531 $Array.push(stack, children[i]); |
530 } | 532 } |
531 }, | 533 }, |
532 | 534 |
533 matchInternal_: function(params) { | 535 matchInternal_: function(params) { |
534 if (Object.keys(params).length == 0) | 536 if ($Object.keys(params).length === 0) |
535 return false; | 537 return false; |
536 | 538 |
537 if ('role' in params && this.role != params.role) | 539 if ('role' in params && this.role != params.role) |
538 return false; | 540 return false; |
539 | 541 |
540 if ('state' in params) { | 542 if ('state' in params) { |
541 for (var state in params.state) { | 543 for (var state in params.state) { |
542 if (params.state[state] != (state in this.state)) | 544 if (params.state[state] != (state in this.state)) |
543 return false; | 545 return false; |
544 } | 546 } |
545 } | 547 } |
546 if ('attributes' in params) { | 548 if ('attributes' in params) { |
547 for (var attribute in params.attributes) { | 549 for (var attribute in params.attributes) { |
548 var attrValue = params.attributes[attribute]; | 550 var attrValue = params.attributes[attribute]; |
549 if (typeof attrValue != 'object') { | 551 if (typeof attrValue != 'object') { |
550 if (this[attribute] !== attrValue) | 552 if (this[attribute] !== attrValue) |
551 return false; | 553 return false; |
552 } else if (attrValue instanceof RegExp) { | 554 } else if (attrValue instanceof $RegExp.self) { |
553 if (typeof this[attribute] != 'string') | 555 if (typeof this[attribute] != 'string') |
554 return false; | 556 return false; |
555 if (!attrValue.test(this[attribute])) | 557 if (!attrValue.test(this[attribute])) |
556 return false; | 558 return false; |
557 } else { | 559 } else { |
558 // TODO(aboxhall): handle intlist case. | 560 // TODO(aboxhall): handle intlist case. |
559 return false; | 561 return false; |
560 } | 562 } |
561 } | 563 } |
562 } | 564 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 'valueForRange', | 653 'valueForRange', |
652 'minValueForRange', | 654 'minValueForRange', |
653 'maxValueForRange', | 655 'maxValueForRange', |
654 'fontSize']; | 656 'fontSize']; |
655 | 657 |
656 var htmlAttributes = [ | 658 var htmlAttributes = [ |
657 ['type', 'inputType']]; | 659 ['type', 'inputType']]; |
658 | 660 |
659 var publicAttributes = []; | 661 var publicAttributes = []; |
660 | 662 |
661 stringAttributes.forEach(function (attributeName) { | 663 $Array.forEach(stringAttributes, function(attributeName) { |
662 publicAttributes.push(attributeName); | 664 $Array.push(publicAttributes, attributeName); |
663 Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 665 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
| 666 __proto__: null, |
664 get: function() { | 667 get: function() { |
665 return GetStringAttribute(this.treeID, this.id, attributeName); | 668 return GetStringAttribute(this.treeID, this.id, attributeName); |
666 } | 669 } |
667 }); | 670 }); |
668 }); | 671 }); |
669 | 672 |
670 boolAttributes.forEach(function (attributeName) { | 673 $Array.forEach(boolAttributes, function(attributeName) { |
671 publicAttributes.push(attributeName); | 674 $Array.push(publicAttributes, attributeName); |
672 Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 675 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
| 676 __proto__: null, |
673 get: function() { | 677 get: function() { |
674 return GetBoolAttribute(this.treeID, this.id, attributeName); | 678 return GetBoolAttribute(this.treeID, this.id, attributeName); |
675 } | 679 } |
676 }); | 680 }); |
677 }); | 681 }); |
678 | 682 |
679 intAttributes.forEach(function (attributeName) { | 683 $Array.forEach(intAttributes, function(attributeName) { |
680 publicAttributes.push(attributeName); | 684 $Array.push(publicAttributes, attributeName); |
681 Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 685 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
| 686 __proto__: null, |
682 get: function() { | 687 get: function() { |
683 return GetIntAttribute(this.treeID, this.id, attributeName); | 688 return GetIntAttribute(this.treeID, this.id, attributeName); |
684 } | 689 } |
685 }); | 690 }); |
686 }); | 691 }); |
687 | 692 |
688 nodeRefAttributes.forEach(function (params) { | 693 $Array.forEach(nodeRefAttributes, function(params) { |
689 var srcAttributeName = params[0]; | 694 var srcAttributeName = params[0]; |
690 var dstAttributeName = params[1]; | 695 var dstAttributeName = params[1]; |
691 publicAttributes.push(dstAttributeName); | 696 $Array.push(publicAttributes, dstAttributeName); |
692 Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { | 697 $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { |
| 698 __proto__: null, |
693 get: function() { | 699 get: function() { |
694 var id = GetIntAttribute(this.treeID, this.id, srcAttributeName); | 700 var id = GetIntAttribute(this.treeID, this.id, srcAttributeName); |
695 if (id) | 701 if (id) |
696 return this.rootImpl.get(id); | 702 return this.rootImpl.get(id); |
697 else | 703 else |
698 return undefined; | 704 return undefined; |
699 } | 705 } |
700 }); | 706 }); |
701 }); | 707 }); |
702 | 708 |
703 intListAttributes.forEach(function (attributeName) { | 709 $Array.forEach(intListAttributes, function(attributeName) { |
704 publicAttributes.push(attributeName); | 710 $Array.push(publicAttributes, attributeName); |
705 Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 711 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
| 712 __proto__: null, |
706 get: function() { | 713 get: function() { |
707 return GetIntListAttribute(this.treeID, this.id, attributeName); | 714 return GetIntListAttribute(this.treeID, this.id, attributeName); |
708 } | 715 } |
709 }); | 716 }); |
710 }); | 717 }); |
711 | 718 |
712 nodeRefListAttributes.forEach(function (params) { | 719 $Array.forEach(nodeRefListAttributes, function(params) { |
713 var srcAttributeName = params[0]; | 720 var srcAttributeName = params[0]; |
714 var dstAttributeName = params[1]; | 721 var dstAttributeName = params[1]; |
715 publicAttributes.push(dstAttributeName); | 722 $Array.push(publicAttributes, dstAttributeName); |
716 Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { | 723 $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { |
| 724 __proto__: null, |
717 get: function() { | 725 get: function() { |
718 var ids = GetIntListAttribute(this.treeID, this.id, srcAttributeName); | 726 var ids = GetIntListAttribute(this.treeID, this.id, srcAttributeName); |
719 if (!ids) | 727 if (!ids) |
720 return undefined; | 728 return undefined; |
721 var result = []; | 729 var result = []; |
722 for (var i = 0; i < ids.length; ++i) { | 730 for (var i = 0; i < ids.length; ++i) { |
723 var node = this.rootImpl.get(ids[i]); | 731 var node = this.rootImpl.get(ids[i]); |
724 if (node) | 732 if (node) |
725 result.push(node); | 733 $Array.push(result, node); |
726 } | 734 } |
727 return result; | 735 return result; |
728 } | 736 } |
729 }); | 737 }); |
730 }); | 738 }); |
731 | 739 |
732 floatAttributes.forEach(function (attributeName) { | 740 $Array.forEach(floatAttributes, function(attributeName) { |
733 publicAttributes.push(attributeName); | 741 $Array.push(publicAttributes, attributeName); |
734 Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { | 742 $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, { |
| 743 __proto__: null, |
735 get: function() { | 744 get: function() { |
736 return GetFloatAttribute(this.treeID, this.id, attributeName); | 745 return GetFloatAttribute(this.treeID, this.id, attributeName); |
737 } | 746 } |
738 }); | 747 }); |
739 }); | 748 }); |
740 | 749 |
741 htmlAttributes.forEach(function (params) { | 750 $Array.forEach(htmlAttributes, function(params) { |
742 var srcAttributeName = params[0]; | 751 var srcAttributeName = params[0]; |
743 var dstAttributeName = params[1]; | 752 var dstAttributeName = params[1]; |
744 publicAttributes.push(dstAttributeName); | 753 $Array.push(publicAttributes, dstAttributeName); |
745 Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { | 754 $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, { |
| 755 __proto__: null, |
746 get: function() { | 756 get: function() { |
747 return GetHtmlAttribute(this.treeID, this.id, srcAttributeName); | 757 return GetHtmlAttribute(this.treeID, this.id, srcAttributeName); |
748 } | 758 } |
749 }); | 759 }); |
750 }); | 760 }); |
751 | 761 |
752 /** | 762 /** |
753 * AutomationRootNode. | 763 * AutomationRootNode. |
754 * | 764 * |
755 * An AutomationRootNode is the javascript end of an AXTree living in the | 765 * An AutomationRootNode is the javascript end of an AXTree living in the |
756 * browser. AutomationRootNode handles unserializing incremental updates from | 766 * browser. AutomationRootNode handles unserializing incremental updates from |
757 * the source AXTree. Each update contains node data that form a complete tree | 767 * the source AXTree. Each update contains node data that form a complete tree |
758 * after applying the update. | 768 * after applying the update. |
759 * | 769 * |
760 * A brief note about ids used through this class. The source AXTree assigns | 770 * A brief note about ids used through this class. The source AXTree assigns |
761 * unique ids per node and we use these ids to build a hash to the actual | 771 * unique ids per node and we use these ids to build a hash to the actual |
762 * AutomationNode object. | 772 * AutomationNode object. |
763 * Thus, tree traversals amount to a lookup in our hash. | 773 * Thus, tree traversals amount to a lookup in our hash. |
764 * | 774 * |
765 * The tree itself is identified by the accessibility tree id of the | 775 * The tree itself is identified by the accessibility tree id of the |
766 * renderer widget host. | 776 * renderer widget host. |
767 * @constructor | 777 * @constructor |
768 */ | 778 */ |
769 function AutomationRootNodeImpl(treeID) { | 779 function AutomationRootNodeImpl(treeID) { |
770 AutomationNodeImpl.call(this, this); | 780 $Function.call(AutomationNodeImpl, this, this); |
771 this.treeID = treeID; | 781 this.treeID = treeID; |
772 this.axNodeDataCache_ = {}; | 782 this.axNodeDataCache_ = {__proto__: null}; |
773 } | 783 } |
774 | 784 |
775 AutomationRootNodeImpl.idToAutomationRootNode_ = {}; | 785 utils.defineProperty(AutomationRootNodeImpl, 'idToAutomationRootNode_', |
| 786 {__proto__: null}); |
776 | 787 |
777 AutomationRootNodeImpl.get = function(treeID) { | 788 utils.defineProperty(AutomationRootNodeImpl, 'get', function(treeID) { |
778 var result = AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; | 789 var result = AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; |
779 return result || undefined; | 790 return result || undefined; |
780 } | 791 }); |
781 | 792 |
782 AutomationRootNodeImpl.getOrCreate = function(treeID) { | 793 utils.defineProperty(AutomationRootNodeImpl, 'getOrCreate', function(treeID) { |
783 if (AutomationRootNodeImpl.idToAutomationRootNode_[treeID]) | 794 if (AutomationRootNodeImpl.idToAutomationRootNode_[treeID]) |
784 return AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; | 795 return AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; |
785 var result = new AutomationRootNode(treeID); | 796 var result = new AutomationRootNode(treeID); |
786 AutomationRootNodeImpl.idToAutomationRootNode_[treeID] = result; | 797 AutomationRootNodeImpl.idToAutomationRootNode_[treeID] = result; |
787 return result; | 798 return result; |
788 } | 799 }); |
789 | 800 |
790 AutomationRootNodeImpl.destroy = function(treeID) { | 801 utils.defineProperty(AutomationRootNodeImpl, 'destroy', function(treeID) { |
791 delete AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; | 802 delete AutomationRootNodeImpl.idToAutomationRootNode_[treeID]; |
792 } | 803 }); |
793 | 804 |
794 AutomationRootNodeImpl.prototype = { | 805 AutomationRootNodeImpl.prototype = { |
795 __proto__: AutomationNodeImpl.prototype, | 806 __proto__: AutomationNodeImpl.prototype, |
796 | 807 |
797 /** | 808 /** |
798 * @type {boolean} | 809 * @type {boolean} |
799 */ | 810 */ |
800 isRootNode: true, | 811 isRootNode: true, |
801 | 812 |
802 /** | 813 /** |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 }, | 929 }, |
919 | 930 |
920 toString: function() { | 931 toString: function() { |
921 function toStringInternal(nodeImpl, indent) { | 932 function toStringInternal(nodeImpl, indent) { |
922 if (!nodeImpl) | 933 if (!nodeImpl) |
923 return ''; | 934 return ''; |
924 var output = ''; | 935 var output = ''; |
925 if (nodeImpl.isRootNode) | 936 if (nodeImpl.isRootNode) |
926 output += indent + 'tree id=' + nodeImpl.treeID + '\n'; | 937 output += indent + 'tree id=' + nodeImpl.treeID + '\n'; |
927 output += indent + | 938 output += indent + |
928 AutomationNodeImpl.prototype.toString.call(nodeImpl) + | 939 $Function.call(AutomationNodeImpl.prototype.toString, nodeImpl) + '\n'; |
929 '\n'; | |
930 indent += ' '; | 940 indent += ' '; |
931 var children = nodeImpl.children; | 941 var children = nodeImpl.children; |
932 for (var i = 0; i < children.length; ++i) | 942 for (var i = 0; i < children.length; ++i) |
933 output += toStringInternal(privates(children[i]).impl, indent); | 943 output += toStringInternal(privates(children[i]).impl, indent); |
934 return output; | 944 return output; |
935 } | 945 } |
936 return toStringInternal(this, ''); | 946 return toStringInternal(this, ''); |
937 }, | 947 }, |
938 }; | 948 }; |
939 | 949 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 'docUrl', | 992 'docUrl', |
983 'docLoaded', | 993 'docLoaded', |
984 'docLoadingProgress', | 994 'docLoadingProgress', |
985 'anchorObject', | 995 'anchorObject', |
986 'anchorOffset', | 996 'anchorOffset', |
987 'focusObject', | 997 'focusObject', |
988 'focusOffset', | 998 'focusOffset', |
989 ], | 999 ], |
990 }); | 1000 }); |
991 | 1001 |
992 AutomationRootNode.get = function(treeID) { | 1002 utils.defineProperty(AutomationRootNode, 'get', function(treeID) { |
993 return AutomationRootNodeImpl.get(treeID); | 1003 return AutomationRootNodeImpl.get(treeID); |
994 } | 1004 }); |
995 | 1005 |
996 AutomationRootNode.getOrCreate = function(treeID) { | 1006 utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) { |
997 return AutomationRootNodeImpl.getOrCreate(treeID); | 1007 return AutomationRootNodeImpl.getOrCreate(treeID); |
998 } | 1008 }); |
999 | 1009 |
1000 AutomationRootNode.destroy = function(treeID) { | 1010 utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) { |
1001 AutomationRootNodeImpl.destroy(treeID); | 1011 AutomationRootNodeImpl.destroy(treeID); |
1002 } | 1012 }); |
1003 | 1013 |
1004 exports.$set('AutomationNode', AutomationNode); | 1014 exports.$set('AutomationNode', AutomationNode); |
1005 exports.$set('AutomationRootNode', AutomationRootNode); | 1015 exports.$set('AutomationRootNode', AutomationRootNode); |
OLD | NEW |