| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @extends {WebInspector.VBox} |
| 8 * @param {string} title |
| 9 */ |
| 10 WebInspector.ReportView = function(title) |
| 11 { |
| 12 WebInspector.VBox.call(this, true); |
| 13 this.registerRequiredCSS("ui/reportView.css"); |
| 14 |
| 15 var contentBox = this.contentElement.createChild("div", "report-content-box"
); |
| 16 this._headerElement = contentBox.createChild("div", "report-header vbox"); |
| 17 this._headerElement.createChild("div", "report-title").textContent = title; |
| 18 |
| 19 this._sectionList = contentBox.createChild("div", "vbox"); |
| 20 } |
| 21 |
| 22 WebInspector.ReportView.prototype = { |
| 23 /** |
| 24 * @param {?string} url |
| 25 */ |
| 26 setURL: function(url) |
| 27 { |
| 28 if (this._url === url) |
| 29 return; |
| 30 if (!this._urlElement) |
| 31 this._urlElement = this._headerElement.createChild("div", "report-ur
l link"); |
| 32 |
| 33 this._url = url; |
| 34 this._urlElement.removeChildren(); |
| 35 if (url) |
| 36 this._urlElement.appendChild(WebInspector.linkifyURLAsNode(url)); |
| 37 }, |
| 38 |
| 39 /** |
| 40 * @return {!WebInspector.Toolbar} |
| 41 */ |
| 42 createToolbar: function() |
| 43 { |
| 44 var toolbar = new WebInspector.Toolbar(""); |
| 45 this._headerElement.appendChild(toolbar.element); |
| 46 return toolbar; |
| 47 }, |
| 48 |
| 49 /** |
| 50 * @param {string} title |
| 51 * @return {!WebInspector.ReportView.Section} |
| 52 */ |
| 53 appendSection: function(title) |
| 54 { |
| 55 var section = new WebInspector.ReportView.Section(title); |
| 56 section.show(this._sectionList); |
| 57 return section; |
| 58 }, |
| 59 |
| 60 removeAllSection: function() |
| 61 { |
| 62 this._sectionList.removeChildren(); |
| 63 }, |
| 64 |
| 65 __proto__: WebInspector.VBox.prototype |
| 66 } |
| 67 |
| 68 /** |
| 69 * @constructor |
| 70 * @extends {WebInspector.VBox} |
| 71 * @param {string} title |
| 72 */ |
| 73 WebInspector.ReportView.Section = function(title) |
| 74 { |
| 75 WebInspector.VBox.call(this); |
| 76 this.element.classList.add("report-section"); |
| 77 this._headerElement = this.element.createChild("div", "report-section-header
"); |
| 78 this._titleElement = this._headerElement.createChild("div", "report-section-
title"); |
| 79 this._titleElement.textContent = title; |
| 80 this._fieldList = this.element.createChild("div", "vbox"); |
| 81 /** @type {!Map.<string, !Element>} */ |
| 82 this._fieldMap = new Map(); |
| 83 } |
| 84 |
| 85 WebInspector.ReportView.Section.prototype = { |
| 86 /** |
| 87 * @param {string} title |
| 88 */ |
| 89 setTitle: function(title) |
| 90 { |
| 91 if (this._titleElement.textContent !== title) |
| 92 this._titleElement.textContent = title; |
| 93 }, |
| 94 |
| 95 /** |
| 96 * @return {!WebInspector.Toolbar} |
| 97 */ |
| 98 createToolbar: function() |
| 99 { |
| 100 var toolbar = new WebInspector.Toolbar(""); |
| 101 this._headerElement.appendChild(toolbar.element); |
| 102 return toolbar; |
| 103 }, |
| 104 |
| 105 /** |
| 106 * @param {string} title |
| 107 * @param {string=} textValue |
| 108 * @return {!Element} |
| 109 */ |
| 110 appendField: function(title, textValue) |
| 111 { |
| 112 var row = this._fieldMap.get(title); |
| 113 if (!row) { |
| 114 row = this._fieldList.createChild("div", "report-field"); |
| 115 row.createChild("div", "report-field-name").textContent = title; |
| 116 this._fieldMap.set(title, row); |
| 117 row.createChild("div", "report-field-value"); |
| 118 } |
| 119 if (textValue) |
| 120 row.lastElementChild.textContent = textValue; |
| 121 return /** @type {!Element} */ (row.lastElementChild); |
| 122 }, |
| 123 |
| 124 remove: function() |
| 125 { |
| 126 this.element.remove(); |
| 127 }, |
| 128 |
| 129 /** |
| 130 * @param {string} title |
| 131 */ |
| 132 removeField: function(title) |
| 133 { |
| 134 var row = this._fieldMap.get(title); |
| 135 if (row) |
| 136 row.remove(); |
| 137 this._fieldMap.delete(title); |
| 138 }, |
| 139 |
| 140 /** |
| 141 * @param {string} title |
| 142 * @param {boolean} visible |
| 143 */ |
| 144 setFieldVisible: function(title, visible) |
| 145 { |
| 146 var row = this._fieldMap.get(title); |
| 147 if (row) |
| 148 row.classList.toggle("hidden", !visible); |
| 149 }, |
| 150 |
| 151 /** |
| 152 * @param {string} title |
| 153 * @return {?Element} |
| 154 */ |
| 155 fieldValue: function(title) |
| 156 { |
| 157 var row = this._fieldMap.get(title); |
| 158 return row ? row.lastElementChild : null; |
| 159 }, |
| 160 |
| 161 /** |
| 162 * @return {!Element} |
| 163 */ |
| 164 appendRow: function() |
| 165 { |
| 166 return this._fieldList.createChild("div", "report-row"); |
| 167 }, |
| 168 |
| 169 clearContent: function() |
| 170 { |
| 171 this._fieldList.removeChildren(); |
| 172 this._fieldMap.clear(); |
| 173 }, |
| 174 |
| 175 __proto__: WebInspector.VBox.prototype |
| 176 } |
| OLD | NEW |