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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 this._executionContextById = new Map(); | 46 this._executionContextById = new Map(); |
47 this._executionContextComparator = SDK.ExecutionContext.comparator; | 47 this._executionContextComparator = SDK.ExecutionContext.comparator; |
48 | 48 |
49 if (Common.moduleSetting('customFormatters').get()) | 49 if (Common.moduleSetting('customFormatters').get()) |
50 this._agent.setCustomObjectFormatterEnabled(true); | 50 this._agent.setCustomObjectFormatterEnabled(true); |
51 | 51 |
52 Common.moduleSetting('customFormatters').addChangeListener(this._customForma
ttersStateChanged.bind(this)); | 52 Common.moduleSetting('customFormatters').addChangeListener(this._customForma
ttersStateChanged.bind(this)); |
53 } | 53 } |
54 | 54 |
55 /** | 55 /** |
| 56 * @return {!SDK.DebuggerModel} |
| 57 */ |
| 58 debuggerModel() { |
| 59 return /** @type {!SDK.DebuggerModel} */ (this.target().model(SDK.DebuggerMo
del)); |
| 60 } |
| 61 |
| 62 /** |
| 63 * @return {!SDK.HeapProfilerModel} |
| 64 */ |
| 65 heapProfilerModel() { |
| 66 return /** @type {!SDK.HeapProfilerModel} */ (this.target().model(SDK.HeapPr
ofilerModel)); |
| 67 } |
| 68 |
| 69 /** |
56 * @return {!Array.<!SDK.ExecutionContext>} | 70 * @return {!Array.<!SDK.ExecutionContext>} |
57 */ | 71 */ |
58 executionContexts() { | 72 executionContexts() { |
59 return this._executionContextById.valuesArray().sort(this.executionContextCo
mparator()); | 73 return this._executionContextById.valuesArray().sort(this.executionContextCo
mparator()); |
60 } | 74 } |
61 | 75 |
62 /** | 76 /** |
63 * @param {function(!SDK.ExecutionContext,!SDK.ExecutionContext)} comparator | 77 * @param {function(!SDK.ExecutionContext,!SDK.ExecutionContext)} comparator |
64 */ | 78 */ |
65 setExecutionContextComparator(comparator) { | 79 setExecutionContextComparator(comparator) { |
(...skipping 24 matching lines...) Expand all Loading... |
90 */ | 104 */ |
91 executionContext(id) { | 105 executionContext(id) { |
92 return this._executionContextById.get(id) || null; | 106 return this._executionContextById.get(id) || null; |
93 } | 107 } |
94 | 108 |
95 /** | 109 /** |
96 * @param {!Protocol.Runtime.ExecutionContextDescription} context | 110 * @param {!Protocol.Runtime.ExecutionContextDescription} context |
97 */ | 111 */ |
98 _executionContextCreated(context) { | 112 _executionContextCreated(context) { |
99 var data = context.auxData || {isDefault: true}; | 113 var data = context.auxData || {isDefault: true}; |
100 var executionContext = new SDK.ExecutionContext( | 114 var executionContext = |
101 this.target(), context.id, context.name, context.origin, data['isDefault
'], data['frameId']); | 115 new SDK.ExecutionContext(this, context.id, context.name, context.origin,
data['isDefault'], data['frameId']); |
102 this._executionContextById.set(executionContext.id, executionContext); | 116 this._executionContextById.set(executionContext.id, executionContext); |
103 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextCreate
d, executionContext); | 117 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextCreate
d, executionContext); |
104 } | 118 } |
105 | 119 |
106 /** | 120 /** |
107 * @param {number} executionContextId | 121 * @param {number} executionContextId |
108 */ | 122 */ |
109 _executionContextDestroyed(executionContextId) { | 123 _executionContextDestroyed(executionContextId) { |
110 var executionContext = this._executionContextById.get(executionContextId); | 124 var executionContext = this._executionContextById.get(executionContextId); |
111 if (!executionContext) | 125 if (!executionContext) |
112 return; | 126 return; |
113 this._executionContextById.delete(executionContextId); | 127 this._executionContextById.delete(executionContextId); |
114 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDestro
yed, executionContext); | 128 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDestro
yed, executionContext); |
115 } | 129 } |
116 | 130 |
117 fireExecutionContextOrderChanged() { | 131 fireExecutionContextOrderChanged() { |
118 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextOrderC
hanged, this); | 132 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextOrderC
hanged, this); |
119 } | 133 } |
120 | 134 |
121 _executionContextsCleared() { | 135 _executionContextsCleared() { |
122 var debuggerModel = SDK.DebuggerModel.fromTarget(this.target()); | 136 this.debuggerModel().globalObjectCleared(); |
123 if (debuggerModel) | |
124 debuggerModel.globalObjectCleared(); | |
125 var contexts = this.executionContexts(); | 137 var contexts = this.executionContexts(); |
126 this._executionContextById.clear(); | 138 this._executionContextById.clear(); |
127 for (var i = 0; i < contexts.length; ++i) | 139 for (var i = 0; i < contexts.length; ++i) |
128 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDest
royed, contexts[i]); | 140 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDest
royed, contexts[i]); |
129 } | 141 } |
130 | 142 |
131 /** | 143 /** |
132 * @param {!Protocol.Runtime.RemoteObject} payload | 144 * @param {!Protocol.Runtime.RemoteObject} payload |
133 * @return {!SDK.RemoteObject} | 145 * @return {!SDK.RemoteObject} |
134 */ | 146 */ |
135 createRemoteObject(payload) { | 147 createRemoteObject(payload) { |
136 console.assert(typeof payload === 'object', 'Remote object payload should on
ly be an object'); | 148 console.assert(typeof payload === 'object', 'Remote object payload should on
ly be an object'); |
137 return new SDK.RemoteObjectImpl( | 149 return new SDK.RemoteObjectImpl( |
138 this.target(), payload.objectId, payload.type, payload.subtype, payload.
value, payload.unserializableValue, | 150 this, payload.objectId, payload.type, payload.subtype, payload.value, pa
yload.unserializableValue, |
139 payload.description, payload.preview, payload.customPreview); | 151 payload.description, payload.preview, payload.customPreview); |
140 } | 152 } |
141 | 153 |
142 /** | 154 /** |
143 * @param {!Protocol.Runtime.RemoteObject} payload | 155 * @param {!Protocol.Runtime.RemoteObject} payload |
144 * @param {!SDK.ScopeRef} scopeRef | 156 * @param {!SDK.ScopeRef} scopeRef |
145 * @return {!SDK.RemoteObject} | 157 * @return {!SDK.RemoteObject} |
146 */ | 158 */ |
147 createScopeRemoteObject(payload, scopeRef) { | 159 createScopeRemoteObject(payload, scopeRef) { |
148 return new SDK.ScopeRemoteObject( | 160 return new SDK.ScopeRemoteObject( |
149 this.target(), payload.objectId, scopeRef, payload.type, payload.subtype
, payload.value, | 161 this, payload.objectId, scopeRef, payload.type, payload.subtype, payload
.value, payload.unserializableValue, |
150 payload.unserializableValue, payload.description, payload.preview); | 162 payload.description, payload.preview); |
151 } | 163 } |
152 | 164 |
153 /** | 165 /** |
154 * @param {number|string|boolean|undefined} value | 166 * @param {number|string|boolean|undefined} value |
155 * @return {!SDK.RemoteObject} | 167 * @return {!SDK.RemoteObject} |
156 */ | 168 */ |
157 createRemoteObjectFromPrimitiveValue(value) { | 169 createRemoteObjectFromPrimitiveValue(value) { |
158 var type = typeof value; | 170 var type = typeof value; |
159 var unserializableValue = undefined; | 171 var unserializableValue = undefined; |
160 if (typeof value === 'number') { | 172 if (typeof value === 'number') { |
161 var description = String(value); | 173 var description = String(value); |
162 if (value === 0 && 1 / value < 0) | 174 if (value === 0 && 1 / value < 0) |
163 unserializableValue = Protocol.Runtime.UnserializableValue.Negative0; | 175 unserializableValue = Protocol.Runtime.UnserializableValue.Negative0; |
164 if (description === 'NaN') | 176 if (description === 'NaN') |
165 unserializableValue = Protocol.Runtime.UnserializableValue.NaN; | 177 unserializableValue = Protocol.Runtime.UnserializableValue.NaN; |
166 if (description === 'Infinity') | 178 if (description === 'Infinity') |
167 unserializableValue = Protocol.Runtime.UnserializableValue.Infinity; | 179 unserializableValue = Protocol.Runtime.UnserializableValue.Infinity; |
168 if (description === '-Infinity') | 180 if (description === '-Infinity') |
169 unserializableValue = Protocol.Runtime.UnserializableValue.NegativeInfin
ity; | 181 unserializableValue = Protocol.Runtime.UnserializableValue.NegativeInfin
ity; |
170 if (typeof unserializableValue !== 'undefined') | 182 if (typeof unserializableValue !== 'undefined') |
171 value = undefined; | 183 value = undefined; |
172 } | 184 } |
173 return new SDK.RemoteObjectImpl(this.target(), undefined, type, undefined, v
alue, unserializableValue); | 185 return new SDK.RemoteObjectImpl(this, undefined, type, undefined, value, uns
erializableValue); |
174 } | 186 } |
175 | 187 |
176 /** | 188 /** |
177 * @param {string} name | 189 * @param {string} name |
178 * @param {number|string|boolean} value | 190 * @param {number|string|boolean} value |
179 * @return {!SDK.RemoteObjectProperty} | 191 * @return {!SDK.RemoteObjectProperty} |
180 */ | 192 */ |
181 createRemotePropertyFromPrimitiveValue(name, value) { | 193 createRemotePropertyFromPrimitiveValue(name, value) { |
182 return new SDK.RemoteObjectProperty(name, this.createRemoteObjectFromPrimiti
veValue(value)); | 194 return new SDK.RemoteObjectProperty(name, this.createRemoteObjectFromPrimiti
veValue(value)); |
183 } | 195 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 * @param {!Object=} hints | 489 * @param {!Object=} hints |
478 */ | 490 */ |
479 inspectRequested(payload, hints) { | 491 inspectRequested(payload, hints) { |
480 this._runtimeModel._inspectRequested(payload, hints); | 492 this._runtimeModel._inspectRequested(payload, hints); |
481 } | 493 } |
482 }; | 494 }; |
483 | 495 |
484 /** | 496 /** |
485 * @unrestricted | 497 * @unrestricted |
486 */ | 498 */ |
487 SDK.ExecutionContext = class extends SDK.SDKObject { | 499 SDK.ExecutionContext = class { |
488 /** | 500 /** |
489 * @param {!SDK.Target} target | 501 * @param {!SDK.RuntimeModel} runtimeModel |
490 * @param {number} id | 502 * @param {number} id |
491 * @param {string} name | 503 * @param {string} name |
492 * @param {string} origin | 504 * @param {string} origin |
493 * @param {boolean} isDefault | 505 * @param {boolean} isDefault |
494 * @param {string=} frameId | 506 * @param {string=} frameId |
495 */ | 507 */ |
496 constructor(target, id, name, origin, isDefault, frameId) { | 508 constructor(runtimeModel, id, name, origin, isDefault, frameId) { |
497 super(target); | |
498 this.id = id; | 509 this.id = id; |
499 this.name = name; | 510 this.name = name; |
500 this.origin = origin; | 511 this.origin = origin; |
501 this.isDefault = isDefault; | 512 this.isDefault = isDefault; |
502 this.runtimeModel = target.runtimeModel; | 513 this.runtimeModel = runtimeModel; |
503 this.debuggerModel = SDK.DebuggerModel.fromTarget(target); | 514 this.debuggerModel = runtimeModel.debuggerModel(); |
504 this.frameId = frameId; | 515 this.frameId = frameId; |
505 this._setLabel(''); | 516 this._setLabel(''); |
506 } | 517 } |
507 | 518 |
508 /** | 519 /** |
| 520 * @return {!SDK.Target} |
| 521 */ |
| 522 target() { |
| 523 return this.runtimeModel.target(); |
| 524 } |
| 525 |
| 526 /** |
509 * @param {!SDK.ExecutionContext} a | 527 * @param {!SDK.ExecutionContext} a |
510 * @param {!SDK.ExecutionContext} b | 528 * @param {!SDK.ExecutionContext} b |
511 * @return {number} | 529 * @return {number} |
512 */ | 530 */ |
513 static comparator(a, b) { | 531 static comparator(a, b) { |
514 /** | 532 /** |
515 * @param {!SDK.Target} target | 533 * @param {!SDK.Target} target |
516 * @return {number} | 534 * @return {number} |
517 */ | 535 */ |
518 function targetWeight(target) { | 536 function targetWeight(target) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 if (this.name) { | 662 if (this.name) { |
645 this._label = this.name; | 663 this._label = this.name; |
646 return; | 664 return; |
647 } | 665 } |
648 var parsedUrl = this.origin.asParsedURL(); | 666 var parsedUrl = this.origin.asParsedURL(); |
649 this._label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : ''; | 667 this._label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : ''; |
650 } | 668 } |
651 }; | 669 }; |
652 | 670 |
653 | 671 |
654 /** | 672 SDK.EventListener = class { |
655 * @unrestricted | |
656 */ | |
657 SDK.EventListener = class extends SDK.SDKObject { | |
658 /** | 673 /** |
659 * @param {!SDK.Target} target | 674 * @param {!SDK.RuntimeModel} runtimeModel |
660 * @param {!SDK.RemoteObject} eventTarget | 675 * @param {!SDK.RemoteObject} eventTarget |
661 * @param {string} type | 676 * @param {string} type |
662 * @param {boolean} useCapture | 677 * @param {boolean} useCapture |
663 * @param {boolean} passive | 678 * @param {boolean} passive |
664 * @param {boolean} once | 679 * @param {boolean} once |
665 * @param {?SDK.RemoteObject} handler | 680 * @param {?SDK.RemoteObject} handler |
666 * @param {?SDK.RemoteObject} originalHandler | 681 * @param {?SDK.RemoteObject} originalHandler |
667 * @param {!SDK.DebuggerModel.Location} location | 682 * @param {!SDK.DebuggerModel.Location} location |
668 * @param {?SDK.RemoteObject} customRemoveFunction | 683 * @param {?SDK.RemoteObject} customRemoveFunction |
669 * @param {!SDK.EventListener.Origin=} origin | 684 * @param {!SDK.EventListener.Origin=} origin |
670 */ | 685 */ |
671 constructor( | 686 constructor( |
672 target, | 687 runtimeModel, eventTarget, type, useCapture, passive, once, handler, origi
nalHandler, location, |
673 eventTarget, | 688 customRemoveFunction, origin) { |
674 type, | 689 this._runtimeModel = runtimeModel; |
675 useCapture, | |
676 passive, | |
677 once, | |
678 handler, | |
679 originalHandler, | |
680 location, | |
681 customRemoveFunction, | |
682 origin) { | |
683 super(target); | |
684 this._eventTarget = eventTarget; | 690 this._eventTarget = eventTarget; |
685 this._type = type; | 691 this._type = type; |
686 this._useCapture = useCapture; | 692 this._useCapture = useCapture; |
687 this._passive = passive; | 693 this._passive = passive; |
688 this._once = once; | 694 this._once = once; |
689 this._handler = handler; | 695 this._handler = handler; |
690 this._originalHandler = originalHandler || handler; | 696 this._originalHandler = originalHandler || handler; |
691 this._location = location; | 697 this._location = location; |
692 var script = location.script(); | 698 var script = location.script(); |
693 this._sourceURL = script ? script.contentURL() : ''; | 699 this._sourceURL = script ? script.contentURL() : ''; |
694 this._customRemoveFunction = customRemoveFunction; | 700 this._customRemoveFunction = customRemoveFunction; |
695 this._origin = origin || SDK.EventListener.Origin.Raw; | 701 this._origin = origin || SDK.EventListener.Origin.Raw; |
696 } | 702 } |
697 | 703 |
698 /** | 704 /** |
| 705 * @return {!SDK.RuntimeModel} |
| 706 */ |
| 707 runtimeModel() { |
| 708 return this._runtimeModel; |
| 709 } |
| 710 |
| 711 /** |
699 * @return {string} | 712 * @return {string} |
700 */ | 713 */ |
701 type() { | 714 type() { |
702 return this._type; | 715 return this._type; |
703 } | 716 } |
704 | 717 |
705 /** | 718 /** |
706 * @return {boolean} | 719 * @return {boolean} |
707 */ | 720 */ |
708 useCapture() { | 721 useCapture() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 this._type === 'wheel'; | 873 this._type === 'wheel'; |
861 } | 874 } |
862 }; | 875 }; |
863 | 876 |
864 /** @enum {string} */ | 877 /** @enum {string} */ |
865 SDK.EventListener.Origin = { | 878 SDK.EventListener.Origin = { |
866 Raw: 'Raw', | 879 Raw: 'Raw', |
867 Framework: 'Framework', | 880 Framework: 'Framework', |
868 FrameworkUser: 'FrameworkUser' | 881 FrameworkUser: 'FrameworkUser' |
869 }; | 882 }; |
OLD | NEW |