Changeset 126426 in webkit
- Timestamp:
- Aug 23, 2012 8:08:29 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/inspector/styles/styles-url-linkify.html
r124590 r126426 11 11 function completeURL(baseURL, href) 12 12 { 13 InspectorTest.addResult(WebInspector. completeURL(baseURL, href));13 InspectorTest.addResult(WebInspector.ParsedURL.completeURL(baseURL, href)); 14 14 } 15 15 -
trunk/Source/WebCore/ChangeLog
r126425 r126426 1 2012-08-23 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: extract ParsedURL into a separate file. 4 https://bugs.webkit.org/show_bug.cgi?id=94817 5 6 Reviewed by Alexander Pavlov. 7 8 * WebCore.gypi: 9 * WebCore.vcproj/WebCore.vcproj: 10 * inspector/compile-front-end.py: 11 * inspector/front-end/AuditRules.js: 12 (WebInspector.AuditRules.ImageDimensionsRule.prototype.doRun): 13 (WebInspector.AuditRules.CssInHeadRule.prototype.doRun.externalStylesheetsReceived): 14 (WebInspector.AuditRules.StylesScriptsOrderRule.prototype.doRun.cssBeforeInlineReceived): 15 * inspector/front-end/DefaultTextEditor.js: 16 (WebInspector.TextEditorMainPanel.prototype._rewriteHref): 17 * inspector/front-end/ParsedURL.js: Added. 18 (WebInspector.ParsedURL): 19 (WebInspector.ParsedURL.completeURL): 20 (WebInspector.ParsedURL.prototype.get displayName): 21 (String.prototype.asParsedURL): 22 * inspector/front-end/ResourceUtils.js: 23 (WebInspector.resourceURLForRelatedNode): 24 * inspector/front-end/StylesSidebarPane.js: 25 (WebInspector.StylePropertyTreeElement.prototype.updateTitle.linkifyURL): 26 * inspector/front-end/WebKit.qrc: 27 * inspector/front-end/inspector.html: 28 1 29 2012-08-23 Pavel Feldman <pfeldman@chromium.org> 2 30 -
trunk/Source/WebCore/WebCore.gypi
r126425 r126426 6348 6348 'inspector/front-end/Panel.js', 6349 6349 'inspector/front-end/PanelEnablerView.js', 6350 'inspector/front-end/ParsedURL.js', 6350 6351 'inspector/front-end/Placard.js', 6351 6352 'inspector/front-end/Popover.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r126425 r126426 76191 76191 </File> 76192 76192 <File 76193 RelativePath="..\inspector\front-end\ParsedURL.js" 76194 > 76195 </File> 76196 <File 76193 76197 RelativePath="..\inspector\front-end\panelEnablerView.css" 76194 76198 > -
trunk/Source/WebCore/inspector/compile-front-end.py
r126425 r126426 46 46 "Color.js", 47 47 "Object.js", 48 "ParsedURL.js", 48 49 "Settings.js", 49 50 "UIString.js", -
trunk/Source/WebCore/inspector/front-end/AuditRules.js
r125399 r126426 719 719 for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) { 720 720 if (frameOwnerCandidate.documentURL) { 721 var completeSrc = WebInspector. completeURL(frameOwnerCandidate.documentURL, src);721 var completeSrc = WebInspector.ParsedURL.completeURL(frameOwnerCandidate.documentURL, src); 722 722 break; 723 723 } … … 859 859 for (var j = 0; j < externalStylesheetNodeIds.length; ++j) { 860 860 var linkNode = WebInspector.domAgent.nodeForId(externalStylesheetNodeIds[j]); 861 var completeHref = WebInspector. completeURL(linkNode.ownerDocument.documentURL, linkNode.getAttribute("href"));861 var completeHref = WebInspector.ParsedURL.completeURL(linkNode.ownerDocument.documentURL, linkNode.getAttribute("href")); 862 862 externalStylesheetHrefs.push(completeHref || "<empty>"); 863 863 } … … 940 940 for (var i = 0; i < lateStyleIds.length; ++i) { 941 941 var lateStyleNode = WebInspector.domAgent.nodeForId(lateStyleIds[i]); 942 var completeHref = WebInspector. completeURL(lateStyleNode.ownerDocument.documentURL, lateStyleNode.getAttribute("href"));942 var completeHref = WebInspector.ParsedURL.completeURL(lateStyleNode.ownerDocument.documentURL, lateStyleNode.getAttribute("href")); 943 943 lateStyleUrls.push(completeHref || "<empty>"); 944 944 } -
trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js
r126210 r126426 2111 2111 if (!this._url || !hrefValue || hrefValue.indexOf("://") > 0) 2112 2112 return hrefValue; 2113 return WebInspector. completeURL(this._url, hrefValue);2113 return WebInspector.ParsedURL.completeURL(this._url, hrefValue); 2114 2114 }, 2115 2115 -
trunk/Source/WebCore/inspector/front-end/ResourceUtils.js
r124792 r126426 30 30 31 31 /** 32 * @constructor33 * @param {string} url34 */35 WebInspector.ParsedURL = function(url)36 {37 this.isValid = false;38 this.url = url;39 this.scheme = "";40 this.host = "";41 this.port = "";42 this.path = "";43 this.queryParams = "";44 this.fragment = "";45 this.folderPathComponents = "";46 this.lastPathComponent = "";47 48 // RegExp groups:49 // 1 - scheme50 // 2 - hostname51 // 3 - ?port52 // 4 - ?path53 // 5 - ?fragment54 var match = url.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);55 if (match) {56 this.isValid = true;57 this.scheme = match[1].toLowerCase();58 this.host = match[2];59 this.port = match[3];60 this.path = match[4] || "/";61 this.fragment = match[5];62 } else {63 if (this.url.startsWith("data:")) {64 this.scheme = "data";65 return;66 }67 if (this.url === "about:blank") {68 this.scheme = "about";69 return;70 }71 this.path = this.url;72 }73 74 if (this.path) {75 // First cut the query params.76 var path = this.path;77 var indexOfQuery = path.indexOf("?");78 if (indexOfQuery !== -1) {79 this.queryParams = path.substring(indexOfQuery + 1)80 path = path.substring(0, indexOfQuery);81 }82 83 // Then take last path component.84 var lastSlashIndex = path.lastIndexOf("/");85 if (lastSlashIndex !== -1) {86 this.folderPathComponents = path.substring(0, lastSlashIndex);87 this.lastPathComponent = path.substring(lastSlashIndex + 1);88 } else89 this.lastPathComponent = path;90 }91 }92 93 WebInspector.ParsedURL.prototype = {94 get displayName()95 {96 if (this._displayName)97 return this._displayName;98 99 if (this.scheme === "data") {100 this._displayName = this.url.trimEnd(20);101 return this._displayName;102 }103 104 if (this.url === "about:blank")105 return this.url;106 107 this._displayName = this.lastPathComponent;108 if (!this._displayName)109 this._displayName = WebInspector.displayDomain(this.host);110 if (!this._displayName && this.url)111 this._displayName = this.url.trimURL(WebInspector.inspectedPageDomain ? WebInspector.inspectedPageDomain : "");112 if (this._displayName === "/")113 this._displayName = this.url;114 return this._displayName;115 }116 }117 /**118 * @return {?WebInspector.ParsedURL}119 */120 String.prototype.asParsedURL = function()121 {122 var parsedURL = new WebInspector.ParsedURL(this.toString());123 if (parsedURL.isValid)124 return parsedURL;125 return null;126 }127 128 /**129 32 * @param {string} url 130 33 * @return {?WebInspector.Resource} … … 348 251 for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) { 349 252 if (frameOwnerCandidate.documentURL) { 350 var result = WebInspector. completeURL(frameOwnerCandidate.documentURL, url);253 var result = WebInspector.ParsedURL.completeURL(frameOwnerCandidate.documentURL, url); 351 254 if (result) 352 255 return result; … … 367 270 return resourceURL; 368 271 } 369 370 /**371 * @param {string} baseURL372 * @param {string} href373 * @return {?string}374 */375 WebInspector.completeURL = function(baseURL, href)376 {377 if (href) {378 // Return absolute URLs as-is.379 var parsedHref = href.asParsedURL();380 if (parsedHref && parsedHref.scheme)381 return href;382 383 // Return special URLs as-is.384 var trimmedHref = href.trim();385 if (trimmedHref.startsWith("data:") || trimmedHref.startsWith("javascript:") || trimmedHref.startsWith("blob:"))386 return href;387 }388 389 var parsedURL = baseURL.asParsedURL();390 if (parsedURL) {391 var path = href;392 if (path.charAt(0) !== "/") {393 var basePath = parsedURL.path;394 395 // Trim off the query part of the basePath.396 var questionMarkIndex = basePath.indexOf("?");397 if (questionMarkIndex > 0)398 basePath = basePath.substring(0, questionMarkIndex);399 // A href of "?foo=bar" implies "basePath?foo=bar".400 // With "basePath?a=b" and "?foo=bar" we should get "basePath?foo=bar".401 var prefix;402 if (path.charAt(0) === "?") {403 var basePathCutIndex = basePath.indexOf("?");404 if (basePathCutIndex !== -1)405 prefix = basePath.substring(0, basePathCutIndex);406 else407 prefix = basePath;408 } else409 prefix = basePath.substring(0, basePath.lastIndexOf("/")) + "/";410 411 path = prefix + path;412 } else if (path.length > 1 && path.charAt(1) === "/") {413 // href starts with "//" which is a full URL with the protocol dropped (use the baseURL protocol).414 return parsedURL.scheme + ":" + path;415 }416 return parsedURL.scheme + "://" + parsedURL.host + (parsedURL.port ? (":" + parsedURL.port) : "") + path;417 }418 return null;419 } -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r125965 r126426 1718 1718 container.appendChild(document.createTextNode("url(")); 1719 1719 if (self._styleRule.sourceURL) 1720 hrefUrl = WebInspector. completeURL(self._styleRule.sourceURL, hrefUrl);1720 hrefUrl = WebInspector.ParsedURL.completeURL(self._styleRule.sourceURL, hrefUrl); 1721 1721 else if (this._parentPane.node) 1722 1722 hrefUrl = WebInspector.resourceURLForRelatedNode(this._parentPane.node, hrefUrl); -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r126425 r126426 118 118 <file>Panel.js</file> 119 119 <file>PanelEnablerView.js</file> 120 <file>ParsedURL.js</file> 120 121 <file>Placard.js</file> 121 122 <file>Popover.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r126425 r126426 75 75 <script type="text/javascript" src="NetworkLog.js"></script> 76 76 <script type="text/javascript" src="ResourceTreeModel.js"></script> 77 <script type="text/javascript" src="ParsedURL.js"></script> 77 78 <script type="text/javascript" src="ResourceUtils.js"></script> 78 79 <script type="text/javascript" src="ResourceType.js"></script>
Note: See TracChangeset
for help on using the changeset viewer.