mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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:
parent
82ca2b92cd
commit
b75c3feb97
11 changed files with 307 additions and 210 deletions
29
components/script/dom/document_event_handler.rs
Normal file
29
components/script/dom/document_event_handler.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
use embedder_traits::Cursor;
|
||||
use euclid::Point2D;
|
||||
use style_traits::CSSPixel;
|
||||
|
||||
use crate::dom::bindings::root::MutNullableDom;
|
||||
use crate::dom::types::Element;
|
||||
|
||||
/// The [`DocumentEventHandler`] is a structure responsible for handling events for
|
||||
/// the [`crate::Document`] and storing data related to event handling. It exists to
|
||||
/// decrease the size of the [`crate::Document`] structure.
|
||||
#[derive(Default, JSTraceable, MallocSizeOf)]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct DocumentEventHandler {
|
||||
/// The element that is currently hovered by the cursor.
|
||||
pub(crate) current_hover_target: MutNullableDom<Element>,
|
||||
/// The most recent mouse movement point, used for processing `mouseleave` events.
|
||||
#[no_trace]
|
||||
pub(crate) most_recent_mousemove_point: Point2D<f32, CSSPixel>,
|
||||
/// The currently set [`Cursor`] or `None` if the `Document` isn't being hovered
|
||||
/// by the cursor.
|
||||
#[no_trace]
|
||||
pub(crate) current_cursor: Cell<Option<Cursor>>,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue