[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
pfeldman at chromium.org
pfeldman at chromium.org
Wed Dec 22 14:42:40 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 4cfd961e723f8d83f84d76c29c0c3033ebfa0859
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 18 09:18:29 2010 +0000
2010-10-16 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: brush up URL parsing on the front-end.
https://bugs.webkit.org/show_bug.cgi?id=47772
* inspector/InspectorResource.cpp:
(WebCore::InspectorResource::updateScriptObject):
* inspector/front-end/AuditRules.js:
(WebInspector.AuditRules.getDomainToResourcesMap):
(WebInspector.AuditRules.CombineExternalResourcesRule.prototype.doRun):
(WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype.doRun):
(WebInspector.AuditRules.ParallelizeDownloadRule.prototype.doRun):
(WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun):
(WebInspector.AuditRules.CookieSizeRule.prototype.processCookies):
(WebInspector.AuditRules.StaticCookielessRule.prototype.processCookies):
* inspector/front-end/CookieItemsView.js:
(WebInspector.CookieItemsView.prototype._filterCookiesForDomain):
* inspector/front-end/DOMAgent.js:
(WebInspector.Cookies.cookieMatchesResourceURL):
* inspector/front-end/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.set url):
(WebInspector.Resource.prototype.get displayName):
* inspector/front-end/ResourceCategory.js:
(WebInspector.ResourceCategory.prototype.addResource):
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceView):
* inspector/front-end/inspector.js:
(WebInspector.documentClick.followLink):
(WebInspector.documentClick):
(WebInspector.updateResource):
(WebInspector.linkifyStringAsFragment):
(WebInspector.resourceURLForRelatedNode):
(WebInspector.completeURL):
* inspector/front-end/utilities.js:
(String.prototype.asParsedURL):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/inspector/elements-panel-rewrite-href.html b/LayoutTests/inspector/elements-panel-rewrite-href.html
index a92a337..f17c300 100644
--- a/LayoutTests/inspector/elements-panel-rewrite-href.html
+++ b/LayoutTests/inspector/elements-panel-rewrite-href.html
@@ -42,10 +42,10 @@ function frontend_testRewriteHrefsContinuation(testController)
segments.push("<empty>");
continue;
}
- var match = href.match(WebInspector.URLRegExp);
- if (!match)
+ var parsedURL = href.asParsedURL();
+ if (!parsedURL)
testController.notifyDone("FAIL: no URL match for <" + href + ">");
- var split = match[4].split("/");
+ var split = parsedURL.path.split("/");
for (var i = split.length - 1, j = 0; j < 3 && i >= 0; --i, ++j)
segments.push(split[i]);
result.push(segments.reverse());
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 447fa08..2e62d74 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2010-10-16 Pavel Feldman <pfeldman at chromium.org>
+
+ Reviewed by Yury Semikhatsky.
+
+ Web Inspector: brush up URL parsing on the front-end.
+ https://bugs.webkit.org/show_bug.cgi?id=47772
+
+ * inspector/InspectorResource.cpp:
+ (WebCore::InspectorResource::updateScriptObject):
+ * inspector/front-end/AuditRules.js:
+ (WebInspector.AuditRules.getDomainToResourcesMap):
+ (WebInspector.AuditRules.CombineExternalResourcesRule.prototype.doRun):
+ (WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype.doRun):
+ (WebInspector.AuditRules.ParallelizeDownloadRule.prototype.doRun):
+ (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun):
+ (WebInspector.AuditRules.CookieSizeRule.prototype.processCookies):
+ (WebInspector.AuditRules.StaticCookielessRule.prototype.processCookies):
+ * inspector/front-end/CookieItemsView.js:
+ (WebInspector.CookieItemsView.prototype._filterCookiesForDomain):
+ * inspector/front-end/DOMAgent.js:
+ (WebInspector.Cookies.cookieMatchesResourceURL):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource):
+ (WebInspector.Resource.prototype.set url):
+ (WebInspector.Resource.prototype.get displayName):
+ * inspector/front-end/ResourceCategory.js:
+ (WebInspector.ResourceCategory.prototype.addResource):
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.ResourceView):
+ * inspector/front-end/inspector.js:
+ (WebInspector.documentClick.followLink):
+ (WebInspector.documentClick):
+ (WebInspector.updateResource):
+ (WebInspector.linkifyStringAsFragment):
+ (WebInspector.resourceURLForRelatedNode):
+ (WebInspector.completeURL):
+ * inspector/front-end/utilities.js:
+ (String.prototype.asParsedURL):
+
2010-10-17 Andreas Kling <kling at webkit.org>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp
index 5ee4a95..5a6caad 100644
--- a/WebCore/inspector/InspectorResource.cpp
+++ b/WebCore/inspector/InspectorResource.cpp
@@ -262,9 +262,6 @@ void InspectorResource::updateScriptObject(InspectorFrontend* frontend)
m_documentURL = m_frame->document()->url();
jsonObject->setString("url", m_requestURL.string());
jsonObject->setString("documentURL", m_documentURL.string());
- jsonObject->setString("host", m_requestURL.host());
- jsonObject->setString("path", m_requestURL.path());
- jsonObject->setString("lastPathComponent", m_requestURL.lastPathComponent());
RefPtr<InspectorObject> requestHeaders = buildHeadersObject(m_requestHeaderFields);
jsonObject->setObject("requestHeaders", requestHeaders);
jsonObject->setBoolean("mainResource", m_isMainResource);
diff --git a/WebCore/inspector/front-end/AuditRules.js b/WebCore/inspector/front-end/AuditRules.js
index a72de56..cd9f13e 100644
--- a/WebCore/inspector/front-end/AuditRules.js
+++ b/WebCore/inspector/front-end/AuditRules.js
@@ -42,17 +42,17 @@ WebInspector.AuditRules.CacheableResponseCodes =
304: true // Underlying resource is cacheable
}
-WebInspector.AuditRules.getDomainToResourcesMap = function(resources, types, regexp, needFullResources)
+WebInspector.AuditRules.getDomainToResourcesMap = function(resources, types, needFullResources)
{
var domainToResourcesMap = {};
for (var i = 0, size = resources.length; i < size; ++i) {
var resource = resources[i];
if (types && types.indexOf(resource.type) === -1)
continue;
- var match = resource.url.match(regexp);
- if (!match)
+ var parsedURL = resource.url.asParsedURL();
+ if (!parsedURL)
continue;
- var domain = match[2];
+ var domain = parsedURL.host;
var domainResources = domainToResourcesMap[domain];
if (domainResources === undefined) {
domainResources = [];
@@ -128,7 +128,7 @@ WebInspector.AuditRules.CombineExternalResourcesRule = function(id, name, type,
WebInspector.AuditRules.CombineExternalResourcesRule.prototype = {
doRun: function(resources, result, callback)
{
- var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, [this._type], WebInspector.URLRegExp);
+ var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, [this._type]);
var penalizedResourceCount = 0;
// TODO: refactor according to the chosen i18n approach
var summary = result.addChild("", true);
@@ -175,14 +175,14 @@ WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype = {
doRun: function(resources, result, callback)
{
var summary = result.addChild("");
- var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, undefined, WebInspector.URLRegExp);
+ var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, undefined);
for (var domain in domainToResourcesMap) {
if (domainToResourcesMap[domain].length > 1)
continue;
- var match = domain.match(WebInspector.URLRegExp);
- if (!match)
+ var parsedURL = domain.asParsedURL();
+ if (!parsedURL)
continue;
- if (!match[2].search(WebInspector.AuditRules.IPAddressRegexp))
+ if (!parsedURL.host.search(WebInspector.AuditRules.IPAddressRegexp))
continue; // an IP address
summary.addSnippet(match[2]);
result.violationCount++;
@@ -220,7 +220,6 @@ WebInspector.AuditRules.ParallelizeDownloadRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(
resources,
[WebInspector.Resource.Type.Stylesheet, WebInspector.Resource.Type.Image],
- WebInspector.URLRegExp,
true);
var hosts = [];
@@ -647,7 +646,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
const node = WebInspector.domAgent.nodeForId(imageId);
var src = node.getAttribute("src");
- if (!WebInspector.URLRegExp.test(src)) {
+ if (!src.asParsedURL()) {
for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) {
if (frameOwnerCandidate.documentURL) {
var completeSrc = WebInspector.completeURL(frameOwnerCandidate.documentURL, src);
@@ -934,7 +933,6 @@ WebInspector.AuditRules.CookieSizeRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources,
null,
- WebInspector.URLRegExp,
true);
var matchingResourceData = {};
this.mapResourceCookies(domainToResourcesMap, allCookies, collectorCallback.bind(this));
@@ -998,7 +996,6 @@ WebInspector.AuditRules.StaticCookielessRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources,
[WebInspector.Resource.Type.Stylesheet,
WebInspector.Resource.Type.Image],
- WebInspector.URLRegExp,
true);
var totalStaticResources = 0;
for (var domain in domainToResourcesMap)
diff --git a/WebCore/inspector/front-end/CookieItemsView.js b/WebCore/inspector/front-end/CookieItemsView.js
index 1baf4a6..88cbe05 100644
--- a/WebCore/inspector/front-end/CookieItemsView.js
+++ b/WebCore/inspector/front-end/CookieItemsView.js
@@ -122,8 +122,8 @@ WebInspector.CookieItemsView.prototype = {
for (var id in WebInspector.resources) {
var resource = WebInspector.resources[id];
- var match = resource.documentURL.match(WebInspector.GenericURLRegExp);
- if (match && match[2] === this._cookieDomain)
+ var url = resource.documentURL.asParsedURL();
+ if (url && url.host == this._cookieDomain)
resourceURLsForDocumentURL.push(resource.url);
}
diff --git a/WebCore/inspector/front-end/DOMAgent.js b/WebCore/inspector/front-end/DOMAgent.js
index e99624d..5153fb1 100644
--- a/WebCore/inspector/front-end/DOMAgent.js
+++ b/WebCore/inspector/front-end/DOMAgent.js
@@ -500,17 +500,12 @@ WebInspector.Cookies.buildCookiesFromString = function(rawCookieString)
WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL)
{
- var match = resourceURL.match(WebInspector.GenericURLRegExp);
- if (!match)
+ var url = resourceURL.asParsedURL();
+ if (!url || !this.cookieDomainMatchesResourceDomain(cookie.domain, url.host))
return false;
- // See WebInspector.URLRegExp for definitions of the group index constants.
- if (!this.cookieDomainMatchesResourceDomain(cookie.domain, match[2]))
- return false;
- var resourcePort = match[3] ? match[3] : undefined;
- var resourcePath = match[4] ? match[4] : '/';
- return (resourcePath.indexOf(cookie.path) === 0
- && (!cookie.port || resourcePort == cookie.port)
- && (!cookie.secure || match[1].toLowerCase() === 'https'));
+ return (url.path.indexOf(cookie.path) === 0
+ && (!cookie.port || url.port == cookie.port)
+ && (!cookie.secure || url.scheme === "https"));
}
WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain, resourceDomain)
diff --git a/WebCore/inspector/front-end/Resource.js b/WebCore/inspector/front-end/Resource.js
index ea9052d..9bbf90b 100644
--- a/WebCore/inspector/front-end/Resource.js
+++ b/WebCore/inspector/front-end/Resource.js
@@ -29,7 +29,7 @@
WebInspector.Resource = function(identifier, url)
{
this.identifier = identifier;
- this._url = url;
+ this.url = url;
this._startTime = -1;
this._endTime = -1;
this._requestMethod = "";
@@ -97,14 +97,19 @@ WebInspector.Resource.prototype = {
if (this._url === x)
return;
- var oldURL = this._url;
this._url = x;
delete this._parsedQueryParameters;
- // FIXME: We should make the WebInspector object listen for the "url changed" event.
- // Then resourceURLChanged can be removed.
- WebInspector.resourceURLChanged(this, oldURL);
- this.dispatchEventToListeners("url changed");
+ var parsedURL = x.asParsedURL();
+ this.domain = parsedURL ? parsedURL.host : "";
+ this.path = parsedURL ? parsedURL.path : "";
+ this.lastPathComponent = "";
+ if (parsedURL && parsedURL.path) {
+ var lastSlashIndex = parsedURL.path.lastIndexOf("/");
+ if (lastSlashIndex !== -1)
+ this.lastPathComponent = parsedURL.path.substring(lastSlashIndex + 1);
+ }
+ this.lastPathComponentLowerCase = this.lastPathComponent.toLowerCase();
},
get documentURL()
@@ -119,41 +124,18 @@ WebInspector.Resource.prototype = {
this._documentURL = x;
},
- get domain()
- {
- return this._domain;
- },
-
- set domain(x)
- {
- if (this._domain === x)
- return;
- this._domain = x;
- },
-
- get lastPathComponent()
- {
- return this._lastPathComponent;
- },
-
- set lastPathComponent(x)
- {
- if (this._lastPathComponent === x)
- return;
- this._lastPathComponent = x;
- this._lastPathComponentLowerCase = x ? x.toLowerCase() : null;
- },
-
get displayName()
{
- var title = this.lastPathComponent;
- if (!title)
- title = this.displayDomain;
- if (!title && this.url)
- title = this.url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "");
- if (title === "/")
- title = this.url;
- return title;
+ 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.mainResource ? WebInspector.mainResource.domain : "");
+ if (this._displayName === "/")
+ this._displayName = this.url;
+ return this._displayName;
},
get displayDomain()
diff --git a/WebCore/inspector/front-end/ResourceCategory.js b/WebCore/inspector/front-end/ResourceCategory.js
index 84f2cf9..7d95a1f 100644
--- a/WebCore/inspector/front-end/ResourceCategory.js
+++ b/WebCore/inspector/front-end/ResourceCategory.js
@@ -47,8 +47,8 @@ WebInspector.ResourceCategory.prototype = {
var resourcesLength = this.resources.length;
for (var i = 0; i < resourcesLength; ++i) {
var b = this.resources[i];
- if (a._lastPathComponentLowerCase && b._lastPathComponentLowerCase)
- if (a._lastPathComponentLowerCase < b._lastPathComponentLowerCase)
+ if (a.lastPathComponentLowerCase && b.lastPathComponentLowerCase)
+ if (a.lastPathComponentLowerCase < b.lastPathComponentLowerCase)
break;
else if (a.name && b.name)
if (a.name < b.name)
diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js
index 1c2574f..862569f 100644
--- a/WebCore/inspector/front-end/ResourceView.js
+++ b/WebCore/inspector/front-end/ResourceView.js
@@ -99,7 +99,6 @@ WebInspector.ResourceView = function(resource)
this.headersVisible = true;
- resource.addEventListener("url changed", this._refreshURL, this);
resource.addEventListener("requestHeaders changed", this._refreshRequestHeaders, this);
resource.addEventListener("responseHeaders changed", this._refreshResponseHeaders, this);
resource.addEventListener("finished", this._refreshHTTPInformation, this);
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 87ae8a3..a6b4845 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -56,15 +56,6 @@ var WebInspector = {
missingLocalizedStrings: {},
pendingDispatches: 0,
- // RegExp groups:
- // 1 - scheme
- // 2 - hostname
- // 3 - ?port
- // 4 - ?path
- // 5 - ?fragment
- URLRegExp: /^(http[s]?|file):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i,
- GenericURLRegExp: /^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i,
-
get platform()
{
if (!("_platform" in this))
@@ -770,10 +761,10 @@ WebInspector.documentClick = function(event)
return;
}
- const urlMatch = WebInspector.GenericURLRegExp.exec(anchor.href);
- if (urlMatch && urlMatch[1] === "webkit-link-action") {
- if (urlMatch[2] === "show-panel") {
- const panel = urlMatch[4].substring(1);
+ var parsedURL = anchor.href.asParsedURL();
+ if (parsedURL && parsedURL.scheme === "webkit-link-action") {
+ if (parsedURL.host === "show-panel") {
+ var panel = parsedURL.path.substring(1);
if (WebInspector.panels[panel])
WebInspector.currentPanel = WebInspector.panels[panel];
}
@@ -1234,9 +1225,6 @@ WebInspector.updateResource = function(payload)
}
if (payload.didRequestChange) {
- resource.domain = payload.host;
- resource.path = payload.path;
- resource.lastPathComponent = payload.lastPathComponent;
resource.requestHeaders = payload.requestHeaders;
resource.mainResource = payload.mainResource;
resource.requestMethod = payload.requestMethod;
@@ -1248,11 +1236,10 @@ WebInspector.updateResource = function(payload)
if (resource.mainResource)
this.mainResource = resource;
- var match = payload.documentURL.match(WebInspector.GenericURLRegExp);
- if (match) {
- var protocol = match[1].toLowerCase();
- this._addCookieDomain(match[2]);
- this._addAppCacheDomain(match[2]);
+ var parsedURL = payload.documentURL.asParsedURL();
+ if (parsedURL) {
+ this._addCookieDomain(parsedURL.host);
+ this._addAppCacheDomain(parsedURL.host);
}
}
@@ -1499,12 +1486,6 @@ WebInspector.inspectedURLChanged = function(url)
this.extensionServer.notifyInspectedURLChanged();
}
-WebInspector.resourceURLChanged = function(resource, oldURL)
-{
- delete this.resourceURLMap[oldURL];
- this.resourceURLMap[resource.url] = resource;
-}
-
WebInspector.didCommitLoad = function()
{
// Cleanup elements panel early on inspected page refresh.
@@ -1838,8 +1819,8 @@ WebInspector.resourceURLForRelatedNode = function(node, url)
// documentURL not found or has bad value
for (var resourceURL in WebInspector.resourceURLMap) {
- var match = resourceURL.match(WebInspector.URLRegExp);
- if (match && match[4] === url)
+ var parsedURL = resourceURL.asParsedURL();
+ if (parsedURL && parsedURL.path === url)
return resourceURL;
}
return url;
@@ -1847,17 +1828,17 @@ WebInspector.resourceURLForRelatedNode = function(node, url)
WebInspector.completeURL = function(baseURL, href)
{
- var match = baseURL.match(WebInspector.URLRegExp);
- if (match) {
+ var parsedURL = baseURL.asParsedURL();
+ if (parsedURL) {
var path = href;
if (path.charAt(0) !== "/") {
- var basePath = match[4] || "/";
+ var basePath = parsedURL.path;
path = basePath.substring(0, basePath.lastIndexOf("/")) + "/" + path;
} else if (path.length > 1 && path.charAt(1) === "/") {
// href starts with "//" which is a full URL with the protocol dropped (use the baseURL protocol).
- return match[1] + ":" + path;
+ return parsedURL.scheme + ":" + path;
}
- return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path;
+ return parsedURL.scheme + "://" + parsedURL.host + (parsedURL.port ? (":" + parsedURL.port) : "") + path;
}
return null;
}
diff --git a/WebCore/inspector/front-end/utilities.js b/WebCore/inspector/front-end/utilities.js
index 5e41da6..036dc17 100644
--- a/WebCore/inspector/front-end/utilities.js
+++ b/WebCore/inspector/front-end/utilities.js
@@ -393,6 +393,26 @@ String.prototype.hasSubstring = function(string, caseInsensitive)
return this.match(new RegExp(string.escapeForRegExp(), "i"));
}
+String.prototype.asParsedURL = function()
+{
+ // RegExp groups:
+ // 1 - scheme
+ // 2 - hostname
+ // 3 - ?port
+ // 4 - ?path
+ // 5 - ?fragment
+ var match = this.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
+ if (!match)
+ 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];
+ return result;
+}
+
String.prototype.escapeCharacters = function(chars)
{
var foundChar = false;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list