Class: WebkitRemote::Client::DomNode

Inherits:
Object
  • Object
show all
Defined in:
lib/webkit_remote_unstable/dom.rb,
lib/webkit_remote_unstable/css.rb

Overview

Unstable cached information about a DOM node.

Instance Method Summary collapse

Instance Method Details

#box_modelWebkitRemote::Client::BoxModel

This node’s box model information.

Returns:

  • (WebkitRemote::Client::BoxModel)

    the node’s box model layout



28
29
30
# File 'lib/webkit_remote_unstable/dom.rb', line 28

def box_model
  @box_model ||= box_model!
end

#box_model!WebkitRemote::Client::BoxModel

Retrieves this node’s box model, bypassing the cache.

Returns:

  • (WebkitRemote::Client::BoxModel)

    the node’s box model layout



35
36
37
38
# File 'lib/webkit_remote_unstable/dom.rb', line 35

def box_model!
  result = @client.rpc.call 'DOM.getBoxModel', nodeId: @remote_id
  WebkitRemote::Client::DomBoxModel.new result['model']
end

#computed_styleHash<Symbol, String>

Returns computed CSS attributes for this node.

Returns:

  • (Hash<Symbol, String>)

    computed CSS attributes for this node



42
43
44
# File 'lib/webkit_remote_unstable/css.rb', line 42

def computed_style
  @computed_style ||= computed_style!
end

#computed_style!Hash<Symbol, String>

Gets the node’s computed CSS attributes, bypassing the node cache.

Returns:

  • (Hash<Symbol, String>)

    computed CSS attributes for this node



49
50
51
52
53
54
# File 'lib/webkit_remote_unstable/css.rb', line 49

def computed_style!
  result = @client.rpc.call 'CSS.getComputedStyleForNode', nodeId: @remote_id
  @computed_style = Hash[result['computedStyle'].map { |property|
    [property['name'].gsub('-', '_').to_sym, property['value']]
  }]
end

#initialize_cssObject



57
58
59
# File 'lib/webkit_remote_unstable/css.rb', line 57

def initialize_css
  @computed_style = nil
end

#initialize_unstableObject



41
42
43
# File 'lib/webkit_remote_unstable/dom.rb', line 41

def initialize_unstable
  @box_model = nil
end