LayerTree¶
This CDP domain is experimental.
Types¶
Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.
-
class
cdp.layer_tree.
LayerId
¶ Unique Layer identifier.
-
class
cdp.layer_tree.
SnapshotId
¶ Unique snapshot identifier.
-
class
cdp.layer_tree.
ScrollRect
(rect, type_)¶ Rectangle where scrolling happens on the main thread.
-
rect
= None¶ Rectangle itself.
-
type_
= None¶ Reason for rectangle to force scrolling on the main thread
-
-
class
cdp.layer_tree.
StickyPositionConstraint
(sticky_box_rect, containing_block_rect, nearest_layer_shifting_sticky_box=None, nearest_layer_shifting_containing_block=None)¶ Sticky position constraints.
-
containing_block_rect
= None¶ Layout rectangle of the containing block of the sticky element
-
nearest_layer_shifting_containing_block
= None¶ The nearest sticky layer that shifts the containing block
-
nearest_layer_shifting_sticky_box
= None¶ The nearest sticky layer that shifts the sticky box
-
sticky_box_rect
= None¶ Layout rectangle of the sticky element before being shifted
-
-
class
cdp.layer_tree.
PictureTile
(x, y, picture)¶ Serialized fragment of layer picture along with its offset within the layer.
-
picture
= None¶ Base64-encoded snapshot data.
-
x
= None¶ Offset from owning layer left boundary
-
y
= None¶ Offset from owning layer top boundary
-
-
class
cdp.layer_tree.
Layer
(layer_id, offset_x, offset_y, width, height, paint_count, draws_content, parent_layer_id=None, backend_node_id=None, transform=None, anchor_x=None, anchor_y=None, anchor_z=None, invisible=None, scroll_rects=None, sticky_position_constraint=None)¶ Information about a compositing layer.
-
anchor_x
= None¶ Transform anchor point X, absent if no transform specified
-
anchor_y
= None¶ Transform anchor point Y, absent if no transform specified
-
anchor_z
= None¶ Transform anchor point Z, absent if no transform specified
-
backend_node_id
= None¶ The backend id for the node associated with this layer.
-
draws_content
= None¶ Indicates whether this layer hosts any content, rather than being used for transform/scrolling purposes only.
-
height
= None¶ Layer height.
-
invisible
= None¶ Set if layer is not visible.
-
layer_id
= None¶ The unique id for this layer.
-
offset_x
= None¶ Offset from parent layer, X coordinate.
-
offset_y
= None¶ Offset from parent layer, Y coordinate.
-
paint_count
= None¶ Indicates how many time this layer has painted.
-
parent_layer_id
= None¶ The id of parent (not present for root).
-
scroll_rects
= None¶ Rectangles scrolling on main thread only.
-
sticky_position_constraint
= None¶ Sticky position constraint information
-
transform
= None¶ Transformation matrix for layer, default is identity matrix
-
width
= None¶ Layer width.
-
-
class
cdp.layer_tree.
PaintProfile
¶ Array of timings, one per paint step.
Commands¶
Each command is a generator function. The return
type Generator[x, y, z]
indicates that the generator
yields arguments of type x
, it must be resumed with
an argument of type y
, and it returns type z
. In
this library, types x
and y
are the same for all
commands, and z
is the return type you should pay attention
to. For more information, see
Getting Started: Commands.
-
cdp.layer_tree.
compositing_reasons
(layer_id)¶ Provides the reasons why the given layer was composited.
Parameters: layer_id ( LayerId
) – The id of the layer for which we want to get the reasons it was composited.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[str
]]Returns: A list of strings specifying reasons for the given layer to become composited.
-
cdp.layer_tree.
disable
()¶ Disables compositing tree inspection.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.layer_tree.
enable
()¶ Enables compositing tree inspection.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.layer_tree.
load_snapshot
(tiles)¶ Returns the snapshot identifier.
Parameters: tiles ( List
[PictureTile
]) – An array of tiles composing the snapshot.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],SnapshotId
]Returns: The id of the snapshot.
-
cdp.layer_tree.
make_snapshot
(layer_id)¶ Returns the layer snapshot identifier.
Parameters: layer_id ( LayerId
) – The id of the layer.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],SnapshotId
]Returns: The id of the layer snapshot.
-
cdp.layer_tree.
profile_snapshot
(snapshot_id, min_repeat_count=None, min_duration=None, clip_rect=None)¶ Parameters: - snapshot_id (
SnapshotId
) – The id of the layer snapshot. - min_repeat_count (
Optional
[int
]) – (Optional) The maximum number of times to replay the snapshot (1, if not specified). - min_duration (
Optional
[float
]) – (Optional) The minimum duration (in seconds) to replay the snapshot. - clip_rect (
Optional
[Rect
]) – (Optional) The clip rectangle to apply when replaying the snapshot.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[PaintProfile
]]Returns: The array of paint profiles, one per run.
- snapshot_id (
-
cdp.layer_tree.
release_snapshot
(snapshot_id)¶ Releases layer snapshot captured by the back-end.
Parameters: snapshot_id ( SnapshotId
) – The id of the layer snapshot.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.layer_tree.
replay_snapshot
(snapshot_id, from_step=None, to_step=None, scale=None)¶ Replays the layer snapshot and returns the resulting bitmap.
Parameters: - snapshot_id (
SnapshotId
) – The id of the layer snapshot. - from_step (
Optional
[int
]) – (Optional) The first step to replay from (replay from the very start if not specified). - to_step (
Optional
[int
]) – (Optional) The last step to replay to (replay till the end if not specified). - scale (
Optional
[float
]) – (Optional) The scale to apply while replaying (defaults to 1).
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],str
]Returns: A data: URL for resulting image.
- snapshot_id (
-
cdp.layer_tree.
snapshot_command_log
(snapshot_id)¶ Replays the layer snapshot and returns canvas log.
Parameters: snapshot_id ( SnapshotId
) – The id of the layer snapshot.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[dict
]]Returns: The array of canvas function calls.