Module: WebkitRemote::Client::Dom

Included in:
WebkitRemote::Client
Defined in:
lib/webkit_remote/client/dom.rb

Overview

API for the DOM domain.

Instance Method Summary collapse

Instance Method Details

#clear_domWebkitRemote::Client

Removes all the cached DOM information.

Returns:



23
24
25
26
27
# File 'lib/webkit_remote/client/dom.rb', line 23

def clear_dom
  @dom_root = nil
  @dom_nodes.clear
  self
end

#dom_node(remote_id) ⇒ WebkitRemote::Client::DomNode

Looks up cached information about a DOM node.

Parameters:

  • remote_id (String)

    value of the nodeId attribute in the JSON returned by a Webkit remote debugging server

Returns:



38
39
40
# 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_rootWebkitRemote::Client::DomNode

Returns the root DOM node.

Returns:



8
9
10
# File 'lib/webkit_remote/client/dom.rb', line 8

def dom_root
  @dom_root ||= dom_root!
end

#dom_root!WebkitRemote::Client::DomNode

Obtains the root DOM node, bypassing the cache.

Returns:



15
16
17
18
# 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) ⇒ WebkitRemote::Client::DomNode

Updates cached information about a DOM node.

Parameters:

  • raw_node (Hash<String, Object>)

    a Node data structure in the DOM domain, as returned by a raw JSON RPC call to a Webkit remote debugging server

Returns:



53
54
55
56
# 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_domObject



43
44
45
# File 'lib/webkit_remote/client/dom.rb', line 43

def initialize_dom
  @dom_nodes = {}
end