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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** @typedef {!{ 4 /** @typedef {!{
5 rect: !Protocol.DOM.Rect, 5 rect: !Protocol.DOM.Rect,
6 snapshot: !WebInspector.PaintProfilerSnapshot 6 snapshot: !SDK.PaintProfilerSnapshot
7 }} 7 }}
8 */ 8 */
9 WebInspector.SnapshotWithRect; 9 SDK.SnapshotWithRect;
10 10
11 /** 11 /**
12 * @interface 12 * @interface
13 */ 13 */
14 WebInspector.Layer = function() {}; 14 SDK.Layer = function() {};
15 15
16 WebInspector.Layer.prototype = { 16 SDK.Layer.prototype = {
17 /** 17 /**
18 * @return {string} 18 * @return {string}
19 */ 19 */
20 id: function() {}, 20 id: function() {},
21 21
22 /** 22 /**
23 * @return {?string} 23 * @return {?string}
24 */ 24 */
25 parentId: function() {}, 25 parentId: function() {},
26 26
27 /** 27 /**
28 * @return {?WebInspector.Layer} 28 * @return {?SDK.Layer}
29 */ 29 */
30 parent: function() {}, 30 parent: function() {},
31 31
32 /** 32 /**
33 * @return {boolean} 33 * @return {boolean}
34 */ 34 */
35 isRoot: function() {}, 35 isRoot: function() {},
36 36
37 /** 37 /**
38 * @return {!Array.<!WebInspector.Layer>} 38 * @return {!Array.<!SDK.Layer>}
39 */ 39 */
40 children: function() {}, 40 children: function() {},
41 41
42 /** 42 /**
43 * @param {!WebInspector.Layer} child 43 * @param {!SDK.Layer} child
44 */ 44 */
45 addChild: function(child) {}, 45 addChild: function(child) {},
46 46
47 /** 47 /**
48 * @return {?WebInspector.DOMNode} 48 * @return {?SDK.DOMNode}
49 */ 49 */
50 node: function() {}, 50 node: function() {},
51 51
52 /** 52 /**
53 * @return {?WebInspector.DOMNode} 53 * @return {?SDK.DOMNode}
54 */ 54 */
55 nodeForSelfOrAncestor: function() {}, 55 nodeForSelfOrAncestor: function() {},
56 56
57 /** 57 /**
58 * @return {number} 58 * @return {number}
59 */ 59 */
60 offsetX: function() {}, 60 offsetX: function() {},
61 61
62 /** 62 /**
63 * @return {number} 63 * @return {number}
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * @param {function(!Array.<string>)} callback 118 * @param {function(!Array.<string>)} callback
119 */ 119 */
120 requestCompositingReasons: function(callback) {}, 120 requestCompositingReasons: function(callback) {},
121 121
122 /** 122 /**
123 * @return {boolean} 123 * @return {boolean}
124 */ 124 */
125 drawsContent: function() {}, 125 drawsContent: function() {},
126 126
127 /** 127 /**
128 * @return {!Array<!Promise<?WebInspector.SnapshotWithRect>>} 128 * @return {!Array<!Promise<?SDK.SnapshotWithRect>>}
129 */ 129 */
130 snapshots: function() {} 130 snapshots: function() {}
131 }; 131 };
132 132
133 WebInspector.Layer.ScrollRectType = { 133 SDK.Layer.ScrollRectType = {
134 NonFastScrollable: 'NonFastScrollable', 134 NonFastScrollable: 'NonFastScrollable',
135 TouchEventHandler: 'TouchEventHandler', 135 TouchEventHandler: 'TouchEventHandler',
136 WheelEventHandler: 'WheelEventHandler', 136 WheelEventHandler: 'WheelEventHandler',
137 RepaintsOnScroll: 'RepaintsOnScroll' 137 RepaintsOnScroll: 'RepaintsOnScroll'
138 }; 138 };
139 139
140 /** 140 /**
141 * @unrestricted 141 * @unrestricted
142 */ 142 */
143 WebInspector.LayerTreeBase = class { 143 SDK.LayerTreeBase = class {
144 /** 144 /**
145 * @param {?WebInspector.Target} target 145 * @param {?SDK.Target} target
146 */ 146 */
147 constructor(target) { 147 constructor(target) {
148 this._target = target; 148 this._target = target;
149 this._domModel = target ? WebInspector.DOMModel.fromTarget(target) : null; 149 this._domModel = target ? SDK.DOMModel.fromTarget(target) : null;
150 this._layersById = {}; 150 this._layersById = {};
151 this._root = null; 151 this._root = null;
152 this._contentRoot = null; 152 this._contentRoot = null;
153 /** @type Map<number, ?WebInspector.DOMNode> */ 153 /** @type Map<number, ?SDK.DOMNode> */
154 this._backendNodeIdToNode = new Map(); 154 this._backendNodeIdToNode = new Map();
155 } 155 }
156 156
157 /** 157 /**
158 * @return {?WebInspector.Target} 158 * @return {?SDK.Target}
159 */ 159 */
160 target() { 160 target() {
161 return this._target; 161 return this._target;
162 } 162 }
163 163
164 /** 164 /**
165 * @return {?WebInspector.Layer} 165 * @return {?SDK.Layer}
166 */ 166 */
167 root() { 167 root() {
168 return this._root; 168 return this._root;
169 } 169 }
170 170
171 /** 171 /**
172 * @param {?WebInspector.Layer} root 172 * @param {?SDK.Layer} root
173 * @protected 173 * @protected
174 */ 174 */
175 setRoot(root) { 175 setRoot(root) {
176 this._root = root; 176 this._root = root;
177 } 177 }
178 178
179 /** 179 /**
180 * @return {?WebInspector.Layer} 180 * @return {?SDK.Layer}
181 */ 181 */
182 contentRoot() { 182 contentRoot() {
183 return this._contentRoot; 183 return this._contentRoot;
184 } 184 }
185 185
186 /** 186 /**
187 * @param {?WebInspector.Layer} contentRoot 187 * @param {?SDK.Layer} contentRoot
188 * @protected 188 * @protected
189 */ 189 */
190 setContentRoot(contentRoot) { 190 setContentRoot(contentRoot) {
191 this._contentRoot = contentRoot; 191 this._contentRoot = contentRoot;
192 } 192 }
193 193
194 /** 194 /**
195 * @param {function(!WebInspector.Layer)} callback 195 * @param {function(!SDK.Layer)} callback
196 * @param {?WebInspector.Layer=} root 196 * @param {?SDK.Layer=} root
197 * @return {boolean} 197 * @return {boolean}
198 */ 198 */
199 forEachLayer(callback, root) { 199 forEachLayer(callback, root) {
200 if (!root) { 200 if (!root) {
201 root = this.root(); 201 root = this.root();
202 if (!root) 202 if (!root)
203 return false; 203 return false;
204 } 204 }
205 return callback(root) || root.children().some(this.forEachLayer.bind(this, c allback)); 205 return callback(root) || root.children().some(this.forEachLayer.bind(this, c allback));
206 } 206 }
207 207
208 /** 208 /**
209 * @param {string} id 209 * @param {string} id
210 * @return {?WebInspector.Layer} 210 * @return {?SDK.Layer}
211 */ 211 */
212 layerById(id) { 212 layerById(id) {
213 return this._layersById[id] || null; 213 return this._layersById[id] || null;
214 } 214 }
215 215
216 /** 216 /**
217 * @param {!Set<number>} requestedNodeIds 217 * @param {!Set<number>} requestedNodeIds
218 * @param {function()} callback 218 * @param {function()} callback
219 */ 219 */
220 _resolveBackendNodeIds(requestedNodeIds, callback) { 220 _resolveBackendNodeIds(requestedNodeIds, callback) {
221 if (!requestedNodeIds.size || !this._domModel) { 221 if (!requestedNodeIds.size || !this._domModel) {
222 callback(); 222 callback();
223 return; 223 return;
224 } 224 }
225 if (this._domModel) 225 if (this._domModel)
226 this._domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateB ackendNodeMap.bind(this)); 226 this._domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateB ackendNodeMap.bind(this));
227 227
228 /** 228 /**
229 * @this {WebInspector.LayerTreeBase} 229 * @this {SDK.LayerTreeBase}
230 * @param {?Map<number, ?WebInspector.DOMNode>} nodesMap 230 * @param {?Map<number, ?SDK.DOMNode>} nodesMap
231 */ 231 */
232 function populateBackendNodeMap(nodesMap) { 232 function populateBackendNodeMap(nodesMap) {
233 if (nodesMap) { 233 if (nodesMap) {
234 for (var nodeId of nodesMap.keysArray()) 234 for (var nodeId of nodesMap.keysArray())
235 this._backendNodeIdToNode.set(nodeId, nodesMap.get(nodeId) || null); 235 this._backendNodeIdToNode.set(nodeId, nodesMap.get(nodeId) || null);
236 } 236 }
237 callback(); 237 callback();
238 } 238 }
239 } 239 }
240 240
241 /** 241 /**
242 * @param {!{width: number, height: number}} viewportSize 242 * @param {!{width: number, height: number}} viewportSize
243 */ 243 */
244 setViewportSize(viewportSize) { 244 setViewportSize(viewportSize) {
245 this._viewportSize = viewportSize; 245 this._viewportSize = viewportSize;
246 } 246 }
247 247
248 /** 248 /**
249 * @return {!{width: number, height: number}|undefined} 249 * @return {!{width: number, height: number}|undefined}
250 */ 250 */
251 viewportSize() { 251 viewportSize() {
252 return this._viewportSize; 252 return this._viewportSize;
253 } 253 }
254 254
255 /** 255 /**
256 * @param {number} id 256 * @param {number} id
257 * @return {?WebInspector.DOMNode} 257 * @return {?SDK.DOMNode}
258 */ 258 */
259 _nodeForId(id) { 259 _nodeForId(id) {
260 return this._domModel ? this._domModel.nodeForId(id) : null; 260 return this._domModel ? this._domModel.nodeForId(id) : null;
261 } 261 }
262 }; 262 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698