Tungsten v0.1.0 Tungsten.CDP.CSS View Source
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
Link to this section Types
cdp_css_computed_style_property_type() View Source
This type has no documentation
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()
}
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 keyframe rule representation.
cdp_css_keyframes_rule_type()
View Source
cdp_css_keyframes_rule_type() :: %{
animation_name: cdp_value_type(),
keyframes: [cdp_css_keyframe_rule_type()]
}
cdp_css_keyframes_rule_type() :: %{
animation_name: cdp_value_type(),
keyframes: [cdp_css_keyframe_rule_type()]
}
CSS keyframes rule representation.
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()]
}
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 media rule descriptor.
cdp_css_property_type() View Source
CSS property declaration data.
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()]
}
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 rule representation.
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()
}
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 stylesheet metainformation.
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()
}
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 style representation.
cdp_font_face_type() View Source
Properties of a web font: https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions
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()]
}
cdp_inherited_style_entry_type() :: %{
optional(:inline_style) => cdp_css_style_type(),
:matched_css_rules => [cdp_rule_match_type()]
}
Inherited CSS rule collection from ancestor node.
cdp_media_query_expression_type() View Source
Media query expression descriptor.
cdp_media_query_type()
View Source
cdp_media_query_type() :: %{
expressions: [cdp_media_query_expression_type()],
active: boolean()
}
cdp_media_query_type() :: %{
expressions: [cdp_media_query_expression_type()],
active: boolean()
}
Media query descriptor.
cdp_platform_font_usage_type() View Source
Information about amount of glyphs that were rendered with given font.
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()]
}
cdp_pseudo_element_matches_type() :: %{
pseudo_type: Tungsten.CDP.DOM.cdp_pseudo_type_type(),
matches: [cdp_rule_match_type()]
}
CSS rule collection for a single pseudo style.
cdp_rule_match_type()
View Source
cdp_rule_match_type() :: %{
rule: cdp_css_rule_type(),
matching_selectors: [integer()]
}
cdp_rule_match_type() :: %{
rule: cdp_css_rule_type(),
matching_selectors: [integer()]
}
Match data for a CSS rule.
cdp_rule_usage_type() View Source
CSS coverage information.
cdp_selector_list_type()
View Source
cdp_selector_list_type() :: %{selectors: [cdp_value_type()], text: String.t()}
cdp_selector_list_type() :: %{selectors: [cdp_value_type()], text: String.t()}
Selector list data.
cdp_shorthand_entry_type() View Source
This type has no documentation
cdp_source_range_type() View Source
Text range within a resource. All numbers are zero-based.
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()
}
cdp_style_declaration_edit_type() :: %{
style_sheet_id: cdp_style_sheet_id_type(),
range: cdp_source_range_type(),
text: String.t()
}
A descriptor of operation to mutate style declaration text.
cdp_style_sheet_id_type()
View Source
cdp_style_sheet_id_type() :: String.t()
cdp_style_sheet_id_type() :: String.t()
This type has no documentation
cdp_style_sheet_origin_type()
View Source
cdp_style_sheet_origin_type() ::
:regular | :inspector | :"user-agent" | :injected
cdp_style_sheet_origin_type() :: :regular | :inspector | :"user-agent" | :injected
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.
cdp_value_type()
View Source
cdp_value_type() :: %{
:text => String.t(),
optional(:range) => cdp_source_range_type()
}
cdp_value_type() :: %{
:text => String.t(),
optional(:range) => cdp_source_range_type()
}
Data for a simple selector (these are delimited by commas in a selector list).
Link to this section Functions
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()}
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()}
Inserts a new rule with the given ruleText in a stylesheet with given styleSheetId, at the
position specified by location.
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()}
collect_class_names( GenServer.server(), %{style_sheet_id: cdp_style_sheet_id_type()}, Tungsten.Connection.exec_options() ) :: {:ok, %{class_names: [String.t()]}} | {:error, term()}
Returns all class names from specified stylesheet.
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()}
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()}
Creates a new special "via-inspector" stylesheet in the frame with given frameId.
disable(session, parameters \\ %{}, options \\ [])
View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
{:ok, map()} | {:error, term()}
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) :: {:ok, map()} | {:error, term()}
Disables the CSS agent for the given page.
enable(session, parameters \\ %{}, options \\ [])
View Source
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
{:ok, map()} | {:error, term()}
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) :: {:ok, map()} | {:error, term()}
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(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()}
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()}
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
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()}
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()}
This command has no documentation
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()}
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()}
Returns the computed style for a DOM node identified by nodeId.
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()}
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()}
Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM
attributes) for a DOM node identified by nodeId.
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()}
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()}
Returns requested styles for a DOM node identified by nodeId.
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()}
get_media_queries( GenServer.server(), map(), Tungsten.Connection.exec_options() ) :: {:ok, %{medias: [cdp_css_media_type()]}} | {:error, term()}
Returns all media queries parsed by the rendering engine.
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()}
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()}
Requests information about platform fonts which we used to render child TextNodes in the given node.
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()}
get_style_sheet_text( GenServer.server(), %{style_sheet_id: cdp_style_sheet_id_type()}, Tungsten.Connection.exec_options() ) :: {:ok, %{text: String.t()}} | {:error, term()}
Returns the current textual content for a stylesheet.
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()}
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
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()}
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()}
Modifies the keyframe rule key text.
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()}
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()}
Modifies the rule selector.
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()}
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()}
Modifies the rule selector.
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()}
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()}
Sets the new stylesheet text.
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()}
set_style_texts( GenServer.server(), %{edits: [cdp_style_declaration_edit_type()]}, Tungsten.Connection.exec_options() ) :: {:ok, %{styles: [cdp_css_style_type()]}} | {:error, term()}
Applies specified style edits one after another in the given order.
start_rule_usage_tracking(session, parameters \\ %{}, options \\ [])
View Source
start_rule_usage_tracking(
GenServer.server(),
map(),
Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}
start_rule_usage_tracking( GenServer.server(), map(), Tungsten.Connection.exec_options() ) :: {:ok, map()} | {:error, term()}
Enables the selector recording.
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()}
stop_rule_usage_tracking( GenServer.server(), map(), Tungsten.Connection.exec_options() ) :: {:ok, %{rule_usage: [cdp_rule_usage_type()]}} | {:error, term()}
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(session, parameters \\ %{}, options \\ [])
View Source
take_coverage_delta(
GenServer.server(),
map(),
Tungsten.Connection.exec_options()
) :: {:ok, %{coverage: [cdp_rule_usage_type()]}} | {:error, term()}
take_coverage_delta( GenServer.server(), map(), Tungsten.Connection.exec_options() ) :: {:ok, %{coverage: [cdp_rule_usage_type()]}} | {:error, term()}
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation)