Skip to content

Commit

Permalink
fix: use content box for OOPIF offset calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeIwaki committed Mar 23, 2022
1 parent 70128a8 commit 96c4ade
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/puppeteer/element_handle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,9 @@ def initialize
next
end
backend_node_id = parent._client.send_message('DOM.getFrameOwner', frameId: frame.id)['backendNodeId']
quads = parent._client.send_message('DOM.getContentQuads', backendNodeId: backend_node_id)['quads']
if !quads || quads.empty?
break
end
protocol_quads = quads.map { |quad| from_protocol_quad(quad) }
top_left_corner = protocol_quads.first.first
offset = offset + top_left_corner
result = parent._client.send_message('DOM.getBoxModel', backendNodeId: backend_node_id)
break unless result
offset = BoxModel.new(result['model'], offset: offset).content.first
frame = parent
end
offset
Expand Down Expand Up @@ -199,10 +195,10 @@ def clickable_point(offset = nil)
client_width = layout_viewport["clientWidth"]
client_height = layout_viewport["clientHeight"]

offset = oopif_offsets(@frame)
oopif_offset = oopif_offsets(@frame)
quads = result["quads"].
map { |quad| from_protocol_quad(quad) }.
map { |quad| apply_offsets_to_quad(quad, offset) }.
map { |quad| apply_offsets_to_quad(quad, oopif_offset) }.
map { |quad| intersect_quad_with_viewport(quad, client_width, client_height) }.
select { |quad| compute_quad_area(quad) > 1 }
if quads.empty?
Expand Down

0 comments on commit 96c4ade

Please sign in to comment.