Index: third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.js b/third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.js |
index 24ab215229703ce5e88f58ad5b466444ee072525..0783adfc7f8ae3816e9daf93d0b4e3d784312885 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/LayerTreeBase.js |
@@ -1,7 +1,6 @@ |
// Copyright 2016 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
- |
/** @typedef {!{ |
rect: !DOMAgent.Rect, |
snapshot: !WebInspector.PaintProfilerSnapshot |
@@ -12,140 +11,140 @@ WebInspector.SnapshotWithRect; |
/** |
* @interface |
*/ |
-WebInspector.Layer = function() |
-{ |
-}; |
+WebInspector.Layer = function() {}; |
WebInspector.Layer.prototype = { |
- /** |
- * @return {string} |
- */ |
- id: function() { }, |
- |
- /** |
- * @return {?string} |
- */ |
- parentId: function() { }, |
- |
- /** |
- * @return {?WebInspector.Layer} |
- */ |
- parent: function() { }, |
- |
- /** |
- * @return {boolean} |
- */ |
- isRoot: function() { }, |
- |
- /** |
- * @return {!Array.<!WebInspector.Layer>} |
- */ |
- children: function() { }, |
- |
- /** |
- * @param {!WebInspector.Layer} child |
- */ |
- addChild: function(child) { }, |
- |
- /** |
- * @return {?WebInspector.DOMNode} |
- */ |
- node: function() { }, |
- |
- /** |
- * @return {?WebInspector.DOMNode} |
- */ |
- nodeForSelfOrAncestor: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- offsetX: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- offsetY: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- width: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- height: function() { }, |
- |
- /** |
- * @return {?Array.<number>} |
- */ |
- transform: function() { }, |
- |
- /** |
- * @return {!Array.<number>} |
- */ |
- quad: function() { }, |
- |
- /** |
- * @return {!Array.<number>} |
- */ |
- anchorPoint: function() { }, |
- |
- /** |
- * @return {boolean} |
- */ |
- invisible: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- paintCount: function() { }, |
- |
- /** |
- * @return {?DOMAgent.Rect} |
- */ |
- lastPaintRect: function() { }, |
- |
- /** |
- * @return {!Array.<!LayerTreeAgent.ScrollRect>} |
- */ |
- scrollRects: function() { }, |
- |
- /** |
- * @return {number} |
- */ |
- gpuMemoryUsage: function() { }, |
- |
- /** |
- * @param {function(!Array.<string>)} callback |
- */ |
- requestCompositingReasons: function(callback) { }, |
- |
- /** |
- * @return {boolean} |
- */ |
- drawsContent: function() { }, |
+ /** |
+ * @return {string} |
+ */ |
+ id: function() {}, |
+ |
+ /** |
+ * @return {?string} |
+ */ |
+ parentId: function() {}, |
+ |
+ /** |
+ * @return {?WebInspector.Layer} |
+ */ |
+ parent: function() {}, |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ isRoot: function() {}, |
+ |
+ /** |
+ * @return {!Array.<!WebInspector.Layer>} |
+ */ |
+ children: function() {}, |
+ |
+ /** |
+ * @param {!WebInspector.Layer} child |
+ */ |
+ addChild: function(child) {}, |
+ |
+ /** |
+ * @return {?WebInspector.DOMNode} |
+ */ |
+ node: function() {}, |
+ |
+ /** |
+ * @return {?WebInspector.DOMNode} |
+ */ |
+ nodeForSelfOrAncestor: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ offsetX: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ offsetY: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ width: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ height: function() {}, |
+ |
+ /** |
+ * @return {?Array.<number>} |
+ */ |
+ transform: function() {}, |
+ |
+ /** |
+ * @return {!Array.<number>} |
+ */ |
+ quad: function() {}, |
+ |
+ /** |
+ * @return {!Array.<number>} |
+ */ |
+ anchorPoint: function() {}, |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ invisible: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ paintCount: function() {}, |
+ |
+ /** |
+ * @return {?DOMAgent.Rect} |
+ */ |
+ lastPaintRect: function() {}, |
+ |
+ /** |
+ * @return {!Array.<!LayerTreeAgent.ScrollRect>} |
+ */ |
+ scrollRects: function() {}, |
+ |
+ /** |
+ * @return {number} |
+ */ |
+ gpuMemoryUsage: function() {}, |
+ |
+ /** |
+ * @param {function(!Array.<string>)} callback |
+ */ |
+ requestCompositingReasons: function(callback) {}, |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ drawsContent: function() {}, |
+ |
+ /** |
+ * @return {!Array<!Promise<?WebInspector.SnapshotWithRect>>} |
+ */ |
+ snapshots: function() {} |
+}; |
- /** |
- * @return {!Array<!Promise<?WebInspector.SnapshotWithRect>>} |
- */ |
- snapshots: function() { } |
-} |
- |
-WebInspector.Layer.ScrollRectType = { |
- NonFastScrollable: "NonFastScrollable", |
- TouchEventHandler: "TouchEventHandler", |
- WheelEventHandler: "WheelEventHandler", |
- RepaintsOnScroll: "RepaintsOnScroll" |
+ WebInspector.Layer.ScrollRectType = { |
+ NonFastScrollable: 'NonFastScrollable', |
+ TouchEventHandler: 'TouchEventHandler', |
+ WheelEventHandler: 'WheelEventHandler', |
+ RepaintsOnScroll: 'RepaintsOnScroll' |
}; |
/** |
- * @constructor |
- * @param {?WebInspector.Target} target |
- */ |
-WebInspector.LayerTreeBase = function(target) |
-{ |
+ * @unrestricted |
+ */ |
+WebInspector.LayerTreeBase = class { |
+ /** |
+ * @param {?WebInspector.Target} target |
+ */ |
+ constructor(target) { |
this._target = target; |
this._domModel = target ? WebInspector.DOMModel.fromTarget(target) : null; |
this._layersById = {}; |
@@ -153,124 +152,111 @@ WebInspector.LayerTreeBase = function(target) |
this._contentRoot = null; |
/** @type Map<number, ?WebInspector.DOMNode> */ |
this._backendNodeIdToNode = new Map(); |
-}; |
- |
-WebInspector.LayerTreeBase.prototype = { |
- /** |
- * @return {?WebInspector.Target} |
- */ |
- target: function() |
- { |
- return this._target; |
- }, |
- |
- /** |
- * @return {?WebInspector.Layer} |
- */ |
- root: function() |
- { |
- return this._root; |
- }, |
- |
- /** |
- * @param {?WebInspector.Layer} root |
- * @protected |
- */ |
- setRoot: function(root) |
- { |
- this._root = root; |
- }, |
- |
- /** |
- * @return {?WebInspector.Layer} |
- */ |
- contentRoot: function() |
- { |
- return this._contentRoot; |
- }, |
- |
- /** |
- * @param {?WebInspector.Layer} contentRoot |
- * @protected |
- */ |
- setContentRoot: function(contentRoot) |
- { |
- this._contentRoot = contentRoot; |
- }, |
- |
- /** |
- * @param {function(!WebInspector.Layer)} callback |
- * @param {?WebInspector.Layer=} root |
- * @return {boolean} |
- */ |
- forEachLayer: function(callback, root) |
- { |
- if (!root) { |
- root = this.root(); |
- if (!root) |
- return false; |
- } |
- return callback(root) || root.children().some(this.forEachLayer.bind(this, callback)); |
- }, |
- |
- /** |
- * @param {string} id |
- * @return {?WebInspector.Layer} |
- */ |
- layerById: function(id) |
- { |
- return this._layersById[id] || null; |
- }, |
- |
- /** |
- * @param {!Set<number>} requestedNodeIds |
- * @param {function()} callback |
- */ |
- _resolveBackendNodeIds: function(requestedNodeIds, callback) |
- { |
- if (!requestedNodeIds.size || !this._domModel) { |
- callback(); |
- return; |
- } |
- if (this._domModel) |
- this._domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateBackendNodeMap.bind(this)); |
- |
- /** |
- * @this {WebInspector.LayerTreeBase} |
- * @param {?Map<number, ?WebInspector.DOMNode>} nodesMap |
- */ |
- function populateBackendNodeMap(nodesMap) |
- { |
- if (nodesMap) { |
- for (var nodeId of nodesMap.keysArray()) |
- this._backendNodeIdToNode.set(nodeId, nodesMap.get(nodeId) || null); |
- } |
- callback(); |
- } |
- }, |
- |
- /** |
- * @param {!{width: number, height: number}} viewportSize |
- */ |
- setViewportSize: function(viewportSize) |
- { |
- this._viewportSize = viewportSize; |
- }, |
- |
- /** |
- * @return {!{width: number, height: number}|undefined} |
- */ |
- viewportSize: function() |
- { |
- return this._viewportSize; |
- }, |
+ } |
+ |
+ /** |
+ * @return {?WebInspector.Target} |
+ */ |
+ target() { |
+ return this._target; |
+ } |
+ |
+ /** |
+ * @return {?WebInspector.Layer} |
+ */ |
+ root() { |
+ return this._root; |
+ } |
+ |
+ /** |
+ * @param {?WebInspector.Layer} root |
+ * @protected |
+ */ |
+ setRoot(root) { |
+ this._root = root; |
+ } |
+ |
+ /** |
+ * @return {?WebInspector.Layer} |
+ */ |
+ contentRoot() { |
+ return this._contentRoot; |
+ } |
+ |
+ /** |
+ * @param {?WebInspector.Layer} contentRoot |
+ * @protected |
+ */ |
+ setContentRoot(contentRoot) { |
+ this._contentRoot = contentRoot; |
+ } |
+ |
+ /** |
+ * @param {function(!WebInspector.Layer)} callback |
+ * @param {?WebInspector.Layer=} root |
+ * @return {boolean} |
+ */ |
+ forEachLayer(callback, root) { |
+ if (!root) { |
+ root = this.root(); |
+ if (!root) |
+ return false; |
+ } |
+ return callback(root) || root.children().some(this.forEachLayer.bind(this, callback)); |
+ } |
+ |
+ /** |
+ * @param {string} id |
+ * @return {?WebInspector.Layer} |
+ */ |
+ layerById(id) { |
+ return this._layersById[id] || null; |
+ } |
+ |
+ /** |
+ * @param {!Set<number>} requestedNodeIds |
+ * @param {function()} callback |
+ */ |
+ _resolveBackendNodeIds(requestedNodeIds, callback) { |
+ if (!requestedNodeIds.size || !this._domModel) { |
+ callback(); |
+ return; |
+ } |
+ if (this._domModel) |
+ this._domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateBackendNodeMap.bind(this)); |
/** |
- * @param {number} id |
- * @return {?WebInspector.DOMNode} |
+ * @this {WebInspector.LayerTreeBase} |
+ * @param {?Map<number, ?WebInspector.DOMNode>} nodesMap |
*/ |
- _nodeForId: function(id) |
- { |
- return this._domModel ? this._domModel.nodeForId(id) : null; |
+ function populateBackendNodeMap(nodesMap) { |
+ if (nodesMap) { |
+ for (var nodeId of nodesMap.keysArray()) |
+ this._backendNodeIdToNode.set(nodeId, nodesMap.get(nodeId) || null); |
+ } |
+ callback(); |
} |
+ } |
+ |
+ /** |
+ * @param {!{width: number, height: number}} viewportSize |
+ */ |
+ setViewportSize(viewportSize) { |
+ this._viewportSize = viewportSize; |
+ } |
+ |
+ /** |
+ * @return {!{width: number, height: number}|undefined} |
+ */ |
+ viewportSize() { |
+ return this._viewportSize; |
+ } |
+ |
+ /** |
+ * @param {number} id |
+ * @return {?WebInspector.DOMNode} |
+ */ |
+ _nodeForId(id) { |
+ return this._domModel ? this._domModel.nodeForId(id) : null; |
+ } |
}; |