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

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

Issue 2604883002: DevTools: namespace globals (Closed)
Patch Set: address CL feedback Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 19 matching lines...) Expand all
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 Audits.AuditCategoryResultPane = class extends UI.SimpleView { 34 Audits.AuditCategoryResultPane = class extends UI.SimpleView {
35 /** 35 /**
36 * @param {!Audits.AuditCategoryResult} categoryResult 36 * @param {!Audits.AuditCategoryResult} categoryResult
37 */ 37 */
38 constructor(categoryResult) { 38 constructor(categoryResult) {
39 super(categoryResult.title); 39 super(categoryResult.title);
40 this._treeOutline = new TreeOutlineInShadow(); 40 this._treeOutline = new UI.TreeOutlineInShadow();
41 this._treeOutline.registerRequiredCSS('audits/auditResultTree.css'); 41 this._treeOutline.registerRequiredCSS('audits/auditResultTree.css');
42 this._treeOutline.element.classList.add('audit-result-tree'); 42 this._treeOutline.element.classList.add('audit-result-tree');
43 this.element.appendChild(this._treeOutline.element); 43 this.element.appendChild(this._treeOutline.element);
44 this._treeOutline.expandTreeElementsWhenArrowing = true; 44 this._treeOutline.expandTreeElementsWhenArrowing = true;
45 45
46 function ruleSorter(a, b) { 46 function ruleSorter(a, b) {
47 var result = Audits.AuditRule.SeverityOrder[a.severity || 0] - Audits.Audi tRule.SeverityOrder[b.severity || 0]; 47 var result = Audits.AuditRule.SeverityOrder[a.severity || 0] - Audits.Audi tRule.SeverityOrder[b.severity || 0];
48 if (!result) 48 if (!result)
49 result = (a.value || '').localeCompare(b.value || ''); 49 result = (a.value || '').localeCompare(b.value || '');
50 return result; 50 return result;
51 } 51 }
52 52
53 categoryResult.ruleResults.sort(ruleSorter); 53 categoryResult.ruleResults.sort(ruleSorter);
54 54
55 for (var i = 0; i < categoryResult.ruleResults.length; ++i) { 55 for (var i = 0; i < categoryResult.ruleResults.length; ++i) {
56 var ruleResult = categoryResult.ruleResults[i]; 56 var ruleResult = categoryResult.ruleResults[i];
57 var treeElement = this._appendResult(this._treeOutline.rootElement(), rule Result, ruleResult.severity); 57 var treeElement = this._appendResult(this._treeOutline.rootElement(), rule Result, ruleResult.severity);
58 treeElement.listItemElement.classList.add('audit-result'); 58 treeElement.listItemElement.classList.add('audit-result');
59 } 59 }
60 this.revealView(); 60 this.revealView();
61 } 61 }
62 62
63 /** 63 /**
64 * @param {!TreeElement} parentTreeNode 64 * @param {!UI.TreeElement} parentTreeNode
65 * @param {!Audits.AuditRuleResult} result 65 * @param {!Audits.AuditRuleResult} result
66 * @param {?Audits.AuditRule.Severity=} severity 66 * @param {?Audits.AuditRule.Severity=} severity
67 */ 67 */
68 _appendResult(parentTreeNode, result, severity) { 68 _appendResult(parentTreeNode, result, severity) {
69 var title = ''; 69 var title = '';
70 70
71 if (typeof result.value === 'string') { 71 if (typeof result.value === 'string') {
72 title = result.value; 72 title = result.value;
73 if (result.violationCount) 73 if (result.violationCount)
74 title = String.sprintf('%s (%d)', title, result.violationCount); 74 title = String.sprintf('%s (%d)', title, result.violationCount);
75 } 75 }
76 76
77 var titleFragment = createDocumentFragment(); 77 var titleFragment = createDocumentFragment();
78 if (severity) { 78 if (severity) {
79 var severityElement = UI.Icon.create(); 79 var severityElement = UI.Icon.create();
80 if (severity === Audits.AuditRule.Severity.Info) 80 if (severity === Audits.AuditRule.Severity.Info)
81 severityElement.setIconType('smallicon-green-ball'); 81 severityElement.setIconType('smallicon-green-ball');
82 else if (severity === Audits.AuditRule.Severity.Warning) 82 else if (severity === Audits.AuditRule.Severity.Warning)
83 severityElement.setIconType('smallicon-orange-ball'); 83 severityElement.setIconType('smallicon-orange-ball');
84 else if (severity === Audits.AuditRule.Severity.Severe) 84 else if (severity === Audits.AuditRule.Severity.Severe)
85 severityElement.setIconType('smallicon-red-ball'); 85 severityElement.setIconType('smallicon-red-ball');
86 severityElement.classList.add('severity'); 86 severityElement.classList.add('severity');
87 titleFragment.appendChild(severityElement); 87 titleFragment.appendChild(severityElement);
88 } 88 }
89 titleFragment.createTextChild(title); 89 titleFragment.createTextChild(title);
90 90
91 var treeElement = new TreeElement(titleFragment, !!result.children); 91 var treeElement = new UI.TreeElement(titleFragment, !!result.children);
92 treeElement.selectable = false; 92 treeElement.selectable = false;
93 parentTreeNode.appendChild(treeElement); 93 parentTreeNode.appendChild(treeElement);
94 94
95 if (result.className) 95 if (result.className)
96 treeElement.listItemElement.classList.add(result.className); 96 treeElement.listItemElement.classList.add(result.className);
97 if (typeof result.value !== 'string') 97 if (typeof result.value !== 'string')
98 treeElement.listItemElement.appendChild(Audits.auditFormatters.apply(resul t.value)); 98 treeElement.listItemElement.appendChild(Audits.auditFormatters.apply(resul t.value));
99 99
100 if (result.children) { 100 if (result.children) {
101 for (var i = 0; i < result.children.length; ++i) 101 for (var i = 0; i < result.children.length; ++i)
102 this._appendResult(treeElement, result.children[i]); 102 this._appendResult(treeElement, result.children[i]);
103 } 103 }
104 if (result.expanded) { 104 if (result.expanded) {
105 treeElement.listItemElement.classList.remove('parent'); 105 treeElement.listItemElement.classList.remove('parent');
106 treeElement.listItemElement.classList.add('parent-expanded'); 106 treeElement.listItemElement.classList.add('parent-expanded');
107 treeElement.expand(); 107 treeElement.expand();
108 } 108 }
109 return treeElement; 109 return treeElement;
110 } 110 }
111 }; 111 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698