Changeset 93977 in webkit
- Timestamp:
- Aug 29, 2011, 8:14:07 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r93976 r93977 1 2011-08-25 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: rename sourceFile to (raw|ui)SourceCode in DebuggerPresentationModel. 4 https://bugs.webkit.org/show_bug.cgi?id=66769 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/debugger/scripts-panel.html: 9 * inspector/debugger/source-file.html: 10 1 11 2011-08-29 Gabor Loki <loki@webkit.org> 2 12 -
trunk/LayoutTests/inspector/debugger/scripts-panel.html
r92838 r93977 154 154 model._addScript(createMockScript("foo.js", "1")); 155 155 model._addScript(createMockScript("bar.js", "2")); 156 var sourceFile = model._ sourceFileForScript("bar.js");156 var sourceFile = model._rawSourceCodeForScript("bar.js"); 157 157 panel._sourceFileReplaced({ data: { oldSourceCode: sourceFile, sourceCode: sourceFile }}); 158 158 showSourceFrame(panel, "bar.js"); -
trunk/LayoutTests/inspector/debugger/source-file.html
r93963 r93977 44 44 } 45 45 46 function checkUILocation( sourceFile, lineNumber, columnNumber, location)46 function checkUILocation(rawSourceCode, lineNumber, columnNumber, location) 47 47 { 48 InspectorTest.assertEquals( sourceFile, location.sourceFile);48 InspectorTest.assertEquals(rawSourceCode.uiSourceCode, location.uiSourceCode); 49 49 InspectorTest.assertEquals(lineNumber, location.lineNumber); 50 50 InspectorTest.assertEquals(columnNumber, location.columnNumber); … … 55 55 { 56 56 var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false); 57 var sourceFile = new WebInspector.RawSourceCode("id", script);57 var rawSourceCode = new WebInspector.RawSourceCode("id", script); 58 58 59 checkUILocation( sourceFile, 10, 20, sourceFile.rawLocationToUILocation(rl(10, 20)));60 checkRawLocation(script, 30, 40, sourceFile.uiLocationToRawLocation(30, 40));59 checkUILocation(rawSourceCode, 10, 20, rawSourceCode.rawLocationToUILocation(rl(10, 20))); 60 checkRawLocation(script, 30, 40, rawSourceCode.uiLocationToRawLocation(30, 40)); 61 61 62 62 next(); … … 67 67 var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false); 68 68 var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false); 69 var sourceFile = new WebInspector.RawSourceCode("id", script1);70 sourceFile.addScript(script2);69 var rawSourceCode = new WebInspector.RawSourceCode("id", script1); 70 rawSourceCode.addScript(script2); 71 71 72 checkUILocation( sourceFile, 20, 0, sourceFile.rawLocationToUILocation(rl(20, 0)));72 checkUILocation(rawSourceCode, 20, 0, rawSourceCode.rawLocationToUILocation(rl(20, 0))); 73 73 74 checkRawLocation(script1, 0, 40, sourceFile.uiLocationToRawLocation(0, 40));75 checkRawLocation(script1, 20, 0, sourceFile.uiLocationToRawLocation(20, 0));76 checkRawLocation(script2, 50, 60, sourceFile.uiLocationToRawLocation(50, 60));74 checkRawLocation(script1, 0, 40, rawSourceCode.uiLocationToRawLocation(0, 40)); 75 checkRawLocation(script1, 20, 0, rawSourceCode.uiLocationToRawLocation(20, 0)); 76 checkRawLocation(script2, 50, 60, rawSourceCode.uiLocationToRawLocation(50, 60)); 77 77 78 78 next(); … … 82 82 { 83 83 var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false); 84 var sourceFile = new WebInspector.RawSourceCode("id", script, mockScriptFormatter, true);84 var rawSourceCode = new WebInspector.RawSourceCode("id", script, mockScriptFormatter, true); 85 85 86 86 function didCreateSourceMapping() 87 87 { 88 checkUILocation( sourceFile, 22, 40, sourceFile.rawLocationToUILocation(rl(11, 20)));89 checkRawLocation(script, 7, 9, sourceFile.uiLocationToRawLocation(14, 19));88 checkUILocation(rawSourceCode, 22, 40, rawSourceCode.rawLocationToUILocation(rl(11, 20))); 89 checkRawLocation(script, 7, 9, rawSourceCode.uiLocationToRawLocation(14, 19)); 90 90 next(); 91 91 } 92 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);92 rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping); 93 93 }, 94 94 … … 97 97 var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false); 98 98 var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false); 99 var sourceFile = new WebInspector.RawSourceCode("id", script1, mockScriptFormatter, true);100 sourceFile.addScript(script2);99 var rawSourceCode = new WebInspector.RawSourceCode("id", script1, mockScriptFormatter, true); 100 rawSourceCode.addScript(script2); 101 101 102 102 function didCreateSourceMapping() 103 103 { 104 checkUILocation( sourceFile, 22, 60, sourceFile.rawLocationToUILocation(rl(11, 30)));105 checkRawLocation(script1, 12, 10, sourceFile.uiLocationToRawLocation(24, 20));106 checkRawLocation(script2, 60, 19, sourceFile.uiLocationToRawLocation(121, 38));104 checkUILocation(rawSourceCode, 22, 60, rawSourceCode.rawLocationToUILocation(rl(11, 30))); 105 checkRawLocation(script1, 12, 10, rawSourceCode.uiLocationToRawLocation(24, 20)); 106 checkRawLocation(script2, 60, 19, rawSourceCode.uiLocationToRawLocation(121, 38)); 107 107 next(); 108 108 } 109 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);109 rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping); 110 110 }, 111 111 … … 113 113 { 114 114 var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false); 115 var sourceFile = new WebInspector.RawSourceCode("id", script);115 var rawSourceCode = new WebInspector.RawSourceCode("id", script); 116 116 function uiSourceCodeAdded(event) 117 117 { 118 118 InspectorTest.assertEquals("foo.js", event.data.url); 119 119 } 120 sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this);120 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this); 121 121 122 122 next(); -
trunk/Source/WebCore/ChangeLog
r93974 r93977 1 2011-08-25 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: rename sourceFile to (raw|ui)SourceCode in DebuggerPresentationModel. 4 https://bugs.webkit.org/show_bug.cgi?id=66769 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/front-end/DebuggerPresentationModel.js: 9 (WebInspector.DebuggerPresentationModel): 10 (WebInspector.DebuggerPresentationModel.prototype.uiSourceCode): 11 (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation.didCreateSourceMapping): 12 (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation): 13 (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation.didCreateSourceMapping): 14 (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation): 15 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor.didGetLocation): 16 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor): 17 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation): 18 (WebInspector.DebuggerPresentationModel.prototype._addScript.didCreateSourceMapping): 19 (WebInspector.DebuggerPresentationModel.prototype._addScript): 20 (WebInspector.DebuggerPresentationModel.prototype._uiSourceCodeReplaced): 21 (WebInspector.DebuggerPresentationModel.prototype.canEditScriptSource): 22 (WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource): 23 (WebInspector.DebuggerPresentationModel.prototype.setScriptSource): 24 (WebInspector.DebuggerPresentationModel.prototype._updateBreakpointsAfterLiveEdit): 25 (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles): 26 (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage.didGetUILocation): 27 (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage): 28 (WebInspector.DebuggerPresentationModel.prototype._consoleCleared): 29 (WebInspector.DebuggerPresentationModel.prototype.continueToLine): 30 (WebInspector.DebuggerPresentationModel.prototype.breakpointsForSourceFileId): 31 (WebInspector.DebuggerPresentationModel.prototype.setBreakpoint): 32 (WebInspector.DebuggerPresentationModel.prototype.setBreakpointEnabled): 33 (WebInspector.DebuggerPresentationModel.prototype.updateBreakpoint): 34 (WebInspector.DebuggerPresentationModel.prototype.removeBreakpoint): 35 (WebInspector.DebuggerPresentationModel.prototype.findBreakpoint): 36 (WebInspector.DebuggerPresentationModel.prototype._breakpointAdded): 37 (WebInspector.DebuggerPresentationModel.prototype._breakpointRemoved): 38 (WebInspector.DebuggerPresentationModel.prototype._debuggerPaused): 39 (WebInspector.DebuggerPresentationModel.prototype._rawSourceCodeForScript): 40 (WebInspector.DebuggerPresentationModel.prototype._scriptForRawSourceCode): 41 (WebInspector.DebuggerPresentationModel.prototype._createRawSourceCodeId): 42 (WebInspector.DebuggerPresentationModel.prototype._debuggerReset): 43 (WebInspector.PresentationBreakpoint): 44 (WebInspector.PresenationCallFrame.prototype.sourceLine.didGetUILocation): 45 (WebInspector.PresenationCallFrame.prototype.sourceLine): 46 (WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent): 47 (WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent): 48 (WebInspector.DebuggerPresentationModelResourceBinding.prototype._setContentWithInitialContent): 49 * inspector/front-end/ScriptsPanel.js: 50 (WebInspector.ScriptsPanel.prototype.canShowAnchorLocation): 51 (WebInspector.ScriptsPanel.prototype._createSourceFrame): 52 (WebInspector.ScriptsPanel.prototype._sourceFrameLoaded): 53 (WebInspector.ScriptsPanel.prototype._callFrameSelected.didGetSourceLocation): 54 (WebInspector.ScriptsPanel.prototype._callFrameSelected): 55 (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.requestContent): 56 (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName): 57 * inspector/front-end/SourceFile.js: 58 (WebInspector.RawSourceCode.prototype.rawLocationToUILocation): 59 (WebInspector.UILocation): 60 1 61 2011-08-29 Ilya Tikhonovsky <loislo@chromium.org> 2 62 -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r93963 r93977 36 36 // FIXME: apply formatter from outside as a generic mapping. 37 37 this._formatter = new WebInspector.ScriptFormatter(); 38 this._ sourceFiles= {};38 this._rawSourceCode = {}; 39 39 this._messages = []; 40 40 // FIXME: move this to RawSourceCode when it's not re-created in pretty-print mode. … … 71 71 72 72 WebInspector.DebuggerPresentationModel.prototype = { 73 sourceFile: function(sourceFileId) 74 { 75 return this._sourceFiles[sourceFileId]; 76 }, 77 78 sourceFileForScriptURL: function(scriptURL) 79 { 80 return this._sourceFiles[this._createSourceFileId(scriptURL)]; 73 uiSourceCode: function(uiSourceCodeId) 74 { 75 // FIXME: get rid of uiSourceCodeId (currently uiSourceCodeId == rawSourceCodeId). 76 var rawSourceCode = this._rawSourceCode[uiSourceCodeId]; 77 return rawSourceCode && rawSourceCode.uiSourceCode; 81 78 }, 82 79 83 80 _scriptLocationToUILocation: function(sourceURL, scriptId, lineNumber, columnNumber, callback) 84 81 { 85 var sourceFile = this._sourceFileForScript(sourceURL, scriptId);82 var rawSourceCode = this._rawSourceCodeForScript(sourceURL, scriptId); 86 83 87 84 function didCreateSourceMapping() 88 85 { 89 var uiLocation = sourceFile.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });90 callback(uiLocation. sourceFile.id, uiLocation.lineNumber);86 var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber }); 87 callback(uiLocation.uiSourceCode, uiLocation.lineNumber); 91 88 } 92 89 // FIXME: force source formatting if needed. This will go away once formatting 93 90 // is fully encapsulated in RawSourceCode class. 94 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);95 }, 96 97 _uiLocationToScriptLocation: function( sourceFileId, lineNumber, callback)98 { 99 var sourceFile = this._sourceFiles[sourceFileId];91 rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping); 92 }, 93 94 _uiLocationToScriptLocation: function(uiSourceCodeId, lineNumber, callback) 95 { 96 var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode; 100 97 101 98 function didCreateSourceMapping() 102 99 { 103 var rawLocation = sourceFile.uiLocationToRawLocation(lineNumber, 0);100 var rawLocation = rawSourceCode.uiLocationToRawLocation(lineNumber, 0); 104 101 callback(rawLocation); 105 102 } 106 103 // FIXME: force source formatting if needed. This will go away once formatting 107 104 // is fully encapsulated in RawSourceCode class. 108 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping); 109 }, 110 111 requestSourceFileContent: function(sourceFileId, callback) 112 { 113 this._sourceFiles[sourceFileId].requestContent(callback); 105 rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping); 114 106 }, 115 107 … … 129 121 var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes, false); 130 122 131 var sourceFile = this._sourceFileForScript(sourceURL);132 if (! sourceFile) {123 var rawSourceCode = this._rawSourceCodeForScript(sourceURL); 124 if (!rawSourceCode) { 133 125 anchor.setAttribute("preferred_panel", "resources"); 134 126 anchor.setAttribute("line_number", lineNumber); … … 138 130 function updateAnchor() 139 131 { 140 function didGetLocation( sourceFileId, lineNumber)132 function didGetLocation(uiSourceCode, lineNumber) 141 133 { 142 anchor.textContent = WebInspector.formatLinkText( sourceFile.url, lineNumber);134 anchor.textContent = WebInspector.formatLinkText(uiSourceCode.url, lineNumber); 143 135 anchor.setAttribute("preferred_panel", "scripts"); 144 anchor.setAttribute("source_file_id", sourceFileId);136 anchor.setAttribute("source_file_id", uiSourceCode.id); 145 137 anchor.setAttribute("line_number", lineNumber); 146 138 } … … 164 156 _addScript: function(script) 165 157 { 166 var sourceFileId = this._createSourceFileId(script.sourceURL, script.scriptId);167 var sourceFile = this._sourceFiles[sourceFileId];168 if ( sourceFile) {169 sourceFile.addScript(script);170 return; 171 } 172 173 sourceFile = new WebInspector.RawSourceCode(sourceFileId, script, this._formatter, this._formatSourceFiles);174 this._ sourceFiles[sourceFileId] = sourceFile;175 sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);158 var rawSourceCodeId = this._createRawSourceCodeId(script.sourceURL, script.scriptId); 159 var rawSourceCode = this._rawSourceCode[rawSourceCodeId]; 160 if (rawSourceCode) { 161 rawSourceCode.addScript(script); 162 return; 163 } 164 165 rawSourceCode = new WebInspector.RawSourceCode(rawSourceCodeId, script, this._formatter, this._formatSource); 166 this._rawSourceCode[rawSourceCodeId] = rawSourceCode; 167 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this); 176 168 177 169 function didCreateSourceMapping() 178 170 { 179 this._breakpointManager.uiSourceCodeAdded( sourceFile);180 var breakpoints = this._breakpointManager.breakpointsForUISourceCode( sourceFileId);171 this._breakpointManager.uiSourceCodeAdded(rawSourceCode.uiSourceCode); 172 var breakpoints = this._breakpointManager.breakpointsForUISourceCode(rawSourceCode.uiSourceCode.id); 181 173 for (var lineNumber in breakpoints) { 182 174 var breakpoint = breakpoints[lineNumber]; … … 186 178 // FIXME: force source formatting if needed. This will go away once formatting 187 179 // is fully encapsulated in RawSourceCode class. 188 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping.bind(this)); 189 190 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, sourceFile.uiSourceCode); 180 rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping.bind(this)); 181 182 var uiSourceCode = rawSourceCode.uiSourceCode; 183 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, uiSourceCode); 191 184 }, 192 185 193 186 _uiSourceCodeReplaced: function(event) 194 187 { 195 var oldUISourceCode = event.data.oldSourceCode;196 var newUISourceCode = event.data.sourceCode;197 198 delete this._sourceFiles[oldUISourceCode.id];199 this._sourceFiles[newUISourceCode.id] = newUISourceCode;200 201 188 // FIXME: restore breakpoints in new source code (currently we just recreate everything when switching to pretty-print mode). 202 189 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileReplaced, event.data); 203 190 }, 204 191 205 canEditScriptSource: function( sourceFileId)206 { 207 if (!Preferences.canEditScriptSource || this._formatSource Files)192 canEditScriptSource: function(uiSourceCodeId) 193 { 194 if (!Preferences.canEditScriptSource || this._formatSource) 208 195 return false; 209 var script = this._scriptForSourceFileId(sourceFileId); 196 var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode; 197 var script = this._scriptForRawSourceCode(rawSourceCode); 210 198 return !script.lineOffset && !script.columnOffset; 211 199 }, 212 200 213 setScriptSource: function( sourceFileId, newSource, callback)214 { 215 var script = this._scriptForSourceFileId(sourceFileId);216 var s ourceFile = this._sourceFiles[sourceFileId];217 218 function didEditScriptSource( oldSource,error)201 setScriptSource: function(uiSourceCodeId, newSource, callback) 202 { 203 var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode; 204 var script = this._scriptForRawSourceCode(rawSourceCode); 205 206 function didEditScriptSource(error) 219 207 { 220 208 if (!error) { 221 sourceFile.content = newSource;222 223 var resource = WebInspector.resourceForURL( sourceFile.url);209 rawSourceCode.content = newSource; 210 211 var resource = WebInspector.resourceForURL(rawSourceCode.url); 224 212 if (resource) 225 213 resource.addRevision(newSource); … … 231 219 this._debuggerPaused(); 232 220 } 233 234 var oldSource = sourceFile.requestContent(didReceiveSource.bind(this)); 235 function didReceiveSource(oldSource) 236 { 237 WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this, oldSource)); 238 } 239 }, 240 241 _updateBreakpointsAfterLiveEdit: function(sourceFileId, oldSource, newSource) 242 { 243 var sourceFile = this._sourceFiles[sourceFileId]; 221 WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this)); 222 }, 223 224 _updateBreakpointsAfterLiveEdit: function(uiSourceCodeId, oldSource, newSource) 225 { 226 var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId); 244 227 245 228 // Clear and re-create breakpoints according to text diff. 246 229 var diff = Array.diff(oldSource.split("\n"), newSource.split("\n")); 247 for (var lineNumber in sourceFile.breakpoints) { 248 var breakpoint = sourceFile.breakpoints[lineNumber]; 249 250 var lineNumber = breakpoint.lineNumber; 251 this.removeBreakpoint(sourceFileId, lineNumber); 230 for (var lineNumber in breakpoints) { 231 var breakpoint = breakpoints[lineNumber]; 232 233 this.removeBreakpoint(uiSourceCodeId, lineNumber); 252 234 253 235 var newLineNumber = diff.left[lineNumber].row; … … 266 248 } 267 249 if (newLineNumber !== undefined) 268 this.setBreakpoint( sourceFileId, newLineNumber, breakpoint.condition, breakpoint.enabled);269 } 270 }, 271 272 setFormatSourceFiles: function(formatSource Files)273 { 274 if (this._formatSource Files === formatSourceFiles)275 return; 276 277 this._formatSource Files = formatSourceFiles;250 this.setBreakpoint(uiSourceCodeId, newLineNumber, breakpoint.condition, breakpoint.enabled); 251 } 252 }, 253 254 setFormatSourceFiles: function(formatSource) 255 { 256 if (this._formatSource === formatSource) 257 return; 258 259 this._formatSource = formatSource; 278 260 279 261 this._breakpointManager.reset(); 280 this._ sourceFiles= {};262 this._rawSourceCode = {}; 281 263 var messages = this._messages; 282 264 this._messages = []; … … 308 290 this._messages.push(message); 309 291 310 var sourceFile = this._sourceFileForScript(message.url);311 if (! sourceFile)312 return; 313 314 function didGetUILocation( sourceFileId, lineNumber)292 var rawSourceCode = this._rawSourceCodeForScript(message.url); 293 if (!rawSourceCode) 294 return; 295 296 function didGetUILocation(uiSourceCode, lineNumber) 315 297 { 316 298 var presentationMessage = {}; 317 presentationMessage.sourceFileId = sourceFileId;299 presentationMessage.sourceFileId = uiSourceCode.id; 318 300 presentationMessage.lineNumber = lineNumber; 319 301 presentationMessage.originalMessage = message; 320 sourceFile.messages.push(presentationMessage);302 uiSourceCode.messages.push(presentationMessage); 321 303 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage); 322 304 } … … 330 312 { 331 313 this._messages = []; 332 for (var id in this._ sourceFiles)333 this._ sourceFiles[id].messages = [];314 for (var id in this._rawSourceCode) 315 this._rawSourceCode[id].messages = []; 334 316 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared); 335 317 }, 336 318 337 continueToLine: function( sourceFileId, lineNumber)319 continueToLine: function(uiSourceCodeId, lineNumber) 338 320 { 339 321 function didGetScriptLocation(location) … … 341 323 WebInspector.debuggerModel.continueToLocation(location); 342 324 } 343 this._uiLocationToScriptLocation( sourceFileId, lineNumber, didGetScriptLocation);344 }, 345 346 breakpointsForSourceFileId: function( sourceFileId)347 { 348 var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode( sourceFileId);325 this._uiLocationToScriptLocation(uiSourceCodeId, lineNumber, didGetScriptLocation); 326 }, 327 328 breakpointsForSourceFileId: function(uiSourceCodeId) 329 { 330 var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId); 349 331 var breakpointsList = []; 350 332 for (var lineNumber in breakpointsMap) … … 353 335 }, 354 336 355 setBreakpoint: function( sourceFileId, lineNumber, condition, enabled)356 { 357 this._breakpointManager.setBreakpoint(this. _sourceFiles[sourceFileId], lineNumber, condition, enabled);358 }, 359 360 setBreakpointEnabled: function( sourceFileId, lineNumber, enabled)361 { 362 var breakpoint = this.findBreakpoint( sourceFileId, lineNumber);337 setBreakpoint: function(uiSourceCodeId, lineNumber, condition, enabled) 338 { 339 this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, condition, enabled); 340 }, 341 342 setBreakpointEnabled: function(uiSourceCodeId, lineNumber, enabled) 343 { 344 var breakpoint = this.findBreakpoint(uiSourceCodeId, lineNumber); 363 345 if (!breakpoint) 364 346 return; 365 this._breakpointManager.removeBreakpoint( sourceFileId, lineNumber);366 this._breakpointManager.setBreakpoint(this. _sourceFiles[sourceFileId], lineNumber, breakpoint.condition, enabled);367 }, 368 369 updateBreakpoint: function( sourceFileId, lineNumber, condition, enabled)370 { 371 this._breakpointManager.removeBreakpoint( sourceFileId, lineNumber);372 this._breakpointManager.setBreakpoint(this. _sourceFiles[sourceFileId], lineNumber, condition, enabled);373 }, 374 375 removeBreakpoint: function( sourceFileId, lineNumber)376 { 377 this._breakpointManager.removeBreakpoint( sourceFileId, lineNumber);378 }, 379 380 findBreakpoint: function( sourceFileId, lineNumber)381 { 382 return this._breakpointManager.breakpointsForUISourceCode( sourceFileId)[lineNumber];383 }, 384 385 _breakpointAdded: function( sourceFileId, lineNumber, condition, enabled)386 { 387 var sourceFile = this._sourceFiles[sourceFileId];388 if (! sourceFile)389 return; 390 var presentationBreakpoint = new WebInspector.PresentationBreakpoint( sourceFile, lineNumber, condition, enabled);347 this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber); 348 this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, breakpoint.condition, enabled); 349 }, 350 351 updateBreakpoint: function(uiSourceCodeId, lineNumber, condition, enabled) 352 { 353 this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber); 354 this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, condition, enabled); 355 }, 356 357 removeBreakpoint: function(uiSourceCodeId, lineNumber) 358 { 359 this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber); 360 }, 361 362 findBreakpoint: function(uiSourceCodeId, lineNumber) 363 { 364 return this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId)[lineNumber]; 365 }, 366 367 _breakpointAdded: function(uiSourceCodeId, lineNumber, condition, enabled) 368 { 369 var uiSourceCode = this.uiSourceCode(uiSourceCodeId); 370 if (!uiSourceCode) 371 return; 372 var presentationBreakpoint = new WebInspector.PresentationBreakpoint(uiSourceCode, lineNumber, condition, enabled); 391 373 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, presentationBreakpoint); 392 374 }, 393 375 394 _breakpointRemoved: function( sourceFileId, lineNumber)395 { 396 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, { sourceFileId: sourceFileId, lineNumber: lineNumber });376 _breakpointRemoved: function(uiSourceCodeId, lineNumber) 377 { 378 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, { sourceFileId: uiSourceCodeId, lineNumber: lineNumber }); 397 379 }, 398 380 … … 403 385 for (var i = 0; i < callFrames.length; ++i) { 404 386 var callFrame = callFrames[i]; 405 var sourceFile;387 var rawSourceCode; 406 388 var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId); 407 389 if (script) 408 sourceFile = this._sourceFileForScript(script.sourceURL, script.scriptId);409 this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, this, sourceFile));390 rawSourceCode = this._rawSourceCodeForScript(script.sourceURL, script.scriptId); 391 this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, this, rawSourceCode)); 410 392 } 411 393 var details = WebInspector.debuggerModel.debuggerPausedDetails; … … 434 416 }, 435 417 436 _ sourceFileForScript: function(sourceURL, scriptId)418 _rawSourceCodeForScript: function(sourceURL, scriptId) 437 419 { 438 420 if (!sourceURL) { … … 442 424 sourceURL = script.sourceURL; 443 425 } 444 return this._ sourceFiles[this._createSourceFileId(sourceURL, scriptId)];445 }, 446 447 _scriptFor SourceFileId: function(sourceFileId)426 return this._rawSourceCode[this._createRawSourceCodeId(sourceURL, scriptId)]; 427 }, 428 429 _scriptForRawSourceCode: function(rawSourceCode) 448 430 { 449 431 function filter(script) 450 432 { 451 return this._create SourceFileId(script.sourceURL, script.scriptId) === sourceFileId;433 return this._createRawSourceCodeId(script.sourceURL, script.scriptId) === rawSourceCode.id; 452 434 } 453 435 return WebInspector.debuggerModel.queryScripts(filter.bind(this))[0]; 454 436 }, 455 437 456 _create SourceFileId: function(sourceURL, scriptId)457 { 458 var prefix = this._formatSource Files? "deobfuscated:" : "";438 _createRawSourceCodeId: function(sourceURL, scriptId) 439 { 440 var prefix = this._formatSource ? "deobfuscated:" : ""; 459 441 return prefix + (sourceURL || scriptId); 460 442 }, … … 462 444 _debuggerReset: function() 463 445 { 464 this._ sourceFiles= {};446 this._rawSourceCode = {}; 465 447 this._messages = []; 466 448 this._sourceMappingListeners = []; … … 476 458 * @constructor 477 459 */ 478 WebInspector.PresentationBreakpoint = function( sourceFile, lineNumber, condition, enabled)460 WebInspector.PresentationBreakpoint = function(uiSourceCode, lineNumber, condition, enabled) 479 461 { 480 this.sourceFile = sourceFile;481 this.sourceFileId = sourceFile.id;462 this.sourceFile = uiSourceCode; 463 this.sourceFileId = uiSourceCode.id; 482 464 this.lineNumber = lineNumber; 483 465 this.condition = condition; … … 590 572 { 591 573 var location = this._callFrame.location; 592 if (!this.isInternalScript) 593 this._model._scriptLocationToUILocation(null, location.scriptId, location.lineNumber, location.columnNumber, callback); 594 else 574 if (!this.isInternalScript) { 575 function didGetUILocation(uiSourceCode, lineNumber) 576 { 577 callback(uiSourceCode.id, lineNumber); 578 } 579 this._model._scriptLocationToUILocation(null, location.scriptId, location.lineNumber, location.columnNumber, didGetUILocation); 580 } else 595 581 callback(undefined, location.lineNumber); 596 582 } … … 610 596 canSetContent: function(resource) 611 597 { 612 var sourceFile = this._presentationModel._sourceFileForScript(resource.url)613 if (! sourceFile)598 var rawSourceCode = this._presentationModel._rawSourceCodeForScript(resource.url) 599 if (!rawSourceCode) 614 600 return false; 615 return this._presentationModel.canEditScriptSource( sourceFile.id);601 return this._presentationModel.canEditScriptSource(rawSourceCode.id); 616 602 }, 617 603 … … 621 607 return; 622 608 623 var sourceFile = this._presentationModel._sourceFileForScript(resource.url);624 if (! sourceFile) {609 var rawSourceCode = this._presentationModel._rawSourceCodeForScript(resource.url); 610 if (!rawSourceCode) { 625 611 userCallback("Resource is not editable"); 626 612 return; 627 613 } 628 614 629 resource.requestContent(this._setContentWithInitialContent.bind(this, sourceFile, content, userCallback));630 }, 631 632 _setContentWithInitialContent: function( sourceFile, content, userCallback, oldContent)615 resource.requestContent(this._setContentWithInitialContent.bind(this, rawSourceCode, content, userCallback)); 616 }, 617 618 _setContentWithInitialContent: function(rawSourceCode, content, userCallback, oldContent) 633 619 { 634 620 function callback(error) … … 637 623 userCallback(error); 638 624 if (!error) { 639 this._presentationModel._updateBreakpointsAfterLiveEdit( sourceFile.id, oldContent, content);640 sourceFile.reload();625 this._presentationModel._updateBreakpointsAfterLiveEdit(rawSourceCode.id, oldContent, content); 626 rawSourceCode.reload(); 641 627 } 642 628 } 643 this._presentationModel.setScriptSource( sourceFile.id, content, callback.bind(this));629 this._presentationModel.setScriptSource(rawSourceCode.id, content, callback.bind(this)); 644 630 } 645 631 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r93701 r93977 598 598 canShowAnchorLocation: function(anchor) 599 599 { 600 return this._debuggerEnabled && this._presentationModel.sourceFileForScriptURL(anchor.href);600 return this._debuggerEnabled && WebInspector.debuggerModel.scriptsForURL(anchor.href).length; 601 601 }, 602 602 … … 645 645 this.visibleView = sourceFrame; 646 646 647 var sourceFile = this._presentationModel. sourceFile(sourceFileId);647 var sourceFile = this._presentationModel.uiSourceCode(sourceFileId); 648 648 if (sourceFile.url) 649 649 WebInspector.settings.lastViewedScriptFile.set(sourceFile.url); … … 660 660 _createSourceFrame: function(sourceFileId) 661 661 { 662 var sourceFile = this._presentationModel. sourceFile(sourceFileId);662 var sourceFile = this._presentationModel.uiSourceCode(sourceFileId); 663 663 var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(this._presentationModel, sourceFileId); 664 664 var sourceFrame = new WebInspector.SourceFrame(delegate, sourceFile.url); … … 701 701 var sourceFrame = event.target; 702 702 var sourceFileId = sourceFrame._sourceFileId; 703 var sourceFile = this._presentationModel. sourceFile(sourceFileId);703 var sourceFile = this._presentationModel.uiSourceCode(sourceFileId); 704 704 705 705 var messages = sourceFile.messages; … … 743 743 if (!(sourceFileId in this._sourceFileIdToFilesSelectOption)) { 744 744 // Anonymous scripts are not added to files select by default. 745 var sourceFile = this._presentationModel. sourceFile(sourceFileId);745 var sourceFile = this._presentationModel.uiSourceCode(sourceFileId); 746 746 this._addOptionToFilesSelect(sourceFile); 747 747 } … … 1189 1189 requestContent: function(callback) 1190 1190 { 1191 this._model. requestSourceFileContent(this._sourceFileId,callback);1191 this._model.uiSourceCode(this._sourceFileId).requestContent(callback); 1192 1192 }, 1193 1193 … … 1257 1257 suggestedFileName: function() 1258 1258 { 1259 var sourceFile = this._model. sourceFile(this._sourceFileId);1259 var sourceFile = this._model.uiSourceCode(this._sourceFileId); 1260 1260 var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(sourceFile.url); 1261 1261 return names.displayName || "untitled.js"; -
trunk/Source/WebCore/inspector/front-end/SourceFile.js
r93972 r93977 79 79 rawLocationToUILocation: function(rawLocation) 80 80 { 81 var uiLocation = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation; 82 uiLocation.sourceFile = this; 83 return uiLocation; 81 var location = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation; 82 return new WebInspector.UILocation(this, location.lineNumber, location.columnNumber); 84 83 }, 85 84 … … 244 243 245 244 WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype; 245 246 247 /** 248 * @constructor 249 */ 250 WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber) 251 { 252 this.uiSourceCode = uiSourceCode; 253 this.lineNumber = lineNumber; 254 this.columnNumber = columnNumber; 255 } 246 256 247 257
Note:
See TracChangeset
for help on using the changeset viewer.