OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
34 */ | 34 */ |
35 WebInspector.DebuggerPresentationModel = function() | 35 WebInspector.DebuggerPresentationModel = function() |
36 { | 36 { |
37 // FIXME: apply formatter from outside as a generic mapping. | 37 // FIXME: apply formatter from outside as a generic mapping. |
38 this._formatter = new WebInspector.ScriptFormatter(); | 38 this._formatter = new WebInspector.ScriptFormatter(); |
| 39 this._rawSourceCodes = []; |
39 this._rawSourceCodeForScriptId = {}; | 40 this._rawSourceCodeForScriptId = {}; |
40 this._rawSourceCodeForURL = {}; | 41 this._rawSourceCodeForURL = {}; |
41 this._rawSourceCodeForDocumentURL = {}; | 42 this._rawSourceCodeForDocumentURL = {}; |
42 this._presentationCallFrames = []; | 43 this._presentationCallFrames = []; |
43 | 44 |
44 this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.se
ttings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bi
nd(this), WebInspector.debuggerModel); | 45 this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.se
ttings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bi
nd(this), WebInspector.debuggerModel); |
45 | 46 |
46 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.ParsedScriptSource, this._parsedScriptSource, this); | 47 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.ParsedScriptSource, this._parsedScriptSource, this); |
47 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.FailedToParseScriptSource, this._failedToParseScriptSource, this); | 48 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.FailedToParseScriptSource, this._failedToParseScriptSource, this); |
48 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerPaused, this._debuggerPaused, this); | 49 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event
s.DebuggerPaused, this._debuggerPaused, this); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sou
rceURL]; | 134 var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sou
rceURL]; |
134 if (rawSourceCode) { | 135 if (rawSourceCode) { |
135 rawSourceCode.addScript(script); | 136 rawSourceCode.addScript(script); |
136 this._bindScriptToRawSourceCode(script, rawSourceCode); | 137 this._bindScriptToRawSourceCode(script, rawSourceCode); |
137 return; | 138 return; |
138 } | 139 } |
139 } | 140 } |
140 } | 141 } |
141 | 142 |
142 rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script,
resource, this._formatter, this._formatSource); | 143 rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script,
resource, this._formatter, this._formatSource); |
| 144 this._rawSourceCodes.push(rawSourceCode); |
143 this._bindScriptToRawSourceCode(script, rawSourceCode); | 145 this._bindScriptToRawSourceCode(script, rawSourceCode); |
144 | 146 |
145 if (isInlineScript) | 147 if (isInlineScript) |
146 this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode; | 148 this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode; |
147 | 149 |
148 if (rawSourceCode.sourceMapping) | 150 if (rawSourceCode.sourceMapping) |
149 this._updateSourceMapping(rawSourceCode, null); | 151 this._updateSourceMapping(rawSourceCode, null); |
150 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceM
appingUpdated, this._sourceMappingUpdated, this); | 152 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceM
appingUpdated, this._sourceMappingUpdated, this); |
151 }, | 153 }, |
152 | 154 |
(...skipping 16 matching lines...) Expand all Loading... |
169 var oldSourceMapping = /** @type {WebInspector.RawSourceCode.SourceMappi
ng} */ event.data["oldSourceMapping"]; | 171 var oldSourceMapping = /** @type {WebInspector.RawSourceCode.SourceMappi
ng} */ event.data["oldSourceMapping"]; |
170 this._updateSourceMapping(rawSourceCode, oldSourceMapping); | 172 this._updateSourceMapping(rawSourceCode, oldSourceMapping); |
171 }, | 173 }, |
172 | 174 |
173 /** | 175 /** |
174 * @return {Array.<WebInspector.UISourceCode>} | 176 * @return {Array.<WebInspector.UISourceCode>} |
175 */ | 177 */ |
176 uiSourceCodes: function() | 178 uiSourceCodes: function() |
177 { | 179 { |
178 var result = []; | 180 var result = []; |
179 for (var id in this._rawSourceCodeForScriptId) { | 181 for (var i = 0; i < this._rawSourceCodes.length; ++i) { |
180 var uiSourceCodeList = this._rawSourceCodeForScriptId[id].sourceMapp
ing.uiSourceCodeList(); | 182 var uiSourceCodeList = this._rawSourceCodes[i].sourceMapping.uiSourc
eCodeList(); |
181 for (var i = 0; i < uiSourceCodeList.length; ++i) | 183 for (var j = 0; j < uiSourceCodeList.length; ++j) |
182 result.push(uiSourceCodeList[i]); | 184 result.push(uiSourceCodeList[j]); |
183 } | 185 } |
184 return result; | 186 return result; |
185 }, | 187 }, |
186 | 188 |
187 /** | 189 /** |
188 * @param {WebInspector.RawSourceCode} rawSourceCode | 190 * @param {WebInspector.RawSourceCode} rawSourceCode |
189 * @param {WebInspector.RawSourceCode.SourceMapping} oldSourceMapping | 191 * @param {WebInspector.RawSourceCode.SourceMapping} oldSourceMapping |
190 */ | 192 */ |
191 _updateSourceMapping: function(rawSourceCode, oldSourceMapping) | 193 _updateSourceMapping: function(rawSourceCode, oldSourceMapping) |
192 { | 194 { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 /** | 326 /** |
325 * @param {boolean} formatSource | 327 * @param {boolean} formatSource |
326 */ | 328 */ |
327 setFormatSource: function(formatSource) | 329 setFormatSource: function(formatSource) |
328 { | 330 { |
329 if (this._formatSource === formatSource) | 331 if (this._formatSource === formatSource) |
330 return; | 332 return; |
331 | 333 |
332 this._formatSource = formatSource; | 334 this._formatSource = formatSource; |
333 this._breakpointManager.reset(); | 335 this._breakpointManager.reset(); |
334 for (var id in this._rawSourceCodeForScriptId) | 336 for (var i = 0; i < this._rawSourceCodes.length; ++i) |
335 this._rawSourceCodeForScriptId[id].setFormatted(this._formatSource); | 337 this._rawSourceCodes[i].setFormatted(this._formatSource); |
336 }, | 338 }, |
337 | 339 |
338 /** | 340 /** |
339 * @param {WebInspector.UISourceCode} uiSourceCode | 341 * @param {WebInspector.UISourceCode} uiSourceCode |
340 * @param {string} sourceMappingURL | 342 * @param {string} sourceMappingURL |
341 */ | 343 */ |
342 setCompilerSourceMapping: function(uiSourceCode, sourceMappingURL) | 344 setCompilerSourceMapping: function(uiSourceCode, sourceMappingURL) |
343 { | 345 { |
344 var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(source
MappingURL); | 346 var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(source
MappingURL); |
345 uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping); | 347 uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping); |
(...skipping 29 matching lines...) Expand all Loading... |
375 // FIXME(62725): stack trace line/column numbers are one-based. | 377 // FIXME(62725): stack trace line/column numbers are one-based. |
376 var lineNumber = message.stackTrace ? message.stackTrace[0].lineNumber -
1 : message.line - 1; | 378 var lineNumber = message.stackTrace ? message.stackTrace[0].lineNumber -
1 : message.line - 1; |
377 var columnNumber = message.stackTrace ? message.stackTrace[0].columnNumb
er - 1 : 0; | 379 var columnNumber = message.stackTrace ? message.stackTrace[0].columnNumb
er - 1 : 0; |
378 var uiLocation = sourceMapping.rawLocationToUILocation(/** @type {Debugg
erAgent.Location} */ { lineNumber: lineNumber, columnNumber: columnNumber }); | 380 var uiLocation = sourceMapping.rawLocationToUILocation(/** @type {Debugg
erAgent.Location} */ { lineNumber: lineNumber, columnNumber: columnNumber }); |
379 var presentationMessage = new WebInspector.PresentationConsoleMessage(ui
Location.uiSourceCode, uiLocation.lineNumber, message); | 381 var presentationMessage = new WebInspector.PresentationConsoleMessage(ui
Location.uiSourceCode, uiLocation.lineNumber, message); |
380 return presentationMessage; | 382 return presentationMessage; |
381 }, | 383 }, |
382 | 384 |
383 _consoleCleared: function() | 385 _consoleCleared: function() |
384 { | 386 { |
385 for (var id in this._rawSourceCodeForScriptId) | 387 for (var i = 0; i < this._rawSourceCodes.length; ++i) |
386 this._rawSourceCodeForScriptId[id].messages = []; | 388 this._rawSourceCodes[i].messages = []; |
387 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.ConsoleMessagesCleared); | 389 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.ConsoleMessagesCleared); |
388 }, | 390 }, |
389 | 391 |
390 /** | 392 /** |
391 * @param {WebInspector.UISourceCode} uiSourceCode | 393 * @param {WebInspector.UISourceCode} uiSourceCode |
392 * @param {number} lineNumber | 394 * @param {number} lineNumber |
393 */ | 395 */ |
394 continueToLine: function(uiSourceCode, lineNumber) | 396 continueToLine: function(uiSourceCode, lineNumber) |
395 { | 397 { |
396 // FIXME: use RawSourceCode.uiLocationToRawLocation. | 398 // FIXME: use RawSourceCode.uiLocationToRawLocation. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 */ | 649 */ |
648 function filter(script) | 650 function filter(script) |
649 { | 651 { |
650 return script.scriptId === rawSourceCode.id; | 652 return script.scriptId === rawSourceCode.id; |
651 } | 653 } |
652 return WebInspector.debuggerModel.queryScripts(filter.bind(this))[0]; | 654 return WebInspector.debuggerModel.queryScripts(filter.bind(this))[0]; |
653 }, | 655 }, |
654 | 656 |
655 _debuggerReset: function() | 657 _debuggerReset: function() |
656 { | 658 { |
657 for (var id in this._rawSourceCodeForScriptId) { | 659 for (var i = 0; i < this._rawSourceCodes.length; ++i) { |
658 var rawSourceCode = this._rawSourceCodeForScriptId[id]; | 660 var rawSourceCode = this._rawSourceCodes[i]; |
659 if (rawSourceCode.sourceMapping) { | 661 if (rawSourceCode.sourceMapping) { |
660 var uiSourceCodeList = rawSourceCode.sourceMapping.uiSourceCodeL
ist(); | 662 var uiSourceCodeList = rawSourceCode.sourceMapping.uiSourceCodeL
ist(); |
661 for (var i = 0; i < uiSourceCodeList.length; ++i) | 663 for (var j = 0; j < uiSourceCodeList.length; ++j) |
662 this.dispatchEventToListeners(WebInspector.DebuggerPresentat
ionModel.Events.UISourceCodeRemoved, uiSourceCodeList[i]); | 664 this.dispatchEventToListeners(WebInspector.DebuggerPresentat
ionModel.Events.UISourceCodeRemoved, uiSourceCodeList[j]); |
663 } | 665 } |
664 rawSourceCode.removeAllListeners(); | 666 rawSourceCode.removeAllListeners(); |
665 } | 667 } |
| 668 this._rawSourceCodes = []; |
666 this._rawSourceCodeForScriptId = {}; | 669 this._rawSourceCodeForScriptId = {}; |
667 this._rawSourceCodeForURL = {}; | 670 this._rawSourceCodeForURL = {}; |
668 this._rawSourceCodeForDocumentURL = {}; | 671 this._rawSourceCodeForDocumentURL = {}; |
669 this._presentationCallFrames = []; | 672 this._presentationCallFrames = []; |
670 this._selectedCallFrame = null; | 673 this._selectedCallFrame = null; |
671 this._breakpointManager.debuggerReset(); | 674 this._breakpointManager.debuggerReset(); |
672 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.DebuggerReset); | 675 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.DebuggerReset); |
673 } | 676 } |
674 } | 677 } |
675 | 678 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 this._formatter.formatRawSourceCodeAnchor(rawSourceCode, anchor); | 1019 this._formatter.formatRawSourceCodeAnchor(rawSourceCode, anchor); |
1017 } | 1020 } |
1018 } | 1021 } |
1019 | 1022 |
1020 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebI
nspector.ResourceDomainModelBinding.prototype; | 1023 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebI
nspector.ResourceDomainModelBinding.prototype; |
1021 | 1024 |
1022 /** | 1025 /** |
1023 * @type {?WebInspector.DebuggerPresentationModel} | 1026 * @type {?WebInspector.DebuggerPresentationModel} |
1024 */ | 1027 */ |
1025 WebInspector.debuggerPresentationModel = null; | 1028 WebInspector.debuggerPresentationModel = null; |
OLD | NEW |