Title: [114623] trunk
Revision
114623
Author
pfeld...@chromium.org
Date
2012-04-19 04:39:50 -0700 (Thu, 19 Apr 2012)

Log Message

Web Inspector: reuse ParsedUrl in the UISourceCode
https://bugs.webkit.org/show_bug.cgi?id=84326

Reviewed by Yury Semikhatsky.

Source/WebCore:

Migrated UISourceCode to ParsedURL, moved the displayName logic into its only client:
TabbedEditorContainer.

* inspector/front-end/CompilerScriptMapping.js:
(WebInspector.SourceMapParser.prototype._canonicalizeURL):
* inspector/front-end/FilteredItemSelectionDialog.js:
(WebInspector.OpenResourceDialog.filterOutEmptyURLs):
(WebInspector.OpenResourceDialog.compareFunction):
(WebInspector.OpenResourceDialog):
(WebInspector.OpenResourceDialog.prototype.itemTitleAt):
(WebInspector.OpenResourceDialog.prototype.itemKeyAt):
* inspector/front-end/ResourceUtils.js:
(WebInspector.ParsedURL):
* inspector/front-end/ScriptsNavigator.js:
(WebInspector.ScriptsNavigator.prototype._getOrCreateFolderTreeElement):
(WebInspector.NavigatorFolderTreeElement):
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer.prototype._titleForFile):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.get parsedURL):

LayoutTests:

* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest):
* inspector/debugger/ui-source-code-display-name.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114622 => 114623)


--- trunk/LayoutTests/ChangeLog	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/LayoutTests/ChangeLog	2012-04-19 11:39:50 UTC (rev 114623)
@@ -1,3 +1,14 @@
+2012-04-19  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: reuse ParsedUrl in the UISourceCode
+        https://bugs.webkit.org/show_bug.cgi?id=84326
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/debugger-test.js:
+        (initialize_DebuggerTest):
+        * inspector/debugger/ui-source-code-display-name.html:
+
 2012-04-18  Takashi Toyoshima  <toyos...@chromium.org>
 
         Unreviewed, add expected.txt for cookies-wrong-domain-rejected-result.php .

Modified: trunk/LayoutTests/http/tests/inspector/debugger-test.js (114622 => 114623)


