pub(crate) struct DocumentFocusHandler {
window: Dom<Window>,
focused_element: MutNullableDom<Element>,
focus_sequence: Cell<FocusSequenceNumber>,
has_focus: Cell<bool>,
}Expand description
The DocumentFocusHandler is a structure responsible for handling and storing data related to
focus for the Document. It exists to decrease the size of the Document.
structure.
Fields§
§window: Dom<Window>The Window element for this DocumentFocusHandler.
focused_element: MutNullableDom<Element>The element that currently has focus in the Document.
focus_sequence: Cell<FocusSequenceNumber>The last sequence number sent to the constellation.
has_focus: Cell<bool>Indicates whether the container is included in the top-level browsing
context’s focus chain (not considering system focus). Permanently true
for a top-level document.
Implementations§
Source§impl DocumentFocusHandler
impl DocumentFocusHandler
pub(crate) fn new(window: &Window, has_focus: bool) -> Self
pub(crate) fn has_focus(&self) -> bool
Sourcepub(crate) fn focused_element(&self) -> Option<DomRoot<Element>>
pub(crate) fn focused_element(&self) -> Option<DomRoot<Element>>
Return the element that currently has focus. If None is returned the viewport itself has focus.
Sourcepub(crate) fn set_focused_element(&self, new_element: Option<&Element>)
pub(crate) fn set_focused_element(&self, new_element: Option<&Element>)
Set the element that currently has focus and update the focus state for both the previously
set element (if any) and the new one, as well as the new one. This will not do anything if
the new element is the same as the previous one. Note that this will not fire any focus
events. If that is necessary the DocumentFocusHandler::focus should be used.
Sourcepub fn focus_sequence(&self) -> FocusSequenceNumber
pub fn focus_sequence(&self) -> FocusSequenceNumber
Get the last sequence number sent to the constellation.
Received focus-related messages with sequence numbers less than the one returned by this method must be discarded.
Sourcefn increment_fetch_focus_sequence(&self) -> FocusSequenceNumber
fn increment_fetch_focus_sequence(&self) -> FocusSequenceNumber
Generate the next sequence number for focus-related messages.
Sourcepub(crate) fn handle_container_unfocus(&self, can_gc: CanGc)
pub(crate) fn handle_container_unfocus(&self, can_gc: CanGc)
Update the local focus state accordingly after being notified that the document’s container is removed from the top-level browsing context’s focus chain (not considering system focus).
Sourcepub(crate) fn focus(
&self,
focus_operation: FocusOperation,
focus_initiator: FocusInitiator,
can_gc: CanGc,
)
pub(crate) fn focus( &self, focus_operation: FocusOperation, focus_initiator: FocusInitiator, can_gc: CanGc, )
Reassign the focus context to the element that last requested focus during this transaction, or the document if no elements requested it.
Sourcefn fire_focus_event(
&self,
focus_event_type: FocusEventType,
event_target: &EventTarget,
related_target: Option<&EventTarget>,
can_gc: CanGc,
)
fn fire_focus_event( &self, focus_event_type: FocusEventType, event_target: &EventTarget, related_target: Option<&EventTarget>, can_gc: CanGc, )
Sourcepub(crate) fn perform_focus_fixup_rule(&self, can_gc: CanGc)
pub(crate) fn perform_focus_fixup_rule(&self, can_gc: CanGc)
https://html.spec.whatwg.org/multipage/#focus-fixup-rule
For each doc of docs, if the focused area of doc is not a focusable area, then run the focusing steps for doc’s viewport, and set doc’s relevant global object’s navigation API’s focus changed during ongoing navigation to false.
TODO: Handle the “focus changed during ongoing navigation” flag.
Trait Implementations§
Source§impl MallocSizeOf for DocumentFocusHandler
impl MallocSizeOf for DocumentFocusHandler
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl !Freeze for DocumentFocusHandler
impl !RefUnwindSafe for DocumentFocusHandler
impl !Send for DocumentFocusHandler
impl !Sync for DocumentFocusHandler
impl Unpin for DocumentFocusHandler
impl !UnwindSafe for DocumentFocusHandler
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