OLD | NEW |
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 |
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 | |
33 * @param {!WebInspector.LayerViewHost} layerViewHost | |
34 * @extends {WebInspector.Widget} | |
35 * @implements {WebInspector.LayerView} | 31 * @implements {WebInspector.LayerView} |
| 32 * @unrestricted |
36 */ | 33 */ |
37 WebInspector.LayerDetailsView = function(layerViewHost) | 34 WebInspector.LayerDetailsView = class extends WebInspector.Widget { |
38 { | 35 /** |
39 WebInspector.Widget.call(this, true); | 36 * @param {!WebInspector.LayerViewHost} layerViewHost |
40 this.registerRequiredCSS("layer_viewer/layerDetailsView.css"); | 37 */ |
| 38 constructor(layerViewHost) { |
| 39 super(true); |
| 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 } |
| 46 |
| 47 /** |
| 48 * @param {?WebInspector.LayerView.Selection} selection |
| 49 * @override |
| 50 */ |
| 51 hoverObject(selection) { |
| 52 } |
| 53 |
| 54 /** |
| 55 * @param {?WebInspector.LayerView.Selection} selection |
| 56 * @override |
| 57 */ |
| 58 selectObject(selection) { |
| 59 this._selection = selection; |
| 60 if (this.isShowing()) |
| 61 this.update(); |
| 62 } |
| 63 |
| 64 /** |
| 65 * @param {?WebInspector.LayerTreeBase} layerTree |
| 66 * @override |
| 67 */ |
| 68 setLayerTree(layerTree) { |
| 69 } |
| 70 |
| 71 /** |
| 72 * @override |
| 73 */ |
| 74 wasShown() { |
| 75 super.wasShown(); |
| 76 this.update(); |
| 77 } |
| 78 |
| 79 /** |
| 80 * @param {number} index |
| 81 * @param {!Event} event |
| 82 */ |
| 83 _onScrollRectClicked(index, event) { |
| 84 if (event.which !== 1) |
| 85 return; |
| 86 this._layerViewHost.selectObject(new WebInspector.LayerView.ScrollRectSelect
ion(this._selection.layer(), index)); |
| 87 } |
| 88 |
| 89 _onPaintProfilerButtonClicked() { |
| 90 if (this._selection.type() === WebInspector.LayerView.Selection.Type.Snapsho
t || this._selection.layer()) |
| 91 this.dispatchEventToListeners(WebInspector.LayerDetailsView.Events.PaintPr
ofilerRequested, this._selection); |
| 92 } |
| 93 |
| 94 /** |
| 95 * @param {!LayerTreeAgent.ScrollRect} scrollRect |
| 96 * @param {number} index |
| 97 */ |
| 98 _createScrollRectElement(scrollRect, index) { |
| 99 if (index) |
| 100 this._scrollRectsCell.createTextChild(', '); |
| 101 var element = this._scrollRectsCell.createChild('span', 'scroll-rect'); |
| 102 if (this._selection.scrollRectIndex === index) |
| 103 element.classList.add('active'); |
| 104 element.textContent = WebInspector.UIString( |
| 105 '%s (%s, %s, %s, %s)', WebInspector.LayerDetailsView._slowScrollRectName
s.get(scrollRect.type), |
| 106 scrollRect.rect.x, scrollRect.rect.y, scrollRect.rect.width, scrollRect.
rect.height); |
| 107 element.addEventListener('click', this._onScrollRectClicked.bind(this, index
), false); |
| 108 } |
| 109 |
| 110 update() { |
| 111 var layer = this._selection && this._selection.layer(); |
| 112 if (!layer) { |
| 113 this._tableElement.remove(); |
| 114 this._paintProfilerButton.remove(); |
| 115 this._emptyWidget.show(this.contentElement); |
| 116 return; |
| 117 } |
| 118 this._emptyWidget.detach(); |
| 119 this.contentElement.appendChild(this._tableElement); |
| 120 this.contentElement.appendChild(this._paintProfilerButton); |
| 121 this._sizeCell.textContent = |
| 122 WebInspector.UIString('%d × %d (at %d,%d)', layer.width(), layer.height(
), layer.offsetX(), layer.offsetY()); |
| 123 this._paintCountCell.parentElement.classList.toggle('hidden', !layer.paintCo
unt()); |
| 124 this._paintCountCell.textContent = layer.paintCount(); |
| 125 this._memoryEstimateCell.textContent = Number.bytesToString(layer.gpuMemoryU
sage()); |
| 126 layer.requestCompositingReasons(this._updateCompositingReasons.bind(this)); |
| 127 this._scrollRectsCell.removeChildren(); |
| 128 layer.scrollRects().forEach(this._createScrollRectElement.bind(this)); |
| 129 var snapshot = this._selection.type() === WebInspector.LayerView.Selection.T
ype.Snapshot ? |
| 130 /** @type {!WebInspector.LayerView.SnapshotSelection} */ (this._selectio
n).snapshot() : |
| 131 null; |
| 132 this._paintProfilerButton.classList.toggle('hidden', !snapshot); |
| 133 } |
| 134 |
| 135 _buildContent() { |
| 136 this._tableElement = this.contentElement.createChild('table'); |
| 137 this._tbodyElement = this._tableElement.createChild('tbody'); |
| 138 this._sizeCell = this._createRow(WebInspector.UIString('Size')); |
| 139 this._compositingReasonsCell = this._createRow(WebInspector.UIString('Compos
iting Reasons')); |
| 140 this._memoryEstimateCell = this._createRow(WebInspector.UIString('Memory est
imate')); |
| 141 this._paintCountCell = this._createRow(WebInspector.UIString('Paint count'))
; |
| 142 this._scrollRectsCell = this._createRow(WebInspector.UIString('Slow scroll r
egions')); |
| 143 this._paintProfilerButton = this.contentElement.createChild('a', 'hidden lin
k'); |
| 144 this._paintProfilerButton.textContent = WebInspector.UIString('Paint Profile
r'); |
| 145 this._paintProfilerButton.addEventListener('click', this._onPaintProfilerBut
tonClicked.bind(this)); |
| 146 } |
| 147 |
| 148 /** |
| 149 * @param {string} title |
| 150 */ |
| 151 _createRow(title) { |
| 152 var tr = this._tbodyElement.createChild('tr'); |
| 153 var titleCell = tr.createChild('td'); |
| 154 titleCell.textContent = title; |
| 155 return tr.createChild('td'); |
| 156 } |
| 157 |
| 158 /** |
| 159 * @param {!Array.<string>} compositingReasons |
| 160 */ |
| 161 _updateCompositingReasons(compositingReasons) { |
| 162 if (!compositingReasons || !compositingReasons.length) { |
| 163 this._compositingReasonsCell.textContent = 'n/a'; |
| 164 return; |
| 165 } |
| 166 this._compositingReasonsCell.removeChildren(); |
| 167 var list = this._compositingReasonsCell.createChild('ul'); |
| 168 for (var i = 0; i < compositingReasons.length; ++i) { |
| 169 var text = WebInspector.LayerDetailsView.CompositingReasonDetail[compositi
ngReasons[i]] || compositingReasons[i]; |
| 170 // If the text is more than one word but does not terminate with period, a
dd the period. |
| 171 if (/\s.*[^.]$/.test(text)) |
| 172 text += '.'; |
| 173 list.createChild('li').textContent = text; |
| 174 } |
| 175 } |
45 }; | 176 }; |
46 | 177 |
47 /** | 178 /** |
48 * @enum {string} | 179 * @enum {string} |
49 */ | 180 */ |
50 /** @enum {symbol} */ | 181 /** @enum {symbol} */ |
51 WebInspector.LayerDetailsView.Events = { | 182 WebInspector.LayerDetailsView.Events = { |
52 PaintProfilerRequested: Symbol("PaintProfilerRequested") | 183 PaintProfilerRequested: Symbol('PaintProfilerRequested') |
53 }; | 184 }; |
54 | 185 |
55 /** | 186 /** |
56 * @type {!Object.<string, string>} | 187 * @type {!Object.<string, string>} |
57 */ | 188 */ |
58 WebInspector.LayerDetailsView.CompositingReasonDetail = { | 189 WebInspector.LayerDetailsView.CompositingReasonDetail = { |
59 "transform3D": WebInspector.UIString("Composition due to association with an
element with a CSS 3D transform."), | 190 'transform3D': WebInspector.UIString('Composition due to association with an e
lement with a CSS 3D transform.'), |
60 "video": WebInspector.UIString("Composition due to association with a <video
> element."), | 191 'video': WebInspector.UIString('Composition due to association with a <video>
element.'), |
61 "canvas": WebInspector.UIString("Composition due to the element being a <can
vas> element."), | 192 'canvas': WebInspector.UIString('Composition due to the element being a <canva
s> element.'), |
62 "plugin": WebInspector.UIString("Composition due to association with a plugi
n."), | 193 'plugin': WebInspector.UIString('Composition due to association with a plugin.
'), |
63 "iFrame": WebInspector.UIString("Composition due to association with an <ifr
ame> element."), | 194 'iFrame': WebInspector.UIString('Composition due to association with an <ifram
e> element.'), |
64 "backfaceVisibilityHidden": WebInspector.UIString("Composition due to associ
ation with an element with a \"backface-visibility: hidden\" style."), | 195 'backfaceVisibilityHidden': WebInspector.UIString( |
65 "animation": WebInspector.UIString("Composition due to association with an a
nimated element."), | 196 'Composition due to association with an element with a "backface-visibilit
y: hidden" style.'), |
66 "filters": WebInspector.UIString("Composition due to association with an ele
ment with CSS filters applied."), | 197 'animation': WebInspector.UIString('Composition due to association with an ani
mated element.'), |
67 "scrollDependentPosition": WebInspector.UIString("Composition due to associa
tion with an element with a \"position: fixed\" or \"position: sticky\" style.")
, | 198 'filters': WebInspector.UIString('Composition due to association with an eleme
nt with CSS filters applied.'), |
68 "overflowScrollingTouch": WebInspector.UIString("Composition due to associat
ion with an element with a \"overflow-scrolling: touch\" style."), | 199 'scrollDependentPosition': WebInspector.UIString( |
69 "blending": WebInspector.UIString("Composition due to association with an el
ement that has blend mode other than \"normal\"."), | 200 'Composition due to association with an element with a "position: fixed" o
r "position: sticky" style.'), |
70 "assumedOverlap": WebInspector.UIString("Composition due to association with
an element that may overlap other composited elements."), | 201 'overflowScrollingTouch': |
71 "overlap": WebInspector.UIString("Composition due to association with an ele
ment overlapping other composited elements."), | 202 WebInspector.UIString('Composition due to association with an element with
a "overflow-scrolling: touch" style.'), |
72 "negativeZIndexChildren": WebInspector.UIString("Composition due to associat
ion with an element with descendants that have a negative z-index."), | 203 'blending': |
73 "transformWithCompositedDescendants": WebInspector.UIString("Composition due
to association with an element with composited descendants."), | 204 WebInspector.UIString('Composition due to association with an element that
has blend mode other than "normal".'), |
74 "opacityWithCompositedDescendants": WebInspector.UIString("Composition due t
o association with an element with opacity applied and composited descendants.")
, | 205 'assumedOverlap': WebInspector.UIString( |
75 "maskWithCompositedDescendants": WebInspector.UIString("Composition due to a
ssociation with a masked element and composited descendants."), | 206 'Composition due to association with an element that may overlap other com
posited elements.'), |
76 "reflectionWithCompositedDescendants": WebInspector.UIString("Composition du
e to association with an element with a reflection and composited descendants.")
, | 207 'overlap': |
77 "filterWithCompositedDescendants": WebInspector.UIString("Composition due to
association with an element with CSS filters applied and composited descendants
."), | 208 WebInspector.UIString('Composition due to association with an element over
lapping other composited elements.'), |
78 "blendingWithCompositedDescendants": WebInspector.UIString("Composition due
to association with an element with CSS blending applied and composited descenda
nts."), | 209 'negativeZIndexChildren': WebInspector.UIString( |
79 "clipsCompositingDescendants": WebInspector.UIString("Composition due to ass
ociation with an element clipping compositing descendants."), | 210 'Composition due to association with an element with descendants that have
a negative z-index.'), |
80 "perspective": WebInspector.UIString("Composition due to association with an
element with perspective applied."), | 211 'transformWithCompositedDescendants': |
81 "preserve3D": WebInspector.UIString("Composition due to association with an
element with a \"transform-style: preserve-3d\" style."), | 212 WebInspector.UIString('Composition due to association with an element with
composited descendants.'), |
82 "root": WebInspector.UIString("Root layer."), | 213 'opacityWithCompositedDescendants': WebInspector.UIString( |
83 "layerForClip": WebInspector.UIString("Layer for clip."), | 214 'Composition due to association with an element with opacity applied and c
omposited descendants.'), |
84 "layerForScrollbar": WebInspector.UIString("Layer for scrollbar."), | 215 'maskWithCompositedDescendants': |
85 "layerForScrollingContainer": WebInspector.UIString("Layer for scrolling con
tainer."), | 216 WebInspector.UIString('Composition due to association with a masked elemen
t and composited descendants.'), |
86 "layerForForeground": WebInspector.UIString("Layer for foreground."), | 217 'reflectionWithCompositedDescendants': WebInspector.UIString( |
87 "layerForBackground": WebInspector.UIString("Layer for background."), | 218 'Composition due to association with an element with a reflection and comp
osited descendants.'), |
88 "layerForMask": WebInspector.UIString("Layer for mask."), | 219 'filterWithCompositedDescendants': WebInspector.UIString( |
89 "layerForVideoOverlay": WebInspector.UIString("Layer for video overlay."), | 220 'Composition due to association with an element with CSS filters applied a
nd composited descendants.'), |
| 221 'blendingWithCompositedDescendants': WebInspector.UIString( |
| 222 'Composition due to association with an element with CSS blending applied
and composited descendants.'), |
| 223 'clipsCompositingDescendants': |
| 224 WebInspector.UIString('Composition due to association with an element clip
ping compositing descendants.'), |
| 225 'perspective': WebInspector.UIString('Composition due to association with an e
lement with perspective applied.'), |
| 226 'preserve3D': WebInspector.UIString( |
| 227 'Composition due to association with an element with a "transform-style: p
reserve-3d" style.'), |
| 228 'root': WebInspector.UIString('Root layer.'), |
| 229 'layerForClip': WebInspector.UIString('Layer for clip.'), |
| 230 'layerForScrollbar': WebInspector.UIString('Layer for scrollbar.'), |
| 231 'layerForScrollingContainer': WebInspector.UIString('Layer for scrolling conta
iner.'), |
| 232 'layerForForeground': WebInspector.UIString('Layer for foreground.'), |
| 233 'layerForBackground': WebInspector.UIString('Layer for background.'), |
| 234 'layerForMask': WebInspector.UIString('Layer for mask.'), |
| 235 'layerForVideoOverlay': WebInspector.UIString('Layer for video overlay.'), |
90 }; | 236 }; |
91 | 237 |
92 WebInspector.LayerDetailsView._slowScrollRectNames = new Map([ | 238 WebInspector.LayerDetailsView._slowScrollRectNames = new Map([ |
93 [WebInspector.Layer.ScrollRectType.NonFastScrollable, WebInspector.UIString(
"Non fast scrollable")], | 239 [WebInspector.Layer.ScrollRectType.NonFastScrollable, WebInspector.UIString('N
on fast scrollable')], |
94 [WebInspector.Layer.ScrollRectType.TouchEventHandler, WebInspector.UIString(
"Touch event handler")], | 240 [WebInspector.Layer.ScrollRectType.TouchEventHandler, WebInspector.UIString('T
ouch event handler')], |
95 [WebInspector.Layer.ScrollRectType.WheelEventHandler,WebInspector.UIString("
Wheel event handler")], | 241 [WebInspector.Layer.ScrollRectType.WheelEventHandler, WebInspector.UIString('W
heel event handler')], |
96 [WebInspector.Layer.ScrollRectType.RepaintsOnScroll, WebInspector.UIString("
Repaints on scroll")] | 242 [WebInspector.Layer.ScrollRectType.RepaintsOnScroll, WebInspector.UIString('Re
paints on scroll')] |
97 ]); | 243 ]); |
98 | |
99 WebInspector.LayerDetailsView.prototype = { | |
100 /** | |
101 * @param {?WebInspector.LayerView.Selection} selection | |
102 * @override | |
103 */ | |
104 hoverObject: function(selection) { }, | |
105 | |
106 /** | |
107 * @param {?WebInspector.LayerView.Selection} selection | |
108 * @override | |
109 */ | |
110 selectObject: function(selection) | |
111 { | |
112 this._selection = selection; | |
113 if (this.isShowing()) | |
114 this.update(); | |
115 }, | |
116 | |
117 /** | |
118 * @param {?WebInspector.LayerTreeBase} layerTree | |
119 * @override | |
120 */ | |
121 setLayerTree: function(layerTree) { }, | |
122 | |
123 wasShown: function() | |
124 { | |
125 WebInspector.Widget.prototype.wasShown.call(this); | |
126 this.update(); | |
127 }, | |
128 | |
129 /** | |
130 * @param {number} index | |
131 * @param {!Event} event | |
132 */ | |
133 _onScrollRectClicked: function(index, event) | |
134 { | |
135 if (event.which !== 1) | |
136 return; | |
137 this._layerViewHost.selectObject(new WebInspector.LayerView.ScrollRectSe
lection(this._selection.layer(), index)); | |
138 }, | |
139 | |
140 _onPaintProfilerButtonClicked: function() | |
141 { | |
142 if (this._selection.type() === WebInspector.LayerView.Selection.Type.Sna
pshot || this._selection.layer()) | |
143 this.dispatchEventToListeners(WebInspector.LayerDetailsView.Events.P
aintProfilerRequested, this._selection); | |
144 }, | |
145 | |
146 /** | |
147 * @param {!LayerTreeAgent.ScrollRect} scrollRect | |
148 * @param {number} index | |
149 */ | |
150 _createScrollRectElement: function(scrollRect, index) | |
151 { | |
152 if (index) | |
153 this._scrollRectsCell.createTextChild(", "); | |
154 var element = this._scrollRectsCell.createChild("span", "scroll-rect"); | |
155 if (this._selection.scrollRectIndex === index) | |
156 element.classList.add("active"); | |
157 element.textContent = WebInspector.UIString("%s (%s, %s, %s, %s)", | |
158 WebInspector.LayerDetailsView._slowScrollRectNames.get(scrollRect.ty
pe), | |
159 scrollRect.rect.x, scrollRect.rect.y, scrollRect.rect.width, scrollR
ect.rect.height); | |
160 element.addEventListener("click", this._onScrollRectClicked.bind(this, i
ndex), false); | |
161 }, | |
162 | |
163 update: function() | |
164 { | |
165 var layer = this._selection && this._selection.layer(); | |
166 if (!layer) { | |
167 this._tableElement.remove(); | |
168 this._paintProfilerButton.remove(); | |
169 this._emptyWidget.show(this.contentElement); | |
170 return; | |
171 } | |
172 this._emptyWidget.detach(); | |
173 this.contentElement.appendChild(this._tableElement); | |
174 this.contentElement.appendChild(this._paintProfilerButton); | |
175 this._sizeCell.textContent = WebInspector.UIString("%d × %d (at %d,%d)",
layer.width(), layer.height(), layer.offsetX(), layer.offsetY()); | |
176 this._paintCountCell.parentElement.classList.toggle("hidden", !layer.pai
ntCount()); | |
177 this._paintCountCell.textContent = layer.paintCount(); | |
178 this._memoryEstimateCell.textContent = Number.bytesToString(layer.gpuMem
oryUsage()); | |
179 layer.requestCompositingReasons(this._updateCompositingReasons.bind(this
)); | |
180 this._scrollRectsCell.removeChildren(); | |
181 layer.scrollRects().forEach(this._createScrollRectElement.bind(this)); | |
182 var snapshot = this._selection.type() === WebInspector.LayerView.Selecti
on.Type.Snapshot ? /** @type {!WebInspector.LayerView.SnapshotSelection} */ (thi
s._selection).snapshot() : null; | |
183 this._paintProfilerButton.classList.toggle("hidden", !snapshot); | |
184 }, | |
185 | |
186 _buildContent: function() | |
187 { | |
188 this._tableElement = this.contentElement.createChild("table"); | |
189 this._tbodyElement = this._tableElement.createChild("tbody"); | |
190 this._sizeCell = this._createRow(WebInspector.UIString("Size")); | |
191 this._compositingReasonsCell = this._createRow(WebInspector.UIString("Co
mpositing Reasons")); | |
192 this._memoryEstimateCell = this._createRow(WebInspector.UIString("Memory
estimate")); | |
193 this._paintCountCell = this._createRow(WebInspector.UIString("Paint coun
t")); | |
194 this._scrollRectsCell = this._createRow(WebInspector.UIString("Slow scro
ll regions")); | |
195 this._paintProfilerButton = this.contentElement.createChild("a", "hidden
link"); | |
196 this._paintProfilerButton.textContent = WebInspector.UIString("Paint Pro
filer"); | |
197 this._paintProfilerButton.addEventListener("click", this._onPaintProfile
rButtonClicked.bind(this)); | |
198 }, | |
199 | |
200 /** | |
201 * @param {string} title | |
202 */ | |
203 _createRow: function(title) | |
204 { | |
205 var tr = this._tbodyElement.createChild("tr"); | |
206 var titleCell = tr.createChild("td"); | |
207 titleCell.textContent = title; | |
208 return tr.createChild("td"); | |
209 }, | |
210 | |
211 /** | |
212 * @param {!Array.<string>} compositingReasons | |
213 */ | |
214 _updateCompositingReasons: function(compositingReasons) | |
215 { | |
216 if (!compositingReasons || !compositingReasons.length) { | |
217 this._compositingReasonsCell.textContent = "n/a"; | |
218 return; | |
219 } | |
220 this._compositingReasonsCell.removeChildren(); | |
221 var list = this._compositingReasonsCell.createChild("ul"); | |
222 for (var i = 0; i < compositingReasons.length; ++i) { | |
223 var text = WebInspector.LayerDetailsView.CompositingReasonDetail[com
positingReasons[i]] || compositingReasons[i]; | |
224 // If the text is more than one word but does not terminate with per
iod, add the period. | |
225 if (/\s.*[^.]$/.test(text)) | |
226 text += "."; | |
227 list.createChild("li").textContent = text; | |
228 } | |
229 }, | |
230 | |
231 __proto__: WebInspector.Widget.prototype | |
232 }; | |
OLD | NEW |