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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 var stubUISourceCode = this._stubUISourceCodes.get(debuggerModelLocation
.scriptId); | 90 var stubUISourceCode = this._stubUISourceCodes.get(debuggerModelLocation
.scriptId); |
91 if (stubUISourceCode) | 91 if (stubUISourceCode) |
92 return new WebInspector.UILocation(stubUISourceCode, rawLocation.lin
eNumber, rawLocation.columnNumber); | 92 return new WebInspector.UILocation(stubUISourceCode, rawLocation.lin
eNumber, rawLocation.columnNumber); |
93 | 93 |
94 var sourceMap = this._sourceMapForScriptId[debuggerModelLocation.scriptI
d]; | 94 var sourceMap = this._sourceMapForScriptId[debuggerModelLocation.scriptI
d]; |
95 if (!sourceMap) | 95 if (!sourceMap) |
96 return null; | 96 return null; |
97 var lineNumber = debuggerModelLocation.lineNumber; | 97 var lineNumber = debuggerModelLocation.lineNumber; |
98 var columnNumber = debuggerModelLocation.columnNumber || 0; | 98 var columnNumber = debuggerModelLocation.columnNumber || 0; |
99 var entry = sourceMap.findEntry(lineNumber, columnNumber); | 99 var entry = sourceMap.findEntry(lineNumber, columnNumber); |
100 if (!entry || entry.length === 2) | 100 if (!entry || !entry.sourceURL) |
101 return null; | 101 return null; |
102 var url = /** @type {string} */ (entry[2]); | 102 var uiSourceCode = this._networkMapping.uiSourceCodeForURL(/** @type {st
ring} */ (entry.sourceURL), this._target); |
103 var uiSourceCode = this._networkMapping.uiSourceCodeForURL(url, this._ta
rget); | |
104 if (!uiSourceCode) | 103 if (!uiSourceCode) |
105 return null; | 104 return null; |
106 return uiSourceCode.uiLocation(/** @type {number} */ (entry[3]), /** @ty
pe {number} */ (entry[4])); | 105 return uiSourceCode.uiLocation(/** @type {number} */ (entry.sourceLineNu
mber), /** @type {number} */ (entry.sourceColumnNumber)); |
107 }, | 106 }, |
108 | 107 |
109 /** | 108 /** |
110 * @override | 109 * @override |
111 * @param {!WebInspector.UISourceCode} uiSourceCode | 110 * @param {!WebInspector.UISourceCode} uiSourceCode |
112 * @param {number} lineNumber | 111 * @param {number} lineNumber |
113 * @param {number} columnNumber | 112 * @param {number} columnNumber |
114 * @return {?WebInspector.DebuggerModel.Location} | 113 * @return {?WebInspector.DebuggerModel.Location} |
115 */ | 114 */ |
116 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) | 115 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) |
117 { | 116 { |
118 if (uiSourceCode.project().type() === WebInspector.projectTypes.Service) | 117 if (uiSourceCode.project().type() === WebInspector.projectTypes.Service) |
119 return null; | 118 return null; |
120 var networkURL = this._networkMapping.networkURL(uiSourceCode); | 119 var networkURL = this._networkMapping.networkURL(uiSourceCode); |
121 if (!networkURL) | 120 if (!networkURL) |
122 return null; | 121 return null; |
123 var sourceMap = this._sourceMapForURL.get(networkURL); | 122 var sourceMap = this._sourceMapForURL.get(networkURL); |
124 if (!sourceMap) | 123 if (!sourceMap) |
125 return null; | 124 return null; |
126 var script = /** @type {!WebInspector.Script} */ (this._scriptForSourceM
ap.get(sourceMap)); | 125 var script = /** @type {!WebInspector.Script} */ (this._scriptForSourceM
ap.get(sourceMap)); |
127 console.assert(script); | 126 console.assert(script); |
128 var mappingSearchLinesCount = 5; | 127 var entry = sourceMap.firstSourceLineMapping(networkURL, lineNumber); |
129 // We do not require precise (breakpoint) location but limit the number
of lines to search or mapping. | |
130 var entry = sourceMap.findEntryReversed(networkURL, lineNumber, mappingS
earchLinesCount); | |
131 if (!entry) | 128 if (!entry) |
132 return null; | 129 return null; |
133 return this._debuggerModel.createRawLocation(script, /** @type {number}
*/ (entry[0]), /** @type {number} */ (entry[1])); | 130 return this._debuggerModel.createRawLocation(script, entry.lineNumber, e
ntry.columnNumber); |
134 }, | 131 }, |
135 | 132 |
136 /** | 133 /** |
137 * @param {!WebInspector.Script} script | 134 * @param {!WebInspector.Script} script |
138 */ | 135 */ |
139 addScript: function(script) | 136 addScript: function(script) |
140 { | 137 { |
141 if (!script.sourceMapURL) { | 138 if (!script.sourceMapURL) { |
142 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded
, this._sourceMapURLAdded.bind(this)); | 139 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded
, this._sourceMapURLAdded.bind(this)); |
143 return; | 140 return; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 * @return {boolean} | 242 * @return {boolean} |
246 */ | 243 */ |
247 uiLineHasMapping: function(uiSourceCode, lineNumber) | 244 uiLineHasMapping: function(uiSourceCode, lineNumber) |
248 { | 245 { |
249 var networkURL = this._networkMapping.networkURL(uiSourceCode); | 246 var networkURL = this._networkMapping.networkURL(uiSourceCode); |
250 if (!networkURL) | 247 if (!networkURL) |
251 return true; | 248 return true; |
252 var sourceMap = this._sourceMapForURL.get(networkURL); | 249 var sourceMap = this._sourceMapForURL.get(networkURL); |
253 if (!sourceMap) | 250 if (!sourceMap) |
254 return true; | 251 return true; |
255 return !!sourceMap.findEntryReversed(networkURL, lineNumber, 0); | 252 return !!sourceMap.firstSourceLineMapping(networkURL, lineNumber); |
256 }, | 253 }, |
257 | 254 |
258 /** | 255 /** |
259 * @param {!WebInspector.UISourceCode} uiSourceCode | 256 * @param {!WebInspector.UISourceCode} uiSourceCode |
260 */ | 257 */ |
261 _bindUISourceCode: function(uiSourceCode) | 258 _bindUISourceCode: function(uiSourceCode) |
262 { | 259 { |
263 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo
de, this); | 260 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo
de, this); |
264 }, | 261 }, |
265 | 262 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 this._sourceMapForScriptId = {}; | 359 this._sourceMapForScriptId = {}; |
363 this._scriptForSourceMap.clear(); | 360 this._scriptForSourceMap.clear(); |
364 this._sourceMapForURL.clear(); | 361 this._sourceMapForURL.clear(); |
365 }, | 362 }, |
366 | 363 |
367 dispose: function() | 364 dispose: function() |
368 { | 365 { |
369 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); | 366 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour
ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); |
370 } | 367 } |
371 } | 368 } |
OLD | NEW |