Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1108)

Side by Side Diff: Source/devtools/front_end/bindings/ResourceUtils.js

Issue 675753002: [DevTools] Drop "ui" module from toolbox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 var domain = parsedURL.host + (parsedURL.port ? (":" + parsedURL.port) : "") ; 88 var domain = parsedURL.host + (parsedURL.port ? (":" + parsedURL.port) : "") ;
89 var displayName = url.trimURL(domain); 89 var displayName = url.trimURL(domain);
90 return displayName === "/" ? domain + "/" : displayName; 90 return displayName === "/" ? domain + "/" : displayName;
91 } 91 }
92 92
93 /** 93 /**
94 * @param {string} string 94 * @param {string} string
95 * @param {function(string,string,number=,number=):!Node} linkifier 95 * @param {function(string,string,number=,number=):!Node} linkifier
96 * @return {!DocumentFragment} 96 * @return {!DocumentFragment}
97 * // FIXME: remove this suppression (crbug.com/425498).
98 * @suppressGlobalPropertiesCheck
99 */ 97 */
100 WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki fier) 98 WebInspector.linkifyStringAsFragmentWithCustomLinkifier = function(string, linki fier)
101 { 99 {
102 var container = document.createDocumentFragment(); 100 var container = createDocumentFragment();
103 var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|data:|www\.)[\w$\- _+*'=\|\/\\(){}[\]^%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({^%@&#~]/; 101 var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|data:|www\.)[\w$\- _+*'=\|\/\\(){}[\]^%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({^%@&#~]/;
104 var lineColumnRegEx = /:(\d+)(:(\d+))?$/; 102 var lineColumnRegEx = /:(\d+)(:(\d+))?$/;
105 103
106 while (string) { 104 while (string) {
107 var linkString = linkStringRegEx.exec(string); 105 var linkString = linkStringRegEx.exec(string);
108 if (!linkString) 106 if (!linkString)
109 break; 107 break;
110 108
111 linkString = linkString[0]; 109 linkString = linkString[0];
112 var linkIndex = string.indexOf(linkString); 110 var linkIndex = string.indexOf(linkString);
113 var nonLink = string.substring(0, linkIndex); 111 var nonLink = string.substring(0, linkIndex);
114 container.appendChild(document.createTextNode(nonLink)); 112 container.appendChild(createTextNode(nonLink));
115 113
116 var title = linkString; 114 var title = linkString;
117 var realURL = (linkString.startsWith("www.") ? "http://" + linkString : linkString); 115 var realURL = (linkString.startsWith("www.") ? "http://" + linkString : linkString);
118 var parsedURL = new WebInspector.ParsedURL(realURL); 116 var parsedURL = new WebInspector.ParsedURL(realURL);
119 var lineColumnMatch = lineColumnRegEx.exec(parsedURL.lastPathComponent); 117 var lineColumnMatch = lineColumnRegEx.exec(parsedURL.lastPathComponent);
120 var lineNumber; 118 var lineNumber;
121 var columnNumber; 119 var columnNumber;
122 if (lineColumnMatch) { 120 if (lineColumnMatch) {
123 realURL = realURL.substring(0, realURL.length - lineColumnMatch[0].l ength); 121 realURL = realURL.substring(0, realURL.length - lineColumnMatch[0].l ength);
124 lineNumber = parseInt(lineColumnMatch[1], 10); 122 lineNumber = parseInt(lineColumnMatch[1], 10);
125 // Immediately convert line and column to 0-based numbers. 123 // Immediately convert line and column to 0-based numbers.
126 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1; 124 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1;
127 if (typeof(lineColumnMatch[3]) === "string") { 125 if (typeof(lineColumnMatch[3]) === "string") {
128 columnNumber = parseInt(lineColumnMatch[3], 10); 126 columnNumber = parseInt(lineColumnMatch[3], 10);
129 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1; 127 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1;
130 } 128 }
131 } 129 }
132 130
133 var linkNode = linkifier(title, realURL, lineNumber, columnNumber); 131 var linkNode = linkifier(title, realURL, lineNumber, columnNumber);
134 container.appendChild(linkNode); 132 container.appendChild(linkNode);
135 string = string.substring(linkIndex + linkString.length, string.length); 133 string = string.substring(linkIndex + linkString.length, string.length);
136 } 134 }
137 135
138 if (string) 136 if (string)
139 container.appendChild(document.createTextNode(string)); 137 container.appendChild(createTextNode(string));
140 138
141 return container; 139 return container;
142 } 140 }
143 141
144 /** 142 /**
145 * @param {string} url 143 * @param {string} url
146 * @param {string=} linkText 144 * @param {string=} linkText
147 * @param {string=} classes 145 * @param {string=} classes
148 * @param {boolean=} isExternal 146 * @param {boolean=} isExternal
149 * @param {string=} tooltipText 147 * @param {string=} tooltipText
150 * @return {!Element} 148 * @return {!Element}
151 * // FIXME: remove this suppression (crbug.com/425498).
152 * @suppressGlobalPropertiesCheck
153 */ 149 */
154 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ltipText) 150 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ltipText)
155 { 151 {
156 if (!linkText) 152 if (!linkText)
157 linkText = url; 153 linkText = url;
158 classes = (classes ? classes + " " : ""); 154 classes = (classes ? classes + " " : "");
159 classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource- link"; 155 classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource- link";
160 156
161 var a = document.createElement("a"); 157 var a = createElement("a");
162 var href = sanitizeHref(url); 158 var href = sanitizeHref(url);
163 if (href !== null) 159 if (href !== null)
164 a.href = href; 160 a.href = href;
165 a.className = classes; 161 a.className = classes;
166 if (typeof tooltipText === "undefined") 162 if (typeof tooltipText === "undefined")
167 a.title = url; 163 a.title = url;
168 else if (typeof tooltipText !== "string" || tooltipText.length) 164 else if (typeof tooltipText !== "string" || tooltipText.length)
169 a.title = tooltipText; 165 a.title = tooltipText;
170 a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDispl ayedURLs); 166 a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDispl ayedURLs);
171 if (isExternal) 167 if (isExternal)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 /** 207 /**
212 * @param {!WebInspector.NetworkRequest} request 208 * @param {!WebInspector.NetworkRequest} request
213 * @return {!Element} 209 * @return {!Element}
214 */ 210 */
215 WebInspector.linkifyRequestAsNode = function(request) 211 WebInspector.linkifyRequestAsNode = function(request)
216 { 212 {
217 var anchor = WebInspector.linkifyURLAsNode(request.url); 213 var anchor = WebInspector.linkifyURLAsNode(request.url);
218 anchor.requestId = request.requestId; 214 anchor.requestId = request.requestId;
219 return anchor; 215 return anchor;
220 } 216 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/bindings/Linkifier.js ('k') | Source/devtools/front_end/host/DOMExtension.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698