Changeset 92598 in webkit
- Timestamp:
- Aug 8, 2011 8:50:36 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92596 r92598 1 2011-08-08 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: refactor links creation. 4 https://bugs.webkit.org/show_bug.cgi?id=65612 5 6 Reviewed by Pavel Feldman. 7 8 No new tests - it is refactoring, modified code covered by script-formatter.html test. 9 10 * inspector/front-end/ConsoleView.js: 11 (WebInspector.ConsoleMessage.prototype._formatMessage): 12 (WebInspector.ConsoleMessage.prototype._linkifyLocation): 13 (WebInspector.ConsoleMessage.prototype._linkifyCallFrame): 14 (WebInspector.ConsoleMessage.prototype._populateStackTraceTreeElement): 15 * inspector/front-end/DebuggerPresentationModel.js: 16 (WebInspector.DebuggerPresentationModel): 17 (WebInspector.DebuggerPresentationModel.prototype.addSourceMappingListener): 18 (WebInspector.DebuggerPresentationModel.prototype.removeSourceMappingListener): 19 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor.didGetLocation): 20 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor): 21 (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation): 22 (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles): 23 (WebInspector.DebuggerPresentationModel.prototype._sourceFileForScript): 24 (WebInspector.DebuggerPresentationModel.prototype._debuggerReset): 25 * inspector/front-end/EventListenersSidebarPane.js: 26 * inspector/front-end/NetworkPanel.js: 27 (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell): 28 * inspector/front-end/Panel.js: 29 * inspector/front-end/ProfileDataGridTree.js: 30 (WebInspector.ProfileDataGridNode.prototype.createCell): 31 * inspector/front-end/ScriptsPanel.js: 32 (WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL): 33 * inspector/front-end/StylesSidebarPane.js: 34 (WebInspector.StylePropertiesSection.linkifyUncopyable): 35 (WebInspector.StylePropertiesSection): 36 * inspector/front-end/TimelinePanel.js: 37 (WebInspector.TimelinePanel.FormattedRecord.prototype._getRecordDetails): 38 (WebInspector.TimelinePanel.FormattedRecord.prototype._linkifyLocation): 39 (WebInspector.TimelinePanel.FormattedRecord.prototype._linkifyCallFrame): 40 (WebInspector.TimelinePanel.PopupContentHelper.prototype._appendLinkRow): 41 (WebInspector.TimelinePanel.PopupContentHelper.prototype._appendStackTrace): 42 * inspector/front-end/inspector.js: 43 (WebInspector._showSettingsScreen): 44 (WebInspector.formatLinkText): 45 (WebInspector.linkifyResourceAsNode): 46 1 47 2011-08-08 Andrew Wason <rectalogic@rectalogic.com> 2 48 -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r92278 r92598 741 741 return this._format(output, output.subtype && output.subtype === "array"); 742 742 }, 743 743 744 744 get scrollLeft() 745 745 { … … 845 845 846 846 if (this._stackTrace && this._stackTrace.length && this._stackTrace[0].url) { 847 var urlElement = WebInspector.linkifyCallFrameAsNode(this._stackTrace[0], "console-message-url");847 var urlElement = this._linkifyCallFrame(this._stackTrace[0]); 848 848 this._formattedMessage.appendChild(urlElement); 849 849 } else if (this.url && this.url !== "undefined") { 850 var urlElement = WebInspector.linkifyResourceAsNode(this.url, "scripts", this.line, "console-message-url");850 var urlElement = this._linkifyLocation(this.url, this.line, 0); 851 851 this._formattedMessage.appendChild(urlElement); 852 852 } … … 881 881 }, 882 882 883 _linkifyLocation: function(url, lineNumber, columnNumber) 884 { 885 // FIXME(62725): stack trace line/column numbers are one-based. 886 lineNumber = lineNumber ? lineNumber - 1 : undefined; 887 columnNumber = columnNumber ? columnNumber - 1 : 0; 888 return WebInspector.debuggerPresentationModel.linkifyLocation(url, lineNumber, columnNumber, "console-message-url"); 889 }, 890 891 _linkifyCallFrame: function(callFrame) 892 { 893 return this._linkifyLocation(callFrame.url, callFrame.lineNumber, callFrame.columnNumber); 894 }, 895 883 896 isErrorOrWarning: function() 884 897 { … … 1045 1058 1046 1059 if (frame.url) { 1047 var urlElement = WebInspector.linkifyCallFrameAsNode(frame, "console-message-url");1060 var urlElement = this._linkifyCallFrame(frame); 1048 1061 content.appendChild(urlElement); 1049 1062 } -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r92369 r92598 35 35 this._sourceFiles = {}; 36 36 this._messages = []; 37 this._anchors = []; 37 // FIXME: move this to RawSourceCode when it's not re-created in pretty-print mode. 38 this._sourceMappingListeners = []; 38 39 this._breakpointsByDebuggerId = {}; 39 40 this._breakpointsWithoutSourceFile = {}; … … 120 121 }, 121 122 122 registerAnchor: function(sourceURL, scriptId, lineNumber, columnNumber, updateHandler) 123 { 124 var anchor = { sourceURL: sourceURL, scriptId: scriptId, lineNumber: lineNumber, columnNumber: columnNumber, updateHandler: updateHandler }; 125 this._anchors.push(anchor); 126 this._updateAnchor(anchor); 127 }, 128 129 _updateAnchor: function(anchor) 130 { 131 var sourceFile = this._sourceFileForScript(anchor.sourceURL, anchor.scriptId); 132 if (!sourceFile) 133 return; 134 135 this._scriptLocationToUILocation(anchor.sourceURL, anchor.scriptId, anchor.lineNumber, anchor.columnNumber, anchor.updateHandler); 123 addSourceMappingListener: function(sourceURL, sourceId, listener) 124 { 125 this._sourceMappingListeners.push(listener); 126 }, 127 128 removeSourceMappingListener: function(sourceURL, sourceId, listener) 129 { 130 // FIXME: implement this. 131 }, 132 133 linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes) 134 { 135 var linkText = WebInspector.formatLinkText(sourceURL, lineNumber); 136 var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes, false); 137 138 var sourceFile = this._sourceFileForScript(sourceURL); 139 if (!sourceFile) { 140 anchor.setAttribute("preferred_panel", "resources"); 141 anchor.setAttribute("line_number", lineNumber); 142 return anchor; 143 } 144 145 function updateAnchor() 146 { 147 function didGetLocation(sourceFileId, lineNumber) 148 { 149 anchor.textContent = WebInspector.formatLinkText(sourceFile.url, lineNumber); 150 anchor.setAttribute("preferred_panel", "scripts"); 151 anchor.setAttribute("source_file_id", sourceFileId); 152 anchor.setAttribute("line_number", lineNumber); 153 } 154 this._scriptLocationToUILocation(sourceURL, null, lineNumber, columnNumber, didGetLocation.bind(this)); 155 } 156 updateAnchor.call(this); 157 this.addSourceMappingListener(sourceURL, null, updateAnchor.bind(this)); 158 return anchor; 136 159 }, 137 160 … … 282 305 this._addConsoleMessage(messages[i]); 283 306 284 for (var i = 0; i < this._anchors.length; ++i) 285 this._updateAnchor(this._anchors[i]); 307 // FIXME: move this to RawSourceCode. 308 for (var i = 0; i < this._sourceMappingListeners.length; ++i) 309 this._sourceMappingListeners[i](); 286 310 287 311 if (WebInspector.debuggerModel.callFrames) … … 617 641 _sourceFileForScript: function(sourceURL, scriptId) 618 642 { 619 if (!sourceURL) 620 sourceURL = WebInspector.debuggerModel.scriptForSourceID(scriptId).sourceURL; 643 if (!sourceURL) { 644 var script = WebInspector.debuggerModel.scriptForSourceID(scriptId); 645 if (!script) 646 return; 647 sourceURL = script.sourceURL; 648 } 621 649 return this._sourceFiles[this._createSourceFileId(sourceURL, scriptId)]; 622 650 }, … … 659 687 { 660 688 this._reset(); 661 this._ anchors = [];689 this._sourceMappingListeners = []; 662 690 this._presentationCallFrames = []; 663 691 this._selectedCallFrameIndex = 0; -
trunk/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js
r92369 r92598 237 237 if (this.eventListener.location) { 238 238 this.subtitleElement.removeChildren(); 239 this.subtitleElement.appendChild(WebInspector.linkifyResourceAsNode(this.eventListener.location.scriptId, "scripts", this.eventListener.location.lineNumber)); 239 // FIXME(62725): eventListener.location should be a debugger Location. 240 var url = this.eventListener.location.scriptId; 241 var lineNumber = this.eventListener.location.lineNumber - 1; 242 var columnNumber = 0; 243 var urlElement = WebInspector.debuggerPresentationModel.linkifyLocation(url, lineNumber, columnNumber); 244 this.subtitleElement.appendChild(urlElement); 240 245 } else { 241 246 var match = this.eventListener.handlerBody.match(/function ([^\(]+?)\(/); -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r92213 r92598 1978 1978 } 1979 1979 this._initiatorCell.title = topFrame.url + ":" + topFrame.lineNumber; 1980 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(topFrame.url, "scripts", topFrame.lineNumber)); 1980 var urlElement = WebInspector.debuggerPresentationModel.linkifyLocation(topFrame.url, topFrame.lineNumber - 1, 0); 1981 this._initiatorCell.appendChild(urlElement); 1981 1982 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script")); 1982 1983 } else { // initiator.type === "parser" 1983 1984 this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber; 1984 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, "resources", initiator.lineNumber));1985 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1)); 1985 1986 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Parser")); 1986 1987 } -
trunk/Source/WebCore/inspector/front-end/Panel.js
r91902 r92598 396 396 }, 397 397 398 createAnchor: function(url, lineNumber, columnNumber, classes, tooltipText)399 {400 var linkText = this.formatAnchorText(url, lineNumber);401 var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);402 anchor.setAttribute("preferred_panel", "resources");403 if (lineNumber !== undefined)404 anchor.setAttribute("line_number", lineNumber);405 return anchor;406 },407 408 formatAnchorText: function(url, lineNumber)409 {410 var text = WebInspector.displayNameForURL(url);411 if (lineNumber !== undefined)412 text += ":" + (lineNumber + 1);413 return text;414 },415 416 398 canShowAnchorLocation: function(anchor) 417 399 { -
trunk/Source/WebCore/inspector/front-end/ProfileDataGridTree.js
r75714 r92598 97 97 98 98 if (this.profileNode.url) { 99 var lineNumber; 100 if (this.profileNode.lineNumber > 0) 101 lineNumber = this.profileNode.lineNumber; 102 var urlElement = WebInspector.linkifyResourceAsNode(this.profileNode.url, "scripts", lineNumber, "profile-node-file"); 99 // FIXME(62725): profileNode should reference a debugger location. 100 var lineNumber = this.profileNode.lineNumber ? this.profileNode.lineNumber - 1 : 0; 101 var urlElement = WebInspector.debuggerPresentationModel.linkifyLocation(this.profileNode.url, lineNumber, 0, "profile-node-file"); 103 102 cell.insertBefore(urlElement, cell.firstChild); 104 103 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r92300 r92598 29 29 WebInspector.Panel.call(this, "scripts"); 30 30 31 this._presentationModel = new WebInspector.DebuggerPresentationModel();31 this._presentationModel = WebInspector.debuggerPresentationModel; 32 32 33 33 this.registerShortcuts(); … … 325 325 if (folderName.length > 80) 326 326 folderName = "\u2026" + folderName.substring(folderName.length - 80); 327 327 328 328 return { folderName: folderName, displayName: displayName}; 329 329 }, … … 546 546 }, 547 547 548 createAnchor: function(url, lineNumber, columnNumber, classes, tooltipText)549 {550 var anchor = WebInspector.Panel.prototype.createAnchor.call(this, url, lineNumber, columnNumber, classes, tooltipText);551 if (lineNumber !== undefined)552 this._presentationModel.registerAnchor(url, null, lineNumber, columnNumber, this._updateAnchor.bind(this, anchor));553 return anchor;554 },555 556 548 canShowAnchorLocation: function(anchor) 557 549 { … … 562 554 { 563 555 this._showSourceLine(anchor.getAttribute("source_file_id"), parseInt(anchor.getAttribute("line_number"))); 564 },565 566 _updateAnchor: function(anchor, sourceFileId, lineNumber)567 {568 var sourceFile = this._presentationModel.sourceFile(sourceFileId);569 var url = sourceFile.url || WebInspector.UIString("(program)");570 anchor.textContent = this.formatAnchorText(url, lineNumber)571 // Used for showing anchor location.572 anchor.setAttribute("preferred_panel", "scripts");573 anchor.setAttribute("source_file_id", sourceFileId);574 anchor.setAttribute("line_number", lineNumber);575 556 }, 576 557 -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r92192 r92598 837 837 function linkifyUncopyable(url, line) 838 838 { 839 var link = WebInspector.linkifyResourceAsNode(url, "resources", line + 1);839 var link = WebInspector.linkifyResourceAsNode(url, line); 840 840 return link; 841 841 } -
trunk/Source/WebCore/inspector/front-end/TimelinePanel.js
r92284 r92598 357 357 this._scheduleRefresh(true); 358 358 }, 359 359 360 360 _garbageCollectButtonClicked: function() 361 361 { … … 1116 1116 return WebInspector.UIString("%s collected", Number.bytesToString(this.data.usedHeapSizeDelta)); 1117 1117 case WebInspector.TimelineAgent.RecordType.TimerFire: 1118 return this.scriptName ? WebInspector.linkifyResourceAsNode(this.scriptName, "scripts", this.scriptLine, "", "") : this.data.timerId;1118 return this.scriptName ? this._linkifyLocation(this.scriptName, this.scriptLine, 0) : this.data.timerId; 1119 1119 case WebInspector.TimelineAgent.RecordType.FunctionCall: 1120 return this.scriptName ? WebInspector.linkifyResourceAsNode(this.scriptName, "scripts", this.scriptLine, "", "") : null;1120 return this.scriptName ? this._linkifyLocation(this.scriptName, this.scriptLine, 0) : null; 1121 1121 case WebInspector.TimelineAgent.RecordType.EventDispatch: 1122 1122 return this.data ? this.data.type : null; … … 1125 1125 case WebInspector.TimelineAgent.RecordType.TimerInstall: 1126 1126 case WebInspector.TimelineAgent.RecordType.TimerRemove: 1127 return this.stackTrace ? WebInspector.linkifyCallFrameAsNode(this.stackTrace[0], "") : this.data.timerId;1127 return this.stackTrace ? this._linkifyCallFrame(this.stackTrace[0]) : this.data.timerId; 1128 1128 case WebInspector.TimelineAgent.RecordType.ParseHTML: 1129 1129 case WebInspector.TimelineAgent.RecordType.RecalculateStyles: 1130 return this.stackTrace ? WebInspector.linkifyCallFrameAsNode(this.stackTrace[0], "") : null;1130 return this.stackTrace ? this._linkifyCallFrame(this.stackTrace[0]) : null; 1131 1131 case WebInspector.TimelineAgent.RecordType.EvaluateScript: 1132 return this.url ? WebInspector.linkifyResourceAsNode(this.url, "scripts", this.data.lineNumber, "", "") : null;1132 return this.url ? this._linkifyLocation(this.url, this.data.lineNumber, 0) : null; 1133 1133 case WebInspector.TimelineAgent.RecordType.XHRReadyStateChange: 1134 1134 case WebInspector.TimelineAgent.RecordType.XHRLoad: … … 1146 1146 }, 1147 1147 1148 _linkifyLocation: function(url, lineNumber, columnNumber) 1149 { 1150 // FIXME(62725): stack trace line/column numbers are one-based. 1151 lineNumber = lineNumber ? lineNumber - 1 : lineNumber; 1152 columnNumber = columnNumber ? columnNumber - 1 : 0; 1153 return WebInspector.debuggerPresentationModel.linkifyLocation(url, lineNumber, columnNumber, "timeline-details"); 1154 }, 1155 1156 _linkifyCallFrame: function(callFrame) 1157 { 1158 return this._linkifyLocation(callFrame.url, callFrame.lineNumber, callFrame.columnNumber); 1159 }, 1160 1148 1161 _calculateAggregatedStats: function(categories) 1149 1162 { … … 1213 1226 _appendLinkRow: function(title, scriptName, scriptLine) 1214 1227 { 1215 var link = WebInspector. linkifyResourceAsNode(scriptName, "scripts", scriptLine, "timeline-details");1228 var link = WebInspector.TimelinePanel.FormattedRecord.prototype._linkifyLocation(scriptName, scriptLine, 0, "timeline-details"); 1216 1229 this._appendElementRow(title, link); 1217 1230 }, … … 1228 1241 row.appendChild(this._createCell(" @ ")); 1229 1242 var linkCell = document.createElement("td"); 1230 linkCell.appendChild(WebInspector.linkifyCallFrameAsNode(stackFrame, "timeline-details")); 1243 var urlElement = WebInspector.TimelinePanel.FormattedRecord.prototype._linkifyCallFrame(stackFrame); 1244 linkCell.appendChild(urlElement); 1231 1245 row.appendChild(linkCell); 1232 1246 framesTable.appendChild(row); -
trunk/Source/WebCore/inspector/front-end/inspector.js
r92587 r92598 241 241 delete this._settingsScreen; 242 242 } 243 243 244 244 if (!this._settingsScreen) { 245 245 this._settingsScreen = new WebInspector.SettingsScreen(); … … 520 520 this.cssModel = new WebInspector.CSSStyleModel(); 521 521 this.debuggerModel = new WebInspector.DebuggerModel(); 522 this.debuggerPresentationModel = new WebInspector.DebuggerPresentationModel(); 522 523 523 524 this.searchController = new WebInspector.SearchController(); … … 1323 1324 } 1324 1325 1325 WebInspector.linkifyResourceAsNode = function(url, preferredPanel, oneBasedLineNumber, classes, tooltipText) 1326 { 1327 preferredPanel = preferredPanel || "scripts"; 1328 // FIXME(62725): stack trace line/column numbers are one-based. 1329 var lineNumber = oneBasedLineNumber ? oneBasedLineNumber - 1 : undefined; 1330 return this.panels[preferredPanel].createAnchor(url, lineNumber, 0, classes, tooltipText); 1331 } 1332 1333 WebInspector.linkifyCallFrameAsNode = function(callFrame, classes, tooltipText) 1334 { 1335 // FIXME(62725): stack trace line/column numbers are one-based. 1336 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; 1337 return this.panels.scripts.createAnchor(callFrame.url, callFrame.lineNumber - 1, columnNumber, classes, tooltipText); 1326 WebInspector.formatLinkText = function(url, lineNumber) 1327 { 1328 var text = WebInspector.displayNameForURL(url); 1329 if (lineNumber !== undefined) 1330 text += ":" + (lineNumber + 1); 1331 return text; 1332 } 1333 1334 WebInspector.linkifyResourceAsNode = function(url, lineNumber, classes, tooltipText) 1335 { 1336 var linkText = this.formatLinkText(url, lineNumber); 1337 var anchor = this.linkifyURLAsNode(url, linkText, classes, false, tooltipText); 1338 anchor.setAttribute("preferred_panel", "resources"); 1339 anchor.setAttribute("line_number", lineNumber); 1340 return anchor; 1338 1341 } 1339 1342
Note: See TracChangeset
for help on using the changeset viewer.