CSSApi class

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.

Constructors

CSSApi(Client _client)

Properties

hashCode int
The hash code for this object.
no setterinherited
onFontsUpdated Stream<FontFace>
Fires whenever a web font is updated. A non-empty font parameter indicates a successfully loaded web font.
no setter
onMediaQueryResultChanged Stream<void>
Fires whenever a MediaQuery result changes (for example, after a browser window has been resized.) The current implementation considers only viewport-dependent media features.
no setter
onStyleSheetAdded Stream<CSSStyleSheetHeader>
Fired whenever an active document stylesheet is added.
no setter
onStyleSheetChanged Stream<StyleSheetId>
Fired whenever a stylesheet is changed as a result of the client operation.
no setter
onStyleSheetRemoved Stream<StyleSheetId>
Fired whenever an active document stylesheet is removed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addRule(StyleSheetId styleSheetId, String ruleText, SourceRange location, {NodeId? nodeForPropertySyntaxValidation}) Future<CSSRule>
Inserts a new rule with the given ruleText in a stylesheet with given styleSheetId, at the position specified by location. styleSheetId The css style sheet identifier where a new rule should be inserted. ruleText The text of a new rule. location Text position of a new rule in the target style sheet. nodeForPropertySyntaxValidation 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. Returns: The newly created rule.
collectClassNames(StyleSheetId styleSheetId) Future<List<String>>
Returns all class names from specified stylesheet. Returns: Class name list.
createStyleSheet(FrameId frameId) Future<StyleSheetId>
Creates a new special "via-inspector" stylesheet in the frame with given frameId. frameId Identifier of the frame where "via-inspector" stylesheet should be created. Returns: Identifier of the created "via-inspector" stylesheet.
disable() Future<void>
Disables the CSS agent for the given page.
enable() Future<void>
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.
forcePseudoState(NodeId nodeId, List<String> forcedPseudoClasses) Future<void>
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser. nodeId The element id for which to force the pseudo state. forcedPseudoClasses Element pseudo classes to force when computing the element's style.
getBackgroundColors(NodeId nodeId) Future<GetBackgroundColorsResult>
nodeId Id of the node to get background colors for.
getComputedStyleForNode(NodeId nodeId) Future<List<CSSComputedStyleProperty>>
Returns the computed style for a DOM node identified by nodeId. Returns: Computed style for the specified DOM node.
getInlineStylesForNode(NodeId nodeId) Future<GetInlineStylesForNodeResult>
Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by nodeId.
getLayersForNode(NodeId nodeId) Future<CSSLayerData>
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.
getMatchedStylesForNode(NodeId nodeId) Future<GetMatchedStylesForNodeResult>
Returns requested styles for a DOM node identified by nodeId.
getMediaQueries() Future<List<CSSMedia>>
Returns all media queries parsed by the rendering engine.
getPlatformFontsForNode(NodeId nodeId) Future<List<PlatformFontUsage>>
Requests information about platform fonts which we used to render child TextNodes in the given node. Returns: Usage statistics for every employed platform font.
getStyleSheetText(StyleSheetId styleSheetId) Future<String>
Returns the current textual content for a stylesheet. Returns: The stylesheet text.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setContainerQueryText(StyleSheetId styleSheetId, SourceRange range, String text) Future<CSSContainerQuery>
Modifies the expression of a container query. Returns: The resulting CSS container query rule after modification.
setEffectivePropertyValueForNode(NodeId nodeId, String propertyName, String value) Future<void>
Find a rule with the given active property for the given node and set the new value for this property nodeId The element id for which to set property.
setKeyframeKey(StyleSheetId styleSheetId, SourceRange range, String keyText) Future<Value>
Modifies the keyframe rule key text. Returns: The resulting key text after modification.
setLocalFontsEnabled(bool enabled) Future<void>
Enables/disables rendering of local CSS fonts (enabled by default). enabled Whether rendering of local fonts is enabled.
setMediaText(StyleSheetId styleSheetId, SourceRange range, String text) Future<CSSMedia>
Modifies the rule selector. Returns: The resulting CSS media rule after modification.
setPropertyRulePropertyName(StyleSheetId styleSheetId, SourceRange range, String propertyName) Future<Value>
Modifies the property rule property name. Returns: The resulting key text after modification.
setRuleSelector(StyleSheetId styleSheetId, SourceRange range, String selector) Future<SelectorList>
Modifies the rule selector. Returns: The resulting selector list after modification.
setScopeText(StyleSheetId styleSheetId, SourceRange range, String text) Future<CSSScope>
Modifies the expression of a scope at-rule. Returns: The resulting CSS Scope rule after modification.
setStyleSheetText(StyleSheetId styleSheetId, String text) Future<String>
Sets the new stylesheet text. Returns: URL of source map associated with script (if any).
setStyleTexts(List<StyleDeclarationEdit> edits, {NodeId? nodeForPropertySyntaxValidation}) Future<List<CSSStyle>>
Applies specified style edits one after another in the given order. nodeForPropertySyntaxValidation 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. Returns: The resulting styles after modification.
setSupportsText(StyleSheetId styleSheetId, SourceRange range, String text) Future<CSSSupports>
Modifies the expression of a supports at-rule. Returns: The resulting CSS Supports rule after modification.
startRuleUsageTracking() Future<void>
Enables the selector recording.
stopRuleUsageTracking() Future<List<RuleUsage>>
Stop tracking rule usage and return the list of rules that were used since last call to takeCoverageDelta (or since start of coverage instrumentation).
takeComputedStyleUpdates() Future<List<NodeId>>
Polls the next batch of computed style updates. Returns: The list of node Ids that have their tracked computed styles updated.
takeCoverageDelta() Future<TakeCoverageDeltaResult>
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation).
toString() String
A string representation of this object.
inherited
trackComputedStyleUpdates(List<CSSComputedStyleProperty> propertiesToTrack) Future<void>
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.

Operators

operator ==(Object other) bool
The equality operator.
inherited