Tungsten v0.1.0 Tungsten.CDP.DOMSnapshot View Source

DOMSnapshot

This domain facilitates obtaining document snapshots with DOM, layout, and style information.

Link to this section Summary

Link to this section Types

Link to this type

cdp_array_of_strings_type() View Source
cdp_array_of_strings_type() :: [cdp_string_index_type()]

DOMSnapshot.ArrayOfStrings

Index of the string in the strings table.

Link to this type

cdp_computed_style_type() View Source
cdp_computed_style_type() :: %{properties: [cdp_name_value_type()]}

DOMSnapshot.ComputedStyle

A subset of the full ComputedStyle as defined by the request whitelist.

Link to this type

cdp_document_snapshot_type() View Source
cdp_document_snapshot_type() :: %{
  :document_url => cdp_string_index_type(),
  :base_url => cdp_string_index_type(),
  :content_language => cdp_string_index_type(),
  :encoding_name => cdp_string_index_type(),
  :public_id => cdp_string_index_type(),
  :system_id => cdp_string_index_type(),
  :frame_id => cdp_string_index_type(),
  :nodes => cdp_node_tree_snapshot_type(),
  :layout => cdp_layout_tree_snapshot_type(),
  :text_boxes => cdp_text_box_snapshot_type(),
  optional(:scroll_offset_x) => integer() | float(),
  optional(:scroll_offset_y) => integer() | float()
}

DOMSnapshot.DocumentSnapshot

Document snapshot.

Link to this type

cdp_dom_node_type() View Source
cdp_dom_node_type() :: %{
  :node_type => integer(),
  :node_name => String.t(),
  :node_value => String.t(),
  optional(:text_value) => String.t(),
  optional(:input_value) => String.t(),
  optional(:input_checked) => boolean(),
  optional(:option_selected) => boolean(),
  :backend_node_id => Tungsten.CDP.DOM.cdp_backend_node_id_type(),
  optional(:child_node_indexes) => [integer()],
  optional(:attributes) => [cdp_name_value_type()],
  optional(:pseudo_element_indexes) => [integer()],
  optional(:layout_node_index) => integer(),
  optional(:document_url) => String.t(),
  optional(:base_url) => String.t(),
  optional(:content_language) => String.t(),
  optional(:document_encoding) => String.t(),
  optional(:public_id) => String.t(),
  optional(:system_id) => String.t(),
  optional(:frame_id) => Tungsten.CDP.Page.cdp_frame_id_type(),
  optional(:content_document_index) => integer(),
  optional(:pseudo_type) => Tungsten.CDP.DOM.cdp_pseudo_type_type(),
  optional(:shadow_root_type) => Tungsten.CDP.DOM.cdp_shadow_root_type_type(),
  optional(:is_clickable) => boolean(),
  optional(:event_listeners) => [
    Tungsten.CDP.DOMDebugger.cdp_event_listener_type()
  ],
  optional(:current_source_url) => String.t(),
  optional(:origin_url) => String.t(),
  optional(:scroll_offset_x) => integer() | float(),
  optional(:scroll_offset_y) => integer() | float()
}

DOMSnapshot.DOMNode

A Node in the DOM tree.

Link to this type

cdp_inline_text_box_type() View Source
cdp_inline_text_box_type() :: %{
  bounding_box: Tungsten.CDP.DOM.cdp_rect_type(),
  start_character_index: integer(),
  num_characters: integer()
}

DOMSnapshot.InlineTextBox

Details of post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.

Link to this type

cdp_layout_tree_node_type() View Source
cdp_layout_tree_node_type() :: %{
  :dom_node_index => integer(),
  :bounding_box => Tungsten.CDP.DOM.cdp_rect_type(),
  optional(:layout_text) => String.t(),
  optional(:inline_text_nodes) => [cdp_inline_text_box_type()],
  optional(:style_index) => integer(),
  optional(:paint_order) => integer(),
  optional(:is_stacking_context) => boolean()
}

DOMSnapshot.LayoutTreeNode

Details of an element in the DOM tree with a LayoutObject.

Link to this type

