Changeset 74119 in webkit
- Timestamp:
- Dec 15, 2010 9:36:04 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r74118 r74119 1 2010-12-13 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: move scripts storage from ScriptsPanel to DebuggerModel. 6 https://bugs.webkit.org/show_bug.cgi?id=50908 7 8 * inspector/front-end/BreakpointManager.js: 9 (WebInspector.BreakpointManager): 10 (WebInspector.BreakpointManager.prototype._debuggerPaused): 11 * inspector/front-end/CallStackSidebarPane.js: 12 (WebInspector.CallStackSidebarPane): 13 (WebInspector.CallStackSidebarPane.prototype.update): 14 * inspector/front-end/DebuggerModel.js: 15 (WebInspector.DebuggerModel): 16 (WebInspector.DebuggerModel.prototype.setBreakpoint): 17 (WebInspector.DebuggerModel.prototype._setBreakpoint): 18 (WebInspector.DebuggerModel.prototype.scriptForSourceID): 19 (WebInspector.DebuggerModel.prototype.scriptsForURL): 20 (WebInspector.DebuggerModel.prototype.queryScripts): 21 (WebInspector.DebuggerModel.prototype.parsedScriptSource): 22 (WebInspector.DebuggerModel.prototype.failedToParseScriptSource): 23 (WebInspector.DebuggerModel.prototype.breakpointRestored): 24 (WebInspector.DebuggerModel.prototype.debuggerPaused): 25 (WebInspector.DebuggerModel.prototype.debuggerResumed): 26 * inspector/front-end/Resource.js: 27 * inspector/front-end/ScriptsPanel.js: 28 (WebInspector.ScriptsPanel): eliminate sourceIDMap 29 * inspector/front-end/SourceFrame.js: 30 (WebInspector.SourceFrame.prototype._createViewerIfNeeded): 31 (WebInspector.SourceFrame.prototype._setBreakpoint): 32 * inspector/front-end/SourceView.js: 33 (WebInspector.SourceView): 34 * inspector/front-end/inspector.js: 35 (WebInspector.createJSBreakpointsSidebarPane): 36 (WebInspector.parsedScriptSource): 37 (WebInspector.failedToParseScriptSource): 38 1 39 2010-12-15 Eric Carlson <eric.carlson@apple.com> 2 40 -
trunk/WebCore/inspector/front-end/BreakpointManager.js
r74103 r74119 41 41 42 42 WebInspector.settings.addEventListener(WebInspector.Settings.Events.ProjectChanged, this._projectChanged, this); 43 WebInspector.debuggerModel.addEventListener( "native-breakpoint-hit", this._nativeBreakpointHit, this);44 WebInspector.debuggerModel.addEventListener( "debugger-resumed", this._debuggerResumed, this);43 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); 44 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); 45 45 } 46 46 … … 153 153 }, 154 154 155 _nativeBreakpointHit: function(event) 156 { 157 var eventData = event.data; 155 _debuggerPaused: function(event) 156 { 157 var eventType = event.data.eventType; 158 var eventData = event.data.eventData; 159 160 if (eventType !== WebInspector.DebuggerEventTypes.NativeBreakpoint) 161 return; 158 162 159 163 var breakpointId; -
trunk/WebCore/inspector/front-end/CallStackSidebarPane.js
r74103 r74119 28 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); 29 29 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.NativeBreakpointHit, this._nativeBreakpointHit, this); 30 WebInspector.debuggerModel.addEventListener( "script-breakpoint-hit", this._scriptBreakpointHit, this);30 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointHit, this._scriptBreakpointHit, this); 31 31 } 32 32 33 33 WebInspector.CallStackSidebarPane.prototype = { 34 update: function(callFrames , sourceIDMap)34 update: function(callFrames) 35 35 { 36 36 this.bodyElement.removeChildren(); … … 49 49 var title; 50 50 var subtitle; 51 var script OrResource;51 var script; 52 52 53 53 for (var i = 0; i < callFrames.length; ++i) { … … 62 62 } 63 63 64 script OrResource = sourceIDMap[callFrame.sourceID];65 if (script OrResource)66 subtitle = WebInspector.displayNameForURL(script OrResource.sourceURL || scriptOrResource.url);64 script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID); 65 if (script) 66 subtitle = WebInspector.displayNameForURL(script.sourceURL); 67 67 else 68 68 subtitle = WebInspector.UIString("(internal script)"); -
trunk/WebCore/inspector/front-end/DebuggerModel.js
r73916 r74119 31 31 WebInspector.DebuggerModel = function() 32 32 { 33 InspectorBackend.registerDomainDispatcher("Debugger", this); 34 33 35 this._breakpoints = {}; 34 InspectorBackend.registerDomainDispatcher("Debugger", this); 36 this._scripts = {}; 37 } 38 39 WebInspector.DebuggerModel.Events = { 40 DebuggerPaused: "debugger-paused", 41 DebuggerResumed: "debugger-resumed", 42 ParsedScriptSource: "parsed-script-source", 43 FailedToParseScriptSource: "failed-to-parse-script-source", 44 BreakpointAdded: "breakpoint-added", 45 BreakpointHit: "breakpoint-hit" 35 46 } 36 47 … … 56 67 }, 57 68 58 setBreakpoint: function(sourceID, url, line, enabled, condition) 59 { 69 setBreakpoint: function(sourceID, line, enabled, condition) 70 { 71 var url = this._scripts[sourceID].sourceURL; 60 72 var breakpoint = this._setBreakpoint(sourceID, url, line, enabled, condition); 61 73 if (breakpoint) 62 74 this._setBreakpointOnBackend(breakpoint); 63 },64 65 breakpointRestored: function(sourceID, url, line, enabled, condition)66 {67 this._setBreakpoint(sourceID, url, line, enabled, condition);68 75 }, 69 76 … … 89 96 this._breakpoints = {}; 90 97 delete this._oneTimeBreakpoint; 98 this._scripts = {}; 91 99 }, 92 100 … … 100 108 this._breakpoints[breakpoint.id] = breakpoint; 101 109 breakpoint.addEventListener("removed", this._breakpointRemoved, this); 102 this.dispatchEventToListeners( "breakpoint-added", breakpoint);110 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpoint); 103 111 return breakpoint; 104 112 }, … … 129 137 }, 130 138 139 scriptForSourceID: function(sourceID) 140 { 141 return this._scripts[sourceID]; 142 }, 143 144 scriptsForURL: function(url) 145 { 146 return this.queryScripts(function(s) { return s.sourceURL === url; }); 147 }, 148 149 queryScripts: function(filter) 150 { 151 var scripts = []; 152 for (var sourceID in this._scripts) { 153 var script = this._scripts[sourceID]; 154 if (filter(script)) 155 scripts.push(script); 156 } 157 return scripts; 158 }, 159 160 // All the methods below are InspectorBackend notification handlers. 161 162 breakpointRestored: function(sourceID, url, line, enabled, condition) 163 { 164 this._setBreakpoint(sourceID, url, line, enabled, condition); 165 }, 166 131 167 pausedScript: function(details) 132 168 { 133 this.dispatchEventToListeners("debugger-paused", details.callFrames); 134 135 if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause) 136 return; 137 if (details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint) { 138 this.dispatchEventToListeners("native-breakpoint-hit", details.eventData); 139 return; 140 } 169 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerPaused, details); 170 171 if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause || details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint) 172 return; 141 173 142 174 var breakpointId = WebInspector.Breakpoint.jsBreakpointId(details.callFrames[0].sourceID, details.callFrames[0].line); … … 146 178 breakpoint.hit = true; 147 179 this._lastHitBreakpoint = breakpoint; 148 this.dispatchEventToListeners( "script-breakpoint-hit", breakpoint);180 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointHit, breakpoint); 149 181 }, 150 182 151 183 resumedScript: function() 152 184 { 153 this.dispatchEventToListeners( "debugger-resumed");185 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed); 154 186 155 187 if (!this._lastHitBreakpoint) … … 176 208 parsedScriptSource: function(sourceID, sourceURL, source, startingLine, scriptWorldType) 177 209 { 178 WebInspector.panels.scripts.addScript(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType); 210 var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType); 211 this._scripts[sourceID] = script; 212 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); 179 213 }, 180 214 181 215 failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) 182 216 { 183 WebInspector.panels.scripts.addScript(null, sourceURL, source, startingLine, errorLine, errorMessage); 217 var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined); 218 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script); 184 219 }, 185 220 -
trunk/WebCore/inspector/front-end/Resource.js
r73504 r74119 498 498 }, 499 499 500 get scripts()501 {502 if (!("_scripts" in this))503 this._scripts = [];504 return this._scripts;505 },506 507 addScript: function(script)508 {509 if (!script)510 return;511 this.scripts.unshift(script);512 script.resource = this;513 },514 515 removeAllScripts: function()516 {517 if (!this._scripts)518 return;519 520 for (var i = 0; i < this._scripts.length; ++i) {521 if (this._scripts[i].resource === this)522 delete this._scripts[i].resource;523 }524 525 delete this._scripts;526 },527 528 removeScript: function(script)529 {530 if (!script)531 return;532 533 if (script.resource === this)534 delete script.resource;535 536 if (!this._scripts)537 return;538 539 this._scripts.remove(script);540 },541 542 500 get errors() 543 501 { -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r74103 r74119 178 178 this.reset(); 179 179 180 WebInspector.debuggerModel.addEventListener("debugger-paused", this._debuggerPaused, this); 181 WebInspector.debuggerModel.addEventListener("debugger-resumed", this._debuggerResumed, this); 180 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); 181 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._failedToParseScriptSource, this); 182 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); 183 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); 182 184 } 183 185 … … 236 238 }, 237 239 238 addScript: function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType) 239 { 240 var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType); 241 this._sourceIDMap[sourceID] = script; 242 243 var resource = WebInspector.resourceForURL(sourceURL); 240 _parsedScriptSource: function(event) 241 { 242 var sourceID = event.data; 243 var script = WebInspector.debuggerModel.scriptForSourceID(sourceID); 244 this._addScript(script); 245 }, 246 247 _failedToParseScriptSource: function(event) 248 { 249 this._addScript(event.data); 250 }, 251 252 _addScript: function(script) 253 { 254 var resource = WebInspector.resourceForURL(script.sourceURL); 244 255 if (resource) { 245 256 if (resource.finished) { 246 257 // Resource is finished, bind the script right away. 247 resource.addScript(script); 248 this._sourceIDMap[sourceID] = resource; 258 script.resource = resource; 249 259 } else { 250 260 // Resource is not finished, bind the script later. … … 272 282 // Bind script to resource. 273 283 var script = resource._scriptsPendingResourceLoad[i]; 274 resource.addScript(script); 275 this._sourceIDMap[script.sourceID] = resource; 284 script.resource = resource; 276 285 277 286 // Remove script from the files list. … … 303 312 commitEditingCallback(newBodyOrErrorMessage); 304 313 if (callFrames && callFrames.length) 305 this._debuggerPaused({ data: callFrames});314 this._debuggerPaused({ data: { callFrames: callFrames } }); 306 315 } else { 307 316 if (cancelEditingCallback) … … 314 323 if (success && breakpoint.line >= editData.line) 315 324 newLine += editData.linesCountToShift; 316 WebInspector.debuggerModel.setBreakpoint(editData.sourceID, breakpoint.url,newLine, breakpoint.enabled, breakpoint.condition);325 WebInspector.debuggerModel.setBreakpoint(editData.sourceID, newLine, breakpoint.enabled, breakpoint.condition); 317 326 } 318 327 }; … … 359 368 _debuggerPaused: function(event) 360 369 { 361 var callFrames = event.data ;370 var callFrames = event.data.callFrames; 362 371 363 372 WebInspector.debuggerModel.removeOneTimeBreakpoint(); … … 370 379 WebInspector.currentPanel = this; 371 380 372 this.sidebarPanes.callstack.update(callFrames , this._sourceIDMap);381 this.sidebarPanes.callstack.update(callFrames); 373 382 this.sidebarPanes.callstack.selectedCallFrame = callFrames[0]; 374 383 … … 431 440 this.viewsContainerElement.removeChildren(); 432 441 433 if (this._sourceIDMap) { 434 for (var sourceID in this._sourceIDMap) { 435 var object = this._sourceIDMap[sourceID]; 436 if (object instanceof WebInspector.Resource) { 437 object.removeAllScripts(); 438 delete object._resourcesView; 439 } 440 } 441 } 442 443 this._sourceIDMap = {}; 442 var scripts = WebInspector.debuggerModel.queryScripts(function(s) { return !!s.resource; }); 443 for (var i = 0; i < scripts.length; ++i) 444 delete scripts[i].resource._resourcesView; 444 445 445 446 this.sidebarPanes.watchExpressions.refreshExpressions(); … … 488 489 _scriptOrResourceForURLAndLine: function(url, line) 489 490 { 490 var scriptWithMatchingUrl = null; 491 for (var sourceID in this._sourceIDMap) { 492 var scriptOrResource = this._sourceIDMap[sourceID]; 493 if (scriptOrResource instanceof WebInspector.Script) { 494 if (scriptOrResource.sourceURL !== url) 495 continue; 496 scriptWithMatchingUrl = scriptOrResource; 497 if (scriptWithMatchingUrl.startingLine <= line && scriptWithMatchingUrl.startingLine + scriptWithMatchingUrl.linesCount > line) 498 return scriptWithMatchingUrl; 499 } else { 500 var resource = scriptOrResource; 501 if (resource.url === url) 502 return resource; 503 } 504 } 505 return scriptWithMatchingUrl; 491 var scripts = WebInspector.debuggerModel.scriptsForURL(url); 492 for (var i = 0; i < scripts.length; ++i) { 493 var script = scripts[i]; 494 if (script.resource) 495 return script.resource; 496 if (script.startingLine <= line && script.startingLine + script.linesCount > line) 497 return script; 498 } 499 return null; 506 500 }, 507 501 … … 722 716 this.sidebarPanes.watchExpressions.refreshExpressions(); 723 717 724 var scriptOrResource = this._sourceIDMap[currentFrame.sourceID]; 718 var script = WebInspector.debuggerModel.scriptForSourceID(currentFrame.sourceID); 719 var scriptOrResource = script.resource || script; 725 720 this._showScriptOrResource(scriptOrResource, {line: currentFrame.line}); 726 721 -
trunk/WebCore/inspector/front-end/SourceFrame.js
r73913 r74119 221 221 for (var i = 0; i < breakpoints.length; ++i) 222 222 this._addBreakpoint(breakpoints[i]); 223 WebInspector.debuggerModel.addEventListener( "breakpoint-added", this._breakpointAdded, this);223 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this); 224 224 225 225 this._textViewer.endUpdates(); … … 820 820 { 821 821 var sourceID = this._sourceIDForLine(lineNumber); 822 WebInspector.debuggerModel.setBreakpoint(sourceID, this._url,lineNumber, true, "");822 WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber, true, ""); 823 823 if (!WebInspector.panels.scripts.breakpointsActivated) 824 824 WebInspector.panels.scripts.toggleBreakpointsClicked(); -
trunk/WebCore/inspector/front-end/SourceView.js
r73730 r74119 33 33 this.element.addStyleClass("source"); 34 34 35 var scripts = WebInspector.debuggerModel.scriptsForURL(resource.url); 35 36 var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; 36 this.sourceFrame = new WebInspector.SourceFrame(this.element, resource.scripts, canEditScripts);37 this.sourceFrame = new WebInspector.SourceFrame(this.element, scripts, canEditScripts); 37 38 resource.addEventListener("finished", this._resourceLoadingFinished, this); 38 39 this._frameNeedsSetup = true; -
trunk/WebCore/inspector/front-end/inspector.js
r74103 r74119 193 193 pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); 194 194 } 195 WebInspector.debuggerModel.addEventListener( "breakpoint-added", breakpointAdded);195 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpointAdded); 196 196 return pane; 197 197 },
Note: See TracChangeset
for help on using the changeset viewer.