mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 13:44:39 +08:00
Move and rename files. NOAUTOREVERT=true NOPRESUBMIT=true NOTREECHECKS=true Bug: 768828 TBR=darin@chromium.org NOTRY=true Change-Id: I66d3b155808bc5bdbf237b80208e1e552bcf7f28 Reviewed-on: https://chromium-review.googlesource.com/1001153 Reviewed-by: Blink Reformat <blink-reformat@chromium.org> Commit-Queue: Blink Reformat <blink-reformat@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#549061} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0aee4434a4dba42a42abaea9bfbc0cd196a63bc1
317 lines
5.7 KiB
JavaScript
317 lines
5.7 KiB
JavaScript
// 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: !Protocol.DOM.Rect,
|
|
snapshot: !SDK.PaintProfilerSnapshot
|
|
}}
|
|
*/
|
|
SDK.SnapshotWithRect;
|
|
|
|
/**
|
|
* @interface
|
|
*/
|
|
SDK.Layer = function() {};
|
|
|
|
SDK.Layer.prototype = {
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
id() {},
|
|
|
|
/**
|
|
* @return {?string}
|
|
*/
|
|
parentId() {},
|
|
|
|
/**
|
|
* @return {?SDK.Layer}
|
|
*/
|
|
parent() {},
|
|
|
|
/**
|
|
* @return {boolean}
|
|
*/
|
|
isRoot() {},
|
|
|
|
/**
|
|
* @return {!Array.<!SDK.Layer>}
|
|
*/
|
|
children() {},
|
|
|
|
/**
|
|
* @param {!SDK.Layer} child
|
|
*/
|
|
addChild(child) {},
|
|
|
|
/**
|
|
* @return {?SDK.DOMNode}
|
|
*/
|
|
node() {},
|
|
|
|
/**
|
|
* @return {?SDK.DOMNode}
|
|
*/
|
|
nodeForSelfOrAncestor() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
offsetX() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
offsetY() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
width() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
height() {},
|
|
|
|
/**
|
|
* @return {?Array.<number>}
|
|
*/
|
|
transform() {},
|
|
|
|
/**
|
|
* @return {!Array.<number>}
|
|
*/
|
|
quad() {},
|
|
|
|
/**
|
|
* @return {!Array.<number>}
|
|
*/
|
|
anchorPoint() {},
|
|
|
|
/**
|
|
* @return {boolean}
|
|
*/
|
|
invisible() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
paintCount() {},
|
|
|
|
/**
|
|
* @return {?Protocol.DOM.Rect}
|
|
*/
|
|
lastPaintRect() {},
|
|
|
|
/**
|
|
* @return {!Array.<!Protocol.LayerTree.ScrollRect>}
|
|
*/
|
|
scrollRects() {},
|
|
|
|
/**
|
|
* @return {?SDK.Layer.StickyPositionConstraint}
|
|
*/
|
|
stickyPositionConstraint() {},
|
|
|
|
/**
|
|
* @return {number}
|
|
*/
|
|
gpuMemoryUsage() {},
|
|
|
|
/**
|
|
* @return {!Promise<!Array<string>>}
|
|
*/
|
|
requestCompositingReasons() {},
|
|
|
|
/**
|
|
* @return {boolean}
|
|
*/
|
|
drawsContent() {},
|
|
|
|
/**
|
|
* @return {!Array<!Promise<?SDK.SnapshotWithRect>>}
|
|
*/
|
|
snapshots() {}
|
|
};
|
|
|
|
SDK.Layer.ScrollRectType = {
|
|
NonFastScrollable: 'NonFastScrollable',
|
|
TouchEventHandler: 'TouchEventHandler',
|
|
WheelEventHandler: 'WheelEventHandler',
|
|
RepaintsOnScroll: 'RepaintsOnScroll'
|
|
};
|
|
|
|
SDK.Layer.StickyPositionConstraint = class {
|
|
/**
|
|
* @param {?SDK.LayerTreeBase} layerTree
|
|
* @param {!Protocol.LayerTree.StickyPositionConstraint} constraint
|
|
* @struct
|
|
*/
|
|
constructor(layerTree, constraint) {
|
|
/** @type {!Protocol.DOM.Rect} */
|
|
this._stickyBoxRect = constraint.stickyBoxRect;
|
|
/** @type {!Protocol.DOM.Rect} */
|
|
this._containingBlockRect = constraint.containingBlockRect;
|
|
/** @type {?SDK.Layer} */
|
|
this._nearestLayerShiftingStickyBox = null;
|
|
if (layerTree && constraint.nearestLayerShiftingStickyBox)
|
|
this._nearestLayerShiftingStickyBox = layerTree.layerById(constraint.nearestLayerShiftingStickyBox);
|
|
|
|
/** @type {?SDK.Layer} */
|
|
this._nearestLayerShiftingContainingBlock = null;
|
|
if (layerTree && constraint.nearestLayerShiftingContainingBlock)
|
|
this._nearestLayerShiftingContainingBlock = layerTree.layerById(constraint.nearestLayerShiftingContainingBlock);
|
|
}
|
|
|
|
/**
|
|
* @return {!Protocol.DOM.Rect}
|
|
*/
|
|
stickyBoxRect() {
|
|
return this._stickyBoxRect;
|
|
}
|
|
|
|
/**
|
|
* @return {!Protocol.DOM.Rect}
|
|
*/
|
|
containingBlockRect() {
|
|
return this._containingBlockRect;
|
|
}
|
|
|
|
/**
|
|
* @return {?SDK.Layer}
|
|
*/
|
|
nearestLayerShiftingStickyBox() {
|
|
return this._nearestLayerShiftingStickyBox;
|
|
}
|
|
|
|
/**
|
|
* @return {?SDK.Layer}
|
|
*/
|
|
nearestLayerShiftingContainingBlock() {
|
|
return this._nearestLayerShiftingContainingBlock;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
SDK.LayerTreeBase = class {
|
|
/**
|
|
* @param {?SDK.Target} target
|
|
*/
|
|
constructor(target) {
|
|
this._target = target;
|
|
this._domModel = target ? target.model(SDK.DOMModel) : null;
|
|
this._layersById = {};
|
|
this._root = null;
|
|
this._contentRoot = null;
|
|
/** @type {!Map<number, ?SDK.DOMNode>} */
|
|
this._backendNodeIdToNode = new Map();
|
|
}
|
|
|
|
/**
|
|
* @return {?SDK.Target}
|
|
*/
|
|
target() {
|
|
return this._target;
|
|
}
|
|
|
|
/**
|
|
* @return {?SDK.Layer}
|
|
*/
|
|
root() {
|
|
return this._root;
|
|
}
|
|
|
|
/**
|
|
* @param {?SDK.Layer} root
|
|
* @protected
|
|
*/
|
|
setRoot(root) {
|
|
this._root = root;
|
|
}
|
|
|
|
/**
|
|
* @return {?SDK.Layer}
|
|
*/
|
|
contentRoot() {
|
|
return this._contentRoot;
|
|
}
|
|
|
|
/**
|
|
* @param {?SDK.Layer} contentRoot
|
|
* @protected
|
|
*/
|
|
setContentRoot(contentRoot) {
|
|
this._contentRoot = contentRoot;
|
|
}
|
|
|
|
/**
|
|
* @param {function(!SDK.Layer)} callback
|
|
* @param {?SDK.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 {?SDK.Layer}
|
|
*/
|
|
layerById(id) {
|
|
return this._layersById[id] || null;
|
|
}
|
|
|
|
/**
|
|
* @param {!Set<number>} requestedNodeIds
|
|
* @return {!Promise}
|
|
*/
|
|
async resolveBackendNodeIds(requestedNodeIds) {
|
|
if (!requestedNodeIds.size || !this._domModel)
|
|
return;
|
|
|
|
const nodesMap = await this._domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds);
|
|
|
|
if (!nodesMap)
|
|
return;
|
|
for (const nodeId of nodesMap.keysArray())
|
|
this._backendNodeIdToNode.set(nodeId, nodesMap.get(nodeId) || null);
|
|
}
|
|
|
|
/**
|
|
* @return {!Map<number, ?SDK.DOMNode>}
|
|
*/
|
|
backendNodeIdToNode() {
|
|
return this._backendNodeIdToNode;
|
|
}
|
|
|
|
/**
|
|
* @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 {?SDK.DOMNode}
|
|
*/
|
|
_nodeForId(id) {
|
|
return this._domModel ? this._domModel.nodeForId(id) : null;
|
|
}
|
|
};
|