Chromium Code Reviews| 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); |
| 127 var entry = null; | |
| 128 var mappingSearchLinesCount = 5; | 128 var mappingSearchLinesCount = 5; |
|
pfeldman
2015/09/04 01:38:36
Lets remove this.
lushnikov
2015/09/04 17:46:45
Done.
| |
| 129 // We do not require precise (breakpoint) location but limit the number of lines to search or mapping. | 129 for (var i = 0; i < mappingSearchLinesCount && !entry; ++i) |
| 130 var entry = sourceMap.findEntryReversed(networkURL, lineNumber, mappingS earchLinesCount); | 130 entry = sourceMap.firstSourceLineMapping(networkURL, lineNumber + i) ; |
| 131 if (!entry) | 131 if (!entry) |
| 132 return null; | 132 return null; |
| 133 return this._debuggerModel.createRawLocation(script, /** @type {number} */ (entry[0]), /** @type {number} */ (entry[1])); | 133 return this._debuggerModel.createRawLocation(script, entry.lineNumber, e ntry.columnNumber); |
| 134 }, | 134 }, |
| 135 | 135 |
| 136 /** | 136 /** |
| 137 * @param {!WebInspector.Script} script | 137 * @param {!WebInspector.Script} script |
| 138 */ | 138 */ |
| 139 addScript: function(script) | 139 addScript: function(script) |
| 140 { | 140 { |
| 141 if (!script.sourceMapURL) { | 141 if (!script.sourceMapURL) { |
| 142 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded , this._sourceMapURLAdded.bind(this)); | 142 script.addEventListener(WebInspector.Script.Events.SourceMapURLAdded , this._sourceMapURLAdded.bind(this)); |
| 143 return; | 143 return; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 * @return {boolean} | 245 * @return {boolean} |
| 246 */ | 246 */ |
| 247 uiLineHasMapping: function(uiSourceCode, lineNumber) | 247 uiLineHasMapping: function(uiSourceCode, lineNumber) |
| 248 { | 248 { |
| 249 var networkURL = this._networkMapping.networkURL(uiSourceCode); | 249 var networkURL = this._networkMapping.networkURL(uiSourceCode); |
| 250 if (!networkURL) | 250 if (!networkURL) |
| 251 return true; | 251 return true; |
| 252 var sourceMap = this._sourceMapForURL.get(networkURL); | 252 var sourceMap = this._sourceMapForURL.get(networkURL); |
| 253 if (!sourceMap) | 253 if (!sourceMap) |
| 254 return true; | 254 return true; |
| 255 return !!sourceMap.findEntryReversed(networkURL, lineNumber, 0); | 255 return !!sourceMap.firstSourceLineMapping(networkURL, lineNumber); |
| 256 }, | 256 }, |
| 257 | 257 |
| 258 /** | 258 /** |
| 259 * @param {!WebInspector.UISourceCode} uiSourceCode | 259 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 260 */ | 260 */ |
| 261 _bindUISourceCode: function(uiSourceCode) | 261 _bindUISourceCode: function(uiSourceCode) |
| 262 { | 262 { |
| 263 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo de, this); | 263 this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCo de, this); |
| 264 }, | 264 }, |
| 265 | 265 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 this._sourceMapForScriptId = {}; | 362 this._sourceMapForScriptId = {}; |
| 363 this._scriptForSourceMap.clear(); | 363 this._scriptForSourceMap.clear(); |
| 364 this._sourceMapForURL.clear(); | 364 this._sourceMapForURL.clear(); |
| 365 }, | 365 }, |
| 366 | 366 |
| 367 dispose: function() | 367 dispose: function() |
| 368 { | 368 { |
| 369 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); | 369 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); |
| 370 } | 370 } |
| 371 } | 371 } |
| OLD | NEW |