CSSDomain

class CSSDomain

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.

Official doc

Functions

Link copied to clipboard
inline suspend fun addRule(styleSheetId: StyleSheetId, ruleText: String, location: SourceRange, optionalArgs: AddRuleRequest.Builder.() -> Unit = {}): AddRuleResponse

Inserts a new rule with the given ruleText in a stylesheet with given styleSheetId, at the position specified by location.

Link copied to clipboard

Returns all class names from specified stylesheet.

Link copied to clipboard

(undocumented in the protocol definition)

Link copied to clipboard

Creates a new special "via-inspector" stylesheet in the frame with given frameId.

Link copied to clipboard
suspend fun disable(): DisableResponse

Disables the CSS agent for the given page.

Link copied to clipboard
suspend fun enable(): EnableResponse

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.

Link copied to clipboard
fun events(): Flow<CSSEvent>

Subscribes to all events related to this domain.

Link copied to clipboard
Link copied to clipboard

Fires whenever a web font is updated. A non-empty font parameter indicates a successfully loaded web font.

Link copied to clipboard
suspend fun forcePseudoState(nodeId: NodeId, forcedPseudoClasses: List<String>): ForcePseudoStateResponse

Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.

Link copied to clipboard

Ensures that the given node is in its starting-style state.

Link copied to clipboard

Returns the styles coming from animations & transitions including the animation & transition styles coming from inheritance chain.

Link copied to clipboard

(undocumented in the protocol definition)

Link copied to clipboard

Returns the computed style for a DOM node identified by nodeId.

Link copied to clipboard

Returns the values of the default UA-defined environment variables used in env()

Link copied to clipboard

Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by nodeId.

Link copied to clipboard

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.

Link copied to clipboard

Given a CSS selector text and a style sheet ID, getLocationForSelector returns an array of locations of the CSS selector in the style sheet.

Link copied to clipboard

(undocumented in the protocol definition)

Link copied to clipboard

Returns requested styles for a DOM node identified by nodeId.

Link copied to clipboard

Returns all media queries parsed by the rendering engine.

Link copied to clipboard

Requests information about platform fonts which we used to render child TextNodes in the given node.

Link copied to clipboard

Returns the current textual content for a stylesheet.

Link copied to clipboard

Fires whenever a MediaQuery result changes (for example, after a browser window has been resized.) The current implementation considers only viewport-dependent media features.

Link copied to clipboard
inline suspend fun resolveValues(values: List<String>, nodeId: NodeId, optionalArgs: ResolveValuesRequest.Builder.() -> Unit = {}): ResolveValuesResponse

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 propertyName was specified the values are 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 null propertyName was provided. If the value cannot be resolved even then, return the provided value without any changes. Note: this function currently does not resolve CSS random() function, it returns unmodified random() function parts.`

Link copied to clipboard

Modifies the expression of a container query.

Link copied to clipboard

Find a rule with the given active property for the given node and set the new value for this property

Link copied to clipboard
suspend fun setKeyframeKey(styleSheetId: StyleSheetId, range: SourceRange, keyText: String): SetKeyframeKeyResponse

Modifies the keyframe rule key text.

Link copied to clipboard

Enables/disables rendering of local CSS fonts (enabled by default).

Link copied to clipboard
suspend fun setMediaText(styleSheetId: StyleSheetId, range: SourceRange, text: String): SetMediaTextResponse

Modifies the rule selector.

Link copied to clipboard
Link copied to clipboard
suspend fun setRuleSelector(styleSheetId: StyleSheetId, range: SourceRange, selector: String): SetRuleSelectorResponse

Modifies the rule selector.

Link copied to clipboard
suspend fun setScopeText(styleSheetId: StyleSheetId, range: SourceRange, text: String): SetScopeTextResponse

Modifies the expression of a scope at-rule.

Link copied to clipboard

Sets the new stylesheet text.

Link copied to clipboard

Applies specified style edits one after another in the given order.

Link copied to clipboard
suspend fun setSupportsText(styleSheetId: StyleSheetId, range: SourceRange, text: String): SetSupportsTextResponse

Modifies the expression of a supports at-rule.

Link copied to clipboard

Enables the selector recording.

Link copied to clipboard

Stop tracking rule usage and return the list of rules that were used since last call to takeCoverageDelta (or since start of coverage instrumentation).

Link copied to clipboard
Link copied to clipboard

Fired whenever an active document stylesheet is added.

Link copied to clipboard
Link copied to clipboard

Fired whenever a stylesheet is changed as a result of the client operation.

Link copied to clipboard
Link copied to clipboard

Fired whenever an active document stylesheet is removed.

Link copied to clipboard

Polls the next batch of computed style updates.

Link copied to clipboard

Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation).

Link copied to clipboard

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.

Link copied to clipboard

Starts tracking the given node for the computed style updates and whenever the computed style is updated for node, it queues a computedStyleUpdated event 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. Pass undefined to disable tracking.