Changeset 92105 in webkit
- Timestamp:
- Aug 1, 2011 1:17:05 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r92104 r92105 1 2011-08-01 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: group scripts by folder in the scripts selector. 4 https://bugs.webkit.org/show_bug.cgi?id=65321 5 6 Reviewed by Yury Semikhatsky. 7 8 * http/tests/inspector/debugger-test.js: 9 (initialize_DebuggerTest): 10 * inspector/debugger/scripts-sorting-expected.txt: Added. 11 * inspector/debugger/scripts-sorting.html: Added. 12 1 13 2011-07-28 Pavel Feldman <pfeldman@google.com> 2 14 -
trunk/LayoutTests/http/tests/inspector/debugger-test.js
r91568 r92105 160 160 var filesSelect = document.getElementById("scripts-files"); 161 161 for (var i = 0; i < filesSelect.length; ++i) { 162 if (filesSelect[i]. text === scriptName) {162 if (filesSelect[i].scriptNameForTest === scriptName) { 163 163 filesSelect.selectedIndex = i; 164 164 WebInspector.panels.scripts._filesSelectChanged(); -
trunk/Source/WebCore/ChangeLog
r92104 r92105 1 2011-08-01 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: group scripts by folder in the scripts selector. 4 https://bugs.webkit.org/show_bug.cgi?id=65321 5 6 Reviewed by Yury Semikhatsky. 7 8 Test: inspector/debugger/scripts-sorting.html 9 10 * inspector/front-end/ScriptsPanel.js: 11 (WebInspector.ScriptsPanel.prototype._sourceFileAdded.get if): 12 (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered.optionCompare): 13 (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered): 14 (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect): 15 (WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL): 16 (WebInspector.ScriptsPanel.prototype.reset): 17 (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName): 18 1 19 2011-07-28 Pavel Feldman <pfeldman@google.com> 2 20 -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r90365 r92105 241 241 242 242 var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get(); 243 if (this._filesSelectElement.length === 1) { 243 if (!this._filesSelectElement.initialSelectionProcessed) { 244 this._filesSelectElement.initialSelectionProcessed = true; 244 245 // Option we just added is the only option in files select. 245 246 // We have to show corresponding source frame immediately. … … 255 256 { 256 257 var select = this._filesSelectElement; 258 if (!select.folderOptions) 259 select.folderOptions = {}; 260 257 261 var option = document.createElement("option"); 258 option.text = this._displayNameForScriptURL(sourceFile.url) || WebInspector.UIString("(program)"); 262 var parsedURL = sourceFile.url.asParsedURL(); 263 264 var names = this._folderAndDisplayNameForScriptURL(sourceFile.url); 265 option.text = names.displayName ? "\u00a0\u00a0\u00a0\u00a0" + names.displayName : WebInspector.UIString("(program)"); 266 option.scriptNameForTest = names.displayName; 267 var folderNameForSorting = (sourceFile.isContentScript ? "2" : "0") + names.folderName; 268 option.nameForSorting = folderNameForSorting + "\t/\t" + names.displayName; // Use '\t' to make files stick to their folder. 259 269 option.title = sourceFile.url; 260 option.isContentScript = sourceFile.isContentScript;261 270 if (sourceFile.isContentScript) 262 271 option.addStyleClass("extension-script"); 263 function compare(a, b) 272 273 function insertOrdered(option) 264 274 { 265 return a < b ? -1 : (a > b ? 1 : 0); 266 } 267 function optionCompare(a, b) 268 { 269 if (a === select.contentScriptSection) 270 return b.isContentScript ? -1 : 1; 271 if (b === select.contentScriptSection) 272 return a.isContentScript ? 1 : -1; 273 274 if (a.isContentScript && !b.isContentScript) 275 return 1; 276 if (!a.isContentScript && b.isContentScript) 277 return -1; 278 279 return compare(a.text, b.text) || compare(a.title, b.title); 280 } 281 282 var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare); 283 select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex)); 275 function optionCompare(a, b) 276 { 277 return a.nameForSorting.localeCompare(b.nameForSorting); 278 } 279 var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare); 280 select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex)); 281 } 282 283 insertOrdered(option); 284 284 285 285 if (sourceFile.isContentScript && !select.contentScriptSection) { … … 287 287 contentScriptSection.text = WebInspector.UIString("Content scripts"); 288 288 contentScriptSection.disabled = true; 289 option.nameForSorting = "1/ContentScriptSeparator"; 289 290 select.contentScriptSection = contentScriptSection; 290 291 var insertionIndex = insertionIndexForObjectInListSortedByFunction(contentScriptSection, select.childNodes, optionCompare); 292 select.insertBefore(contentScriptSection, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex)); 293 } 291 insertOrdered(contentScriptSection); 292 } 293 294 if (names.folderName && !select.folderOptions[names.folderName]) { 295 var folderOption = document.createElement("option"); 296 folderOption.text = names.folderName; 297 folderOption.nameForSorting = folderNameForSorting; 298 folderOption.disabled = true; 299 select.folderOptions[names.folderName] = folderOption; 300 insertOrdered(folderOption); 301 } 302 294 303 option._sourceFileId = sourceFile.id; 295 304 this._sourceFileIdToFilesSelectOption[sourceFile.id] = option; 296 305 }, 297 306 298 _displayNameForScriptURL: function(url) 299 { 307 _folderAndDisplayNameForScriptURL: function(url) 308 { 309 var parsedURL = url.asParsedURL(); 310 if (parsedURL) 311 url = parsedURL.path; 312 313 var folderName = ""; 300 314 var displayName = url; 301 var indexOfQuery = displayName.indexOf("?"); 302 if (indexOfQuery > 0) 303 displayName = displayName.substring(0, indexOfQuery); 315 304 316 var fromIndex = displayName.lastIndexOf("/", displayName.length - 2); 305 if (fromIndex !== -1) 317 if (fromIndex !== -1) { 318 folderName = displayName.substring(0, fromIndex); 306 319 displayName = displayName.substring(fromIndex + 1); 307 if (displayName.length > 100) 308 displayName = displayName.substring(0, 80) + "..."; 309 return displayName; 320 } 321 322 if (displayName.length > 80) 323 displayName = "\u2026" + displayName.substring(displayName.length - 80); 324 325 if (folderName.length > 80) 326 folderName = "\u2026" + folderName.substring(folderName.length - 80); 327 328 return { folderName: folderName, displayName: displayName}; 310 329 }, 311 330 … … 496 515 this._sourceFileIdToFilesSelectOption = {}; 497 516 this._filesSelectElement.removeChildren(); 517 this._filesSelectElement.removeChildren(); 518 this._filesSelectElement.folderOptions = {}; 519 delete this._filesSelectElement.initialSelectionProcessed; 520 delete this._filesSelectElement.contentScriptSection; 521 498 522 this.functionsSelectElement.removeChildren(); 499 523 this.viewsContainerElement.removeChildren(); … … 1182 1206 { 1183 1207 var sourceFile = this._model.sourceFile(this._sourceFileId); 1184 return WebInspector.panels.scripts._displayNameForScriptURL(sourceFile.url) || "untitled.js"; 1208 var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(sourceFile.url); 1209 return names.displayName || "untitled.js"; 1185 1210 } 1186 1211 }
Note: See TracChangeset
for help on using the changeset viewer.