Tungsten v0.1.0 Tungsten.CDP.CSS View Source

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.

Link to this section Summary

Functions

Link to this section Types

Link to this type

cdp_css_computed_style_property_type() View Source
cdp_css_computed_style_property_type() :: %{name: String.t(), value: String.t()}

CSS.CSSComputedStyleProperty

This type has no documentation

Link to this type

cdp_css_keyframe_rule_type() View Source
cdp_css_keyframe_rule_type() :: %{
  optional(:style_sheet_id) => cdp_style_sheet_id_type(),
  :origin => cdp_style_sheet_origin_type(),
  :key_text => cdp_value_type(),
  :style => cdp_css_style_type()
}

CSS.CSSKeyframeRule

CSS keyframe rule representation.

Link to this type

cdp_css_keyframes_rule_type() View Source
cdp_css_keyframes_rule_type() :: %{
  animation_name: cdp_value_type(),
  keyframes: [cdp_css_keyframe_rule_type()]
}

CSS.CSSKeyframesRule

CSS keyframes rule representation.

Link to this type

cdp_css_media_type() View Source
cdp_css_media_type() :: %{
  :text => String.t(),
  :source => :inline_sheet | :linked_sheet | :import_rule | :media_rule,
  optional(:source_url) => String.t(),
  optional(:range) => cdp_source_range_type(),
  optional(:style_sheet_id) => cdp_style_sheet_id_type(),
  optional(:media_list) => [cdp_media_query_type()]
}

CSS.CSSMedia

CSS media rule descriptor.

Link to this type

cdp_css_property_type() View Source
cdp_css_property_type() :: %{
  :name => String.t(),
  :value => String.t(),
  optional(:important) => boolean(),
  optional(:implicit) => boolean(),
  optional(:text) => String.t(),
  optional(:parsed_ok) => boolean(),
  optional(:disabled) => boolean(),
  optional(:range) => cdp_source_range_type()
}

CSS.CSSProperty

CSS property declaration data.

Link to this type

cdp_css_rule_type() View Source
cdp_css_rule_type() :: %{
  optional(:style_sheet_id) => cdp_style_sheet_id_type(),
  :selector_list => cdp_selector_list_type(),
  :origin => cdp_style_sheet_origin_type(),
  :style => cdp_css_style_type(),
  optional(:media) => [cdp_css_media_type()]
}

CSS.CSSRule

CSS rule representation.

Link to this type

cdp_css_style_sheet_header_type() View Source
cdp_css_style_sheet_header_type() :: %{
  :style_sheet_id => cdp_style_sheet_id_type(),
  :frame_id => Tungsten.CDP.Page.cdp_frame_id_type(),
  :source_url => String.t(),
  optional(:source_map_url) => String.t(),
  :origin => cdp_style_sheet_origin_type(),
  :title => String.t(),
  optional(:owner_node) => Tungsten.CDP.DOM.cdp_backend_node_id_type(),
  :disabled => boolean(),
  optional(:has_source_url) => boolean(),
  :is_inline => boolean(),
  :start_line => integer() | float(),
  :start_column => integer() | float(),
  :length => integer() | float()
}

CSS.CSSStyleSheetHeader

CSS stylesheet metainformation.

Link to this type

cdp_css_style_type() View Source
cdp_css_style_type() :: %{
  optional(:style_sheet_id) => cdp_style_sheet_id_type(),
  :css_properties => [cdp_css_property_type()],
  :shorthand_entries => [cdp_shorthand_entry_type()],
  optional(:css_text) => String.t(),
  optional(:range) => cdp_source_range_type()
}

CSS.CSSStyle

CSS style representation.

Link to this type

cdp_font_face_type() View Source
cdp_font_face_type() :: %{
  font_family: String.t(),
  font_style: String.t(),
  font_variant: String.t(),
  font_weight: String.t(),
  font_stretch: String.t(),
  unicode_range: String.t(),
  src: String.t(),
  platform_font_family: String.t()
}

CSS.FontFace

Properties of a web font: https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions

Link to this type

cdp_inherited_style_entry_type() View Source
cdp_inherited_style_entry_type() :: %{
  optional(:inline_style) => cdp_css_style_type(),
  :matched_css_rules => [cdp_rule_match_type()]
}

CSS.InheritedStyleEntry

Inherited CSS rule collection from ancestor node.

Link to this type

cdp_media_query_expression_type() View Source
cdp_media_query_expression_type() :: %{
  :value => integer() | float(),
  :unit => String.t(),
  :feature => String.t(),
  optional(:value_range) => cdp_source_range_type(),
  optional(:computed_length) => integer() | float()
}

CSS.MediaQueryExpression

Media query expression descriptor.

Link to this type

cdp_media_query_type() View Source
cdp_media_query_type() :: %{
  expressions: [cdp_media_query_expression_type()],
  active: boolean()
}

