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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/audits/AuditsPanel.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.AuditsPanel = class extends WebInspector.PanelWithSidebar { 34 Audits.AuditsPanel = class extends UI.PanelWithSidebar {
35 constructor() { 35 constructor() {
36 super('audits'); 36 super('audits');
37 this.registerRequiredCSS('ui/panelEnablerView.css'); 37 this.registerRequiredCSS('ui/panelEnablerView.css');
38 this.registerRequiredCSS('audits/auditsPanel.css'); 38 this.registerRequiredCSS('audits/auditsPanel.css');
39 39
40 this._sidebarTree = new TreeOutlineInShadow(); 40 this._sidebarTree = new TreeOutlineInShadow();
41 this._sidebarTree.registerRequiredCSS('audits/auditsSidebarTree.css'); 41 this._sidebarTree.registerRequiredCSS('audits/auditsSidebarTree.css');
42 this.panelSidebarElement().appendChild(this._sidebarTree.element); 42 this.panelSidebarElement().appendChild(this._sidebarTree.element);
43 43
44 this._auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement(this ); 44 this._auditsItemTreeElement = new Audits.AuditsSidebarTreeElement(this);
45 this._sidebarTree.appendChild(this._auditsItemTreeElement); 45 this._sidebarTree.appendChild(this._auditsItemTreeElement);
46 46
47 this._auditResultsTreeElement = new TreeElement(WebInspector.UIString('RESUL TS'), true); 47 this._auditResultsTreeElement = new TreeElement(Common.UIString('RESULTS'), true);
48 this._auditResultsTreeElement.selectable = false; 48 this._auditResultsTreeElement.selectable = false;
49 this._auditResultsTreeElement.listItemElement.classList.add('audits-sidebar- results'); 49 this._auditResultsTreeElement.listItemElement.classList.add('audits-sidebar- results');
50 this._auditResultsTreeElement.expand(); 50 this._auditResultsTreeElement.expand();
51 this._sidebarTree.appendChild(this._auditResultsTreeElement); 51 this._sidebarTree.appendChild(this._auditResultsTreeElement);
52 52
53 this._constructCategories(); 53 this._constructCategories();
54 54
55 this._auditController = new WebInspector.AuditController(this); 55 this._auditController = new Audits.AuditController(this);
56 this._launcherView = new WebInspector.AuditLauncherView(this._auditControlle r); 56 this._launcherView = new Audits.AuditLauncherView(this._auditController);
57 for (var id in this.categoriesById) 57 for (var id in this.categoriesById)
58 this._launcherView.addCategory(this.categoriesById[id]); 58 this._launcherView.addCategory(this.categoriesById[id]);
59 59
60 var extensionCategories = WebInspector.extensionServer.auditCategories(); 60 var extensionCategories = Extensions.extensionServer.auditCategories();
61 for (var i = 0; i < extensionCategories.length; ++i) { 61 for (var i = 0; i < extensionCategories.length; ++i) {
62 var category = extensionCategories[i]; 62 var category = extensionCategories[i];
63 this.addCategory(new WebInspector.AuditExtensionCategory( 63 this.addCategory(new Audits.AuditExtensionCategory(
64 category.extensionOrigin, category.id, category.displayName, category. ruleCount)); 64 category.extensionOrigin, category.id, category.displayName, category. ruleCount));
65 } 65 }
66 WebInspector.extensionServer.addEventListener( 66 Extensions.extensionServer.addEventListener(
67 WebInspector.ExtensionServer.Events.AuditCategoryAdded, this._extensionA uditCategoryAdded, this); 67 Extensions.ExtensionServer.Events.AuditCategoryAdded, this._extensionAud itCategoryAdded, this);
68 } 68 }
69 69
70 /** 70 /**
71 * @return {!WebInspector.AuditsPanel} 71 * @return {!Audits.AuditsPanel}
72 */ 72 */
73 static instance() { 73 static instance() {
74 return /** @type {!WebInspector.AuditsPanel} */ (self.runtime.sharedInstance (WebInspector.AuditsPanel)); 74 return /** @type {!Audits.AuditsPanel} */ (self.runtime.sharedInstance(Audit s.AuditsPanel));
75 } 75 }
76 76
77 /** 77 /**
78 * @return {!Object.<string, !WebInspector.AuditCategory>} 78 * @return {!Object.<string, !Audits.AuditCategory>}
79 */ 79 */
80 get categoriesById() { 80 get categoriesById() {
81 return this._auditCategoriesById; 81 return this._auditCategoriesById;
82 } 82 }
83 83
84 /** 84 /**
85 * @param {!WebInspector.AuditCategory} category 85 * @param {!Audits.AuditCategory} category
86 */ 86 */
87 addCategory(category) { 87 addCategory(category) {
88 this.categoriesById[category.id] = category; 88 this.categoriesById[category.id] = category;
89 this._launcherView.addCategory(category); 89 this._launcherView.addCategory(category);
90 } 90 }
91 91
92 /** 92 /**
93 * @param {string} id 93 * @param {string} id
94 * @return {!WebInspector.AuditCategory} 94 * @return {!Audits.AuditCategory}
95 */ 95 */
96 getCategory(id) { 96 getCategory(id) {
97 return this.categoriesById[id]; 97 return this.categoriesById[id];
98 } 98 }
99 99
100 _constructCategories() { 100 _constructCategories() {
101 this._auditCategoriesById = {}; 101 this._auditCategoriesById = {};
102 for (var categoryCtorID in WebInspector.AuditCategories) { 102 for (var categoryCtorID in Audits.AuditCategories) {
103 var auditCategory = new WebInspector.AuditCategories[categoryCtorID](); 103 var auditCategory = new Audits.AuditCategories[categoryCtorID]();
104 auditCategory._id = categoryCtorID; 104 auditCategory._id = categoryCtorID;
105 this.categoriesById[categoryCtorID] = auditCategory; 105 this.categoriesById[categoryCtorID] = auditCategory;
106 } 106 }
107 } 107 }
108 108
109 /** 109 /**
110 * @param {string} mainResourceURL 110 * @param {string} mainResourceURL
111 * @param {!Array.<!WebInspector.AuditCategoryResult>} results 111 * @param {!Array.<!Audits.AuditCategoryResult>} results
112 */ 112 */
113 auditFinishedCallback(mainResourceURL, results) { 113 auditFinishedCallback(mainResourceURL, results) {
114 var ordinal = 1; 114 var ordinal = 1;
115 for (var child of this._auditResultsTreeElement.children()) { 115 for (var child of this._auditResultsTreeElement.children()) {
116 if (child.mainResourceURL === mainResourceURL) 116 if (child.mainResourceURL === mainResourceURL)
117 ordinal++; 117 ordinal++;
118 } 118 }
119 119
120 var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(this, results, mainResourceURL, ordinal); 120 var resultTreeElement = new Audits.AuditResultSidebarTreeElement(this, resul ts, mainResourceURL, ordinal);
121 this._auditResultsTreeElement.appendChild(resultTreeElement); 121 this._auditResultsTreeElement.appendChild(resultTreeElement);
122 resultTreeElement.revealAndSelect(); 122 resultTreeElement.revealAndSelect();
123 } 123 }
124 124
125 /** 125 /**
126 * @param {!Array.<!WebInspector.AuditCategoryResult>} categoryResults 126 * @param {!Array.<!Audits.AuditCategoryResult>} categoryResults
127 */ 127 */
128 showResults(categoryResults) { 128 showResults(categoryResults) {
129 if (!categoryResults._resultLocation) { 129 if (!categoryResults._resultLocation) {
130 categoryResults.sort((a, b) => (a.title || '').localeCompare(b.title || '' )); 130 categoryResults.sort((a, b) => (a.title || '').localeCompare(b.title || '' ));
131 var resultView = WebInspector.viewManager.createStackLocation(); 131 var resultView = UI.viewManager.createStackLocation();
132 resultView.widget().element.classList.add('audit-result-view'); 132 resultView.widget().element.classList.add('audit-result-view');
133 for (var i = 0; i < categoryResults.length; ++i) 133 for (var i = 0; i < categoryResults.length; ++i)
134 resultView.showView(new WebInspector.AuditCategoryResultPane(categoryRes ults[i])); 134 resultView.showView(new Audits.AuditCategoryResultPane(categoryResults[i ]));
135 categoryResults._resultLocation = resultView; 135 categoryResults._resultLocation = resultView;
136 } 136 }
137 this.visibleView = categoryResults._resultLocation.widget(); 137 this.visibleView = categoryResults._resultLocation.widget();
138 } 138 }
139 139
140 showLauncherView() { 140 showLauncherView() {
141 this.visibleView = this._launcherView; 141 this.visibleView = this._launcherView;
142 } 142 }
143 143
144 get visibleView() { 144 get visibleView() {
(...skipping 28 matching lines...) Expand all
173 focus() { 173 focus() {
174 this._sidebarTree.focus(); 174 this._sidebarTree.focus();
175 } 175 }
176 176
177 clearResults() { 177 clearResults() {
178 this._auditsItemTreeElement.revealAndSelect(); 178 this._auditsItemTreeElement.revealAndSelect();
179 this._auditResultsTreeElement.removeChildren(); 179 this._auditResultsTreeElement.removeChildren();
180 } 180 }
181 181
182 /** 182 /**
183 * @param {!WebInspector.Event} event 183 * @param {!Common.Event} event
184 */ 184 */
185 _extensionAuditCategoryAdded(event) { 185 _extensionAuditCategoryAdded(event) {
186 var category = /** @type {!WebInspector.ExtensionAuditCategory} */ (event.da ta); 186 var category = /** @type {!Extensions.ExtensionAuditCategory} */ (event.data );
187 this.addCategory(new WebInspector.AuditExtensionCategory( 187 this.addCategory(new Audits.AuditExtensionCategory(
188 category.extensionOrigin, category.id, category.displayName, category.ru leCount)); 188 category.extensionOrigin, category.id, category.displayName, category.ru leCount));
189 } 189 }
190 }; 190 };
191 191
192 /** 192 /**
193 * @implements {WebInspector.AuditCategory} 193 * @implements {Audits.AuditCategory}
194 * @unrestricted 194 * @unrestricted
195 */ 195 */
196 WebInspector.AuditCategoryImpl = class { 196 Audits.AuditCategoryImpl = class {
197 /** 197 /**
198 * @param {string} displayName 198 * @param {string} displayName
199 */ 199 */
200 constructor(displayName) { 200 constructor(displayName) {
201 this._displayName = displayName; 201 this._displayName = displayName;
202 this._rules = []; 202 this._rules = [];
203 } 203 }
204 204
205 /** 205 /**
206 * @override 206 * @override
207 * @return {string} 207 * @return {string}
208 */ 208 */
209 get id() { 209 get id() {
210 // this._id value is injected at construction time. 210 // this._id value is injected at construction time.
211 return this._id; 211 return this._id;
212 } 212 }
213 213
214 /** 214 /**
215 * @override 215 * @override
216 * @return {string} 216 * @return {string}
217 */ 217 */
218 get displayName() { 218 get displayName() {
219 return this._displayName; 219 return this._displayName;
220 } 220 }
221 221
222 /** 222 /**
223 * @param {!WebInspector.AuditRule} rule 223 * @param {!Audits.AuditRule} rule
224 * @param {!WebInspector.AuditRule.Severity} severity 224 * @param {!Audits.AuditRule.Severity} severity
225 */ 225 */
226 addRule(rule, severity) { 226 addRule(rule, severity) {
227 rule.severity = severity; 227 rule.severity = severity;
228 this._rules.push(rule); 228 this._rules.push(rule);
229 } 229 }
230 230
231 /** 231 /**
232 * @override 232 * @override
233 * @param {!WebInspector.Target} target 233 * @param {!SDK.Target} target
234 * @param {!Array.<!WebInspector.NetworkRequest>} requests 234 * @param {!Array.<!SDK.NetworkRequest>} requests
235 * @param {function(!WebInspector.AuditRuleResult)} ruleResultCallback 235 * @param {function(!Audits.AuditRuleResult)} ruleResultCallback
236 * @param {!WebInspector.Progress} progress 236 * @param {!Common.Progress} progress
237 */ 237 */
238 run(target, requests, ruleResultCallback, progress) { 238 run(target, requests, ruleResultCallback, progress) {
239 this._ensureInitialized(); 239 this._ensureInitialized();
240 var remainingRulesCount = this._rules.length; 240 var remainingRulesCount = this._rules.length;
241 progress.setTotalWork(remainingRulesCount); 241 progress.setTotalWork(remainingRulesCount);
242 function callbackWrapper(result) { 242 function callbackWrapper(result) {
243 ruleResultCallback(result); 243 ruleResultCallback(result);
244 progress.worked(); 244 progress.worked();
245 if (!--remainingRulesCount) 245 if (!--remainingRulesCount)
246 progress.done(); 246 progress.done();
(...skipping 11 matching lines...) Expand all
258 if ('initialize' in this) 258 if ('initialize' in this)
259 this.initialize(); 259 this.initialize();
260 this._initialized = true; 260 this._initialized = true;
261 } 261 }
262 } 262 }
263 }; 263 };
264 264
265 /** 265 /**
266 * @unrestricted 266 * @unrestricted
267 */ 267 */
268 WebInspector.AuditRule = class { 268 Audits.AuditRule = class {
269 /** 269 /**
270 * @param {string} id 270 * @param {string} id
271 * @param {string} displayName 271 * @param {string} displayName
272 */ 272 */
273 constructor(id, displayName) { 273 constructor(id, displayName) {
274 this._id = id; 274 this._id = id;
275 this._displayName = displayName; 275 this._displayName = displayName;
276 } 276 }
277 277
278 get id() { 278 get id() {
279 return this._id; 279 return this._id;
280 } 280 }
281 281
282 get displayName() { 282 get displayName() {
283 return this._displayName; 283 return this._displayName;
284 } 284 }
285 285
286 /** 286 /**
287 * @param {!WebInspector.AuditRule.Severity} severity 287 * @param {!Audits.AuditRule.Severity} severity
288 */ 288 */
289 set severity(severity) { 289 set severity(severity) {
290 this._severity = severity; 290 this._severity = severity;
291 } 291 }
292 292
293 /** 293 /**
294 * @param {!WebInspector.Target} target 294 * @param {!SDK.Target} target
295 * @param {!Array.<!WebInspector.NetworkRequest>} requests 295 * @param {!Array.<!SDK.NetworkRequest>} requests
296 * @param {function(?WebInspector.AuditRuleResult)} callback 296 * @param {function(?Audits.AuditRuleResult)} callback
297 * @param {!WebInspector.Progress} progress 297 * @param {!Common.Progress} progress
298 */ 298 */
299 run(target, requests, callback, progress) { 299 run(target, requests, callback, progress) {
300 if (progress.isCanceled()) 300 if (progress.isCanceled())
301 return; 301 return;
302 302
303 var result = new WebInspector.AuditRuleResult(this.displayName); 303 var result = new Audits.AuditRuleResult(this.displayName);
304 result.severity = this._severity; 304 result.severity = this._severity;
305 this.doRun(target, requests, result, callback, progress); 305 this.doRun(target, requests, result, callback, progress);
306 } 306 }
307 307
308 /** 308 /**
309 * @param {!WebInspector.Target} target 309 * @param {!SDK.Target} target
310 * @param {!Array.<!WebInspector.NetworkRequest>} requests 310 * @param {!Array.<!SDK.NetworkRequest>} requests
311 * @param {!WebInspector.AuditRuleResult} result 311 * @param {!Audits.AuditRuleResult} result
312 * @param {function(?WebInspector.AuditRuleResult)} callback 312 * @param {function(?Audits.AuditRuleResult)} callback
313 * @param {!WebInspector.Progress} progress 313 * @param {!Common.Progress} progress
314 */ 314 */
315 doRun(target, requests, result, callback, progress) { 315 doRun(target, requests, result, callback, progress) {
316 throw new Error('doRun() not implemented'); 316 throw new Error('doRun() not implemented');
317 } 317 }
318 }; 318 };
319 319
320 /** 320 /**
321 * @enum {string} 321 * @enum {string}
322 */ 322 */
323 WebInspector.AuditRule.Severity = { 323 Audits.AuditRule.Severity = {
324 Info: 'info', 324 Info: 'info',
325 Warning: 'warning', 325 Warning: 'warning',
326 Severe: 'severe' 326 Severe: 'severe'
327 }; 327 };
328 328
329 WebInspector.AuditRule.SeverityOrder = { 329 Audits.AuditRule.SeverityOrder = {
330 'info': 3, 330 'info': 3,
331 'warning': 2, 331 'warning': 2,
332 'severe': 1 332 'severe': 1
333 }; 333 };
334 334
335 /** 335 /**
336 * @unrestricted 336 * @unrestricted
337 */ 337 */
338 WebInspector.AuditCategoryResult = class { 338 Audits.AuditCategoryResult = class {
339 /** 339 /**
340 * @param {!WebInspector.AuditCategory} category 340 * @param {!Audits.AuditCategory} category
341 */ 341 */
342 constructor(category) { 342 constructor(category) {
343 this.title = category.displayName; 343 this.title = category.displayName;
344 this.ruleResults = []; 344 this.ruleResults = [];
345 } 345 }
346 346
347 /** 347 /**
348 * @param {!WebInspector.AuditRuleResult} ruleResult 348 * @param {!Audits.AuditRuleResult} ruleResult
349 */ 349 */
350 addRuleResult(ruleResult) { 350 addRuleResult(ruleResult) {
351 this.ruleResults.push(ruleResult); 351 this.ruleResults.push(ruleResult);
352 } 352 }
353 }; 353 };
354 354
355 /** 355 /**
356 * @unrestricted 356 * @unrestricted
357 */ 357 */
358 WebInspector.AuditRuleResult = class { 358 Audits.AuditRuleResult = class {
359 /** 359 /**
360 * @param {(string|boolean|number|!Object)} value 360 * @param {(string|boolean|number|!Object)} value
361 * @param {boolean=} expanded 361 * @param {boolean=} expanded
362 * @param {string=} className 362 * @param {string=} className
363 */ 363 */
364 constructor(value, expanded, className) { 364 constructor(value, expanded, className) {
365 this.value = value; 365 this.value = value;
366 this.className = className; 366 this.className = className;
367 this.expanded = expanded; 367 this.expanded = expanded;
368 this.violationCount = 0; 368 this.violationCount = 0;
369 this._formatters = {r: WebInspector.AuditRuleResult.linkifyDisplayName}; 369 this._formatters = {r: Audits.AuditRuleResult.linkifyDisplayName};
370 var standardFormatters = Object.keys(String.standardFormatters); 370 var standardFormatters = Object.keys(String.standardFormatters);
371 for (var i = 0; i < standardFormatters.length; ++i) 371 for (var i = 0; i < standardFormatters.length; ++i)
372 this._formatters[standardFormatters[i]] = String.standardFormatters[standa rdFormatters[i]]; 372 this._formatters[standardFormatters[i]] = String.standardFormatters[standa rdFormatters[i]];
373 } 373 }
374 374
375 /** 375 /**
376 * @param {string} url 376 * @param {string} url
377 * @return {!Element} 377 * @return {!Element}
378 */ 378 */
379 static linkifyDisplayName(url) { 379 static linkifyDisplayName(url) {
380 return WebInspector.linkifyURLAsNode(url, WebInspector.displayNameForURL(url )); 380 return UI.linkifyURLAsNode(url, Bindings.displayNameForURL(url));
381 } 381 }
382 382
383 /** 383 /**
384 * @param {string} domain 384 * @param {string} domain
385 * @return {string} 385 * @return {string}
386 */ 386 */
387 static resourceDomain(domain) { 387 static resourceDomain(domain) {
388 return domain || WebInspector.UIString('[empty domain]'); 388 return domain || Common.UIString('[empty domain]');
389 } 389 }
390 390
391 /** 391 /**
392 * @param {(string|boolean|number|!Object)} value 392 * @param {(string|boolean|number|!Object)} value
393 * @param {boolean=} expanded 393 * @param {boolean=} expanded
394 * @param {string=} className 394 * @param {string=} className
395 * @return {!WebInspector.AuditRuleResult} 395 * @return {!Audits.AuditRuleResult}
396 */ 396 */
397 addChild(value, expanded, className) { 397 addChild(value, expanded, className) {
398 if (!this.children) 398 if (!this.children)
399 this.children = []; 399 this.children = [];
400 var entry = new WebInspector.AuditRuleResult(value, expanded, className); 400 var entry = new Audits.AuditRuleResult(value, expanded, className);
401 this.children.push(entry); 401 this.children.push(entry);
402 return entry; 402 return entry;
403 } 403 }
404 404
405 /** 405 /**
406 * @param {string} url 406 * @param {string} url
407 */ 407 */
408 addURL(url) { 408 addURL(url) {
409 this.addChild(WebInspector.AuditRuleResult.linkifyDisplayName(url)); 409 this.addChild(Audits.AuditRuleResult.linkifyDisplayName(url));
410 } 410 }
411 411
412 /** 412 /**
413 * @param {!Array.<string>} urls 413 * @param {!Array.<string>} urls
414 */ 414 */
415 addURLs(urls) { 415 addURLs(urls) {
416 for (var i = 0; i < urls.length; ++i) 416 for (var i = 0; i < urls.length; ++i)
417 this.addURL(urls[i]); 417 this.addURL(urls[i]);
418 } 418 }
419 419
420 /** 420 /**
421 * @param {string} snippet 421 * @param {string} snippet
422 */ 422 */
423 addSnippet(snippet) { 423 addSnippet(snippet) {
424 this.addChild(snippet, false, 'source-code'); 424 this.addChild(snippet, false, 'source-code');
425 } 425 }
426 426
427 /** 427 /**
428 * @param {string} format 428 * @param {string} format
429 * @param {...*} vararg 429 * @param {...*} vararg
430 * @return {!WebInspector.AuditRuleResult} 430 * @return {!Audits.AuditRuleResult}
431 */ 431 */
432 addFormatted(format, vararg) { 432 addFormatted(format, vararg) {
433 var substitutions = Array.prototype.slice.call(arguments, 1); 433 var substitutions = Array.prototype.slice.call(arguments, 1);
434 var fragment = createDocumentFragment(); 434 var fragment = createDocumentFragment();
435 435
436 function append(a, b) { 436 function append(a, b) {
437 if (!(b instanceof Node)) 437 if (!(b instanceof Node))
438 b = createTextNode(b); 438 b = createTextNode(b);
439 a.appendChild(b); 439 a.appendChild(b);
440 return a; 440 return a;
441 } 441 }
442 442
443 var formattedResult = String.format(format, substitutions, this._formatters, fragment, append).formattedResult; 443 var formattedResult = String.format(format, substitutions, this._formatters, fragment, append).formattedResult;
444 if (formattedResult instanceof Node) 444 if (formattedResult instanceof Node)
445 formattedResult.normalize(); 445 formattedResult.normalize();
446 return this.addChild(formattedResult); 446 return this.addChild(formattedResult);
447 } 447 }
448 }; 448 };
449 449
450 450
451 /** 451 /**
452 * @unrestricted 452 * @unrestricted
453 */ 453 */
454 WebInspector.AuditsSidebarTreeElement = class extends TreeElement { 454 Audits.AuditsSidebarTreeElement = class extends TreeElement {
455 /** 455 /**
456 * @param {!WebInspector.AuditsPanel} panel 456 * @param {!Audits.AuditsPanel} panel
457 */ 457 */
458 constructor(panel) { 458 constructor(panel) {
459 super(WebInspector.UIString('Audits'), false); 459 super(Common.UIString('Audits'), false);
460 this.selectable = true; 460 this.selectable = true;
461 this._panel = panel; 461 this._panel = panel;
462 this.listItemElement.classList.add('audits-sidebar-header'); 462 this.listItemElement.classList.add('audits-sidebar-header');
463 this.listItemElement.insertBefore(createElementWithClass('div', 'icon'), thi s.listItemElement.firstChild); 463 this.listItemElement.insertBefore(createElementWithClass('div', 'icon'), thi s.listItemElement.firstChild);
464 } 464 }
465 465
466 /** 466 /**
467 * @override 467 * @override
468 * @return {boolean} 468 * @return {boolean}
469 */ 469 */
470 onselect() { 470 onselect() {
471 this._panel.showLauncherView(); 471 this._panel.showLauncherView();
472 return true; 472 return true;
473 } 473 }
474 }; 474 };
475 475
476 /** 476 /**
477 * @unrestricted 477 * @unrestricted
478 */ 478 */
479 WebInspector.AuditResultSidebarTreeElement = class extends TreeElement { 479 Audits.AuditResultSidebarTreeElement = class extends TreeElement {
480 /** 480 /**
481 * @param {!WebInspector.AuditsPanel} panel 481 * @param {!Audits.AuditsPanel} panel
482 * @param {!Array.<!WebInspector.AuditCategoryResult>} results 482 * @param {!Array.<!Audits.AuditCategoryResult>} results
483 * @param {string} mainResourceURL 483 * @param {string} mainResourceURL
484 * @param {number} ordinal 484 * @param {number} ordinal
485 */ 485 */
486 constructor(panel, results, mainResourceURL, ordinal) { 486 constructor(panel, results, mainResourceURL, ordinal) {
487 super(String.sprintf('%s (%d)', mainResourceURL, ordinal), false); 487 super(String.sprintf('%s (%d)', mainResourceURL, ordinal), false);
488 this.selectable = true; 488 this.selectable = true;
489 this._panel = panel; 489 this._panel = panel;
490 this.results = results; 490 this.results = results;
491 this.mainResourceURL = mainResourceURL; 491 this.mainResourceURL = mainResourceURL;
492 this.listItemElement.classList.add('audit-result-sidebar-tree-item'); 492 this.listItemElement.classList.add('audit-result-sidebar-tree-item');
493 this.listItemElement.insertBefore(createElementWithClass('div', 'icon'), thi s.listItemElement.firstChild); 493 this.listItemElement.insertBefore(createElementWithClass('div', 'icon'), thi s.listItemElement.firstChild);
494 } 494 }
495 495
496 /** 496 /**
497 * @override 497 * @override
498 * @return {boolean} 498 * @return {boolean}
499 */ 499 */
500 onselect() { 500 onselect() {
501 this._panel.showResults(this.results); 501 this._panel.showResults(this.results);
502 return true; 502 return true;
503 } 503 }
504 }; 504 };
505 505
506 506
507 // Contributed audit rules should go into this namespace. 507 // Contributed audit rules should go into this namespace.
508 WebInspector.AuditRules = {}; 508 Audits.AuditRules = {};
509 509
510 /** 510 /**
511 * Contributed audit categories should go into this namespace. 511 * Contributed audit categories should go into this namespace.
512 * @type {!Object.<string, function(new:WebInspector.AuditCategory)>} 512 * @type {!Object.<string, function(new:Audits.AuditCategory)>}
513 */ 513 */
514 WebInspector.AuditCategories = {}; 514 Audits.AuditCategories = {};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698