CDPotion.Domain.CSS (cdpotion v0.1.4)

Summary

Types

description not provided :(

CSS container query rule descriptor.

CSS keyframe rule representation.

CSS keyframes rule representation.

CSS Layer at-rule descriptor.

CSS Layer data.

CSS media rule descriptor.

CSS position-fallback rule representation.

CSS property declaration data.

CSS rule representation.

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.

CSS Scope at-rule descriptor.

CSS style representation.

CSS stylesheet metainformation.

CSS Supports at-rule descriptor.

CSS try rule representation.

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.

Information about font variation axes for variable fonts

Inherited pseudo element matches from pseudos of an ancestor node.

Inherited CSS rule collection from ancestor node.

Media query descriptor.

Media query expression descriptor.

Information about amount of glyphs that were rendered with given font.

CSS rule collection for a single pseudo style.

Match data for a CSS rule.

CSS coverage information.

Selector list data.

description not provided :(

Text range within a resource. All numbers are zero-based.

A descriptor of operation to mutate style declaration text.

description not provided :(

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.

Data for a simple selector (these are delimited by commas in a selector list).

Functions

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

Returns all class names from specified stylesheet.

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

Disables the CSS agent for the given page.

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.

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

Parameters:

  • (Required) node_id: Id of the node to get background colors for.

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

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

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.

Returns requested styles for a DOM node identified by nodeId.

Returns all media queries parsed by the rendering engine.

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

Returns the current textual content for a stylesheet.

Modifies the expression of a container query.

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

Modifies the keyframe rule key text.

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

Modifies the rule selector.

Modifies the expression of a scope at-rule.

Sets the new stylesheet text.

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

Modifies the expression of a supports at-rule.

Enables the selector recording.

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

Polls the next batch of computed style updates.

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

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.

Types

Link to this type

css_computed_style_property()

@type css_computed_style_property() :: %{name: String.t(), value: String.t()}

description not provided :(

Link to this type

css_container_query()

@type css_container_query() :: %{
  logicalAxes: CDPotion.Domain.DOM.logical_axes() | nil,
  name: String.t() | nil,
  physicalAxes: CDPotion.Domain.DOM.physical_axes() | nil,
  range: source_range() | nil,
  styleSheetId: style_sheet_id() | nil,
  text: String.t()
}

CSS container query rule descriptor.

Link to this type

css_keyframe_rule()

@type css_keyframe_rule() :: %{
  keyText: value(),
  origin: style_sheet_origin(),
  style: css_style(),
  styleSheetId: style_sheet_id() | nil
}

CSS keyframe rule representation.

Link to this type

css_keyframes_rule()

@type css_keyframes_rule() :: %{
  animationName: value(),
  keyframes: [css_keyframe_rule()]
}

CSS keyframes rule representation.

@type css_layer() :: %{
  range: source_range() | nil,
  styleSheetId: style_sheet_id() | nil,
  text: String.t()
}

CSS Layer at-rule descriptor.

Link to this type

css_layer_data()

@type css_layer_data() :: %{
  name: String.t(),
  order: number(),
  subLayers: [css_layer_data()] | nil
}

CSS Layer data.

@type css_media() :: %{
  mediaList: [media_query()] | nil,
  range: source_range() | nil,
  source: :mediaRule | :importRule | :linkedSheet | :inlineSheet,
  sourceURL: String.t() | nil,
  styleSheetId: style_sheet_id() | nil,
  text: String.t()
}

CSS media rule descriptor.

Link to this type

css_position_fallback_rule()

@type css_position_fallback_rule() :: %{name: value(), tryRules: [css_try_rule()]}

CSS position-fallback rule representation.

Link to this type

css_property()

@type css_property() :: %{
  disabled: boolean() | nil,
  implicit: boolean() | nil,
  important: boolean() | nil,
  longhandProperties: [css_property()] | nil,
  name: String.t(),
  parsedOk: boolean() | nil,
  range: source_range() | nil,
  text: String.t() | nil,
  value: String.t()
}

CSS property declaration data.

@type css_rule() :: %{
  containerQueries: [css_container_query()] | nil,
  layers: [css_layer()] | nil,
  media: [css_media()] | nil,
  nestingSelectors: [String.t()] | nil,
  origin: style_sheet_origin(),
  ruleTypes: [css_rule_type()] | nil,
  scopes: [css_scope()] | nil,
  selectorList: selector_list(),
  style: css_style(),
  styleSheetId: style_sheet_id() | nil,
  supports: [css_supports()] | nil
}

CSS rule representation.

Link to this type

css_rule_type()

@type css_rule_type() ::
  :MediaRule
  | :SupportsRule
  | :ContainerRule
  | :LayerRule
  | :ScopeRule
  | :StyleRule

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.

@type css_scope() :: %{
  range: source_range() | nil,
  styleSheetId: style_sheet_id() | nil,
  text: String.t()
}

CSS Scope at-rule descriptor.

@type css_style() :: %{
  cssProperties: [css_property()],
  cssText: String.t() | nil,
  range: source_range() | nil,
  shorthandEntries: [shorthand_entry()],
  styleSheetId: style_sheet_id() | nil
}

CSS style representation.

Link to this type

css_style_sheet_header()

@type css_style_sheet_header() :: %{
  disabled: boolean(),
  endColumn: number(),
  endLine: number(),
  frameId: CDPotion.Domain.Page.frame_id(),
  hasSourceURL: boolean() | nil,
  isConstructed: boolean(),
  isInline: boolean(),
  isMutable: boolean(),
  length: number(),
  loadingFailed: boolean() | nil,
  origin: style_sheet_origin(),
  ownerNode: CDPotion.Domain.DOM.backend_node_id() | nil,
  sourceMapURL: String.t() | nil,
  sourceURL: String.t(),
  startColumn: number(),
  startLine: number(),
  styleSheetId: style_sheet_id(),
  title: String.t()
}

CSS stylesheet metainformation.

Link to this type

css_supports()

@type css_supports() :: %{
  active: boolean(),
  range: source_range() | nil,
  styleSheetId: style_sheet_id() | nil,
  text: String.t()
}

CSS Supports at-rule descriptor.

Link to this type

css_try_rule()

@type css_try_rule() :: %{
  origin: style_sheet_origin(),
  style: css_style(),
  styleSheetId: style_sheet_id() | nil
}

CSS try rule representation.

@type font_face() :: %{
  fontDisplay: String.t(),
  fontFamily: String.t(),
  fontStretch: String.t(),
  fontStyle: String.t(),
  fontVariant: String.t(),
  fontVariationAxes: [font_variation_axis()] | nil,
  fontWeight: String.t(),
  platformFontFamily: String.t(),
  src: String.t(),
  unicodeRange: String.t()
}

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.

Link to this type

font_variation_axis()

@type font_variation_axis() :: %{
  defaultValue: number(),
  maxValue: number(),
  minValue: number(),
  name: String.t(),
  tag: String.t()
}

Information about font variation axes for variable fonts

Link to this type

inherited_pseudo_element_matches()

@type inherited_pseudo_element_matches() :: %{
  pseudoElements: [pseudo_element_matches()]
}

Inherited pseudo element matches from pseudos of an ancestor node.

Link to this type

inherited_style_entry()

@type inherited_style_entry() :: %{
  inlineStyle: css_style() | nil,
  matchedCSSRules: [rule_match()]
}

Inherited CSS rule collection from ancestor node.

Link to this type

media_query()

@type media_query() :: %{active: boolean(), expressions: [media_query_expression()]}

Media query descriptor.

Link to this type

media_query_expression()

@type media_query_expression() :: %{
  computedLength: number() | nil,
  feature: String.t(),
  unit: String.t(),
  value: number(),
  valueRange: source_range() | nil
}

Media query expression descriptor.

Link to this type

platform_font_usage()

@type platform_font_usage() :: %{
  familyName: String.t(),
  glyphCount: number(),
  isCustomFont: boolean()
}

Information about amount of glyphs that were rendered with given font.

Link to this type

pseudo_element_matches()

@type pseudo_element_matches() :: %{
  matches: [rule_match()],
  pseudoIdentifier: String.t() | nil,
  pseudoType: CDPotion.Domain.DOM.pseudo_type()
}

CSS rule collection for a single pseudo style.

Link to this type

rule_match()

@type rule_match() :: %{matchingSelectors: [integer()], rule: css_rule()}

Match data for a CSS rule.

Link to this type

rule_usage()

@type rule_usage() :: %{
  endOffset: number(),
  startOffset: number(),
  styleSheetId: style_sheet_id(),
  used: boolean()
}

CSS coverage information.

Link to this type

selector_list()

@type selector_list() :: %{selectors: [value()], text: String.t()}

Selector list data.

Link to this type

shorthand_entry()

@type shorthand_entry() :: %{
  important: boolean() | nil,
  name: String.t(),
  value: String.t()
}

description not provided :(

Link to this type

source_range()

@type source_range() :: %{
  endColumn: integer(),
  endLine: integer(),
  startColumn: integer(),
  startLine: integer()
}

Text range within a resource. All numbers are zero-based.

Link to this type

specificity()

@type specificity() :: %{a: integer(), b: integer(), c: integer()}

Specificity: https://drafts.csswg.org/selectors/#specificity-rules

Link to this type

style_declaration_edit()

@type style_declaration_edit() :: %{
  range: source_range(),
  styleSheetId: style_sheet_id(),
  text: String.t()
}

A descriptor of operation to mutate style declaration text.

Link to this type

style_sheet_id()

@type style_sheet_id() :: String.t()

description not provided :(

Link to this type

style_sheet_origin()

@type style_sheet_origin() :: :injected | :"user-agent" | :inspector | :regular

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.

@type value() :: %{
  range: source_range() | nil,
  specificity: specificity() | nil,
  text: String.t()
}

Data for a simple selector (these are delimited by commas in a selector list).

Functions

Link to this function

add_rule(style_sheet_id, rule_text, location)

@spec add_rule(
  style_sheet_id(),
  String.t(),
  source_range()
) :: {String.t(), map()}

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

Parameters:

  • (Required) style_sheet_id: The css style sheet identifier where a new rule should be inserted.
  • (Required) rule_text: The text of a new rule.
  • (Required) location: Text position of a new rule in the target style sheet.
Link to this function

collect_class_names(style_sheet_id)

@spec collect_class_names(style_sheet_id()) :: {String.t(), map()}

Returns all class names from specified stylesheet.

Parameters:

  • (Required) style_sheet_id: description not provided :(
Link to this function

create_style_sheet(frame_id)

@spec create_style_sheet(CDPotion.Domain.Page.frame_id()) :: {String.t(), map()}

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

Parameters:

  • (Required) frame_id: Identifier of the frame where "via-inspector" stylesheet should be created.
@spec disable() :: {String.t(), map()}

Disables the CSS agent for the given page.

@spec enable() :: {String.t(), map()}

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 to this function

force_pseudo_state(node_id, forced_pseudo_classes)

@spec force_pseudo_state(CDPotion.Domain.DOM.node_id(), [String.t()]) ::
  {String.t(), map()}

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

Parameters:

  • (Required) node_id: The element id for which to force the pseudo state.
  • (Required) forced_pseudo_classes: Element pseudo classes to force when computing the element's style.
Link to this function

get_background_colors(node_id)

@spec get_background_colors(CDPotion.Domain.DOM.node_id()) :: {String.t(), map()}

Parameters:

  • (Required) node_id: Id of the node to get background colors for.
Link to this function

get_computed_style_for_node(node_id)

@spec get_computed_style_for_node(CDPotion.Domain.DOM.node_id()) ::
  {String.t(), map()}

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

Parameters:

  • (Required) node_id: description not provided :(
Link to this function

get_inline_styles_for_node(node_id)

@spec get_inline_styles_for_node(CDPotion.Domain.DOM.node_id()) :: {String.t(), map()}

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

Parameters:

  • (Required) node_id: description not provided :(
Link to this function

get_layers_for_node(node_id)

@spec get_layers_for_node(CDPotion.Domain.DOM.node_id()) :: {String.t(), map()}

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.

Parameters:

  • (Required) node_id: description not provided :(
Link to this function

get_matched_styles_for_node(node_id)

@spec get_matched_styles_for_node(CDPotion.Domain.DOM.node_id()) ::
  {String.t(), map()}

Returns requested styles for a DOM node identified by nodeId.

Parameters:

  • (Required) node_id: description not provided :(
Link to this function

get_media_queries()

@spec get_media_queries() :: {String.t(), map()}

Returns all media queries parsed by the rendering engine.

Link to this function

get_platform_fonts_for_node(node_id)

@spec get_platform_fonts_for_node(CDPotion.Domain.DOM.node_id()) ::
  {String.t(), map()}

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

Parameters:

  • (Required) node_id: description not provided :(
Link to this function

get_style_sheet_text(style_sheet_id)

@spec get_style_sheet_text(style_sheet_id()) :: {String.t(), map()}

Returns the current textual content for a stylesheet.

Parameters:

  • (Required) style_sheet_id: description not provided :(
Link to this function

set_container_query_text(style_sheet_id, range, text)

@spec set_container_query_text(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the expression of a container query.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) text: description not provided :(
Link to this function

set_effective_property_value_for_node(node_id, property_name, value)

@spec set_effective_property_value_for_node(
  CDPotion.Domain.DOM.node_id(),
  String.t(),
  String.t()
) :: {String.t(), map()}

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

Parameters:

  • (Required) node_id: The element id for which to set property.
  • (Required) property_name: description not provided :(
  • (Required) value: description not provided :(
Link to this function

set_keyframe_key(style_sheet_id, range, key_text)

@spec set_keyframe_key(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the keyframe rule key text.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) key_text: description not provided :(
Link to this function

set_local_fonts_enabled(enabled)

@spec set_local_fonts_enabled(boolean()) :: {String.t(), map()}

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

Parameters:

  • (Required) enabled: Whether rendering of local fonts is enabled.
Link to this function

set_media_text(style_sheet_id, range, text)

@spec set_media_text(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the rule selector.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) text: description not provided :(
Link to this function

set_rule_selector(style_sheet_id, range, selector)

@spec set_rule_selector(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the rule selector.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) selector: description not provided :(
Link to this function

set_scope_text(style_sheet_id, range, text)

@spec set_scope_text(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the expression of a scope at-rule.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) text: description not provided :(
Link to this function

set_style_sheet_text(style_sheet_id, text)

@spec set_style_sheet_text(style_sheet_id(), String.t()) :: {String.t(), map()}

Sets the new stylesheet text.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) text: description not provided :(
Link to this function

set_style_texts(edits)

@spec set_style_texts([style_declaration_edit()]) :: {String.t(), map()}

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

Parameters:

  • (Required) edits: description not provided :(
Link to this function

set_supports_text(style_sheet_id, range, text)

@spec set_supports_text(
  style_sheet_id(),
  source_range(),
  String.t()
) :: {String.t(), map()}

Modifies the expression of a supports at-rule.

Parameters:

  • (Required) style_sheet_id: description not provided :(
  • (Required) range: description not provided :(
  • (Required) text: description not provided :(
Link to this function

start_rule_usage_tracking()

@spec start_rule_usage_tracking() :: {String.t(), map()}

Enables the selector recording.

Link to this function

stop_rule_usage_tracking()

@spec stop_rule_usage_tracking() :: {String.t(), map()}

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 to this function

take_computed_style_updates()

@spec take_computed_style_updates() :: {String.t(), map()}

Polls the next batch of computed style updates.

Link to this function

take_coverage_delta()

@spec take_coverage_delta() :: {String.t(), map()}

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

Link to this function

track_computed_style_updates(properties_to_track)

@spec track_computed_style_updates([css_computed_style_property()]) ::
  {String.t(), map()}

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.

Parameters:

  • (Required) properties_to_track: description not provided :(