OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 * @this {WebInspector.ExecutionContext} | 519 * @this {WebInspector.ExecutionContext} |
520 */ | 520 */ |
521 function evaluated(result, wasThrown) | 521 function evaluated(result, wasThrown) |
522 { | 522 { |
523 if (!result || wasThrown) { | 523 if (!result || wasThrown) { |
524 completionsReadyCallback([]); | 524 completionsReadyCallback([]); |
525 return; | 525 return; |
526 } | 526 } |
527 | 527 |
528 /** | 528 /** |
529 * @param {?Array<!WebInspector.RemoteObjectProperty>} properties | |
530 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProp erties | |
531 * @this {WebInspector.ExecutionContext} | |
532 */ | |
533 function completionsForProxyTarget(properties, internalProperties) | |
534 { | |
535 if (internalProperties) { | |
lushnikov
2016/05/04 19:27:21
lets use as much fast returns as possible! the les
pfeldman
2016/05/04 22:45:07
+1
kozy
2016/05/05 00:51:08
Done.
| |
536 for (var property of internalProperties) { | |
537 if (property.name === "[[Target]]") { | |
538 var target = property.value; | |
539 if (target.subtype !== "proxy") | |
540 target.callFunctionJSON(getCompletions, [WebInsp ector.RemoteObject.toCallArgument(target.subtype)], receivedPropertyNames.bind(t his)); | |
541 else | |
542 target.getOwnProperties(completionsForProxyTarge t.bind(this)); | |
543 return; | |
544 } | |
545 } | |
546 } | |
547 completionsReadyCallback([]); | |
548 } | |
549 | |
550 /** | |
529 * @param {string=} type | 551 * @param {string=} type |
530 * @suppressReceiverCheck | 552 * @suppressReceiverCheck |
531 * @this {WebInspector.ExecutionContext} | 553 * @this {*} |
532 */ | 554 */ |
533 function getCompletions(type) | 555 function getCompletions(type) |
534 { | 556 { |
535 var object; | 557 var object; |
536 if (type === "string") | 558 if (type === "string") |
537 object = new String(""); | 559 object = new String(""); |
538 else if (type === "number") | 560 else if (type === "number") |
539 object = new Number(0); | 561 object = new Number(0); |
540 else if (type === "boolean") | 562 else if (type === "boolean") |
541 object = new Boolean(false); | 563 object = new Boolean(false); |
542 else | 564 else |
543 object = this; | 565 object = this; |
544 | 566 |
545 var resultSet = {}; | 567 var resultSet = {}; |
546 try { | 568 try { |
547 for (var o = object; o; o = o.__proto__) { | 569 for (var o = object; o; o = o.__proto__) { |
548 if (type === "array" && o === object && ArrayBuffer.isVi ew(o) && o.length > 9999) | 570 if (type === "array" && o === object && ArrayBuffer.isVi ew(o) && o.length > 9999) |
549 continue; | 571 continue; |
550 var names = Object.getOwnPropertyNames(o); | 572 var names = Object.getOwnPropertyNames(/** @type{!Object } */(o)); |
551 var isArray = Array.isArray(o); | 573 var isArray = Array.isArray(o); |
552 for (var i = 0; i < names.length; ++i) { | 574 for (var i = 0; i < names.length; ++i) { |
553 // Skip array elements indexes. | 575 // Skip array elements indexes. |
554 if (isArray && /^[0-9]/.test(names[i])) | 576 if (isArray && /^[0-9]/.test(names[i])) |
555 continue; | 577 continue; |
556 resultSet[names[i]] = true; | 578 resultSet[names[i]] = true; |
557 } | 579 } |
558 } | 580 } |
559 } catch (e) { | 581 } catch (e) { |
560 } | 582 } |
561 return resultSet; | 583 return resultSet; |
562 } | 584 } |
563 | 585 |
564 if (result.type === "object" || result.type === "function") | 586 if (result.type === "object" && result.subtype === "proxy") |
lushnikov
2016/05/04 19:27:21
result = extractTarget(result).then(onTarget);
f
kozy
2016/05/05 00:51:08
Done.
| |
587 result.getOwnProperties(completionsForProxyTarget.bind(this)); | |
588 else if (result.type === "object" || result.type === "function") | |
565 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); | 589 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); |
566 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean") | 590 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean") |
567 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, false, receivedPropertyNamesFromEval. bind(this)); | 591 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, false, receivedPropertyNamesFromEval. bind(this)); |
568 } | 592 } |
569 | 593 |
570 /** | 594 /** |
571 * @param {?WebInspector.RemoteObject} notRelevant | 595 * @param {?WebInspector.RemoteObject} notRelevant |
572 * @param {boolean} wasThrown | 596 * @param {boolean} wasThrown |
573 * @param {?RuntimeAgent.RemoteObject=} result | 597 * @param {?RuntimeAgent.RemoteObject=} result |
574 * @this {WebInspector.ExecutionContext} | 598 * @this {WebInspector.ExecutionContext} |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 /** | 837 /** |
814 * @param {string} listenerType | 838 * @param {string} listenerType |
815 */ | 839 */ |
816 setListenerType: function(listenerType) | 840 setListenerType: function(listenerType) |
817 { | 841 { |
818 this._listenerType = listenerType; | 842 this._listenerType = listenerType; |
819 }, | 843 }, |
820 | 844 |
821 __proto__: WebInspector.SDKObject.prototype | 845 __proto__: WebInspector.SDKObject.prototype |
822 } | 846 } |
OLD | NEW |