Changeset 55231 in webkit
- Timestamp:
- Feb 25, 2010 5:45:27 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55230 r55231 1 2010-02-25 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Scripts panel shows blank source when stopping on a breakpoint on refresh. 6 7 https://bugs.webkit.org/show_bug.cgi?id=35232 8 9 * inspector/front-end/Panel.js: 10 (WebInspector.Panel.prototype.canShowSourceLine): 11 (WebInspector.Panel.prototype.showSourceLine): 12 * inspector/front-end/ResourcesPanel.js: 13 (WebInspector.ResourcesPanel.prototype.canShowSourceLine): 14 (WebInspector.ResourcesPanel.prototype.showSourceLine): 15 * inspector/front-end/Script.js: 16 (WebInspector.Script): 17 * inspector/front-end/ScriptView.js: 18 (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded): 19 * inspector/front-end/ScriptsPanel.js: 20 (WebInspector.ScriptsPanel.prototype.show): 21 (WebInspector.ScriptsPanel.prototype.get searchableViews): 22 (WebInspector.ScriptsPanel.prototype.addScript): 23 (WebInspector.ScriptsPanel.prototype._resourceLoadingFinished): 24 (WebInspector.ScriptsPanel.prototype.addBreakpoint): 25 (WebInspector.ScriptsPanel.prototype.removeBreakpoint): 26 (WebInspector.ScriptsPanel.prototype.reset): 27 (WebInspector.ScriptsPanel.prototype.canShowSourceLine): 28 (WebInspector.ScriptsPanel.prototype.showSourceLine): 29 (WebInspector.ScriptsPanel.prototype._scriptOrResourceForURLAndLine): 30 (WebInspector.ScriptsPanel.prototype.showView): 31 (WebInspector.ScriptsPanel.prototype._sourceFrameForScriptOrResource): 32 (WebInspector.ScriptsPanel.prototype._showScriptOrResource): 33 (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu.optionCompare): 34 (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): 35 * inspector/front-end/SourceView.js: 36 (WebInspector.SourceView.prototype._addBreakpoint): 37 * inspector/front-end/inspector.js: 38 (WebInspector.documentClick.followLink): 39 (WebInspector.documentClick): 40 (WebInspector._choosePanelToShowSourceLine): 41 (WebInspector.canShowSourceLine): 42 (WebInspector.showSourceLine): 43 1 44 2010-02-25 Ben Murdoch <benm@google.com> 2 45 -
trunk/WebCore/inspector/front-end/Panel.js
r54812 r55231 374 374 }, 375 375 376 canShowSourceLine ForURL: function(url)376 canShowSourceLine: function(url, line) 377 377 { 378 378 return false; 379 379 }, 380 380 381 showSourceLine ForURL: function(url, line)381 showSourceLine: function(url, line) 382 382 { 383 383 return false; -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r55052 r55231 455 455 }, 456 456 457 canShowSourceLine ForURL: function(url)457 canShowSourceLine: function(url, line) 458 458 { 459 459 return !!WebInspector.resourceForURL(url); 460 460 }, 461 461 462 showSourceLine ForURL: function(url, line)462 showSourceLine: function(url, line) 463 463 { 464 464 this.showResource(WebInspector.resourceForURL(url), line); -
trunk/WebCore/inspector/front-end/Script.js
r45186 r55231 33 33 this.errorMessage = errorMessage; 34 34 35 this.linesCount = 0; 36 var lastIndex = source.indexOf("\n"); 37 while (lastIndex !== -1) { 38 lastIndex = source.indexOf("\n", lastIndex + 1) 39 this.linesCount++; 40 } 41 35 42 // if no URL, look for "//@ sourceURL=" decorator 36 43 // note that this sourceURL comment decorator is behavior that FireBug added -
trunk/WebCore/inspector/front-end/ScriptView.js
r54657 r55231 53 53 this.attach(); 54 54 55 this.sourceFrame.setContent("text/javascript", this.script.source); 55 var prefix = ""; 56 for (var i = 0; i < this.script.startingLine - 1; ++i) 57 prefix += "\n"; 58 59 this.sourceFrame.setContent("text/javascript", prefix + this.script.source); 56 60 this._sourceFrameSetup = true; 57 61 delete this._frameNeedsSetup; -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r55077 r55231 239 239 this.visibleView.show(this.viewsContainerElement); 240 240 } 241 // Hide any views that are visible that are not this panel's current visible view.242 // This can happen when a ResourceView is visible in the Resources panel then switched243 // to the this panel.244 for (var sourceID in this._sourceIDMap) {245 var scriptOrResource = this._sourceIDMap[sourceID];246 var view = this._sourceViewForScriptOrResource(scriptOrResource);247 if (!view || view === this.visibleView)248 continue;249 view.visible = false;250 }251 241 if (this._attachDebuggerWhenShown) { 252 242 InspectorBackend.enableDebugger(false); … … 257 247 get searchableViews() 258 248 { 259 var views = []; 260 261 const visibleView = this.visibleView; 262 if (visibleView && visibleView.performSearch) { 263 visibleView.alreadySearching = true; 264 views.push(visibleView); 265 } 266 267 for (var sourceID in this._sourceIDMap) { 268 var scriptOrResource = this._sourceIDMap[sourceID]; 269 var view = this._sourceViewForScriptOrResource(scriptOrResource); 270 if (!view || !view.performSearch || view.alreadySearching) 271 continue; 272 273 view.alreadySearching = true; 274 views.push(view); 275 } 276 277 for (var i = 0; i < views.length; ++i) 278 delete views[i].alreadySearching; 279 280 return views; 249 return [ this.visibleView ]; 281 250 }, 282 251 … … 289 258 { 290 259 var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage); 291 292 if (sourceURL in WebInspector.resourceURLMap) { 293 var resource = WebInspector.resourceURLMap[sourceURL]; 260 this._sourceIDMap[sourceID] = script; 261 262 var resource = WebInspector.resourceURLMap[sourceURL]; 263 if (resource) { 264 if (resource.finished) { 265 // Resource is finished, bind the script right away. 266 resource.addScript(script); 267 this._sourceIDMap[sourceID] = resource; 268 } else { 269 // Resource is not finished, bind the script later. 270 if (!resource._scriptsPendingResourceLoad) { 271 resource._scriptsPendingResourceLoad = []; 272 resource.addEventListener("finished", this._resourceLoadingFinished, this); 273 } 274 resource._scriptsPendingResourceLoad.push(script); 275 } 276 } 277 this._addScriptToFilesMenu(script); 278 }, 279 280 _resourceLoadingFinished: function(e) 281 { 282 var resource = e.target; 283 for (var i = 0; i < resource._scriptsPendingResourceLoad.length; ++i) { 284 // Bind script to resource. 285 var script = resource._scriptsPendingResourceLoad[i]; 294 286 resource.addScript(script); 295 }296 297 sourceURL = script.sourceURL;298 299 if (sourceID)300 this._sourceIDMap[sourceID] = (resource || script);301 this._addScriptToFilesMenu(script);302 },303 304 scriptOrResourceForID: function(id)305 {306 return this._sourceIDMap[id];307 },308 309 scriptForURL: function(url)310 {311 return this._scriptsForURLsInFilesSelect[url];287 this._sourceIDMap[script.sourceID] = resource; 288 289 // Remove script from the files list. 290 script.filesSelectOption.parentElement.removeChild(script.filesSelectOption); 291 292 // Move breakpoints to the resource's frame. 293 if (script._scriptView) { 294 var sourceFrame = script._scriptView.sourceFrame; 295 for (var j = 0; j < sourceFrame.breakpoints; ++j) { 296 var resourceFrame = this._sourceFrameForScriptOrResource(resource); 297 resourceFrame.addBreakpoint(sourceFrame.breakpoints[j]); 298 } 299 } 300 } 301 // Adding first script will add resource. 302 this._addScriptToFilesMenu(resource._scriptsPendingResourceLoad[0]); 303 delete resource._scriptsPendingResourceLoad; 312 304 }, 313 305 … … 321 313 var sourceFrame; 322 314 if (breakpoint.url) { 323 if (breakpoint.url in WebInspector.resourceURLMap) {324 var resource = WebInspector.resourceURLMap[breakpoint.url];315 var resource = WebInspector.resourceURLMap[breakpoint.url]; 316 if (resource && resource.finished) 325 317 sourceFrame = this._sourceFrameForScriptOrResource(resource); 326 }327 318 } 328 319 … … 341 332 342 333 var sourceFrame; 343 if (breakpoint.url && breakpoint.url in WebInspector.resourceURLMap) {334 if (breakpoint.url) { 344 335 var resource = WebInspector.resourceURLMap[breakpoint.url]; 345 sourceFrame = this._sourceFrameForScriptOrResource(resource); 336 if (resource && resource.finished) 337 sourceFrame = this._sourceFrameForScriptOrResource(resource); 346 338 } 347 339 … … 454 446 this._updateBackAndForwardButtons(); 455 447 456 this._ scriptsForURLsInFilesSelect = {};448 this._resourceForURLInFilesSelect = {}; 457 449 this.filesSelectElement.removeChildren(); 458 450 this.functionsSelectElement.removeChildren(); … … 498 490 }, 499 491 500 canShowSourceLineForURL: function(url) 501 { 502 return InspectorBackend.debuggerEnabled() && 503 !!(WebInspector.resourceForURL(url) || this.scriptForURL(url)); 504 }, 505 506 showSourceLineForURL: function(url, line) 507 { 508 var resource = WebInspector.resourceForURL(url); 509 if (resource) 510 this.showResource(resource, line); 511 else 512 this.showScript(this.scriptForURL(url), line); 513 }, 514 515 showScript: function(script, line) 516 { 517 this._showScriptOrResource(script, {line: line, shouldHighlightLine: true}); 518 }, 519 520 showResource: function(resource, line) 521 { 522 this._showScriptOrResource(resource, {line: line, shouldHighlightLine: true}); 492 canShowSourceLine: function(url, line) 493 { 494 if (!InspectorBackend.debuggerEnabled()) 495 return false; 496 return !!this._scriptOrResourceForURLAndLine(url, line); 497 }, 498 499 showSourceLine: function(url, line) 500 { 501 var scriptOrResource = this._scriptOrResourceForURLAndLine(url, line); 502 this._showScriptOrResource(scriptOrResource, {line: line, shouldHighlightLine: true}); 503 }, 504 505 _scriptOrResourceForURLAndLine: function(url, line) 506 { 507 for (var sourceID in this._sourceIDMap) { 508 var scriptOrResource = this._sourceIDMap[sourceID]; 509 if (scriptOrResource instanceof WebInspector.Script) { 510 var script = scriptOrResource; 511 if (script.startingLine <= line && script.startingLine + script.linesCount > line) 512 return script; 513 } else { 514 var resource = scriptOrResource; 515 if (resource.url === url) 516 return resource; 517 } 518 } 519 return null; 523 520 }, 524 521 … … 527 524 if (!view) 528 525 return; 529 this._showScriptOrResource( (view.resource || view.script));526 this._showScriptOrResource(view.resource || view.script); 530 527 }, 531 528 … … 577 574 _sourceFrameForScriptOrResource: function(scriptOrResource) 578 575 { 579 if (scriptOrResource instanceof WebInspector.Resource) { 580 if (!WebInspector.panels.resources) 581 return null; 576 if (scriptOrResource instanceof WebInspector.Resource) 582 577 return WebInspector.panels.resources.sourceFrameForResource(scriptOrResource); 583 }584 578 if (scriptOrResource instanceof WebInspector.Script) 585 579 return this.sourceFrameForScript(scriptOrResource); … … 654 648 // so use the force option to force the script into the menu. 655 649 if (!option) { 656 this._addScriptToFilesMenu(scriptOrResource, {force: true});650 this._addScriptToFilesMenu(scriptOrResource, true); 657 651 option = scriptOrResource.filesSelectOption; 658 652 } 659 653 660 654 console.assert(option); 661 } else { 662 var script = this.scriptForURL(url); 663 if (script) 664 option = script.filesSelectOption; 665 } 655 } else 656 option = scriptOrResource.filesSelectOption; 666 657 667 658 if (option) … … 669 660 }, 670 661 671 _addScriptToFilesMenu: function(script, options) 672 { 673 var force = options && options.force; 674 662 _addScriptToFilesMenu: function(script, force) 663 { 675 664 if (!script.sourceURL && !force) 676 665 return; 677 666 678 if (script.resource && this._scriptsForURLsInFilesSelect[script.sourceURL]) 679 return; 680 681 this._scriptsForURLsInFilesSelect[script.sourceURL] = script; 667 if (script.resource) { 668 if (this._resourceForURLInFilesSelect[script.resource.url]) 669 return; 670 this._resourceForURLInFilesSelect[script.resource.url] = script.resource; 671 } 672 673 var displayName = script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : WebInspector.UIString("(program)"); 682 674 683 675 var select = this.filesSelectElement; 684 685 676 var option = document.createElement("option"); 686 option.representedObject = (script.resource || script); 687 option.text = (script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : WebInspector.UIString("(program)")); 677 option.representedObject = script.resource || script; 678 option.url = displayName; 679 option.startingLine = script.startingLine; 680 option.text = script.resource ? displayName : String.sprintf("%s (%d - %d)", displayName, script.startingLine, script.startingLine + script.linesCount); 688 681 689 682 function optionCompare(a, b) 690 683 { 691 var aTitle = a.text.toLowerCase(); 692 var bTitle = b.text.toLowerCase(); 693 if (aTitle < bTitle) 684 if (a.url < b.url) 694 685 return -1; 695 else if (a Title > bTitle)686 else if (a.url > b.url) 696 687 return 1; 697 688 698 var aSourceID = a.representedObject.sourceID; 699 var bSourceID = b.representedObject.sourceID; 700 if (aSourceID < bSourceID) 689 if (typeof a.startingLine !== "number") 701 690 return -1; 702 else if (aSourceID > bSourceID)703 return 1;704 return 0;691 if (typeof b.startingLine !== "number") 692 return -1; 693 return a.startingLine - b.startingLine; 705 694 } 706 695 … … 711 700 select.insertBefore(option, select.childNodes.item(insertionIndex)); 712 701 713 script.filesSelectOption = option; 702 if (script.resource) 703 script.resource.filesSelectOption = option; 704 else 705 script.filesSelectOption = option; 714 706 715 707 // Call _showScriptOrResource if the option we just appended ended up being selected. -
trunk/WebCore/inspector/front-end/SourceView.js
r54657 r55231 93 93 { 94 94 var sourceID = null; 95 var closestStartingLine = 0;96 95 var scripts = this.resource.scripts; 97 96 for (var i = 0; i < scripts.length; ++i) { 98 97 var script = scripts[i]; 99 if (script.startingLine <= line && script.startingLine >= closestStartingLine) { 100 closestStartingLine = script.startingLine; 98 if (script.startingLine <= line && script.startingLine + script.linesCount > line) { 101 99 sourceID = script.sourceID; 100 break; 102 101 } 103 102 } -
trunk/WebCore/inspector/front-end/inspector.js
r55172 r55231 623 623 { 624 624 // FIXME: support webkit-html-external-link links here. 625 if (WebInspector.canShowSourceLine ForURL(anchor.href, anchor.preferredPanel)) {625 if (WebInspector.canShowSourceLine(anchor.href, anchor.lineNumber, anchor.preferredPanel)) { 626 626 if (anchor.hasStyleClass("webkit-html-external-link")) { 627 627 anchor.removeStyleClass("webkit-html-external-link"); … … 629 629 } 630 630 631 WebInspector.showSourceLine ForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel);631 WebInspector.showSourceLine(anchor.href, anchor.lineNumber, anchor.preferredPanel); 632 632 } else { 633 633 var profileString = WebInspector.ProfileType.URLRegExp.exec(anchor.href); 634 634 if (profileString) 635 WebInspector.showProfile ForURL(anchor.href);635 WebInspector.showProfile(anchor.href, anchor.lineNumber); 636 636 } 637 637 } … … 1466 1466 } 1467 1467 1468 WebInspector._choosePanelToShowSourceLine ForURL = function(url, preferredPanel)1468 WebInspector._choosePanelToShowSourceLine = function(url, line, preferredPanel) 1469 1469 { 1470 1470 preferredPanel = preferredPanel || "resources"; 1471 1471 var panel = this.panels[preferredPanel]; 1472 if (panel && panel.canShowSourceLine ForURL(url))1472 if (panel && panel.canShowSourceLine(url, line)) 1473 1473 return panel; 1474 1474 panel = this.panels.resources; 1475 return panel.canShowSourceLine ForURL(url) ? panel : null;1476 } 1477 1478 WebInspector.canShowSourceLine ForURL = function(url, preferredPanel)1479 { 1480 return !!this._choosePanelToShowSourceLine ForURL(url, preferredPanel);1481 } 1482 1483 WebInspector.showSourceLine ForURL= function(url, line, preferredPanel)1484 { 1485 this.currentPanel = this._choosePanelToShowSourceLine ForURL(url, preferredPanel);1475 return panel.canShowSourceLine(url, line) ? panel : null; 1476 } 1477 1478 WebInspector.canShowSourceLine = function(url, line, preferredPanel) 1479 { 1480 return !!this._choosePanelToShowSourceLine(url, line, preferredPanel); 1481 } 1482 1483 WebInspector.showSourceLine = function(url, line, preferredPanel) 1484 { 1485 this.currentPanel = this._choosePanelToShowSourceLine(url, line, preferredPanel); 1486 1486 if (!this.currentPanel) 1487 1487 return false; 1488 this.currentPanel.showSourceLine ForURL(url, line);1488 this.currentPanel.showSourceLine(url, line); 1489 1489 return true; 1490 1490 }
Note: See TracChangeset
for help on using the changeset viewer.