CSS.MediaQuery

Media query descriptor.

Link to this type

cdp_platform_font_usage_type() View Source
cdp_platform_font_usage_type() :: %{
  family_name: String.t(),
  is_custom_font: boolean(),
  glyph_count: integer() | float()
}

CSS.PlatformFontUsage

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

Link to this type

cdp_pseudo_element_matches_type() View Source
cdp_pseudo_element_matches_type() :: %{
  pseudo_type: Tungsten.CDP.DOM.cdp_pseudo_type_type(),
  matches: [cdp_rule_match_type()]
}

CSS.PseudoElementMatches

CSS rule collection for a single pseudo style.

Link to this type

cdp_rule_match_type() View Source
cdp_rule_match_type() :: %{
  rule: cdp_css_rule_type(),
  matching_selectors: [integer()]
}

CSS.RuleMatch

Match data for a CSS rule.

Link to this type

cdp_rule_usage_type() View Source
cdp_rule_usage_type() :: %{
  style_sheet_id: cdp_style_sheet_id_type(),
  start_offset: integer() | float(),
  end_offset: integer() | float(),
  used: boolean()
}

CSS.RuleUsage

CSS coverage information.

Link to this type

cdp_selector_list_type() View Source
cdp_selector_list_type() :: %{selectors: [cdp_value_type()], text: String.t()}

CSS.SelectorList

Selector list data.

Link to this type

cdp_shorthand_entry_type() View Source
cdp_shorthand_entry_type() :: %{
  :name => String.t(),
  :value => String.t(),
  optional(:important) => boolean()
}

CSS.ShorthandEntry

This type has no documentation

Link to this type

cdp_source_range_type() View Source
cdp_source_range_type() :: %{
  start_line: integer(),
  start_column: integer(),
  end_line: integer(),
  end_column: integer()
}

CSS.SourceRange

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

Link to this type

cdp_style_declaration_edit_type() View Source
cdp_style_declaration_edit_type() :: %{
  style_sheet_id: cdp_style_sheet_id_type(),
  range: cdp_source_range_type(),
  text: String.t()
}

CSS.StyleDeclarationEdit

A descriptor of operation to mutate style declaration text.

Link to this type

cdp_style_sheet_id_type() View Source
cdp_style_sheet_id_type() :: String.t()

CSS.StyleSheetId

This type has no documentation

Link to this type

cdp_style_sheet_origin_type() View Source
cdp_style_sheet_origin_type() ::
  :regular | :inspector | :"user-agent" | :injected

CSS.StyleSheetOrigin

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.

Link to this type

cdp_value_type() View Source
cdp_value_type() :: %{
  :text => String.t(),
  optional(:range) => cdp_source_range_type()
}

CSS.Value

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

Link to this section Functions

Link to this function

