Skip to content

Commit

Permalink
Merge pull request #640 from Sharktheone/renderer/unrenderable_nodes
Browse files Browse the repository at this point in the history
remove unrenderable nodes from render_tree
  • Loading branch information
Sharktheone authored Oct 19, 2024
2 parents c83e5a5 + 7e704c2 commit 722aa85
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/gosub_render_utils/src/render_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<L: Layouter, C: CssSystem> RenderTree<L, C> {
render_tree
}

fn generate_from<D: Document<C>>(&mut self, handle: DocumentHandle<D, C>) {
fn generate_from<D: Document<C>>(&mut self, mut handle: DocumentHandle<D, C>) {
// Iterate the complete document tree

let iter_handle = DocumentHandle::clone(&handle);
Expand All @@ -233,9 +233,17 @@ impl<L: Layouter, C: CssSystem> RenderTree<L, C> {

let Some(properties) = C::properties_from_node(node, doc.stylesheets(), handle.clone(), current_node_id)
else {
//we need to remove it from the parent in the render tree and from the document
if let Some(parent) = node.parent_id() {
if let Some(parent) = self.get_node_mut(parent) {
parent.children.retain(|id| *id != current_node_id)
}
}

drop(doc);

let mut doc = handle.get_mut();

// todo!("unrenderable node");
doc.detach_node(current_node_id);

continue;
};
Expand Down

0 comments on commit 722aa85

Please sign in to comment.