script/compositor: Send mouseleave events when cursor moves between <iframe>s (#38539)

Properly send `mouseleave` events when the cursor moves between
`<iframe>`s. This allows a better handling of cursor changes and status
text updates. Specifically, we do not need to continuously update the
cursor and the value can be cached in the `Document`. In addition,
status updates can now be sent properly when moving focus between
`<iframe>`s.

Note that style updates for `:hover` values are still broken, but less
so than before. Now the hover state on the `Node` is updated, but for
some
reason the restyle isn't taking place properly. This maintains the
status quo as far as behavior goes when hover moves between `<iframe>`s.

This change also adds a helper data structure to `Document` which will
eventually be responsible for event handling.

Testing: Cursor and status change are currently very hard to test as
the API test harness makes this difficult at the moment.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-11 14:31:54 +02:00 committed by GitHub
parent 82ca2b92cd
commit b75c3feb97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 307 additions and 210 deletions

View file

@ -2599,21 +2599,25 @@ impl Window {
self.layout().query_elements_from_point(point, flags)
}
#[allow(unsafe_code)]
pub(crate) fn hit_test_from_input_event(
&self,
input_event: &ConstellationInputEvent,
) -> Option<HitTestResult> {
let compositor_hit_test_result = input_event.hit_test_result.as_ref()?;
self.hit_test_from_point_in_viewport(
input_event.hit_test_result.as_ref()?.point_in_viewport,
)
}
#[allow(unsafe_code)]
pub(crate) fn hit_test_from_point_in_viewport(
&self,
point_in_frame: Point2D<f32, CSSPixel>,
) -> Option<HitTestResult> {
let result = self
.elements_from_point_query(
compositor_hit_test_result.point_in_viewport.cast_unit(),
ElementsFromPointFlags::empty(),
)
.elements_from_point_query(point_in_frame.cast_unit(), ElementsFromPointFlags::empty())
.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();