add_rule(session, parameters, options \\ []) View Source
add_rule(
  GenServer.server(),
  %{
    style_sheet_id: cdp_style_sheet_id_type(),
    rule_text: String.t(),
    location: cdp_source_range_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{rule: cdp_css_rule_type()}} | {:error, term()}

CSS.addRule

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

Link to this function

collect_class_names(session, parameters, options \\ []) View Source
collect_class_names(
  GenServer.server(),
  %{style_sheet_id: cdp_style_sheet_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{class_names: [String.t()]}} | {:error, term()}

CSS.collectClassNames

Returns all class names from specified stylesheet.

Link to this function

create_style_sheet(session, parameters, options \\ []) View Source
create_style_sheet(
  GenServer.server(),
  %{frame_id: Tungsten.CDP.Page.cdp_frame_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{style_sheet_id: cdp_style_sheet_id_type()}} | {:error, term()}

CSS.createStyleSheet

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

Link to this function

disable(session, parameters \\ %{}, options \\ []) View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

CSS.disable

Disables the CSS agent for the given page.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

CSS.enable

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(session, parameters, options \\ []) View Source
force_pseudo_state(
  GenServer.server(),
  %{
    node_id: Tungsten.CDP.DOM.cdp_node_id_type(),
    forced_pseudo_classes: [String.t()]
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

CSS.forcePseudoState

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

Link to this function

get_background_colors(session, parameters, options \\ []) View Source
get_background_colors(
  GenServer.server(),
  %{node_id: Tungsten.CDP.DOM.cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     optional(:background_colors) => [String.t()],
     optional(:computed_font_size) => String.t(),
     optional(:computed_font_weight) => String.t()
   }}
  | {:error, term()}

CSS.getBackgroundColors

This command has no documentation

Link to this function

get_computed_style_for_node(session, parameters, options \\ []) View Source
get_computed_style_for_node(
  GenServer.server(),
  %{node_id: Tungsten.CDP.DOM.cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{computed_style: [cdp_css_computed_style_property_type()]}}
  | {:error, term()}

CSS.getComputedStyleForNode

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

Link to this function

get_inline_styles_for_node(session, parameters, options \\ []) View Source
get_inline_styles_for_node(
  GenServer.server(),
  %{node_id: Tungsten.CDP.DOM.cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     optional(:inline_style) => cdp_css_style_type(),
     optional(:attributes_style) => cdp_css_style_type()
   }}
  | {:error, term()}

CSS.getInlineStylesForNode

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

Link to this function

get_matched_styles_for_node(session, parameters, options \\ []) View Source
get_matched_styles_for_node(
  GenServer.server(),
  %{node_id: Tungsten.CDP.DOM.cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     optional(:inline_style) => cdp_css_style_type(),
     optional(:attributes_style) => cdp_css_style_type(),
     optional(:matched_css_rules) => [cdp_rule_match_type()],
     optional(:pseudo_elements) => [cdp_pseudo_element_matches_type()],
     optional(:inherited) => [cdp_inherited_style_entry_type()],
     optional(:css_keyframes_rules) => [cdp_css_keyframes_rule_type()]
   }}
  | {:error, term()}

CSS.getMatchedStylesForNode

Returns requested styles for a DOM node identified by nodeId.

Link to this function

get_media_queries(session, parameters \\ %{}, options \\ []) View Source
get_media_queries(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{medias: [cdp_css_media_type()]}} | {:error, term()}

CSS.getMediaQueries

Returns all media queries parsed by the rendering engine.

Link to this function

get_platform_fonts_for_node(session, parameters, options \\ []) View Source
get_platform_fonts_for_node(
  GenServer.server(),
  %{node_id: Tungsten.CDP.DOM.cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{fonts: [cdp_platform_font_usage_type()]}} | {:error, term()}

CSS.getPlatformFontsForNode

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

Link to this function

get_style_sheet_text(session, parameters, options \\ []) View Source
get_style_sheet_text(
  GenServer.server(),
  %{style_sheet_id: cdp_style_sheet_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{text: String.t()}} | {:error, term()}

CSS.getStyleSheetText

Returns the current textual content for a stylesheet.

Link to this function

set_effective_property_value_for_node(session, parameters, options \\ []) View Source
set_effective_property_value_for_node(
  GenServer.server(),
  %{
    node_id: Tungsten.CDP.DOM.cdp_node_id_type(),
    property_name: String.t(),
    value: String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

CSS.setEffectivePropertyValueForNode

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

Link to this function

set_keyframe_key(session, parameters, options \\ []) View Source
set_keyframe_key(
  GenServer.server(),
  %{
    style_sheet_id: cdp_style_sheet_id_type(),
    range: cdp_source_range_type(),
    key_text: String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{key_text: cdp_value_type()}} | {:error, term()}

CSS.setKeyframeKey

Modifies the keyframe rule key text.

Link to this function

set_media_text(session, parameters, options \\ []) View Source
set_media_text(
  GenServer.server(),
  %{
    style_sheet_id: cdp_style_sheet_id_type(),
    range: cdp_source_range_type(),
    text: String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{media: cdp_css_media_type()}} | {:error, term()}

CSS.setMediaText

Modifies the rule selector.

Link to this function

set_rule_selector(session, parameters, options \\ []) View Source
set_rule_selector(
  GenServer.server(),
  %{
    style_sheet_id: cdp_style_sheet_id_type(),
    range: cdp_source_range_type(),
    selector: String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{selector_list: cdp_selector_list_type()}} | {:error, term()}

CSS.setRuleSelector

Modifies the rule selector.

Link to this function

set_style_sheet_text(session, parameters, options \\ []) View Source
set_style_sheet_text(
  GenServer.server(),
  %{style_sheet_id: cdp_style_sheet_id_type(), text: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{optional(:source_map_url) => String.t()}} | {:error, term()}

CSS.setStyleSheetText

Sets the new stylesheet text.

Link to this function

set_style_texts(session, parameters, options \\ []) View Source
set_style_texts(
  GenServer.server(),
  %{edits: [cdp_style_declaration_edit_type()]},
  Tungsten.Connection.exec_options()
) :: {:ok, %{styles: [cdp_css_style_type()]}} | {:error, term()}

CSS.setStyleTexts

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

Link to this function

start_rule_usage_tracking(session, parameters \\ %{}, options \\ []) View Source
start_rule_usage_tracking(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

CSS.startRuleUsageTracking

Enables the selector recording.

Link to this function

stop_rule_usage_tracking(session, parameters \\ %{}, options \\ []) View Source
stop_rule_usage_tracking(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{rule_usage: [cdp_rule_usage_type()]}} | {:error, term()}

CSS.stopRuleUsageTracking

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_coverage_delta(session, parameters \\ %{}, options \\ []) View Source
take_coverage_delta(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{coverage: [cdp_rule_usage_type()]}} | {:error, term()}

CSS.takeCoverageDelta

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