| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.DebuggerSourceMapping} | 31 * @implements {Bindings.DebuggerSourceMapping} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.DefaultScriptMapping = class { | 34 Bindings.DefaultScriptMapping = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.DebuggerModel} debuggerModel | 36 * @param {!SDK.DebuggerModel} debuggerModel |
| 37 * @param {!WebInspector.Workspace} workspace | 37 * @param {!Workspace.Workspace} workspace |
| 38 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 38 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 39 */ | 39 */ |
| 40 constructor(debuggerModel, workspace, debuggerWorkspaceBinding) { | 40 constructor(debuggerModel, workspace, debuggerWorkspaceBinding) { |
| 41 this._debuggerModel = debuggerModel; | 41 this._debuggerModel = debuggerModel; |
| 42 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; | 42 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
| 43 var projectId = WebInspector.DefaultScriptMapping.projectIdForTarget(debugge
rModel.target()); | 43 var projectId = Bindings.DefaultScriptMapping.projectIdForTarget(debuggerMod
el.target()); |
| 44 this._project = | 44 this._project = |
| 45 new WebInspector.ContentProviderBasedProject(workspace, projectId, WebIn
spector.projectTypes.Debugger, ''); | 45 new Bindings.ContentProviderBasedProject(workspace, projectId, Workspace
.projectTypes.Debugger, ''); |
| 46 /** @type {!Map.<string, !WebInspector.UISourceCode>} */ | 46 /** @type {!Map.<string, !Workspace.UISourceCode>} */ |
| 47 this._uiSourceCodeForScriptId = new Map(); | 47 this._uiSourceCodeForScriptId = new Map(); |
| 48 /** @type {!Map.<!WebInspector.UISourceCode, string>} */ | 48 /** @type {!Map.<!Workspace.UISourceCode, string>} */ |
| 49 this._scriptIdForUISourceCode = new Map(); | 49 this._scriptIdForUISourceCode = new Map(); |
| 50 this._eventListeners = [debuggerModel.addEventListener( | 50 this._eventListeners = [debuggerModel.addEventListener( |
| 51 WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerRes
et, this)]; | 51 SDK.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this)
]; |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * @param {!WebInspector.UISourceCode} uiSourceCode | 55 * @param {!Workspace.UISourceCode} uiSourceCode |
| 56 * @return {?WebInspector.Script} | 56 * @return {?SDK.Script} |
| 57 */ | 57 */ |
| 58 static scriptForUISourceCode(uiSourceCode) { | 58 static scriptForUISourceCode(uiSourceCode) { |
| 59 return uiSourceCode[WebInspector.DefaultScriptMapping._scriptSymbol] || null
; | 59 return uiSourceCode[Bindings.DefaultScriptMapping._scriptSymbol] || null; |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!WebInspector.Target} target | 63 * @param {!SDK.Target} target |
| 64 * @return {string} | 64 * @return {string} |
| 65 */ | 65 */ |
| 66 static projectIdForTarget(target) { | 66 static projectIdForTarget(target) { |
| 67 return 'debugger:' + target.id(); | 67 return 'debugger:' + target.id(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @override | 71 * @override |
| 72 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 72 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 73 * @return {!WebInspector.UILocation} | 73 * @return {!Workspace.UILocation} |
| 74 */ | 74 */ |
| 75 rawLocationToUILocation(rawLocation) { | 75 rawLocationToUILocation(rawLocation) { |
| 76 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location}
*/ (rawLocation); | 76 var debuggerModelLocation = /** @type {!SDK.DebuggerModel.Location} */ (rawL
ocation); |
| 77 var script = debuggerModelLocation.script(); | 77 var script = debuggerModelLocation.script(); |
| 78 var uiSourceCode = this._uiSourceCodeForScriptId.get(script.scriptId); | 78 var uiSourceCode = this._uiSourceCodeForScriptId.get(script.scriptId); |
| 79 var lineNumber = debuggerModelLocation.lineNumber - (script.isInlineScriptWi
thSourceURL() ? script.lineOffset : 0); | 79 var lineNumber = debuggerModelLocation.lineNumber - (script.isInlineScriptWi
thSourceURL() ? script.lineOffset : 0); |
| 80 var columnNumber = debuggerModelLocation.columnNumber || 0; | 80 var columnNumber = debuggerModelLocation.columnNumber || 0; |
| 81 if (script.isInlineScriptWithSourceURL() && !lineNumber && columnNumber) | 81 if (script.isInlineScriptWithSourceURL() && !lineNumber && columnNumber) |
| 82 columnNumber -= script.columnOffset; | 82 columnNumber -= script.columnOffset; |
| 83 return uiSourceCode.uiLocation(lineNumber, columnNumber); | 83 return uiSourceCode.uiLocation(lineNumber, columnNumber); |
| 84 } | 84 } |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * @override | 87 * @override |
| 88 * @param {!WebInspector.UISourceCode} uiSourceCode | 88 * @param {!Workspace.UISourceCode} uiSourceCode |
| 89 * @param {number} lineNumber | 89 * @param {number} lineNumber |
| 90 * @param {number} columnNumber | 90 * @param {number} columnNumber |
| 91 * @return {?WebInspector.DebuggerModel.Location} | 91 * @return {?SDK.DebuggerModel.Location} |
| 92 */ | 92 */ |
| 93 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { | 93 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
| 94 var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode); | 94 var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode); |
| 95 var script = this._debuggerModel.scriptForId(scriptId); | 95 var script = this._debuggerModel.scriptForId(scriptId); |
| 96 if (script.isInlineScriptWithSourceURL()) | 96 if (script.isInlineScriptWithSourceURL()) |
| 97 return this._debuggerModel.createRawLocation( | 97 return this._debuggerModel.createRawLocation( |
| 98 script, lineNumber + script.lineOffset, lineNumber ? columnNumber : co
lumnNumber + script.columnOffset); | 98 script, lineNumber + script.lineOffset, lineNumber ? columnNumber : co
lumnNumber + script.columnOffset); |
| 99 return this._debuggerModel.createRawLocation(script, lineNumber, columnNumbe
r); | 99 return this._debuggerModel.createRawLocation(script, lineNumber, columnNumbe
r); |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * @param {!WebInspector.Script} script | 103 * @param {!SDK.Script} script |
| 104 */ | 104 */ |
| 105 addScript(script) { | 105 addScript(script) { |
| 106 var name = WebInspector.ParsedURL.extractName(script.sourceURL); | 106 var name = Common.ParsedURL.extractName(script.sourceURL); |
| 107 var url = 'debugger:///VM' + script.scriptId + (name ? ' ' + name : ''); | 107 var url = 'debugger:///VM' + script.scriptId + (name ? ' ' + name : ''); |
| 108 | 108 |
| 109 var uiSourceCode = this._project.createUISourceCode(url, WebInspector.resour
ceTypes.Script); | 109 var uiSourceCode = this._project.createUISourceCode(url, Common.resourceType
s.Script); |
| 110 uiSourceCode[WebInspector.DefaultScriptMapping._scriptSymbol] = script; | 110 uiSourceCode[Bindings.DefaultScriptMapping._scriptSymbol] = script; |
| 111 this._uiSourceCodeForScriptId.set(script.scriptId, uiSourceCode); | 111 this._uiSourceCodeForScriptId.set(script.scriptId, uiSourceCode); |
| 112 this._scriptIdForUISourceCode.set(uiSourceCode, script.scriptId); | 112 this._scriptIdForUISourceCode.set(uiSourceCode, script.scriptId); |
| 113 this._project.addUISourceCodeWithProvider(uiSourceCode, script, null); | 113 this._project.addUISourceCodeWithProvider(uiSourceCode, script, null); |
| 114 | 114 |
| 115 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel.target()
, uiSourceCode, this); | 115 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel.target()
, uiSourceCode, this); |
| 116 this._debuggerWorkspaceBinding.pushSourceMapping(script, this); | 116 this._debuggerWorkspaceBinding.pushSourceMapping(script, this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 /** | 119 /** |
| 120 * @override | 120 * @override |
| 121 * @return {boolean} | 121 * @return {boolean} |
| 122 */ | 122 */ |
| 123 isIdentity() { | 123 isIdentity() { |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * @override | 128 * @override |
| 129 * @param {!WebInspector.UISourceCode} uiSourceCode | 129 * @param {!Workspace.UISourceCode} uiSourceCode |
| 130 * @param {number} lineNumber | 130 * @param {number} lineNumber |
| 131 * @return {boolean} | 131 * @return {boolean} |
| 132 */ | 132 */ |
| 133 uiLineHasMapping(uiSourceCode, lineNumber) { | 133 uiLineHasMapping(uiSourceCode, lineNumber) { |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 _debuggerReset() { | 137 _debuggerReset() { |
| 138 this._uiSourceCodeForScriptId.clear(); | 138 this._uiSourceCodeForScriptId.clear(); |
| 139 this._scriptIdForUISourceCode.clear(); | 139 this._scriptIdForUISourceCode.clear(); |
| 140 this._project.reset(); | 140 this._project.reset(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 dispose() { | 143 dispose() { |
| 144 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 144 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 145 this._debuggerReset(); | 145 this._debuggerReset(); |
| 146 this._project.dispose(); | 146 this._project.dispose(); |
| 147 } | 147 } |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 WebInspector.DefaultScriptMapping._scriptSymbol = Symbol('symbol'); | 150 Bindings.DefaultScriptMapping._scriptSymbol = Symbol('symbol'); |
| OLD | NEW |