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
OpaqueNodes 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.
- Once reflow has begun, no further DOM mutations can occur, and we can safely un-root these
nodes by dropping all the strong references being held here. This will allow them to be
potential candidates for GC after reflow has finished.
See
Self::unroot_all_removed_nodes()andSelf::unroot_and_drain_all_removed_nodes().
Sourcepub(crate) fn unroot_and_drain_all_removed_nodes(
&mut self,
) -> FxHashSet<OpaqueNode>
pub(crate) fn unroot_and_drain_all_removed_nodes( &mut self, ) -> FxHashSet<OpaqueNode>
Clear all nodes which were rooted using Self::root_removed_node(), and return the nodes
which are still disconnected from the tree.
This should be called instead of Self::unroot_all_removed_nodes() during reflow
if [pref::expensive_accessibility_test_assertions_enabled] set.
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 only be called during reflow.
Trait Implementations§
Source§impl Clone for AccessibilityData
impl Clone for AccessibilityData
Source§fn clone(&self) -> AccessibilityData
fn clone(&self) -> AccessibilityData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for AccessibilityData
impl Default for AccessibilityData
Source§fn default() -> AccessibilityData
fn default() -> AccessibilityData
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
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
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>
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