| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 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.AuditCategoryResultPane = class extends WebInspector.SimpleView { | 34 Audits.AuditCategoryResultPane = class extends UI.SimpleView { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.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 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 = | 47 var result = |
| 48 WebInspector.AuditRule.SeverityOrder[a.severity || 0] - WebInspector.A
uditRule.SeverityOrder[b.severity || 0]; | 48 Audits.AuditRule.SeverityOrder[a.severity || 0] - Audits.AuditRule.Sev
erityOrder[b.severity || 0]; |
| 49 if (!result) | 49 if (!result) |
| 50 result = (a.value || '').localeCompare(b.value || ''); | 50 result = (a.value || '').localeCompare(b.value || ''); |
| 51 return result; | 51 return result; |
| 52 } | 52 } |
| 53 | 53 |
| 54 categoryResult.ruleResults.sort(ruleSorter); | 54 categoryResult.ruleResults.sort(ruleSorter); |
| 55 | 55 |
| 56 for (var i = 0; i < categoryResult.ruleResults.length; ++i) { | 56 for (var i = 0; i < categoryResult.ruleResults.length; ++i) { |
| 57 var ruleResult = categoryResult.ruleResults[i]; | 57 var ruleResult = categoryResult.ruleResults[i]; |
| 58 var treeElement = this._appendResult(this._treeOutline.rootElement(), rule
Result, ruleResult.severity); | 58 var treeElement = this._appendResult(this._treeOutline.rootElement(), rule
Result, ruleResult.severity); |
| 59 treeElement.listItemElement.classList.add('audit-result'); | 59 treeElement.listItemElement.classList.add('audit-result'); |
| 60 } | 60 } |
| 61 this.revealView(); | 61 this.revealView(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!TreeElement} parentTreeNode | 65 * @param {!TreeElement} parentTreeNode |
| 66 * @param {!WebInspector.AuditRuleResult} result | 66 * @param {!Audits.AuditRuleResult} result |
| 67 * @param {?WebInspector.AuditRule.Severity=} severity | 67 * @param {?Audits.AuditRule.Severity=} severity |
| 68 */ | 68 */ |
| 69 _appendResult(parentTreeNode, result, severity) { | 69 _appendResult(parentTreeNode, result, severity) { |
| 70 var title = ''; | 70 var title = ''; |
| 71 | 71 |
| 72 if (typeof result.value === 'string') { | 72 if (typeof result.value === 'string') { |
| 73 title = result.value; | 73 title = result.value; |
| 74 if (result.violationCount) | 74 if (result.violationCount) |
| 75 title = String.sprintf('%s (%d)', title, result.violationCount); | 75 title = String.sprintf('%s (%d)', title, result.violationCount); |
| 76 } | 76 } |
| 77 | 77 |
| 78 var titleFragment = createDocumentFragment(); | 78 var titleFragment = createDocumentFragment(); |
| 79 if (severity) { | 79 if (severity) { |
| 80 var severityElement = WebInspector.Icon.create(); | 80 var severityElement = UI.Icon.create(); |
| 81 if (severity === WebInspector.AuditRule.Severity.Info) | 81 if (severity === Audits.AuditRule.Severity.Info) |
| 82 severityElement.setIconType('smallicon-green-ball'); | 82 severityElement.setIconType('smallicon-green-ball'); |
| 83 else if (severity === WebInspector.AuditRule.Severity.Warning) | 83 else if (severity === Audits.AuditRule.Severity.Warning) |
| 84 severityElement.setIconType('smallicon-orange-ball'); | 84 severityElement.setIconType('smallicon-orange-ball'); |
| 85 else if (severity === WebInspector.AuditRule.Severity.Severe) | 85 else if (severity === Audits.AuditRule.Severity.Severe) |
| 86 severityElement.setIconType('smallicon-red-ball'); | 86 severityElement.setIconType('smallicon-red-ball'); |
| 87 severityElement.classList.add('severity'); | 87 severityElement.classList.add('severity'); |
| 88 titleFragment.appendChild(severityElement); | 88 titleFragment.appendChild(severityElement); |
| 89 } | 89 } |
| 90 titleFragment.createTextChild(title); | 90 titleFragment.createTextChild(title); |
| 91 | 91 |
| 92 var treeElement = new TreeElement(titleFragment, !!result.children); | 92 var treeElement = new TreeElement(titleFragment, !!result.children); |
| 93 treeElement.selectable = false; | 93 treeElement.selectable = false; |
| 94 parentTreeNode.appendChild(treeElement); | 94 parentTreeNode.appendChild(treeElement); |
| 95 | 95 |
| 96 if (result.className) | 96 if (result.className) |
| 97 treeElement.listItemElement.classList.add(result.className); | 97 treeElement.listItemElement.classList.add(result.className); |
| 98 if (typeof result.value !== 'string') | 98 if (typeof result.value !== 'string') |
| 99 treeElement.listItemElement.appendChild(WebInspector.auditFormatters.apply
(result.value)); | 99 treeElement.listItemElement.appendChild(Audits.auditFormatters.apply(resul
t.value)); |
| 100 | 100 |
| 101 if (result.children) { | 101 if (result.children) { |
| 102 for (var i = 0; i < result.children.length; ++i) | 102 for (var i = 0; i < result.children.length; ++i) |
| 103 this._appendResult(treeElement, result.children[i]); | 103 this._appendResult(treeElement, result.children[i]); |
| 104 } | 104 } |
| 105 if (result.expanded) { | 105 if (result.expanded) { |
| 106 treeElement.listItemElement.classList.remove('parent'); | 106 treeElement.listItemElement.classList.remove('parent'); |
| 107 treeElement.listItemElement.classList.add('parent-expanded'); | 107 treeElement.listItemElement.classList.add('parent-expanded'); |
| 108 treeElement.expand(); | 108 treeElement.expand(); |
| 109 } | 109 } |
| 110 return treeElement; | 110 return treeElement; |
| 111 } | 111 } |
| 112 }; | 112 }; |
| OLD | NEW |