--- trunk/LayoutTests/http/tests/inspector/debugger-test.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/LayoutTests/http/tests/inspector/debugger-test.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -157,7 +157,7 @@
 {
     var uiSourceCodes = panel._presentationModel.uiSourceCodes();
     for (var i = 0; i < uiSourceCodes.length; ++i) {
-        if (uiSourceCodes[i].fileName === scriptName) {
+        if (uiSourceCodes[i].parsedURL.lastPathComponent === scriptName || uiSourceCodes[i].parsedURL.url ="" scriptName) {
             panel.showUISourceCode(uiSourceCodes[i]);
             var sourceFrame = panel.visibleView;
             if (sourceFrame.loaded)

Modified: trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html (114622 => 114623)


--- trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html	2012-04-19 11:39:50 UTC (rev 114623)
@@ -7,7 +7,7 @@
     function dumpUISourceCodeDisplayName(url)
     {
         var uiSourceCode = new WebInspector.UISourceCode("id", url, null, null);
-        InspectorTest.addResult("UISourceCode display name for url \"" + url + "\" is \"" + uiSourceCode.displayName + "\".");
+        InspectorTest.addResult("UISourceCode display name for url \"" + url + "\" is \"" + WebInspector.TabbedEditorContainer.prototype._titleForFile(uiSourceCode) + "\".");
     }
 
     const baseURL = "http://localhost:8080/folder/";

Modified: trunk/Source/WebCore/ChangeLog (114622 => 114623)


--- trunk/Source/WebCore/ChangeLog	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/ChangeLog	2012-04-19 11:39:50 UTC (rev 114623)
@@ -1,3 +1,32 @@
+2012-04-19  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: reuse ParsedUrl in the UISourceCode
+        https://bugs.webkit.org/show_bug.cgi?id=84326
+
+        Reviewed by Yury Semikhatsky.
+
+        Migrated UISourceCode to ParsedURL, moved the displayName logic into its only client:
+        TabbedEditorContainer.
+
+        * inspector/front-end/CompilerScriptMapping.js:
+        (WebInspector.SourceMapParser.prototype._canonicalizeURL):
+        * inspector/front-end/FilteredItemSelectionDialog.js:
+        (WebInspector.OpenResourceDialog.filterOutEmptyURLs):
+        (WebInspector.OpenResourceDialog.compareFunction):
+        (WebInspector.OpenResourceDialog):
+        (WebInspector.OpenResourceDialog.prototype.itemTitleAt):
+        (WebInspector.OpenResourceDialog.prototype.itemKeyAt):
+        * inspector/front-end/ResourceUtils.js:
+        (WebInspector.ParsedURL):
+        * inspector/front-end/ScriptsNavigator.js:
+        (WebInspector.ScriptsNavigator.prototype._getOrCreateFolderTreeElement):
+        (WebInspector.NavigatorFolderTreeElement):
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer.prototype._titleForFile):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+        (WebInspector.UISourceCode.prototype.get parsedURL):
+
 2012-04-19  Xingnan Wang  <xingnan.w...@intel.com>
 
         Optimize for DARWIN in DirectConvolver::process()

Modified: trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -361,7 +361,7 @@
         var baseHost = base.scheme + "://" + base.host + (base.port ? ":" + base.port : "");
         if (url[0] === "/")
             return baseHost + url;
-        return baseHost + base.firstPathComponents + url;
+        return baseHost + base.folderPathComponents + "/" + url;
     },
 
     _VLQ_BASE_SHIFT: 5,

Modified: trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -599,14 +599,14 @@
 
     function filterOutEmptyURLs(uiSourceCode)
     {
-        return !!uiSourceCode.fileName;
+        return !!uiSourceCode.parsedURL.lastPathComponent;
     }
 
     this._uiSourceCodes = this._uiSourceCodes.filter(filterOutEmptyURLs);
 
     function compareFunction(uiSourceCode1, uiSourceCode2)
     {
-        return uiSourceCode1.fileName.localeCompare(uiSourceCode2.fileName);
+        return uiSourceCode1.parsedURL.lastPathComponent.localeCompare(uiSourceCode2.parsedURL.lastPathComponent);
     }
 
     this._uiSourceCodes.sort(compareFunction);
@@ -653,7 +653,7 @@
      */
     itemTitleAt: function(itemIndex)
     {
-        return this._uiSourceCodes[itemIndex].fileName;
+        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
     },
 
     /**
@@ -662,7 +662,7 @@
      */
     itemKeyAt: function(itemIndex)
     {
-        return this._uiSourceCodes[itemIndex].fileName;
+        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -40,7 +40,9 @@
     this.host = "";
     this.port = "";
     this.path = "";
+    this.queryParams = "";
     this.fragment = "";
+    this.folderPathComponents = "";
     this.lastPathComponent = "";
 
     // RegExp groups:
@@ -72,13 +74,15 @@
         // First cut the query params.
         var path = this.path;
         var indexOfQuery = path.indexOf("?");
-        if (indexOfQuery !== -1)
+        if (indexOfQuery !== -1) {
+            this.queryParams = path.substring(indexOfQuery + 1)
             path = path.substring(0, indexOfQuery);
+        }
 
         // Then take last path component.
         var lastSlashIndex = path.lastIndexOf("/");
         if (lastSlashIndex !== -1) {
-            this.firstPathComponents = path.substring(0, lastSlashIndex + 1);
+            this.folderPathComponents = path.substring(0, lastSlashIndex);
             this.lastPathComponent = path.substring(lastSlashIndex + 1);
         }
     }

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -162,8 +162,17 @@
         var scriptTreeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode);
         if (!scriptTreeElement)
             return;
-        var scriptTitle = uiSourceCode.fileName || WebInspector.UIString("(program)");
-        scriptTreeElement.titleText = scriptTitle;
+
+        var titleText;
+        if (uiSourceCode.parsedURL.isValid) {
+            titleText = uiSourceCode.parsedURL.lastPathComponent;
+            if (uiSourceCode.parsedURL.queryParams)
+                titleText += "?" + uiSourceCode.parsedURL.queryParams;
+        } else if (uiSourceCode.parsedURL)
+            titleText = uiSourceCode.parsedURL.url;
+        else
+            titleText = WebInspector.UIString("(program)");
+        scriptTreeElement.titleText = titleText;
     },
 
     /**
@@ -427,7 +436,7 @@
             return this._snippetsTree;
         if (uiSourceCode.isSnippetEvaluation)
             return this._getOrCreateSnippetEvaluationsFolderTreeElement();
-        return this._getOrCreateScriptFolderTreeElement(uiSourceCode.isContentScript, uiSourceCode.domain, uiSourceCode.folderName);
+        return this._getOrCreateScriptFolderTreeElement(uiSourceCode.isContentScript, uiSourceCode.parsedURL.host, uiSourceCode.parsedURL.folderPathComponents);
     },
 
     /**
@@ -663,6 +672,7 @@
     var iconClass = this.isDomain ? "scripts-navigator-domain-tree-item" : "scripts-navigator-folder-tree-item";
     var title = this.isDomain ? domain : folderName.substring(1);
     WebInspector.BaseNavigatorTreeElement.call(this, title, [iconClass], true);
+    this.tooltip = folderName;
 }
 
 WebInspector.NavigatorFolderTreeElement.prototype = {

Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -131,7 +131,18 @@
      */
     _titleForFile: function(uiSourceCode)
     {
-        return uiSourceCode.displayName;
+        const maxDisplayNameLength = 30;
+        const minDisplayQueryParamLength = 5;
+
+        var parsedURL = uiSourceCode.parsedURL;
+        if (!parsedURL.isValid)
+            return parsedURL.url ? parsedURL.url.trimMiddle(maxDisplayNameLength) : WebInspector.UIString("(program)");
+
+        var maxDisplayQueryParamLength = Math.max(minDisplayQueryParamLength, maxDisplayNameLength - parsedURL.lastPathComponent.length);
+        var displayQueryParams = parsedURL.queryParams ? "?" + parsedURL.queryParams.trimEnd(maxDisplayQueryParamLength - 1) : "";
+        var displayLastPathComponent = parsedURL.lastPathComponent.trimMiddle(maxDisplayNameLength - displayQueryParams.length);
+        var displayName = displayLastPathComponent + displayQueryParams;
+        return displayName || WebInspector.UIString("(program)");
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (114622 => 114623)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-04-19 09:08:18 UTC (rev 114622)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-04-19 11:39:50 UTC (rev 114623)
@@ -39,6 +39,7 @@
 {
     this._id = id;
     this._url = url;
+    this._parsedURL = new WebInspector.ParsedURL(url);
     this._contentProvider = contentProvider;
     this.isContentScript = false;
     this.isEditable = false;
@@ -74,6 +75,14 @@
     },
 
     /**
+     * @return {WebInspector.ParsedURL}
+     */
+    get parsedURL()
+    {
+        return this._parsedURL;
+    },
+
+    /**
      * @param {function(?string,boolean,string)} callback
      */
     requestContent: function(callback)
@@ -110,93 +119,6 @@
     },
 
     /**
-     * @type {string}
-     */
-    get domain()
-    {
-        if (typeof(this._domain) === "undefined")
-            this._parseURL();
-
-        return this._domain;
-    },
-
-    /**
-     * @type {string}
-     */
-    get folderName()
-    {
-        if (typeof(this._folderName) === "undefined")
-            this._parseURL();
-
-        return this._folderName;
-    },
-
-    /**
-     * @type {string}
-     */
-    get fileName()
-    {
-        if (typeof(this._fileName) === "undefined")
-            this._parseURL();
-
-        return this._fileName;
-    },
-
-    /**
-     * @type {string}
-     */
-    get displayName()
-    {
-        if (typeof(this._displayName) === "undefined")
-            this._parseURL();
-
-        return this._displayName;
-    },
-
-    _parseURL: function()
-    {
-        var parsedURL = this.url.asParsedURL();
-        var url = "" ? parsedURL.path : this.url;
-
-        var folderName = "";
-        var fileName = url;
-
-        var pathLength = fileName.indexOf("?");
-        if (pathLength === -1)
-            pathLength = fileName.length;
-
-        var fromIndex = fileName.lastIndexOf("/", pathLength - 2);
-        if (fromIndex !== -1) {
-            folderName = fileName.substring(0, fromIndex);
-            fileName = fileName.substring(fromIndex + 1);
-        }
-
-        var indexOfQuery = fileName.indexOf("?");
-        if (indexOfQuery === -1)
-            indexOfQuery = fileName.length;
-        var lastPathComponent = fileName.substring(0, indexOfQuery);
-        var queryParams = fileName.substring(indexOfQuery, fileName.length);
-
-        const maxDisplayNameLength = 30;
-        const minDisplayQueryParamLength = 5;
-
-        var maxDisplayQueryParamLength = Math.max(minDisplayQueryParamLength, maxDisplayNameLength - lastPathComponent.length);
-        var displayQueryParams = queryParams.trimEnd(maxDisplayQueryParamLength);
-        var displayLastPathComponent = lastPathComponent.trimMiddle(maxDisplayNameLength - displayQueryParams.length);
-        var displayName = displayLastPathComponent + displayQueryParams;
-        if (!displayName)
-            displayName = WebInspector.UIString("(program)");
-
-        if (folderName.length > 80)
-            folderName = "\u2026" + folderName.substring(folderName.length - 80);
-
-        this._domain = parsedURL ? parsedURL.host : "";
-        this._folderName = folderName;
-        this._fileName = fileName;
-        this._displayName = displayName;
-    },
-
-    /**
      * @param {?string} content
      * @param {boolean} contentEncoded
      * @param {string} mimeType
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to