pub(crate) struct AccessibilityData {
rooted_nodes: FxHashSet<Dom<Node>>,
}Fields§
§rooted_nodes: FxHashSet<Dom<Node>>Nodes which have been unbound from the DOM but may not yet have been removed from the accessibility tree. This is cleared after each reflow.
Implementations§
Source§impl AccessibilityData
impl AccessibilityData
Sourcepub(crate) fn root_removed_node(&mut self, _no_gc: &NoGC, node_to_root: &Node)
pub(crate) fn root_removed_node(&mut self, _no_gc: &NoGC, node_to_root: &Node)
Root a node which has been removed from the DOM but which may still have an associated accessibility tree node. It will be unrooted after the next reflow, since the accessibility tree is updated as part of the reflow process.
Longer explanation:
- The accessibility tree doesn’t hold strong references to DOM nodes, but uses
[
OpaqueNode]s as a way of mapping from an incoming DOM node to an existing accessibility tree node. This allows us to cache previously computed accessibility data, and update it based on the current DOM node state, which is passed in to the update function. - If a DOM node is garbage collected before its corresponding node is removed from the
accessibility tree, there is a risk that another new DOM node may be created at the same
memory address, causing it to have an identical
OpaqueNode. If thisOpaqueNodewas used to look up a node in the accessibility tree, we would get the stale accessibility node corresponding to the node which was removed. - A DOM node is prevented from being garbage collected while it’s connected to the document;
it’s kept alive by strong references in its parent, child and/or sibling
Nodes (and in the case of the document itself, by a strong reference in the [Window]). SeeNode::first_child,Node::next_sibling, etc. - After a node is removed from the tree, those strong references are removed, and it may become a candidate for GC if its DOM object isn’t held (directly or indirectly) in script and it isn’t immediately inserted elsewhere in the DOM.
- To make sure the node isn’t GCed before the next accessibility update occurs, we temporarily root it here in between its removal from the tree and the subsequent reflow.
- During reflow, the accessibility tree is updated, and all stale accessibility nodes are removed.
- After reflow, we can safely un-root these nodes by dropping all the strong references
being held here, and allow them to potentially be GCed.
See
Self::unroot_all_removed_nodes().
Sourcepub(crate) fn unroot_all_removed_nodes(&mut self)
pub(crate) fn unroot_all_removed_nodes(&mut self)
Clear all nodes which were rooted using Self::root_removed_node().
This should be called at the end of reflow.
Trait Implementations§
Source§impl Clone for AccessibilityData
impl Clone for AccessibilityData
Source§fn clone(&self) -> AccessibilityData
fn clone(&self) -> AccessibilityData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for AccessibilityData
impl Default for AccessibilityData
Source§fn default() -> AccessibilityData
fn default() -> AccessibilityData
Returns the “default value” for a type. Read more
Source§impl MallocSizeOf for AccessibilityData
impl MallocSizeOf for AccessibilityData
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Auto Trait Implementations§
impl Freeze for AccessibilityData
impl !RefUnwindSafe for AccessibilityData
impl !Send for AccessibilityData
impl !Sync for AccessibilityData
impl Unpin for AccessibilityData
impl UnsafeUnpin for AccessibilityData
impl !UnwindSafe for AccessibilityData
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Creates a filterable data provider with the given name for debugging. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert