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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/layer_viewer/LayerDetailsView.js

Issue 2358253002: DevTools: extract a component for layer viewer (Closed)
Patch Set: Created 4 years, 2 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @param {!WebInspector.LayerViewHost} layerViewHost 33 * @param {!WebInspector.LayerViewHost} layerViewHost
34 * @extends {WebInspector.Widget} 34 * @extends {WebInspector.Widget}
35 * @implements {WebInspector.LayerView} 35 * @implements {WebInspector.LayerView}
36 */ 36 */
37 WebInspector.LayerDetailsView = function(layerViewHost) 37 WebInspector.LayerDetailsView = function(layerViewHost)
38 { 38 {
39 WebInspector.Widget.call(this); 39 WebInspector.Widget.call(this, true);
40 this.element.classList.add("layer-details-view"); 40 this.registerRequiredCSS("layer_viewer/layerDetailsView.css");
41 this._layerViewHost = layerViewHost; 41 this._layerViewHost = layerViewHost;
42 this._layerViewHost.registerView(this); 42 this._layerViewHost.registerView(this);
43 this._emptyWidget = new WebInspector.EmptyWidget(WebInspector.UIString("Sele ct a layer to see its details")); 43 this._emptyWidget = new WebInspector.EmptyWidget(WebInspector.UIString("Sele ct a layer to see its details"));
44 this._buildContent(); 44 this._buildContent();
45 } 45 }
46 46
47 /** 47 /**
48 * @enum {string} 48 * @enum {string}
49 */ 49 */
50 /** @enum {symbol} */ 50 /** @enum {symbol} */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ", " + scrollRect.rect.width + ", " + scrollRect.rect.height + ")"; 153 ", " + scrollRect.rect.width + ", " + scrollRect.rect.height + ")";
154 element.addEventListener("click", this._onScrollRectClicked.bind(this, i ndex), false); 154 element.addEventListener("click", this._onScrollRectClicked.bind(this, i ndex), false);
155 }, 155 },
156 156
157 update: function() 157 update: function()
158 { 158 {
159 var layer = this._selection && this._selection.layer(); 159 var layer = this._selection && this._selection.layer();
160 if (!layer) { 160 if (!layer) {
161 this._tableElement.remove(); 161 this._tableElement.remove();
162 this._paintProfilerButton.remove(); 162 this._paintProfilerButton.remove();
163 this._emptyWidget.show(this.element); 163 this._emptyWidget.show(this.contentElement);
164 return; 164 return;
165 } 165 }
166 this._emptyWidget.detach(); 166 this._emptyWidget.detach();
167 this.element.appendChild(this._tableElement); 167 this.contentElement.appendChild(this._tableElement);
168 this.element.appendChild(this._paintProfilerButton); 168 this.contentElement.appendChild(this._paintProfilerButton);
169 this._sizeCell.textContent = WebInspector.UIString("%d × %d (at %d,%d)", layer.width(), layer.height(), layer.offsetX(), layer.offsetY()); 169 this._sizeCell.textContent = WebInspector.UIString("%d × %d (at %d,%d)", layer.width(), layer.height(), layer.offsetX(), layer.offsetY());
170 this._paintCountCell.parentElement.classList.toggle("hidden", !layer.pai ntCount()); 170 this._paintCountCell.parentElement.classList.toggle("hidden", !layer.pai ntCount());
171 this._paintCountCell.textContent = layer.paintCount(); 171 this._paintCountCell.textContent = layer.paintCount();
172 this._memoryEstimateCell.textContent = Number.bytesToString(layer.gpuMem oryUsage()); 172 this._memoryEstimateCell.textContent = Number.bytesToString(layer.gpuMem oryUsage());
173 layer.requestCompositingReasons(this._updateCompositingReasons.bind(this )); 173 layer.requestCompositingReasons(this._updateCompositingReasons.bind(this ));
174 this._scrollRectsCell.removeChildren(); 174 this._scrollRectsCell.removeChildren();
175 layer.scrollRects().forEach(this._createScrollRectElement.bind(this)); 175 layer.scrollRects().forEach(this._createScrollRectElement.bind(this));
176 var traceEvent = this._selection.type() === WebInspector.LayerView.Selec tion.Type.Tile ? /** @type {!WebInspector.LayerView.TileSelection} */ (this._sel ection).traceEvent() : null; 176 var traceEvent = this._selection.type() === WebInspector.LayerView.Selec tion.Type.Tile ? /** @type {!WebInspector.LayerView.TileSelection} */ (this._sel ection).traceEvent() : null;
177 this._paintProfilerButton.classList.toggle("hidden", !traceEvent); 177 this._paintProfilerButton.classList.toggle("hidden", !traceEvent);
178 }, 178 },
179 179
180 _buildContent: function() 180 _buildContent: function()
181 { 181 {
182 this._tableElement = this.element.createChild("table"); 182 this._tableElement = this.contentElement.createChild("table");
183 this._tbodyElement = this._tableElement.createChild("tbody"); 183 this._tbodyElement = this._tableElement.createChild("tbody");
184 this._sizeCell = this._createRow(WebInspector.UIString("Size")); 184 this._sizeCell = this._createRow(WebInspector.UIString("Size"));
185 this._compositingReasonsCell = this._createRow(WebInspector.UIString("Co mpositing Reasons")); 185 this._compositingReasonsCell = this._createRow(WebInspector.UIString("Co mpositing Reasons"));
186 this._memoryEstimateCell = this._createRow(WebInspector.UIString("Memory estimate")); 186 this._memoryEstimateCell = this._createRow(WebInspector.UIString("Memory estimate"));
187 this._paintCountCell = this._createRow(WebInspector.UIString("Paint coun t")); 187 this._paintCountCell = this._createRow(WebInspector.UIString("Paint coun t"));
188 this._scrollRectsCell = this._createRow(WebInspector.UIString("Slow scro ll regions")); 188 this._scrollRectsCell = this._createRow(WebInspector.UIString("Slow scro ll regions"));
189 this._paintProfilerButton = this.element.createChild("a", "hidden link") ; 189 this._paintProfilerButton = this.contentElement.createChild("a", "hidden link");
190 this._paintProfilerButton.textContent = WebInspector.UIString("Paint Pro filer"); 190 this._paintProfilerButton.textContent = WebInspector.UIString("Paint Pro filer");
191 this._paintProfilerButton.addEventListener("click", this._onPaintProfile rButtonClicked.bind(this)); 191 this._paintProfilerButton.addEventListener("click", this._onPaintProfile rButtonClicked.bind(this));
192 }, 192 },
193 193
194 /** 194 /**
195 * @param {string} title 195 * @param {string} title
196 */ 196 */
197 _createRow: function(title) 197 _createRow: function(title)
198 { 198 {
199 var tr = this._tbodyElement.createChild("tr"); 199 var tr = this._tbodyElement.createChild("tr");
(...skipping 17 matching lines...) Expand all
217 var text = WebInspector.LayerDetailsView.CompositingReasonDetail[com positingReasons[i]] || compositingReasons[i]; 217 var text = WebInspector.LayerDetailsView.CompositingReasonDetail[com positingReasons[i]] || compositingReasons[i];
218 // If the text is more than one word but does not terminate with per iod, add the period. 218 // If the text is more than one word but does not terminate with per iod, add the period.
219 if (/\s.*[^.]$/.test(text)) 219 if (/\s.*[^.]$/.test(text))
220 text += "."; 220 text += ".";
221 list.createChild("li").textContent = text; 221 list.createChild("li").textContent = text;
222 } 222 }
223 }, 223 },
224 224
225 __proto__: WebInspector.Widget.prototype 225 __proto__: WebInspector.Widget.prototype
226 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698