Skip to content

Commit

Permalink
fix: Skip updated but also removed accessibility nodes (#964)
Browse files Browse the repository at this point in the history
* fix: Skip updated but also removed accessibility nodes

* fix: lint
  • Loading branch information
marc2332 authored Oct 6, 2024
1 parent debbb04 commit 175aa29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/common/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl AccessibilityDirtyNodes {
self.added_or_updated.insert(node_id);
}

pub fn remove(&mut self, node_id: NodeId, ancestor_node_id: NodeId) {
self.removed.insert(node_id, ancestor_node_id);
pub fn remove(&mut self, node_id: NodeId, parent_id: NodeId) {
self.removed.insert(node_id, parent_id);
}

pub fn clear(&mut self) {
Expand Down
24 changes: 13 additions & 11 deletions crates/core/src/accessibility/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ impl AccessibilityTree {
);
}

// Remove all the removed nodes from the update list
for (node_id, _) in removed_ids.iter() {
added_or_updated_ids.remove(node_id);
self.map.retain(|_, id| id != node_id);
}

// Mark the parent of the removed nodes as updated
for (_, parent_id) in removed_ids.iter() {
if !removed_ids.contains_key(parent_id) {
added_or_updated_ids.insert(*parent_id);
}
}

// Mark the ancestors as modified
for node_id in added_or_updated_ids.clone() {
let node_ref = rdom.get(node_id).unwrap();
Expand All @@ -158,17 +171,6 @@ impl AccessibilityTree {
.insert(node_ref.get_accessibility_id().unwrap(), node_id);
}

// Mark the still existing ancenstors as modified
for (_, ancestor_node_id) in removed_ids.iter() {
added_or_updated_ids.insert(*ancestor_node_id);
}

// Remove all the deleted noeds from the added_or_update list
for (node_id, _) in removed_ids {
added_or_updated_ids.remove(&node_id);
self.map.retain(|_, id| *id != node_id);
}

// Create the updated nodes
let mut nodes = Vec::new();
for node_id in added_or_updated_ids {
Expand Down
5 changes: 2 additions & 3 deletions crates/core/src/dom/mutations_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ impl<'a> MutationsWriter<'a> {

// Remove from the accessibility tree
if node.get_accessibility_id().is_some() {
let closed_accessibility_node_id = node
let parent_id = node
.parent_id()
.unwrap_or(self.native_writer.rdom.root_id());
self.accessibility_dirty_nodes
.remove(node.id(), closed_accessibility_node_id);
self.accessibility_dirty_nodes.remove(node.id(), parent_id);
}

// Unite the removed area with the dirty area
Expand Down

0 comments on commit 175aa29

Please sign in to comment.