pub(crate) struct DocumentEventHandler {Show 21 fields
window: Dom<Window>,
pending_input_events: DomRefCell<Vec<ConstellationInputEvent>>,
mouse_move_event_index: DomRefCell<Option<usize>>,
coalesced_mouse_move_event_ids: DomRefCell<Vec<InputEventId>>,
wheel_event_index: DomRefCell<Option<usize>>,
coalesced_wheel_event_ids: DomRefCell<Vec<InputEventId>>,
click_counting_info: DomRefCell<ClickCountingInfo>,
last_mouse_button_down_point: Cell<Option<Point2D<f32, CSSPixel>>>,
mouse_buttons_down: Cell<u32>,
current_hover_target: MutNullableDom<Element>,
current_active_element: MutNullableDom<Element>,
most_recently_clicked_element: MutNullableDom<Element>,
most_recent_mousemove_point: Cell<Option<Point2D<f32, CSSPixel>>>,
current_cursor: Cell<Option<Cursor>>,
active_touch_points: DomRefCell<Vec<Dom<Touch>>>,
active_keyboard_modifiers: Cell<Modifiers>,
active_pointer_ids: DomRefCell<FxHashMap<i32, i32>>,
next_touch_pointer_id: Cell<i32>,
access_key_handlers: DomRefCell<FxHashMap<NoTrace<Code>, Dom<HTMLElement>>>,
pending_pointer_capture: DomRefCell<FxHashMap<i32, Dom<Element>>>,
pointer_capture_target: DomRefCell<FxHashMap<i32, Dom<Element>>>,
}Expand description
The DocumentEventHandler is a structure responsible for handling input events for
the [crate::Document] and storing data related to event handling. It exists to
decrease the size of the [crate::Document] structure.
Fields§
§window: Dom<Window>The Window element for this DocumentEventHandler.
pending_input_events: DomRefCell<Vec<ConstellationInputEvent>>Pending input events, to be handled at the next rendering opportunity.
mouse_move_event_index: DomRefCell<Option<usize>>The index of the last mouse move event in the pending input events queue.
coalesced_mouse_move_event_ids: DomRefCell<Vec<InputEventId>>The InputEventIds of mousemove events that have been coalesced.
wheel_event_index: DomRefCell<Option<usize>>The index of the last wheel event in the pending input events queue.
This is non-standard behaviour.
According to https://www.w3.org/TR/pointerevents/#dfn-coalesced-events,
we should only coalesce pointermove events.
coalesced_wheel_event_ids: DomRefCell<Vec<InputEventId>>The InputEventIds of wheel events that have been coalesced.
click_counting_info: DomRefCell<ClickCountingInfo>The number of mouse buttons currently being pressed. This is used to ensure
that pointerup and pointerdown events are only sent when transitioning from
having no mouse buttons pressed to having any and vice-versa.
current_hover_target: MutNullableDom<Element>The element that is currently hovered by the cursor.
current_active_element: MutNullableDom<Element>The element that was most recently activated during a mouse button press or touch event.
most_recently_clicked_element: MutNullableDom<Element>The element that was most recently clicked.
most_recent_mousemove_point: Cell<Option<Point2D<f32, CSSPixel>>>The most recent mouse movement point, used for processing mouseleave events.
current_cursor: Cell<Option<Cursor>>The currently set Cursor or None if the Document isn’t being hovered
by the cursor.
active_touch_points: DomRefCell<Vec<Dom<Touch>>>§active_keyboard_modifiers: Cell<Modifiers>The active keyboard modifiers for the WebView. This is updated when receiving any input event.
active_pointer_ids: DomRefCell<FxHashMap<i32, i32>>Map from touch identifier to pointer ID for active touch points
next_touch_pointer_id: Cell<i32>Counter for generating unique pointer IDs for touch inputs
access_key_handlers: DomRefCell<FxHashMap<NoTrace<Code>, Dom<HTMLElement>>>A map holding information about currently registered access key handlers.
pending_pointer_capture: DomRefCell<FxHashMap<i32, Dom<Element>>>Map from pointer ID to pending pointer capture target override element. This is set by setPointerCapture and cleared by releasePointerCapture. https://w3c.github.io/pointerevents/#pointer-capture
pointer_capture_target: DomRefCell<FxHashMap<i32, Dom<Element>>>Map from pointer ID to the actual/current pointer capture target. Updated during process_pending_pointer_capture when events are dispatched.
Implementations§
Source§impl DocumentEventHandler
impl DocumentEventHandler
pub(crate) fn new(window: &Window) -> Self
Sourcepub(crate) fn note_pending_input_event(&self, event: ConstellationInputEvent)
pub(crate) fn note_pending_input_event(&self, event: ConstellationInputEvent)
Note a pending input event, to be processed at the next update_the_rendering task.
Sourcepub(crate) fn has_pending_input_events(&self) -> bool
pub(crate) fn has_pending_input_events(&self) -> bool
Whether or not this [Document] has any pending input events to be processed during
“update the rendering.”
pub(crate) fn alternate_action_keyboard_modifier_active(&self) -> bool
pub(crate) fn handle_pending_input_events(&self, cx: &mut JSContext)
fn notify_embedder_that_events_were_handled( &self, input_event_outcomes: Vec<InputEventOutcome>, )
Sourcefn target_for_events_following_focus(&self) -> DomRoot<EventTarget>
fn target_for_events_following_focus(&self) -> DomRoot<EventTarget>
When an event should be fired on the element that has focus, this returns the target. If
there is no associated element with the focused area (such as when the viewport is focused),
then the body is returned. If no body is returned then the Window is returned.
pub(crate) fn set_cursor(&self, cursor: Option<Cursor>)
fn handle_mouse_left_viewport_event( &self, cx: &mut JSContext, input_event: &ConstellationInputEvent, mouse_leave_event: &MouseLeftViewportEvent, )
fn handle_mouse_enter_leave_event( &self, cx: &mut JSContext, event_target: DomRoot<Node>, related_target: Option<DomRoot<Node>>, event_type: FireMouseEventType, hit_test_result: &HitTestResult, input_event: &ConstellationInputEvent, )
Sourcefn handle_native_mouse_move_event(
&self,
cx: &mut JSContext,
input_event: &ConstellationInputEvent,
)
fn handle_native_mouse_move_event( &self, cx: &mut JSContext, input_event: &ConstellationInputEvent, )
fn update_current_hover_target_and_status( &self, new_hover_target: Option<DomRoot<Element>>, )
pub(crate) fn handle_refresh_cursor(&self)
fn set_active_element(&self, original_target: &Element)
fn unset_active_element(&self)
https://w3c.github.io/uievents/#mouseevent-algorithms Handles native mouse down, mouse up, mouse click.
fn handle_touch_event( &self, cx: &mut JSContext, event: EmbedderTouchEvent, input_event: &ConstellationInputEvent, ) -> InputEventResult
Sourcefn update_active_touch_points_when_early_return(
&self,
event: EmbedderTouchEvent,
)
fn update_active_touch_points_when_early_return( &self, event: EmbedderTouchEvent, )
Updates the active touch points when a hit test fails early.
- For
Down: No action needed; a failed down event won’t create an active point. - For
Move: No action needed; position information is unavailable, so we cannot update. - For
Up/Cancel: Remove the corresponding touch point and its pointer ID mapping.
When a touchup or touchcancel occurs at that touch point, a warning is triggered: Received touchup/touchcancel event for a non-active touch point.
Sourcefn handle_keyboard_event(
&self,
cx: &mut JSContext,
keyboard_event: EmbedderKeyboardEvent,
) -> InputEventResult
fn handle_keyboard_event( &self, cx: &mut JSContext, keyboard_event: EmbedderKeyboardEvent, ) -> InputEventResult
The entry point for all key processing for web content
fn handle_ime_event( &self, cx: &mut JSContext, event: ImeEvent, ) -> InputEventResult
fn handle_wheel_event( &self, cx: &mut JSContext, event: EmbedderWheelEvent, input_event: &ConstellationInputEvent, ) -> InputEventResult
fn handle_gamepad_event(&self, gamepad_event: EmbedderGamepadEvent)
Sourcefn handle_gamepad_connect(
&self,
_index: usize,
name: String,
axis_bounds: (f64, f64),
button_bounds: (f64, f64),
supported_haptic_effects: GamepadSupportedHapticEffects,
)
fn handle_gamepad_connect( &self, _index: usize, name: String, axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, )
Sourcefn handle_gamepad_disconnect(&self, index: usize)
fn handle_gamepad_disconnect(&self, index: usize)
Sourcefn update_gamepad_state(
&self,
gamepad_index: usize,
update_type: GamepadUpdateType,
)
fn update_gamepad_state( &self, gamepad_index: usize, update_type: GamepadUpdateType, )
Sourcepub(crate) fn handle_editing_action(
&self,
cx: &mut JSContext,
element: Option<DomRoot<Element>>,
action: EditingActionEvent,
) -> InputEventResult
pub(crate) fn handle_editing_action( &self, cx: &mut JSContext, element: Option<DomRoot<Element>>, action: EditingActionEvent, ) -> InputEventResult
Sourcepub(crate) fn fire_clipboard_event(
&self,
cx: &mut JSContext,
target: Option<DomRoot<Element>>,
clipboard_event_type: ClipboardEventType,
) -> DomRoot<ClipboardEvent>
pub(crate) fn fire_clipboard_event( &self, cx: &mut JSContext, target: Option<DomRoot<Element>>, clipboard_event_type: ClipboardEventType, ) -> DomRoot<ClipboardEvent>
Sourcefn write_content_to_the_clipboard(&self, drag_data_store: &DragDataStore)
fn write_content_to_the_clipboard(&self, drag_data_store: &DragDataStore)
Sourcepub(crate) fn handle_embedder_scroll_event(
&self,
scrolled_node: ExternalScrollId,
)
pub(crate) fn handle_embedder_scroll_event( &self, scrolled_node: ExternalScrollId, )
Handle a scroll event triggered by user interactions from the embedder. https://drafts.csswg.org/cssom-view/#scrolling-events
Sourcepub(crate) fn maybe_dispatch_simulated_click(
&self,
cx: &mut JSContext,
node: &Node,
event: &KeyboardEvent,
) -> bool
pub(crate) fn maybe_dispatch_simulated_click( &self, cx: &mut JSContext, node: &Node, event: &KeyboardEvent, ) -> bool
https://w3c.github.io/uievents/#keydown
If the key is the Enter or (Space) key and the current focus is on a state-changing element, the default action MUST be to dispatch a click event, and a DOMActivate event if that event type is supported by the user agent.
pub(crate) fn run_default_keyboard_event_handler( &self, cx: &mut JSContext, node: &Node, event: &KeyboardEvent, )
pub(crate) fn do_keyboard_scroll( &self, cx: &mut JSContext, scroll: KeyboardScroll, )
Sourcefn get_or_create_pointer_id_for_touch(&self, touch_id: i32) -> i32
fn get_or_create_pointer_id_for_touch(&self, touch_id: i32) -> i32
Get or create a pointer ID for the given touch identifier. Returns the pointer ID to use for this touch.
Sourcefn remove_pointer_id_for_touch(&self, touch_id: i32)
fn remove_pointer_id_for_touch(&self, touch_id: i32)
Remove the pointer ID mapping for the given touch identifier.
Sourcefn is_primary_pointer(&self, pointer_id: i32) -> bool
fn is_primary_pointer(&self, pointer_id: i32) -> bool
Check if this is the primary pointer (for touch events). The first touch to make contact is the primary pointer.
Sourcefn fire_pointer_event_for_touch(
&self,
cx: &mut JSContext,
target_element: &Element,
touch: &Touch,
pointer_id: i32,
event_name: &str,
is_primary: bool,
pointer_type: &str,
input_event: &ConstellationInputEvent,
hit_test_result: &HitTestResult,
)
fn fire_pointer_event_for_touch( &self, cx: &mut JSContext, target_element: &Element, touch: &Touch, pointer_id: i32, event_name: &str, is_primary: bool, pointer_type: &str, input_event: &ConstellationInputEvent, hit_test_result: &HitTestResult, )
Fire pointerenter events hierarchically from topmost ancestor to target element. Fire pointerleave events hierarchically from target element to topmost ancestor. Used for touch devices that don’t support hover.
pub(crate) fn has_assigned_access_key(&self, element: &HTMLElement) -> bool
pub(crate) fn unassign_access_key(&self, element: &HTMLElement)
pub(crate) fn assign_access_key(&self, element: &HTMLElement, code: Code)
fn maybe_handle_accesskey( &self, cx: &mut JSContext, event: &KeyboardEvent, ) -> bool
pub(crate) fn focus_and_scroll_to_element_for_key_event( &self, cx: &mut JSContext, element: &Element, )
Sourcepub(crate) fn is_active_pointer(&self, pointer_id: i32) -> bool
pub(crate) fn is_active_pointer(&self, pointer_id: i32) -> bool
Check if a pointer ID corresponds to an active pointer. https://w3c.github.io/pointerevents/#dfn-active-pointer
Sourcepub(crate) fn set_pending_pointer_capture(
&self,
pointer_id: i32,
element: &Element,
)
pub(crate) fn set_pending_pointer_capture( &self, pointer_id: i32, element: &Element, )
Set the pending pointer capture target override for a pointer. https://w3c.github.io/pointerevents/#setting-pointer-capture
Sourcepub(crate) fn clear_pending_pointer_capture(&self, pointer_id: i32)
pub(crate) fn clear_pending_pointer_capture(&self, pointer_id: i32)
Clear the pending pointer capture target override for a pointer. https://w3c.github.io/pointerevents/#releasing-pointer-capture
Sourcepub(crate) fn get_pending_pointer_capture(
&self,
pointer_id: i32,
) -> Option<DomRoot<Element>>
pub(crate) fn get_pending_pointer_capture( &self, pointer_id: i32, ) -> Option<DomRoot<Element>>
Get the pending pointer capture target override for a pointer.
Sourcepub(crate) fn has_pointer_capture(
&self,
pointer_id: i32,
element: &Element,
) -> bool
pub(crate) fn has_pointer_capture( &self, pointer_id: i32, element: &Element, ) -> bool
Check if an element has pointer capture for a given pointer ID. https://w3c.github.io/pointerevents/#dom-element-haspointercapture
Sourcefn get_pointer_capture_target(
&self,
pointer_id: i32,
) -> Option<DomRoot<Element>>
fn get_pointer_capture_target( &self, pointer_id: i32, ) -> Option<DomRoot<Element>>
Get the current pointer capture target for event dispatch. Returns the capture target if set and connected, otherwise None. This returns the actual/current target (pointer_capture_target), not the pending target that will be applied after process_pending.
Sourcefn release_disconnected_pointer_capture(
&self,
cx: &mut JSContext,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
) -> bool
fn release_disconnected_pointer_capture( &self, cx: &mut JSContext, pointer_id: i32, pointer_type: &str, is_primary: bool, ) -> bool
Check if the capture target is disconnected and release it if so. This fires lostpointercapture at the document per spec. Must be called before firing any pointer event. Returns true if a disconnected capture was released. https://w3c.github.io/pointerevents/#process-pending-pointer-capture
Sourcefn fire_pointer_capture_event(
&self,
cx: &mut JSContext,
event_type: &str,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
target: &Element,
)
fn fire_pointer_capture_event( &self, cx: &mut JSContext, event_type: &str, pointer_id: i32, pointer_type: &str, is_primary: bool, target: &Element, )
Fire a gotpointercapture or lostpointercapture event at an Element. https://w3c.github.io/pointerevents/#the-gotpointercapture-and-lostpointercapture-events
Sourcefn fire_pointer_capture_event_at_target(
&self,
cx: &mut JSContext,
event_type: &str,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
target: &EventTarget,
)
fn fire_pointer_capture_event_at_target( &self, cx: &mut JSContext, event_type: &str, pointer_id: i32, pointer_type: &str, is_primary: bool, target: &EventTarget, )
Fire a pointer capture event at a specific EventTarget (e.g., the document).
Sourcefn fire_pointer_boundary_event(
&self,
cx: &mut JSContext,
event_type: &str,
bubbles: EventBubbles,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
target: &Element,
related_target: Option<&Element>,
)
fn fire_pointer_boundary_event( &self, cx: &mut JSContext, event_type: &str, bubbles: EventBubbles, pointer_id: i32, pointer_type: &str, is_primary: bool, target: &Element, related_target: Option<&Element>, )
Fire a single boundary PointerEvent (pointerout/pointerleave/
pointerover/pointerenter) at target, with related_target set to
the element being entered from or left to.
Sourcefn fire_pointer_capture_boundary_transition(
&self,
cx: &mut JSContext,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
old_target: &Element,
new_target: &Element,
)
fn fire_pointer_capture_boundary_transition( &self, cx: &mut JSContext, pointer_id: i32, pointer_type: &str, is_primary: bool, old_target: &Element, new_target: &Element, )
Fire the pointer boundary events that accompany a pointer-capture
transition from old_target to new_target for hoverable pointers.
Per spec, only fired for pointer types that support hover (mouse, pen
with hover); touch is skipped.
Sourcefn implicit_release_pointer_capture(
&self,
cx: &mut JSContext,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
)
fn implicit_release_pointer_capture( &self, cx: &mut JSContext, pointer_id: i32, pointer_type: &str, is_primary: bool, )
Implicitly release pointer capture when pointer is lifted or canceled. https://w3c.github.io/pointerevents/#implicit-release-of-pointer-capture
Sourcefn process_pending_pointer_capture(
&self,
cx: &mut JSContext,
pointer_id: i32,
pointer_type: &str,
is_primary: bool,
)
fn process_pending_pointer_capture( &self, cx: &mut JSContext, pointer_id: i32, pointer_type: &str, is_primary: bool, )
Process pending pointer capture before dispatching a pointer event. Fires gotpointercapture/lostpointercapture as needed. https://w3c.github.io/pointerevents/#process-pending-pointer-capture
Trait Implementations§
Source§impl MallocSizeOf for DocumentEventHandler
impl MallocSizeOf for DocumentEventHandler
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl !Freeze for DocumentEventHandler
impl !RefUnwindSafe for DocumentEventHandler
impl !Send for DocumentEventHandler
impl !Sync for DocumentEventHandler
impl Unpin for DocumentEventHandler
impl UnsafeUnpin for DocumentEventHandler
impl !UnwindSafe for DocumentEventHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more