OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 var select = this._filesSelectElement; | 273 var select = this._filesSelectElement; |
274 if (!select.domainOptions) | 274 if (!select.domainOptions) |
275 select.domainOptions = {}; | 275 select.domainOptions = {}; |
276 if (!select.folderOptions) | 276 if (!select.folderOptions) |
277 select.folderOptions = {}; | 277 select.folderOptions = {}; |
278 | 278 |
279 var option = document.createElement("option"); | 279 var option = document.createElement("option"); |
280 option._uiSourceCode = uiSourceCode; | 280 option._uiSourceCode = uiSourceCode; |
281 var parsedURL = uiSourceCode.url.asParsedURL(); | 281 var parsedURL = uiSourceCode.url.asParsedURL(); |
282 | 282 |
| 283 const indent = WebInspector.isMac() ? "" : "\u00a0\u00a0\u00a0\u00a0"; |
| 284 |
283 var names = this._folderAndDisplayNameForScriptURL(uiSourceCode.url); | 285 var names = this._folderAndDisplayNameForScriptURL(uiSourceCode.url); |
284 const indent = (!showScriptFolders || WebInspector.isMac()) ? "" : "\u00
a0\u00a0\u00a0\u00a0"; | |
285 option.text = indent + (names.displayName ? names.displayName : WebInspe
ctor.UIString("(program)")); | |
286 option.displayName = names.displayName; | 286 option.displayName = names.displayName; |
287 | 287 |
288 var folderNameForSorting; | 288 var contentScriptPrefix = uiSourceCode.isContentScript ? "2:" : "0:"; |
289 if (uiSourceCode.isContentScript) | |
290 folderNameForSorting = "2:" + names.folderName; | |
291 else | |
292 folderNameForSorting = "0:" + (names.domain ? names.domain + "\t\t"
: "") + names.folderName; | |
293 | 289 |
294 option.nameForSorting = folderNameForSorting + "\t/\t" + names.displayNa
me; // Use '\t' to make files stick to their folder. | 290 if (uiSourceCode.isContentScript && names.domain) { |
| 291 // Render extension domain as a path in structured view |
| 292 names.folderName = names.domain + (names.folderName ? names.folderNa
me : ""); |
| 293 delete names.domain; |
| 294 } |
| 295 |
| 296 var folderNameForSorting = contentScriptPrefix + (names.domain ? names.d
omain + "\t\t" : "") + names.folderName; |
| 297 |
| 298 if (showScriptFolders) { |
| 299 option.text = indent + (names.displayName ? names.displayName : WebI
nspector.UIString("(program)")); |
| 300 option.nameForSorting = folderNameForSorting + "\t/\t" + names.displ
ayName; // Use '\t' to make files stick to their folder. |
| 301 } else { |
| 302 option.text = names.displayName ? names.displayName : WebInspector.U
IString("(program)"); |
| 303 // Content script should contain its domain name as a prefix |
| 304 if (uiSourceCode.isContentScript && names.folderName) |
| 305 option.text = names.folderName + "/" + option.text; |
| 306 option.nameForSorting = contentScriptPrefix + option.text; |
| 307 } |
295 option.title = uiSourceCode.url; | 308 option.title = uiSourceCode.url; |
| 309 |
296 if (uiSourceCode.isContentScript) | 310 if (uiSourceCode.isContentScript) |
297 option.addStyleClass("extension-script"); | 311 option.addStyleClass("extension-script"); |
298 | 312 |
299 function insertOrdered(option) | 313 function insertOrdered(option) |
300 { | 314 { |
301 function optionCompare(a, b) | 315 function optionCompare(a, b) |
302 { | 316 { |
303 if (showScriptFolders) | 317 return a.nameForSorting.localeCompare(b.nameForSorting); |
304 return a.nameForSorting.localeCompare(b.nameForSorting); | |
305 else | |
306 return a.displayName.localeCompare(b.displayName); | |
307 } | 318 } |
308 var insertionIndex = insertionIndexForObjectInListSortedByFunction(o
ption, select.childNodes, optionCompare); | 319 var insertionIndex = insertionIndexForObjectInListSortedByFunction(o
ption, select.childNodes, optionCompare); |
309 select.insertBefore(option, insertionIndex < 0 ? null : select.child
Nodes.item(insertionIndex)); | 320 select.insertBefore(option, insertionIndex < 0 ? null : select.child
Nodes.item(insertionIndex)); |
310 } | 321 } |
311 | 322 |
312 insertOrdered(option); | 323 insertOrdered(option); |
313 | 324 |
314 if (uiSourceCode.isContentScript && !select.contentScriptSection) { | 325 if (uiSourceCode.isContentScript && !select.contentScriptSection) { |
315 var contentScriptSection = document.createElement("option"); | 326 var contentScriptSection = document.createElement("option"); |
316 contentScriptSection.text = "\u2014 " + WebInspector.UIString("Conte
nt scripts") + " \u2014"; | 327 contentScriptSection.text = "\u2014 " + WebInspector.UIString("Conte
nt scripts") + " \u2014"; |
317 contentScriptSection.disabled = true; | 328 contentScriptSection.disabled = true; |
318 contentScriptSection.nameForSorting = "1/ContentScriptSeparator"; | 329 contentScriptSection.nameForSorting = "1/ContentScriptSeparator"; |
319 select.contentScriptSection = contentScriptSection; | 330 select.contentScriptSection = contentScriptSection; |
320 insertOrdered(contentScriptSection); | 331 insertOrdered(contentScriptSection); |
321 } | 332 } |
322 | 333 |
323 if (showScriptFolders && !uiSourceCode.isContentScript && names.domain &
& !select.domainOptions[names.domain]) { | 334 if (showScriptFolders && !uiSourceCode.isContentScript && names.domain &
& !select.domainOptions[names.domain]) { |
324 var domainOption = document.createElement("option"); | 335 var domainOption = document.createElement("option"); |
325 domainOption.text = "\u2014 " + names.domain + " \u2014"; | 336 domainOption.text = "\u2014 " + names.domain + " \u2014"; |
326 domainOption.nameForSorting = "0:" + names.domain; | 337 domainOption.nameForSorting = "0:" + names.domain; |
327 domainOption.disabled = true; | 338 domainOption.disabled = true; |
328 select.domainOptions[names.domain] = domainOption; | 339 select.domainOptions[names.domain] = domainOption; |
329 insertOrdered(domainOption); | 340 insertOrdered(domainOption); |
330 } | 341 } |
331 | 342 |
332 if (showScriptFolders && names.folderName && !select.folderOptions[names
.folderName]) { | 343 if (showScriptFolders && names.folderName && !select.folderOptions[folde
rNameForSorting]) { |
333 var folderOption = document.createElement("option"); | 344 var folderOption = document.createElement("option"); |
334 folderOption.text = names.folderName; | 345 folderOption.text = names.folderName; |
335 folderOption.nameForSorting = folderNameForSorting; | 346 folderOption.nameForSorting = folderNameForSorting; |
336 folderOption.disabled = true; | 347 folderOption.disabled = true; |
337 select.folderOptions[names.folderName] = folderOption; | 348 select.folderOptions[folderNameForSorting] = folderOption; |
338 insertOrdered(folderOption); | 349 insertOrdered(folderOption); |
339 } | 350 } |
340 | 351 |
341 option._uiSourceCode = uiSourceCode; | 352 option._uiSourceCode = uiSourceCode; |
342 uiSourceCode._option = option; | 353 uiSourceCode._option = option; |
343 }, | 354 }, |
344 | 355 |
345 _folderAndDisplayNameForScriptURL: function(url) | 356 _folderAndDisplayNameForScriptURL: function(url) |
346 { | 357 { |
347 var parsedURL = url.asParsedURL(); | 358 var parsedURL = url.asParsedURL(); |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 }, | 1256 }, |
1246 | 1257 |
1247 suggestedFileName: function() | 1258 suggestedFileName: function() |
1248 { | 1259 { |
1249 var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptUR
L(this._uiSourceCode.url); | 1260 var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptUR
L(this._uiSourceCode.url); |
1250 return names.displayName || "untitled.js"; | 1261 return names.displayName || "untitled.js"; |
1251 } | 1262 } |
1252 } | 1263 } |
1253 | 1264 |
1254 WebInspector.SourceFrameDelegateForScriptsPanel.prototype.__proto__ = WebInspect
or.SourceFrameDelegate.prototype; | 1265 WebInspector.SourceFrameDelegateForScriptsPanel.prototype.__proto__ = WebInspect
or.SourceFrameDelegate.prototype; |
OLD | NEW |