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 StickyPositionConstraint(sticky_box_rect, containing_block_rect, nearest_layer_shifting_sticky_box=None, nearest_layer_shifting_containing_block=None)[source]#
Sticky position constraints.
- class PictureTile(x, y, picture)[source]#
Serialized fragment of layer picture along with its offset within the layer.
- class 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)[source]#
Information about a compositing layer.
-
draws_content:
bool# Indicates whether this layer hosts any content, rather than being used for transform/scrolling purposes only.
-
backend_node_id:
Optional[BackendNodeId] = None# The backend id for the node associated with this layer.
-
transform:
Optional[List[float]] = None# Transformation matrix for layer, default is identity matrix
-
scroll_rects:
Optional[List[ScrollRect]] = None# Rectangles scrolling on main thread only.
-
sticky_position_constraint:
Optional[StickyPositionConstraint] = None# Sticky position constraint information
-
draws_content:
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.
- compositing_reasons(layer_id)[source]#
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],Tuple[List[str],List[str]]]- Returns:
A tuple with the following items:
compositingReasons - A list of strings specifying reasons for the given layer to become composited.
compositingReasonIds - A list of strings specifying reason IDs for the given layer to become composited.
- load_snapshot(tiles)[source]#
Returns the snapshot identifier.
- Parameters:
tiles (
List[PictureTile]) – An array of tiles composing the snapshot.- Return type:
- Returns:
The id of the snapshot.
- profile_snapshot(snapshot_id, min_repeat_count=None, min_duration=None, clip_rect=None)[source]#
- 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.
- replay_snapshot(snapshot_id, from_step=None, to_step=None, scale=None)[source]#
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:
- Returns:
A data: URL for resulting image.
Events#
Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.