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

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

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

Powered by Google App Engine
This is Rietveld 408576698