Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions shell/platform/linux/fl_accessible_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ static ActionData* get_action(FlAccessibleNode* self, gint index) {
return static_cast<ActionData*>(g_ptr_array_index(self->actions, index));
}

// Checks if [object] is in [children].
static gboolean has_child(GPtrArray* children, AtkObject* object) {
for (guint i = 0; i < children->len; i++) {
if (g_ptr_array_index(children, i) == object) {
return TRUE;
}
}

return FALSE;
}

static void fl_accessible_node_dispose(GObject* object) {
FlAccessibleNode* self = FL_ACCESSIBLE_NODE(object);

Expand Down Expand Up @@ -330,11 +341,25 @@ void fl_accessible_node_set_children(FlAccessibleNode* self,
GPtrArray* children) {
g_return_if_fail(FL_IS_ACCESSIBLE_NODE(self));

g_ptr_array_remove_range(self->children, 0, self->children->len);
// Remove nodes that are no longer required.
for (guint i = 0; i < self->children->len;) {
AtkObject* object = ATK_OBJECT(g_ptr_array_index(self->children, i));
if (has_child(children, object)) {
i++;
} else {
g_signal_emit_by_name(self, "children-changed::remove", i, object,
nullptr);
g_ptr_array_remove_index(self->children, i);
}
}

// Add new nodes.
for (guint i = 0; i < children->len; i++) {
AtkObject* object = ATK_OBJECT(g_ptr_array_index(children, i));
g_ptr_array_add(self->children, g_object_ref(object));
g_signal_emit_by_name(self, "children-changed::add", i, object, nullptr);
if (!has_child(self->children, object)) {
g_ptr_array_add(self->children, g_object_ref(object));
g_signal_emit_by_name(self, "children-changed::add", i, object, nullptr);
}
}
}

Expand Down