module WebkitRemote::Client::Dom

API for the DOM domain.

Public Instance Methods

clear_dom() click to toggle source

Removes all the cached DOM information.

@return [WebkitRemote::Client] self

# File lib/webkit_remote/client/dom.rb, line 23
def clear_dom
  @dom_root = nil
  @dom_nodes.clear
  self
end
dom_node(remote_id) click to toggle source

Looks up cached information about a DOM node.

@private Use WebkitRemote::Client::Dom#query_selector or the other public

APIs instead of calling this directly

@param [String] remote_id value of the nodeId attribute in the JSON

returned by a Webkit remote debugging server

@return [WebkitRemote::Client::DomNode] cached information about the given

DOM node
# File lib/webkit_remote/client/dom.rb, line 38
def dom_node(remote_id)
  @dom_nodes[remote_id] ||= WebkitRemote::Client::DomNode.new remote_id, self
end
dom_root() click to toggle source

@return [WebkitRemote::Client::DomNode] the root DOM node

# File lib/webkit_remote/client/dom.rb, line 8
def dom_root
  @dom_root ||= dom_root!
end
dom_root!() click to toggle source

Obtains the root DOM node, bypassing the cache.

@return [WebkitRemote::Client::DomNode] the root DOM node

# File lib/webkit_remote/client/dom.rb, line 15
def dom_root!
  result = @rpc.call 'DOM.getDocument'
  @dom_root = dom_update_node result['root']
end
dom_update_node(raw_node) click to toggle source

Updates cached information about a DOM node.

@param [Hash<String, Object>] raw_node a Node data structure in the DOM

domain, as returned by a raw JSON RPC call to a Webkit remote debugging
server

@return [WebkitRemote::Client::DomNode] the updated cached information

# File lib/webkit_remote/client/dom.rb, line 53
def dom_update_node(raw_node)
  remote_id = raw_node['nodeId']
  dom_node(remote_id).update_all raw_node
end
initialize_dom() click to toggle source

@private Called by the Client constructor to set up Dom data.

# File lib/webkit_remote/client/dom.rb, line 43
def initialize_dom
  @dom_nodes = {}
end