Shorten URLs shown in the Web Inspector to the file name. This makes
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 06:12:57 +0000 (06:12 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 06:12:57 +0000 (06:12 +0000)
finding files in the Console or the Scripts panel easier.

Reviewed by Adam Roben.

* page/inspector/Console.js:
(WebInspector.ConsoleMessage.prototype.get shortURL): Removed dead code.
(WebInspector.ConsoleMessage.prototype.toMessageElement): Call WebInspector.displayNameForURL
for the URL before making the link element.
* page/inspector/ProfileView.js:
(WebInspector.ProfileDataGridNode.prototype.createCell): Use WebInspector.displayNameForURL.
* page/inspector/Resource.js:
(WebInspector.Resource.prototype.get displayName): Use trimURL to
trim the URL with the main resource's domain.
* page/inspector/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): Use WebInspector.displayNameForURL.
* page/inspector/StylesSidebarPane.js:
(WebInspector.StylePropertiesSection): Ditto.
* page/inspector/inspector.js:
(WebInspector.displayNameForURL): Added.
(WebInspector.resourceForURL): Check for a direct match in resourceURLMap first.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/inspector/Console.js
WebCore/page/inspector/ProfileView.js
WebCore/page/inspector/Resource.js
WebCore/page/inspector/ScriptsPanel.js
WebCore/page/inspector/StylesSidebarPane.js
WebCore/page/inspector/inspector.js

index 84cebca..874e75b 100644 (file)
@@ -1,3 +1,27 @@
+2008-05-22  Timothy Hatcher  <timothy@apple.com>
+
+        Shorten URLs shown in the Web Inspector to the file name. This makes
+        finding files in the Console or the Scripts panel easier.
+
+        Reviewed by Adam Roben.
+
+        * page/inspector/Console.js:
+        (WebInspector.ConsoleMessage.prototype.get shortURL): Removed dead code.
+        (WebInspector.ConsoleMessage.prototype.toMessageElement): Call WebInspector.displayNameForURL
+        for the URL before making the link element.
+        * page/inspector/ProfileView.js:
+        (WebInspector.ProfileDataGridNode.prototype.createCell): Use WebInspector.displayNameForURL.
+        * page/inspector/Resource.js:
+        (WebInspector.Resource.prototype.get displayName): Use trimURL to
+        trim the URL with the main resource's domain.
+        * page/inspector/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): Use WebInspector.displayNameForURL.
+        * page/inspector/StylesSidebarPane.js:
+        (WebInspector.StylePropertiesSection): Ditto.
+        * page/inspector/inspector.js:
+        (WebInspector.displayNameForURL): Added.
+        (WebInspector.resourceForURL): Check for a direct match in resourceURLMap first.
+
 2008-05-22  Adam Roben  <aroben@apple.com>
 
         Fix Bug 19204: Inspector should highlight source lines when following
index 97b6c7c..18832de 100644 (file)
@@ -516,13 +516,6 @@ WebInspector.ConsoleMessage.prototype = {
         return formattedResult;
     },
 
-    get shortURL()
-    {
-        if (this.resource)
-            return this.resource.displayName;
-        return this.url;
-    },
-
     toMessageElement: function()
     {
         var element = document.createElement("div");
@@ -575,9 +568,9 @@ WebInspector.ConsoleMessage.prototype = {
             urlElement.lineNumber = this.line;
 
             if (this.line > 0)
-                urlElement.textContent = WebInspector.UIString("%s (line %d)", this.url, this.line);
+                urlElement.textContent = WebInspector.UIString("%s (line %d)", WebInspector.displayNameForURL(this.url), this.line);
             else
-                urlElement.textContent = this.url;
+                urlElement.textContent = WebInspector.displayNameForURL(this.url);
 
             element.appendChild(urlElement);
         }
index cabfe81..2296441 100644 (file)
@@ -235,8 +235,7 @@ WebInspector.ProfileDataGridNode.prototype = {
             return cell;
 
         if (this.profileNode.url) {
-            var resource = WebInspector.resourceURLMap[this.profileNode.url];
-            var fileName = resource ? resource.displayName : this.profileNode.url;
+            var fileName = WebInspector.displayNameForURL(this.profileNode.url);
 
             var urlElement = document.createElement("a");
             urlElement.className = "profile-node-file webkit-html-resource-link";
index ee8297c..e11aac0 100644 (file)
@@ -131,8 +131,8 @@ WebInspector.Resource.prototype = {
         var title = this.lastPathComponent;
         if (!title)
             title = this.displayDomain;
-        if (!title)
-            title = this.url;
+        if (!title && this.url)
+            title = this.url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "");
         return title;
     },
 
index d012cff..9b74bab 100644 (file)
@@ -463,7 +463,7 @@ WebInspector.ScriptsPanel.prototype = {
         // FIXME: Append in some meaningful order.
         var option = document.createElement("option");
         option.representedObject = (script.resource || script);
-        option.text = (script.sourceURL ? script.sourceURL.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "") : "(eval script)");
+        option.text = (script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : "(eval script)");
         select.appendChild(option);
 
         script.filesSelectOption = option;
index d68d604..b1d6205 100644 (file)
@@ -256,7 +256,7 @@ WebInspector.StylePropertiesSection = function(styleRule, subtitle, computedStyl
         if (!subtitle) {
             if (this.styleRule.parentStyleSheet && this.styleRule.parentStyleSheet.href) {
                 var url = this.styleRule.parentStyleSheet.href;
-                subtitle = WebInspector.linkifyURL(url, url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "").escapeHTML());
+                subtitle = WebInspector.linkifyURL(url, WebInspector.displayNameForURL(url).escapeHTML());
                 this.subtitleElement.addStyleClass("file");
             } else if (this.styleRule.parentStyleSheet && !this.styleRule.parentStyleSheet.ownerNode)
                 subtitle = WebInspector.UIString("user agent stylesheet");
index 9a52da5..d6d235d 100644 (file)
@@ -851,8 +851,21 @@ WebInspector.updateFocusedNode = function(node)
     this.panels.elements.focusedDOMNode = node;
 }
 
+WebInspector.displayNameForURL = function(url)
+{
+    var resource = this.resourceURLMap[url];
+    if (resource)
+        return resource.displayName;
+    return url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "");
+}
+
 WebInspector.resourceForURL = function(url)
 {
+    if (url in this.resourceURLMap)
+        return this.resourceURLMap[url];
+
+    // No direct match found. Search for resources that contain
+    // a substring of the URL.
     for (var resourceURL in this.resourceURLMap) {
         if (resourceURL.hasSubstring(url))
             return this.resourceURLMap[resourceURL];