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

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

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done 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) 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
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 16 * this software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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
31 /** 30 /**
32 * @constructor 31 * @unrestricted
33 * @extends {WebInspector.SimpleView}
34 * @param {!WebInspector.AuditCategoryResult} categoryResult
35 */ 32 */
36 WebInspector.AuditCategoryResultPane = function(categoryResult) 33 WebInspector.AuditCategoryResultPane = class extends WebInspector.SimpleView {
37 { 34 /**
38 WebInspector.SimpleView.call(this, categoryResult.title); 35 * @param {!WebInspector.AuditCategoryResult} categoryResult
36 */
37 constructor(categoryResult) {
38 super(categoryResult.title);
39 this._treeOutline = new TreeOutlineInShadow(); 39 this._treeOutline = new TreeOutlineInShadow();
40 this._treeOutline.registerRequiredCSS("audits/auditResultTree.css"); 40 this._treeOutline.registerRequiredCSS('audits/auditResultTree.css');
41 this._treeOutline.element.classList.add("audit-result-tree"); 41 this._treeOutline.element.classList.add('audit-result-tree');
42 this.element.appendChild(this._treeOutline.element); 42 this.element.appendChild(this._treeOutline.element);
43 this._treeOutline.expandTreeElementsWhenArrowing = true; 43 this._treeOutline.expandTreeElementsWhenArrowing = true;
44 44
45 function ruleSorter(a, b) 45 function ruleSorter(a, b) {
46 { 46 var result =
47 var result = WebInspector.AuditRule.SeverityOrder[a.severity || 0] - Web Inspector.AuditRule.SeverityOrder[b.severity || 0]; 47 WebInspector.AuditRule.SeverityOrder[a.severity || 0] - WebInspector.A uditRule.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(), ru leResult, 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 }
62
63 /**
64 * @param {!TreeElement} parentTreeNode
65 * @param {!WebInspector.AuditRuleResult} result
66 * @param {?WebInspector.AuditRule.Severity=} severity
67 */
68 _appendResult(parentTreeNode, result, severity) {
69 var title = '';
70
71 if (typeof result.value === 'string') {
72 title = result.value;
73 if (result.violationCount)
74 title = String.sprintf('%s (%d)', title, result.violationCount);
75 }
76
77 var titleFragment = createDocumentFragment();
78 if (severity) {
79 var severityElement = createElement('div');
80 severityElement.classList.add('severity', severity);
81 titleFragment.appendChild(severityElement);
82 }
83 titleFragment.createTextChild(title);
84
85 var treeElement = new TreeElement(titleFragment, !!result.children);
86 treeElement.selectable = false;
87 parentTreeNode.appendChild(treeElement);
88
89 if (result.className)
90 treeElement.listItemElement.classList.add(result.className);
91 if (typeof result.value !== 'string')
92 treeElement.listItemElement.appendChild(WebInspector.auditFormatters.apply (result.value));
93
94 if (result.children) {
95 for (var i = 0; i < result.children.length; ++i)
96 this._appendResult(treeElement, result.children[i]);
97 }
98 if (result.expanded) {
99 treeElement.listItemElement.classList.remove('parent');
100 treeElement.listItemElement.classList.add('parent-expanded');
101 treeElement.expand();
102 }
103 return treeElement;
104 }
61 }; 105 };
62
63 WebInspector.AuditCategoryResultPane.prototype = {
64 /**
65 * @param {!TreeElement} parentTreeNode
66 * @param {!WebInspector.AuditRuleResult} result
67 * @param {?WebInspector.AuditRule.Severity=} severity
68 */
69 _appendResult: function(parentTreeNode, result, severity)
70 {
71 var title = "";
72
73 if (typeof result.value === "string") {
74 title = result.value;
75 if (result.violationCount)
76 title = String.sprintf("%s (%d)", title, result.violationCount);
77 }
78
79 var titleFragment = createDocumentFragment();
80 if (severity) {
81 var severityElement = createElement("div");
82 severityElement.classList.add("severity", severity);
83 titleFragment.appendChild(severityElement);
84 }
85 titleFragment.createTextChild(title);
86
87 var treeElement = new TreeElement(titleFragment, !!result.children);
88 treeElement.selectable = false;
89 parentTreeNode.appendChild(treeElement);
90
91 if (result.className)
92 treeElement.listItemElement.classList.add(result.className);
93 if (typeof result.value !== "string")
94 treeElement.listItemElement.appendChild(WebInspector.auditFormatters .apply(result.value));
95
96 if (result.children) {
97 for (var i = 0; i < result.children.length; ++i)
98 this._appendResult(treeElement, result.children[i]);
99 }
100 if (result.expanded) {
101 treeElement.listItemElement.classList.remove("parent");
102 treeElement.listItemElement.classList.add("parent-expanded");
103 treeElement.expand();
104 }
105 return treeElement;
106 },
107
108 __proto__: WebInspector.SimpleView.prototype
109 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698