cdp_layout_tree_snapshot_type() View Source
cdp_layout_tree_snapshot_type() :: %{
  node_index: [integer()],
  styles: [cdp_array_of_strings_type()],
  bounds: [cdp_rectangle_type()],
  text: [cdp_string_index_type()],
  stacking_contexts: cdp_rare_boolean_data_type()
}

DOMSnapshot.LayoutTreeSnapshot

Details of an element in the DOM tree with a LayoutObject.

Link to this type

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

DOMSnapshot.NameValue

A name/value pair.

Link to this type

cdp_node_tree_snapshot_type() View Source
cdp_node_tree_snapshot_type() :: %{
  optional(:parent_index) => [integer()],
  optional(:node_type) => [integer()],
  optional(:node_name) => [cdp_string_index_type()],
  optional(:node_value) => [cdp_string_index_type()],
  optional(:backend_node_id) => [Tungsten.CDP.DOM.cdp_backend_node_id_type()],
  optional(:attributes) => [cdp_array_of_strings_type()],
  optional(:text_value) => cdp_rare_string_data_type(),
  optional(:input_value) => cdp_rare_string_data_type(),
  optional(:input_checked) => cdp_rare_boolean_data_type(),
  optional(:option_selected) => cdp_rare_boolean_data_type(),
  optional(:content_document_index) => cdp_rare_integer_data_type(),
  optional(:pseudo_type) => cdp_rare_string_data_type(),
  optional(:is_clickable) => cdp_rare_boolean_data_type(),
  optional(:current_source_url) => cdp_rare_string_data_type(),
  optional(:origin_url) => cdp_rare_string_data_type()
}

DOMSnapshot.NodeTreeSnapshot

Table containing nodes.

Link to this type

cdp_rare_boolean_data_type() View Source
cdp_rare_boolean_data_type() :: %{index: [integer()]}

DOMSnapshot.RareBooleanData

This type has no documentation

Link to this type

cdp_rare_integer_data_type() View Source
cdp_rare_integer_data_type() :: %{index: [integer()], value: [integer()]}

DOMSnapshot.RareIntegerData

This type has no documentation

Link to this type

cdp_rare_string_data_type() View Source
cdp_rare_string_data_type() :: %{
  index: [integer()],
  value: [cdp_string_index_type()]
}

DOMSnapshot.RareStringData

Data that is only present on rare nodes.

Link to this type

cdp_rectangle_type() View Source
cdp_rectangle_type() :: [integer() | float()]

DOMSnapshot.Rectangle

This type has no documentation

Link to this type

cdp_string_index_type() View Source
cdp_string_index_type() :: integer()

DOMSnapshot.StringIndex

Index of the string in the strings table.

Link to this type

cdp_text_box_snapshot_type() View Source
cdp_text_box_snapshot_type() :: %{
  layout_index: [integer()],
  bounds: [cdp_rectangle_type()],
  start: [integer()],
  length: [integer()]
}

DOMSnapshot.TextBoxSnapshot

Details of post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.

Link to this section Functions

Link to this function

capture_snapshot(session, parameters, options \\ []) View Source
capture_snapshot(
  GenServer.server(),
  %{computed_styles: [String.t()]},
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{documents: [cdp_document_snapshot_type()], strings: [String.t()]}}
  | {:error, term()}

DOMSnapshot.captureSnapshot

Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.

Link to this function

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

DOMSnapshot.disable

Disables DOM snapshot 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()}

DOMSnapshot.enable

Enables DOM snapshot agent for the given page.

Link to this function

get_snapshot(session, parameters, options \\ []) View Source
get_snapshot(
  GenServer.server(),
  %{
    :computed_style_whitelist => [String.t()],
    optional(:include_event_listeners) => boolean(),
    optional(:include_paint_order) => boolean(),
    optional(:include_user_agent_shadow_tree) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     dom_nodes: [cdp_dom_node_type()],
     layout_tree_nodes: [cdp_layout_tree_node_type()],
     computed_styles: [cdp_computed_style_type()]
   }}
  | {:error, term()}

DOMSnapshot.getSnapshot

Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.