script: Move point_in_initial_containing_block calculation to script (#38520)

Instead of calculating this value in the compositor, calculate it in
`ScriptThread` now that it is straightforward to get this value from the
layout spatial tree. This allows removing some tricky callback code in
the Compositor.

Testing: This shouldn't change any observable behavior so is covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-11 11:32:38 +02:00 committed by GitHub
parent 9d4004135b
commit 005164df4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 53 deletions

View file

@ -2611,6 +2611,10 @@ impl Window {
.into_iter()
.nth(0)?;
let point_in_frame = compositor_hit_test_result.point_in_viewport;
let point_relative_to_initial_containing_block =
point_in_frame + self.scroll_offset().cast_unit();
// SAFETY: This is safe because `Window::query_elements_from_point` has ensured that
// layout has run and any OpaqueNodes that no longer refer to real nodes are gone.
let address = UntrustedNodeAddress(result.node.0 as *const c_void);
@ -2618,9 +2622,8 @@ impl Window {
node: unsafe { from_untrusted_node_address(address) },
cursor: result.cursor,
point_in_node: result.point_in_target,
point_in_frame: compositor_hit_test_result.point_in_viewport,
point_relative_to_initial_containing_block: compositor_hit_test_result
.point_relative_to_initial_containing_block,
point_in_frame,
point_relative_to_initial_containing_block,
})
}