| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.SidebarPaneStack} | |
| 34 * @param {!Array.<!WebInspector.AuditCategoryResult>} categoryResults | |
| 35 */ | |
| 36 WebInspector.AuditResultView = function(categoryResults) | |
| 37 { | |
| 38 WebInspector.SidebarPaneStack.call(this); | |
| 39 this.setMinimumSize(100, 25); | |
| 40 this.element.classList.add("audit-result-view"); | |
| 41 | |
| 42 function categorySorter(a, b) { | |
| 43 return (a.title || "").localeCompare(b.title || ""); | |
| 44 } | |
| 45 categoryResults.sort(categorySorter); | |
| 46 for (var i = 0; i < categoryResults.length; ++i) | |
| 47 this.addPane(new WebInspector.AuditCategoryResultPane(categoryResults[i]
)); | |
| 48 } | |
| 49 | |
| 50 WebInspector.AuditResultView.prototype = { | |
| 51 __proto__: WebInspector.SidebarPaneStack.prototype | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * @constructor | |
| 56 * @extends {WebInspector.View} | 33 * @extends {WebInspector.View} |
| 57 * @param {!WebInspector.AuditCategoryResult} categoryResult | 34 * @param {!WebInspector.AuditCategoryResult} categoryResult |
| 58 */ | 35 */ |
| 59 WebInspector.AuditCategoryResultPane = function(categoryResult) | 36 WebInspector.AuditCategoryResultPane = function(categoryResult) |
| 60 { | 37 { |
| 61 WebInspector.View.call(this, categoryResult.title); | 38 WebInspector.View.call(this, categoryResult.title); |
| 62 this._treeOutline = new TreeOutlineInShadow(); | 39 this._treeOutline = new TreeOutlineInShadow(); |
| 63 this._treeOutline.registerRequiredCSS("audits/auditResultTree.css"); | 40 this._treeOutline.registerRequiredCSS("audits/auditResultTree.css"); |
| 64 this._treeOutline.element.classList.add("audit-result-tree"); | 41 this._treeOutline.element.classList.add("audit-result-tree"); |
| 65 this.element.appendChild(this._treeOutline.element); | 42 this.element.appendChild(this._treeOutline.element); |
| 66 this._treeOutline.expandTreeElementsWhenArrowing = true; | 43 this._treeOutline.expandTreeElementsWhenArrowing = true; |
| 67 | 44 |
| 68 function ruleSorter(a, b) | 45 function ruleSorter(a, b) |
| 69 { | 46 { |
| 70 var result = WebInspector.AuditRule.SeverityOrder[a.severity || 0] - Web
Inspector.AuditRule.SeverityOrder[b.severity || 0]; | 47 var result = WebInspector.AuditRule.SeverityOrder[a.severity || 0] - Web
Inspector.AuditRule.SeverityOrder[b.severity || 0]; |
| 71 if (!result) | 48 if (!result) |
| 72 result = (a.value || "").localeCompare(b.value || ""); | 49 result = (a.value || "").localeCompare(b.value || ""); |
| 73 return result; | 50 return result; |
| 74 } | 51 } |
| 75 | 52 |
| 76 categoryResult.ruleResults.sort(ruleSorter); | 53 categoryResult.ruleResults.sort(ruleSorter); |
| 77 | 54 |
| 78 for (var i = 0; i < categoryResult.ruleResults.length; ++i) { | 55 for (var i = 0; i < categoryResult.ruleResults.length; ++i) { |
| 79 var ruleResult = categoryResult.ruleResults[i]; | 56 var ruleResult = categoryResult.ruleResults[i]; |
| 80 var treeElement = this._appendResult(this._treeOutline.rootElement(), ru
leResult, ruleResult.severity); | 57 var treeElement = this._appendResult(this._treeOutline.rootElement(), ru
leResult, ruleResult.severity); |
| 81 treeElement.listItemElement.classList.add("audit-result"); | 58 treeElement.listItemElement.classList.add("audit-result"); |
| 82 } | 59 } |
| 83 this.requestReveal(); | 60 this.revealWidget(); |
| 84 } | 61 } |
| 85 | 62 |
| 86 WebInspector.AuditCategoryResultPane.prototype = { | 63 WebInspector.AuditCategoryResultPane.prototype = { |
| 87 /** | 64 /** |
| 88 * @param {!TreeElement} parentTreeNode | 65 * @param {!TreeElement} parentTreeNode |
| 89 * @param {!WebInspector.AuditRuleResult} result | 66 * @param {!WebInspector.AuditRuleResult} result |
| 90 * @param {?WebInspector.AuditRule.Severity=} severity | 67 * @param {?WebInspector.AuditRule.Severity=} severity |
| 91 */ | 68 */ |
| 92 _appendResult: function(parentTreeNode, result, severity) | 69 _appendResult: function(parentTreeNode, result, severity) |
| 93 { | 70 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 123 if (result.expanded) { | 100 if (result.expanded) { |
| 124 treeElement.listItemElement.classList.remove("parent"); | 101 treeElement.listItemElement.classList.remove("parent"); |
| 125 treeElement.listItemElement.classList.add("parent-expanded"); | 102 treeElement.listItemElement.classList.add("parent-expanded"); |
| 126 treeElement.expand(); | 103 treeElement.expand(); |
| 127 } | 104 } |
| 128 return treeElement; | 105 return treeElement; |
| 129 }, | 106 }, |
| 130 | 107 |
| 131 __proto__: WebInspector.View.prototype | 108 __proto__: WebInspector.View.prototype |
| 132 } | 109 } |
| OLD | NEW |