CSS#
This domain exposes CSS read/write operations. All CSS objects (stylesheets, rules, and styles)
have an associated id used in subsequent operations on the related object. Each object type has
a specific id structure, and those are not interchangeable between objects of different kinds.
CSS objects can be loaded using the get*ForNode() calls (which accept a DOM node id). A client
can also keep track of stylesheets via the styleSheetAdded/styleSheetRemoved events and
subsequently load the required stylesheet contents using the getStyleSheet[Text]() methods.
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 StyleSheetOrigin(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Stylesheet type: “injected” for stylesheets injected via extension, “user-agent” for user-agent stylesheets, “inspector” for stylesheets created by the inspector (i.e. those holding the “via inspector” rules), “regular” for regular stylesheets.
- INJECTED = 'injected'#
- USER_AGENT = 'user-agent'#
- INSPECTOR = 'inspector'#
- REGULAR = 'regular'#
- class PseudoElementMatches(pseudo_type, matches, pseudo_identifier=None)[source]#
CSS rule collection for a single pseudo style.
-
pseudo_type:
PseudoType# Pseudo element type.
-
pseudo_type:
- class CSSAnimationStyle(style, name=None)[source]#
CSS style coming from animations with the name of the animation.
- class InheritedStyleEntry(matched_css_rules, inline_style=None)[source]#
Inherited CSS rule collection from ancestor node.
- class InheritedAnimatedStyleEntry(animation_styles=None, transitions_style=None)[source]#
Inherited CSS style collection for animated styles from ancestor node.
-
animation_styles:
Optional[List[CSSAnimationStyle]] = None# Styles coming from the animations of the ancestor, if any, in the style inheritance chain.
-
animation_styles:
- class InheritedPseudoElementMatches(pseudo_elements)[source]#
Inherited pseudo element matches from pseudos of an ancestor node.
-
pseudo_elements:
List[PseudoElementMatches]# Matches of pseudo styles from the pseudos of an ancestor node.
-
pseudo_elements:
- class Value(text, range_=None, specificity=None)[source]#
Data for a simple selector (these are delimited by commas in a selector list).
-
range_:
Optional[SourceRange] = None# Value range in the underlying resource (if available).
-
specificity:
Optional[Specificity] = None# Specificity of the selector.
-
range_:
- class Specificity(a, b, c)[source]#
Specificity: https://drafts.csswg.org/selectors/#specificity-rules
- class CSSStyleSheetHeader(style_sheet_id, frame_id, source_url, origin, title, disabled, is_inline, is_mutable, is_constructed, start_line, start_column, length, end_line, end_column, source_map_url=None, owner_node=None, has_source_url=None, loading_failed=None)[source]#
CSS stylesheet metainformation.
-
style_sheet_id:
StyleSheetId# The stylesheet identifier.
-
source_url:
str# Stylesheet resource URL. Empty if this is a constructed stylesheet created using new CSSStyleSheet() (but non-empty if this is a constructed stylesheet imported as a CSS module script).
-
origin:
StyleSheetOrigin# Stylesheet origin.
-
is_inline:
bool# Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
-
is_mutable:
bool# Whether this stylesheet is mutable. Inline stylesheets become mutable after they have been modified via CSSOM API.
<link>element’s stylesheets become mutable only if DevTools modifies them. Constructed stylesheets (new CSSStyleSheet()) are mutable immediately after creation.
-
is_constructed:
bool# True if this stylesheet is created through new CSSStyleSheet() or imported as a CSS module script.
-
owner_node:
Optional[BackendNodeId] = None# The backend id for the owner node of the stylesheet.
-
style_sheet_id:
- class CSSRule(selector_list, origin, style, style_sheet_id=None, nesting_selectors=None, media=None, container_queries=None, supports=None, layers=None, scopes=None, rule_types=None, starting_styles=None)[source]#
CSS rule representation.
-
selector_list:
SelectorList# Rule selector data.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
nesting_selectors:
Optional[List[str]] = None# Array of selectors from ancestor style rules, sorted by distance from the current rule.
-
media:
Optional[List[CSSMedia]] = None# Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
-
container_queries:
Optional[List[CSSContainerQuery]] = None# Container query list array (for rules involving container queries). The array enumerates container queries starting with the innermost one, going outwards.
-
supports:
Optional[List[CSSSupports]] = None# @supports CSS at-rule array. The array enumerates @supports at-rules starting with the innermost one, going outwards.
-
layers:
Optional[List[CSSLayer]] = None# Cascade layer array. Contains the layer hierarchy that this rule belongs to starting with the innermost layer and going outwards.
-
scopes:
Optional[List[CSSScope]] = None# @scope CSS at-rule array. The array enumerates @scope at-rules starting with the innermost one, going outwards.
-
rule_types:
Optional[List[CSSRuleType]] = None# The array keeps the types of ancestor CSSRules from the innermost going outwards.
-
starting_styles:
Optional[List[CSSStartingStyle]] = None# @starting-style CSS at-rule array. The array enumerates @starting-style at-rules starting with the innermost one, going outwards.
-
selector_list:
- class CSSRuleType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Enum indicating the type of a CSS rule, used to represent the order of a style rule’s ancestors. This list only contains rule types that are collected during the ancestor rule collection.
- MEDIA_RULE = 'MediaRule'#
- SUPPORTS_RULE = 'SupportsRule'#
- CONTAINER_RULE = 'ContainerRule'#
- LAYER_RULE = 'LayerRule'#
- SCOPE_RULE = 'ScopeRule'#
- STYLE_RULE = 'StyleRule'#
- STARTING_STYLE_RULE = 'StartingStyleRule'#
- class RuleUsage(style_sheet_id, start_offset, end_offset, used)[source]#
CSS coverage information.
-
style_sheet_id:
StyleSheetId# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
style_sheet_id:
- class SourceRange(start_line, start_column, end_line, end_column)[source]#
Text range within a resource. All numbers are zero-based.
- class CSSStyle(css_properties, shorthand_entries, style_sheet_id=None, css_text=None, range_=None)[source]#
CSS style representation.
-
css_properties:
List[CSSProperty]# CSS properties in the style.
-
shorthand_entries:
List[ShorthandEntry]# Computed values for all shorthands found in the style.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
range_:
Optional[SourceRange] = None# Style declaration range in the enclosing stylesheet (if available).
-
css_properties:
- class CSSProperty(name, value, important=None, implicit=None, text=None, parsed_ok=None, disabled=None, range_=None, longhand_properties=None)[source]#
CSS property declaration data.
-
important:
Optional[bool] = None# Whether the property has “!important” annotation (implies
falseif absent).
-
parsed_ok:
Optional[bool] = None# Whether the property is understood by the browser (implies
trueif absent).
-
disabled:
Optional[bool] = None# Whether the property is disabled by the user (present for source-based properties only).
-
range_:
Optional[SourceRange] = None# The entire property range in the enclosing style declaration (if available).
-
longhand_properties:
Optional[List[CSSProperty]] = None# Parsed longhand components of this property if it is a shorthand. This field will be empty if the given property is not a shorthand.
-
important:
- class CSSMedia(text, source, source_url=None, range_=None, style_sheet_id=None, media_list=None)[source]#
CSS media rule descriptor.
-
source:
str# “mediaRule” if specified by a @media rule, “importRule” if specified by an @import rule, “linkedSheet” if specified by a “media” attribute in a linked stylesheet’s LINK tag, “inlineSheet” if specified by a “media” attribute in an inline stylesheet’s STYLE tag.
- Type:
Source of the media query
-
range_:
Optional[SourceRange] = None# The associated rule (@media or @import) header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
media_list:
Optional[List[MediaQuery]] = None# Array of media queries.
-
source:
- class MediaQuery(expressions, active)[source]#
Media query descriptor.
-
expressions:
List[MediaQueryExpression]# Array of media query expressions.
-
expressions:
- class MediaQueryExpression(value, unit, feature, value_range=None, computed_length=None)[source]#
Media query expression descriptor.
-
value_range:
Optional[SourceRange] = None# The associated range of the value text in the enclosing stylesheet (if available).
-
value_range:
- class CSSContainerQuery(text, range_=None, style_sheet_id=None, name=None, physical_axes=None, logical_axes=None, queries_scroll_state=None, queries_anchored=None)[source]#
CSS container query rule descriptor.
-
range_:
Optional[SourceRange] = None# The associated rule header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
physical_axes:
Optional[PhysicalAxes] = None# Optional physical axes queried for the container.
-
logical_axes:
Optional[LogicalAxes] = None# Optional logical axes queried for the container.
-
range_:
- class CSSSupports(text, active, range_=None, style_sheet_id=None)[source]#
CSS Supports at-rule descriptor.
-
range_:
Optional[SourceRange] = None# The associated rule header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
range_:
- class CSSScope(text, range_=None, style_sheet_id=None)[source]#
CSS Scope at-rule descriptor.
-
range_:
Optional[SourceRange] = None# The associated rule header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
range_:
- class CSSLayer(text, range_=None, style_sheet_id=None)[source]#
CSS Layer at-rule descriptor.
-
range_:
Optional[SourceRange] = None# The associated rule header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
range_:
- class CSSStartingStyle(range_=None, style_sheet_id=None)[source]#
CSS Starting Style at-rule descriptor.
-
range_:
Optional[SourceRange] = None# The associated rule header range in the enclosing stylesheet (if available).
-
style_sheet_id:
Optional[StyleSheetId] = None# Identifier of the stylesheet containing this object (if exists).
-
range_:
- class CSSLayerData(name, order, sub_layers=None)[source]#
CSS Layer data.
-
order:
float# Layer order. The order determines the order of the layer in the cascade order. A higher number has higher priority in the cascade order.
-
sub_layers:
Optional[List[CSSLayerData]] = None# Direct sub-layers
-
order:
- class PlatformFontUsage(family_name, post_script_name, is_custom_font, glyph_count)[source]#
Information about amount of glyphs that were rendered with given font.
- class FontVariationAxis(tag, name, min_value, max_value, default_value)[source]#
Information about font variation axes for variable fonts
- class FontFace(font_family, font_style, font_variant, font_weight, font_stretch, font_display, unicode_range, src, platform_font_family, font_variation_axes=None)[source]#
Properties of a web font: https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions and additional information such as platformFontFamily and fontVariationAxes.
-
font_variation_axes:
Optional[List[FontVariationAxis]] = None# Available variation settings (a.k.a. “axes”).
-
font_variation_axes:
- class CSSTryRule(origin, style, style_sheet_id=None)[source]#
CSS try rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class CSSPositionTryRule(name, origin, style, active, style_sheet_id=None)[source]#
CSS @position-try rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class CSSKeyframesRule(animation_name, keyframes)[source]#
CSS keyframes rule representation.
-
keyframes:
List[CSSKeyframeRule]# List of keyframes.
-
keyframes:
- class CSSPropertyRegistration(property_name, inherits, syntax, initial_value=None)[source]#
Representation of a custom property registration through CSS.registerProperty
- class CSSFontPaletteValuesRule(origin, font_palette_name, style, style_sheet_id=None)[source]#
CSS font-palette-values rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class CSSPropertyRule(origin, property_name, style, style_sheet_id=None)[source]#
CSS property at-rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class CSSFunctionConditionNode(children, condition_text, media=None, container_queries=None, supports=None)[source]#
CSS function conditional block representation.
-
children:
List[CSSFunctionNode]# Block body.
-
media:
Optional[CSSMedia] = None# Media query for this conditional block. Only one type of condition should be set.
-
container_queries:
Optional[CSSContainerQuery] = None# Container query for this conditional block. Only one type of condition should be set.
-
supports:
Optional[CSSSupports] = None# @supports CSS at-rule condition. Only one type of condition should be set.
-
children:
- class CSSFunctionNode(condition=None, style=None)[source]#
Section of the body of a CSS function rule.
-
condition:
Optional[CSSFunctionConditionNode] = None# A conditional block. If set, style should not be set.
-
condition:
- class CSSFunctionRule(name, origin, parameters, children, style_sheet_id=None)[source]#
CSS function at-rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
parameters:
List[CSSFunctionParameter]# List of parameters.
-
children:
List[CSSFunctionNode]# Function body.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class CSSKeyframeRule(origin, key_text, style, style_sheet_id=None)[source]#
CSS keyframe rule representation.
-
origin:
StyleSheetOrigin# Parent stylesheet’s origin.
-
style_sheet_id:
Optional[StyleSheetId] = None# The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
-
origin:
- class StyleDeclarationEdit(style_sheet_id, range_, text)[source]#
A descriptor of operation to mutate style declaration text.
-
style_sheet_id:
StyleSheetId# The css style sheet identifier.
-
range_:
SourceRange# The range of the style text in the enclosing stylesheet.
-
style_sheet_id:
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.
- add_rule(style_sheet_id, rule_text, location, node_for_property_syntax_validation=None)[source]#
Inserts a new rule with the given
ruleTextin a stylesheet with givenstyleSheetId, at the position specified bylocation.- Parameters:
style_sheet_id (
StyleSheetId) – The css style sheet identifier where a new rule should be inserted.rule_text (
str) – The text of a new rule.location (
SourceRange) – Text position of a new rule in the target style sheet.node_for_property_syntax_validation (
Optional[NodeId]) – (EXPERIMENTAL) (Optional) NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example.
- Return type:
- Returns:
The newly created rule.
- create_style_sheet(frame_id, force=None)[source]#
Creates a new special “via-inspector” stylesheet in the frame with given
frameId.- Parameters:
frame_id (
FrameId) – Identifier of the frame where “via-inspector” stylesheet should be created.force (
Optional[bool]) – (Optional) If true, creates a new stylesheet for every call. If false, returns a stylesheet previously created by a call with force=false for the frame’s document if it exists or creates a new stylesheet (default: false).
- Return type:
- Returns:
Identifier of the created “via-inspector” stylesheet.
- enable()[source]#
Enables the CSS agent for the given page. Clients should not assume that the CSS agent has been enabled until the result of this command is received.
- force_pseudo_state(node_id, forced_pseudo_classes)[source]#
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
- force_starting_style(node_id, forced)[source]#
Ensures that the given node is in its starting-style state.
- get_animated_styles_for_node(node_id)[source]#
Returns the styles coming from animations & transitions including the animation & transition styles coming from inheritance chain.
EXPERIMENTAL
- Parameters:
node_id (
NodeId) –- Return type:
Generator[Dict[str,Any],Dict[str,Any],Tuple[Optional[List[CSSAnimationStyle]],Optional[CSSStyle],Optional[List[InheritedAnimatedStyleEntry]]]]- Returns:
A tuple with the following items:
animationStyles - (Optional) Styles coming from animations.
transitionsStyle - (Optional) Style coming from transitions.
inherited - (Optional) Inherited style entries for animationsStyle and transitionsStyle from the inheritance chain of the element.
- get_background_colors(node_id)[source]#
- Parameters:
node_id (
NodeId) – Id of the node to get background colors for.- Return type:
Generator[Dict[str,Any],Dict[str,Any],Tuple[Optional[List[str]],Optional[str],Optional[str]]]- Returns:
A tuple with the following items:
backgroundColors - (Optional) The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).
computedFontSize - (Optional) The computed font size for this node, as a CSS computed value string (e.g. ‘12px’).
computedFontWeight - (Optional) The computed font weight for this node, as a CSS computed value string (e.g. ‘normal’ or ‘100’).
- get_computed_style_for_node(node_id)[source]#
Returns the computed style for a DOM node identified by
nodeId.- Parameters:
node_id (
NodeId) –- Return type:
Generator[Dict[str,Any],Dict[str,Any],Tuple[List[CSSComputedStyleProperty],ComputedStyleExtraFields]]- Returns:
A tuple with the following items:
computedStyle - Computed style for the specified DOM node.
extraFields - A list of non-standard “extra fields” which blink stores alongside each computed style.
- get_environment_variables()[source]#
Returns the values of the default UA-defined environment variables used in env()
EXPERIMENTAL
- get_inline_styles_for_node(node_id)[source]#
Returns the styles defined inline (explicitly in the “style” attribute and implicitly, using DOM attributes) for a DOM node identified by
nodeId.- Parameters:
node_id (
NodeId) –- Return type:
Generator[Dict[str,Any],Dict[str,Any],Tuple[Optional[CSSStyle],Optional[CSSStyle]]]- Returns:
A tuple with the following items:
inlineStyle - (Optional) Inline style for the specified DOM node.
attributesStyle - (Optional) Attribute-defined element style (e.g. resulting from “width=20 height=100%”).
- get_layers_for_node(node_id)[source]#
Returns all layers parsed by the rendering engine for the tree scope of a node. Given a DOM element identified by nodeId, getLayersForNode returns the root layer for the nearest ancestor document or shadow root. The layer root contains the full layer tree for the tree scope and their ordering.
EXPERIMENTAL
- get_location_for_selector(style_sheet_id, selector_text)[source]#
Given a CSS selector text and a style sheet ID, getLocationForSelector returns an array of locations of the CSS selector in the style sheet.
EXPERIMENTAL
- get_matched_styles_for_node(node_id)[source]#
Returns requested styles for a DOM node identified by
nodeId.- Parameters:
node_id (
NodeId) –- Return type:
Generator[Dict[str,Any],Dict[str,Any],Tuple[Optional[CSSStyle],Optional[CSSStyle],Optional[List[RuleMatch]],Optional[List[PseudoElementMatches]],Optional[List[InheritedStyleEntry]],Optional[List[InheritedPseudoElementMatches]],Optional[List[CSSKeyframesRule]],Optional[List[CSSPositionTryRule]],Optional[int],Optional[List[CSSPropertyRule]],Optional[List[CSSPropertyRegistration]],Optional[CSSFontPaletteValuesRule],Optional[NodeId],Optional[List[CSSFunctionRule]]]]- Returns:
A tuple with the following items:
inlineStyle - (Optional) Inline style for the specified DOM node.
attributesStyle - (Optional) Attribute-defined element style (e.g. resulting from “width=20 height=100%”).
matchedCSSRules - (Optional) CSS rules matching this node, from all applicable stylesheets.
pseudoElements - (Optional) Pseudo style matches for this node.
inherited - (Optional) A chain of inherited styles (from the immediate node parent up to the DOM tree root).
inheritedPseudoElements - (Optional) A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
cssKeyframesRules - (Optional) A list of CSS keyframed animations matching this node.
cssPositionTryRules - (Optional) A list of CSS @position-try rules matching this node, based on the position-try-fallbacks property.
activePositionFallbackIndex - (Optional) Index of the active fallback in the applied position-try-fallback property, will not be set if there is no active position-try fallback.
cssPropertyRules - (Optional) A list of CSS at-property rules matching this node.
cssPropertyRegistrations - (Optional) A list of CSS property registrations matching this node.
cssFontPaletteValuesRule - (Optional) A font-palette-values rule matching this node.
parentLayoutNodeId - (Optional) Id of the first parent element that does not have display: contents.
cssFunctionRules - (Optional) A list of CSS at-function rules referenced by styles of this node.
- get_platform_fonts_for_node(node_id)[source]#
Requests information about platform fonts which we used to render child TextNodes in the given node.
- resolve_values(values, node_id, property_name=None, pseudo_type=None, pseudo_identifier=None)[source]#
Resolve the specified values in the context of the provided element. For example, a value of ‘1em’ is evaluated according to the computed ‘font-size’ of the element and a value ‘calc(1px + 2px)’ will be resolved to ‘3px’. If the
propertyNamewas specified thevaluesare resolved as if they were property’s declaration. If a value cannot be parsed according to the provided property syntax, the value is parsed using combined syntax as if nullpropertyNamewas provided. If the value cannot be resolved even then, return the provided value without any changes.EXPERIMENTAL
- Parameters:
values (
List[str]) – Cascade-dependent keywords (revert/revert-layer) do not work.node_id (
NodeId) – Id of the node in whose context the expression is evaluatedproperty_name (
Optional[str]) – (Optional) Only longhands and custom property names are accepted.pseudo_type (
Optional[PseudoType]) – (Optional) Pseudo element type, only works for pseudo elements that generate elements in the tree, such as ::before and ::after.pseudo_identifier (
Optional[str]) – (Optional) Pseudo element custom ident.
- Return type:
- Returns:
- set_container_query_text(style_sheet_id, range_, text)[source]#
Modifies the expression of a container query.
EXPERIMENTAL
- Parameters:
style_sheet_id (
StyleSheetId) –range –
text (
str) –
- Return type:
Generator[Dict[str,Any],Dict[str,Any],CSSContainerQuery]- Returns:
The resulting CSS container query rule after modification.
- set_effective_property_value_for_node(node_id, property_name, value)[source]#
Find a rule with the given active property for the given node and set the new value for this property
- set_local_fonts_enabled(enabled)[source]#
Enables/disables rendering of local CSS fonts (enabled by default).
EXPERIMENTAL
- set_property_rule_property_name(style_sheet_id, range_, property_name)[source]#
Modifies the property rule property name.
- set_rule_selector(style_sheet_id, range_, selector)[source]#
Modifies the rule selector.
- Parameters:
style_sheet_id (
StyleSheetId) –range –
selector (
str) –
- Return type:
- Returns:
The resulting selector list after modification.
- set_scope_text(style_sheet_id, range_, text)[source]#
Modifies the expression of a scope at-rule.
EXPERIMENTAL
- set_style_texts(edits, node_for_property_syntax_validation=None)[source]#
Applies specified style edits one after another in the given order.
- Parameters:
edits (
List[StyleDeclarationEdit]) –node_for_property_syntax_validation (
Optional[NodeId]) – (EXPERIMENTAL) (Optional) NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example.
- Return type:
- Returns:
The resulting styles after modification.
- set_supports_text(style_sheet_id, range_, text)[source]#
Modifies the expression of a supports at-rule.
EXPERIMENTAL
- Parameters:
style_sheet_id (
StyleSheetId) –range –
text (
str) –
- Return type:
- Returns:
The resulting CSS Supports rule after modification.
- stop_rule_usage_tracking()[source]#
Stop tracking rule usage and return the list of rules that were used since last call to
takeCoverageDelta(or since start of coverage instrumentation).
- take_coverage_delta()[source]#
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation).
- track_computed_style_updates(properties_to_track)[source]#
Starts tracking the given computed styles for updates. The specified array of properties replaces the one previously specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates to retrieve the list of nodes that had properties modified. The changes to computed style properties are only tracked for nodes pushed to the front-end by the DOM agent. If no changes to the tracked properties occur after the node has been pushed to the front-end, no updates will be issued for the node.
EXPERIMENTAL
- track_computed_style_updates_for_node(node_id=None)[source]#
Starts tracking the given node for the computed style updates and whenever the computed style is updated for node, it queues a
computedStyleUpdatedevent with throttling. There can only be 1 node tracked for computed style updates so passing a new node id removes tracking from the previous node. Passundefinedto disable tracking.EXPERIMENTAL
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.
- class FontsUpdated(font)[source]#
Fires whenever a web font is updated. A non-empty font parameter indicates a successfully loaded web font.
- class MediaQueryResultChanged[source]#
Fires whenever a MediaQuery result changes (for example, after a browser window has been resized.) The current implementation considers only viewport-dependent media features.
- class StyleSheetAdded(header)[source]#
Fired whenever an active document stylesheet is added.
-
header:
CSSStyleSheetHeader# Added stylesheet metainfo.
-
header:
- class StyleSheetChanged(style_sheet_id)[source]#
Fired whenever a stylesheet is changed as a result of the client operation.
-
style_sheet_id:
StyleSheetId#
-
style_sheet_id:
- class StyleSheetRemoved(style_sheet_id)[source]#
Fired whenever an active document stylesheet is removed.
-
style_sheet_id:
StyleSheetId# Identifier of the removed stylesheet.
-
style_sheet_id: