Diff
Modified: trunk/LayoutTests/ChangeLog (114116 => 114117)
--- trunk/LayoutTests/ChangeLog 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/LayoutTests/ChangeLog 2012-04-13 12:25:25 UTC (rev 114117)
@@ -1,5 +1,14 @@
2012-04-13 Pavel Feldman <[email protected]>
+ Web Inspector: introduce ParsedURL type, clean up url and displayName mess in Resource and NetworkRequest.
+ https://bugs.webkit.org/show_bug.cgi?id=83871
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/debugger/raw-source-code.html:
+
+2012-04-13 Pavel Feldman <[email protected]>
+
Web Inspector: extracting NetworkRequest from Resource (step 3)
https://bugs.webkit.org/show_bug.cgi?id=83802
Modified: trunk/LayoutTests/inspector/debugger/raw-source-code.html (114116 => 114117)
--- trunk/LayoutTests/inspector/debugger/raw-source-code.html 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/LayoutTests/inspector/debugger/raw-source-code.html 2012-04-13 12:25:25 UTC (rev 114117)
@@ -19,7 +19,7 @@
{
var requestId = ++lastRequestId + "";
WebInspector.resourceTreeModel._addFrame(new WebInspector.ResourceTreeFrame(WebInspector.resourceTreeModel, null, {id: "frame-id"}));
- var request = new WebInspector.NetworkRequest(requestId, "http://fake.url", "frame-id", "loader-id");
+ var request = new WebInspector.NetworkRequest(requestId, "http://fake.url", "http://fake.url", "frame-id", "loader-id");
request.type = type === "document" ? WebInspector.resourceTypes.Document : WebInspector.resourceTypes.Script;
WebInspector.networkManager._dispatcher._startNetworkRequest(request);
Modified: trunk/Source/WebCore/ChangeLog (114116 => 114117)
--- trunk/Source/WebCore/ChangeLog 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/ChangeLog 2012-04-13 12:25:25 UTC (rev 114117)
@@ -1,5 +1,67 @@
2012-04-13 Pavel Feldman <[email protected]>
+ Web Inspector: introduce ParsedURL type, clean up url and displayName mess in Resource and NetworkRequest.
+ https://bugs.webkit.org/show_bug.cgi?id=83871
+
+ Reviewed by Yury Semikhatsky.
+
+ There is a number of random properties created on Resource and NetworkRequest that represent various url
+ fragments. Display name is being based on them and sometimes requires fake Resource instance to be created.
+ This change (officially) introduces WebInspector.ParsedURL as a type that encapsulates this complexity.
+
+ This change also moves documentURL property into the Resource and NetworkRequest constructors and brushes up
+ factory methods used to create the objects.
+
+ * inspector/front-end/AuditRules.js:
+ (WebInspector.AuditRules.GzipRule.prototype._shouldCompress):
+ (WebInspector.AuditRules.CookieSizeRule.prototype.processCookies):
+ * inspector/front-end/Database.js:
+ (WebInspector.Database.prototype.get displayDomain):
+ * inspector/front-end/_javascript_ContextManager.js:
+ (WebInspector.FrameEvaluationContext.prototype.get displayName):
+ * inspector/front-end/NetworkManager.js:
+ (WebInspector.NetworkDispatcher.prototype.webSocketCreated):
+ (WebInspector.NetworkDispatcher.prototype._createNetworkRequest):
+ (get WebInspector):
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkLogView.prototype._highlightNthMatchedRequest):
+ (WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
+ * inspector/front-end/NetworkRequest.js:
+ (WebInspector.NetworkRequest):
+ (WebInspector.NetworkRequest.prototype.set url):
+ (WebInspector.NetworkRequest.prototype.get documentURL):
+ (WebInspector.NetworkRequest.prototype.get parsedURL):
+ (WebInspector.NetworkRequest.prototype.get displayName):
+ (WebInspector.NetworkRequest.prototype.get folder):
+ * inspector/front-end/RequestHeadersView.js:
+ (WebInspector.RequestHeadersView.prototype._refreshUrlFragment):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource):
+ (WebInspector.Resource.prototype.set url):
+ (WebInspector.Resource.prototype.get parsedURL):
+ (WebInspector.Resource.prototype.get frameId):
+ (WebInspector.Resource.prototype.get loaderId):
+ (WebInspector.Resource.prototype.get displayName):
+ * inspector/front-end/ResourceTreeModel.js:
+ (WebInspector.ResourceTreeModel.prototype._onRequestUpdateDropped):
+ (WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
+ (WebInspector.ResourceTreeModel.prototype._createResourceFromFramePayload):
+ (WebInspector.ResourceTreeFrame.prototype._addRequest):
+ * inspector/front-end/ResourceUtils.js:
+ (WebInspector.ParsedURL):
+ (WebInspector.ParsedURL.prototype.get displayName):
+ (String.prototype.asParsedURL):
+ (WebInspector.displayDomain):
+ (WebInspector.resourceURLForRelatedNode.callback):
+ (WebInspector.resourceURLForRelatedNode):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.FrameTreeElement.prototype.frameNavigated):
+ (WebInspector.ApplicationCacheManifestTreeElement):
+ (WebInspector.ApplicationCacheFrameTreeElement.prototype._refreshTitles):
+ * inspector/front-end/utilities.js:
+
+2012-04-13 Pavel Feldman <[email protected]>
+
Web Inspector: extracting NetworkRequest from Resource (step 3)
https://bugs.webkit.org/show_bug.cgi?id=83802
Modified: trunk/Source/WebCore/inspector/front-end/AuditRules.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/AuditRules.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/AuditRules.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -116,7 +116,7 @@
_shouldCompress: function(request)
{
- return request.type.isTextType() && request.domain && request.resourceSize !== undefined && request.resourceSize > 150;
+ return request.type.isTextType() && request.parsedURL.host && request.resourceSize !== undefined && request.resourceSize > 150;
}
}
@@ -1225,10 +1225,10 @@
function collectorCallback(request, cookie)
{
- var cookies = cookiesPerResourceDomain[request.domain];
+ var cookies = cookiesPerResourceDomain[request.parsedURL.host];
if (!cookies) {
cookies = [];
- cookiesPerResourceDomain[request.domain] = cookies;
+ cookiesPerResourceDomain[request.parsedURL.host] = cookies;
}
cookies.push(cookie);
}
Modified: trunk/Source/WebCore/inspector/front-end/Database.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/Database.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/Database.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -80,7 +80,7 @@
/** @return {string} */
get displayDomain()
{
- return WebInspector.Resource.prototype.__lookupGetter__("displayDomain").call(this);
+ return WebInspector.displayDomain(this._domain);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -107,7 +107,7 @@
if (!this._frame.parentFrame)
return "<top frame>";
var name = this._frame.name || "";
- var subtitle = WebInspector.Resource.displayName(this._frame.url);
+ var subtitle = new WebInspector.ParsedURL(this._frame.url).displayName;
if (subtitle) {
if (!name)
return subtitle;
Modified: trunk/Source/WebCore/inspector/front-end/NetworkManager.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/NetworkManager.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/NetworkManager.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -410,7 +410,7 @@
*/
webSocketCreated: function(requestId, requestURL)
{
- var networkRequest = new WebInspector.NetworkRequest(requestId, requestURL, "", "");
+ var networkRequest = new WebInspector.NetworkRequest(requestId, requestURL, "", "", "");
networkRequest.type = WebInspector.resourceTypes.WebSocket;
this._startNetworkRequest(networkRequest);
},
@@ -538,8 +538,7 @@
*/
_createNetworkRequest: function(requestId, frameId, loaderId, url, documentURL, initiator, stackTrace)
{
- var networkRequest = new WebInspector.NetworkRequest(requestId, url, frameId, loaderId);
- networkRequest.documentURL = documentURL;
+ var networkRequest = new WebInspector.NetworkRequest(requestId, url, documentURL, frameId, loaderId);
networkRequest.initiator = initiator;
networkRequest.stackTrace = stackTrace;
return networkRequest;
Modified: trunk/Source/WebCore/inspector/front-end/NetworkPanel.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -1126,7 +1126,7 @@
return;
var nameMatched = request.displayName && request.displayName.match(this._searchRegExp);
- var pathMatched = request.path && request.folder.match(this._searchRegExp);
+ var pathMatched = request.parsedURL.path && request.folder.match(this._searchRegExp);
if (!nameMatched && pathMatched && !this._largerRequestsButton.toggled)
this._toggleLargerRequests();
@@ -1836,9 +1836,9 @@
this._nameCell.appendChild(document.createTextNode(this._fileName()));
- var subtitle = this._request.displayDomain;
+ var subtitle = WebInspector.displayDomain(this._request.parsedURL.host);
- if (this._request.path)
+ if (this._request.parsedURL.path)
subtitle += this._request.folder;
this._appendSubtitle(this._nameCell, subtitle);
Modified: trunk/Source/WebCore/inspector/front-end/NetworkRequest.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/NetworkRequest.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -34,13 +34,15 @@
*
* @param {NetworkAgent.RequestId} requestId
* @param {string} url
+ * @param {string} documentURL
* @param {NetworkAgent.FrameId} frameId
* @param {NetworkAgent.LoaderId} loaderId
*/
-WebInspector.NetworkRequest = function(requestId, url, frameId, loaderId)
+WebInspector.NetworkRequest = function(requestId, url, documentURL, frameId, loaderId)
{
this._requestId = requestId;
- this._url = url;
+ this.url = ""
+ this._documentURL = documentURL;
this._frameId = frameId;
this._loaderId = loaderId;
this._startTime = -1;
@@ -56,14 +58,6 @@
this._content = undefined;
this._contentEncoded = false;
this._pendingContentCallbacks = [];
-
- delete this._parsedQueryParameters;
-
- var parsedURL = url.asParsedURL();
- this.domain = parsedURL ? parsedURL.host : "";
- this.path = parsedURL ? parsedURL.path : "";
- this.urlFragment = parsedURL ? parsedURL.fragment : "";
- this.lastPathComponent = parsedURL ? parsedURL.lastPathComponent : "";
}
WebInspector.NetworkRequest.Events = {
@@ -95,7 +89,30 @@
return this._url;
},
+ set url(x)
+ {
+ if (this._url === x)
+ return;
+
+ this._url = x;
+ this._parsedURL = new WebInspector.ParsedURL(x);
+ delete this._parsedQueryParameters;
+ },
+
/**
+ * @type {string}
+ */
+ get documentURL()
+ {
+ return this._documentURL;
+ },
+
+ get parsedURL()
+ {
+ return this._parsedURL;
+ },
+
+ /**
* @type {NetworkAgent.FrameId}
*/
get frameId()
@@ -336,16 +353,7 @@
*/
get displayName()
{
- if (this._displayName)
- return this._displayName;
- this._displayName = this.lastPathComponent;
- if (!this._displayName)
- this._displayName = this.displayDomain;
- if (!this._displayName && this.url)
- this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
- if (this._displayName === "/")
- this._displayName = this.url;
- return this._displayName;
+ return this._parsedURL.displayName;
},
/**
@@ -353,7 +361,7 @@
*/
get folder()
{
- var path = this.path;
+ var path = this._parsedURL.path;
var indexOfQuery = path.indexOf("?");
if (indexOfQuery !== -1)
path = path.substring(0, indexOfQuery);
@@ -362,17 +370,6 @@
},
/**
- * @type {string}
- */
- get displayDomain()
- {
- // WebInspector.Database calls this, so don't access more than this.domain.
- if (this.domain && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && this.domain !== WebInspector.inspectedPageDomain)))
- return this.domain;
- return "";
- },
-
- /**
* @type {WebInspector.ResourceType}
*/
get type()
Modified: trunk/Source/WebCore/inspector/front-end/RequestHeadersView.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/RequestHeadersView.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/RequestHeadersView.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -168,7 +168,7 @@
_refreshUrlFragment: function()
{
- var urlFragment = this._request.urlFragment;
+ var urlFragment = this._request.parsedURL.fragment;
this._urlFragmentTreeElement.hidden = !urlFragment;
if (!urlFragment)
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -32,18 +32,23 @@
*
* @param {?WebInspector.NetworkRequest} request
* @param {string} url
- * @param {string} frameId
- * @param {?NetworkAgent.LoaderId} loaderId
+ * @param {string} documentURL
+ * @param {NetworkAgent.FrameId} frameId
+ * @param {NetworkAgent.LoaderId} loaderId
+ * @param {WebInspector.ResourceType=} type
+ * @param {string=} mimeType
*/
-WebInspector.Resource = function(request, url, frameId, loaderId)
+WebInspector.Resource = function(request, url, documentURL, frameId, loaderId, type, mimeType)
{
this._request = request;
if (this._request)
this._request.setResource(this);
this.url = ""
- this.frameId = frameId;
- this.loaderId = loaderId;
- this._type = WebInspector.resourceTypes.Other;
+ this._documentURL = documentURL;
+ this._frameId = frameId;
+ this._loaderId = loaderId;
+ this._type = type || WebInspector.resourceTypes.Other;
+ this._mimeType = mimeType;
this.history = [];
this._content = undefined;
@@ -51,15 +56,6 @@
this._pendingContentCallbacks = [];
}
-/**
- * @param {string} url
- * @return {string}
- */
-WebInspector.Resource.displayName = function(url)
-{
- return new WebInspector.Resource(null, url, "", null).displayName;
-}
-
WebInspector.Resource._domainModelBindings = [];
/**
@@ -166,14 +162,6 @@
},
/**
- * @return {WebInspector.Resource}
- */
- resource: function()
- {
- return this;
- },
-
- /**
* @type {string}
*/
get url()
@@ -183,15 +171,13 @@
set url(x)
{
- if (this._url === x)
- return;
-
this._url = x;
+ this._parsedURL = new WebInspector.ParsedURL(x);
+ },
- var parsedURL = x.asParsedURL();
- this.domain = parsedURL ? parsedURL.host : "";
- this.path = parsedURL ? parsedURL.path : "";
- this.lastPathComponent = parsedURL ? parsedURL.lastPathComponent : "";
+ get parsedURL()
+ {
+ return this._parsedURL;
},
/**
@@ -202,50 +188,28 @@
return this._documentURL;
},
- set documentURL(x)
- {
- this._documentURL = x;
- },
-
/**
- * @type {string}
+ * @type {NetworkAgent.FrameId}
*/
- get displayName()
+ get frameId()
{
- if (this._displayName)
- return this._displayName;
- this._displayName = this.lastPathComponent;
- if (!this._displayName)
- this._displayName = this.displayDomain;
- if (!this._displayName && this.url)
- this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
- if (this._displayName === "/")
- this._displayName = this.url;
- return this._displayName;
+ return this._frameId;
},
/**
- * @type {string}
+ * @type {NetworkAgent.LoaderId}
*/
- get folder()
+ get loaderId()
{
- var path = this.path;
- var indexOfQuery = path.indexOf("?");
- if (indexOfQuery !== -1)
- path = path.substring(0, indexOfQuery);
- var lastSlashIndex = path.lastIndexOf("/");
- return lastSlashIndex !== -1 ? path.substring(0, lastSlashIndex) : "";
+ return this._loaderId;
},
/**
* @type {string}
*/
- get displayDomain()
+ get displayName()
{
- // WebInspector.Database calls this, so don't access more than this.domain.
- if (this.domain && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && this.domain !== WebInspector.inspectedPageDomain)))
- return this.domain;
- return "";
+ return this._parsedURL.displayName;
},
/**
@@ -256,11 +220,6 @@
return this._request ? this._request.type : this._type;
},
- set type(x)
- {
- this._type = x;
- },
-
/**
* @type {string}
*/
@@ -269,11 +228,6 @@
return this._request ? this._request.mimeType : this._mimeType;
},
- set mimeType(x)
- {
- this._mimeType = x;
- },
-
/**
* @type {Array.<WebInspector.ConsoleMessage>}
*/
Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -226,10 +226,7 @@
if (frame._resourcesMap[url])
return;
- var resource = this._createResource(url, frame.url, frameId, event.data.loaderId);
- resource.type = WebInspector.resourceTypes[event.data.resourceType];
- resource.mimeType = event.data.mimeType;
- resource.finished = true;
+ var resource = new WebInspector.Resource(null, url, frame.url, frameId, event.data.loaderId, WebInspector.resourceTypes[event.data.resourceType], event.data.mimeType);
frame._addResource(resource);
},
@@ -338,10 +335,7 @@
var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, framePayload);
// Create frame resource.
- var frameResource = this._createResourceFromFramePayload(framePayload, framePayload.url);
- frameResource.mimeType = framePayload.mimeType;
- frameResource.type = WebInspector.resourceTypes.Document;
- frameResource.finished = true;
+ var frameResource = this._createResourceFromFramePayload(framePayload, framePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType);
if (frame.isMainFrame())
WebInspector.inspectedPageURL = frameResource.url;
@@ -358,10 +352,7 @@
// Create frame subresources.
for (var i = 0; i < frameTreePayload.resources.length; ++i) {
var subresource = frameTreePayload.resources[i];
- var resource = this._createResourceFromFramePayload(framePayload, subresource.url);
- resource.type = WebInspector.resourceTypes[subresource.type];
- resource.mimeType = subresource.mimeType;
- resource.finished = true;
+ var resource = this._createResourceFromFramePayload(framePayload, subresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeType);
frame._addResource(resource);
}
},
@@ -369,25 +360,13 @@
/**
* @param {PageAgent.Frame} frame
* @param {string} url
+ * @param {WebInspector.ResourceType} type
+ * @param {string} mimeType
* @return {WebInspector.Resource}
*/
- _createResourceFromFramePayload: function(frame, url)
+ _createResourceFromFramePayload: function(frame, url, type, mimeType)
{
- return this._createResource(url, frame.url, frame.id, frame.loaderId);
- },
-
- /**
- * @param {string} url
- * @param {string} documentURL
- * @param {NetworkAgent.FrameId} frameId
- * @param {NetworkAgent.LoaderId} loaderId
- * @return {WebInspector.Resource}
- */
- _createResource: function(url, documentURL, frameId, loaderId)
- {
- var resource = new WebInspector.Resource(null, url, frameId, loaderId);
- resource.documentURL = documentURL;
- return resource;
+ return new WebInspector.Resource(null, url, frame.url, frame.id, frame.loaderId, type, mimeType);
}
}
@@ -563,7 +542,7 @@
// Already in the tree, we just got an extra update.
return resource;
}
- resource = new WebInspector.Resource(request, request.url, request.frameId, request.loaderId);
+ resource = new WebInspector.Resource(request, request.url, request.documentURL, request.frameId, request.loaderId);
this._resourcesMap[resource.url] = resource;
this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
return resource;
Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -29,6 +29,89 @@
*/
/**
+ * @constructor
+ * @param {String|string} url
+ */
+WebInspector.ParsedURL = function(url)
+{
+ this.isValid = false;
+ this.url = ""
+ this.scheme = "";
+ this.host = "";
+ this.port = "";
+ this.path = "";
+ this.fragment = "";
+ this.lastPathComponent = "";
+
+ // RegExp groups:
+ // 1 - scheme
+ // 2 - hostname
+ // 3 - ?port
+ // 4 - ?path
+ // 5 - ?fragment
+ var match = url.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
+ if (!match) {
+ if (this == "about:blank") {
+ this.isValid = true;
+ this.scheme = "about";
+ this.host = "blank";
+ this.path = "/";
+ return;
+ }
+ return;
+ }
+
+ this.isValid = true;
+ this.scheme = match[1].toLowerCase();
+ this.host = match[2];
+ this.port = match[3];
+ this.path = match[4] || "/";
+ this.fragment = match[5];
+
+ if (this.path) {
+ // First cut the query params.
+ var path = this.path;
+ var indexOfQuery = path.indexOf("?");
+ if (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.lastPathComponent = path.substring(lastSlashIndex + 1);
+ }
+ }
+}
+
+WebInspector.ParsedURL.prototype = {
+ get displayName()
+ {
+ if (this._displayName)
+ return this._displayName;
+
+ this._displayName = this.lastPathComponent;
+ if (!this._displayName)
+ this._displayName = WebInspector.displayDomain(this.host);
+ if (!this._displayName && this.url)
+ this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");
+ if (this._displayName === "/")
+ this._displayName = this.url;
+ return this._displayName;
+ }
+}
+/**
+ * @return {?WebInspector.ParsedURL}
+ */
+String.prototype.asParsedURL = function()
+{
+ var parsedURL = new WebInspector.ParsedURL(this);
+ if (parsedURL.isValid)
+ return parsedURL;
+ return null;
+}
+
+/**
* @param {string} url
* @return {?WebInspector.Resource}
*/
@@ -46,6 +129,16 @@
}
/**
+ * @param {string} host
+ */
+WebInspector.displayDomain = function(host)
+{
+ if (host && (!WebInspector.inspectedPageDomain || (WebInspector.inspectedPageDomain && host !== WebInspector.inspectedPageDomain)))
+ return host;
+ return "";
+}
+
+/**
* @param {string} url
* @return {string}
*/
@@ -247,7 +340,7 @@
var resourceURL = url;
function callback(resource)
{
- if (resource.path === url) {
+ if (resource.parsedURL.path === url) {
resourceURL = resource.url;
return true;
}
Modified: trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -1081,7 +1081,7 @@
this._frameId = frame.id;
this.titleText = frame.name;
- this.subtitleText = WebInspector.Resource.displayName(frame.url);
+ this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
this._categoryElements = {};
this._treeElementForResource = {};
@@ -1922,7 +1922,7 @@
*/
WebInspector.ApplicationCacheManifestTreeElement = function(storagePanel, manifestURL)
{
- var title = WebInspector.Resource.displayName(manifestURL);
+ var title = new WebInspector.ParsedURL(manifestURL).displayName;
WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["application-cache-storage-tree-item"]);
this.tooltip = manifestURL;
this._manifestURL = manifestURL;
@@ -1983,7 +1983,7 @@
return;
}
this.titleText = frame.name;
- this.subtitleText = WebInspector.Resource.displayName(frame.url);
+ this.subtitleText = new WebInspector.ParsedURL(frame.url).displayName;
},
frameNavigated: function()
Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (114116 => 114117)
--- trunk/Source/WebCore/inspector/front-end/utilities.js 2012-04-13 12:15:05 UTC (rev 114116)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js 2012-04-13 12:25:25 UTC (rev 114117)
@@ -453,49 +453,6 @@
return this._lineEndings;
}
-String.prototype.asParsedURL = function()
-{
- // RegExp groups:
- // 1 - scheme
- // 2 - hostname
- // 3 - ?port
- // 4 - ?path
- // 5 - ?fragment
- var match = this.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
- if (!match) {
- if (this == "about:blank") {
- return { scheme: "about",
- host: "blank",
- path: "/",
- lastPathComponent: ""};
- }
- return null;
- }
- var result = {};
- result.scheme = match[1].toLowerCase();
- result.host = match[2];
- result.port = match[3];
- result.path = match[4] || "/";
- result.fragment = match[5];
-
- result.lastPathComponent = "";
- if (result.path) {
- // First cut the query params.
- var path = result.path;
- var indexOfQuery = path.indexOf("?");
- if (indexOfQuery !== -1)
- path = path.substring(0, indexOfQuery);
-
- // Then take last path component.
- var lastSlashIndex = path.lastIndexOf("/");
- if (lastSlashIndex !== -1) {
- result.firstPathComponents = path.substring(0, lastSlashIndex + 1);
- result.lastPathComponent = path.substring(lastSlashIndex + 1);
- }
- }
- return result;
-}
-
String.prototype.escapeCharacters = function(chars)
{
var foundChar = false;