Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messed some things up with the render tree #415

Closed
Closed
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
15 changes: 13 additions & 2 deletions crates/gosub_styling/src/render_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::css_values::{
};

/// Map of all declared values for all nodes in the document
#[derive(Default)]
#[derive(Default, Debug)]
pub struct RenderTree {
pub nodes: HashMap<NodeId, RenderTreeNode>,
}
Expand Down Expand Up @@ -48,6 +48,7 @@ impl RenderTree {
}
}

#[derive(Debug)]
pub struct RenderTreeNode {
pub properties: CssProperties,
pub children: Vec<NodeId>,
Expand Down Expand Up @@ -128,6 +129,16 @@ pub fn generate_render_tree(document: DocumentHandle) -> Result<RenderTree> {
.get_node_by_id(current_node_id)
.expect("node not found");
if !node.is_element() {
let render_tree_node = RenderTreeNode {
properties: css_map_entry,
children: node.children.clone(),
parent: node.parent,
name: node.name.clone(), // We might be able to move node into render_tree_node
namespace: node.namespace.clone(),
data: node.data.clone(),
};

render_tree.nodes.insert(current_node_id, render_tree_node);
continue;
}

Expand Down Expand Up @@ -168,7 +179,7 @@ pub fn generate_render_tree(document: DocumentHandle) -> Result<RenderTree> {

let render_tree_node = RenderTreeNode {
properties: css_map_entry,
children: Vec::new(),
children: node.children.clone(),
parent: node.parent,
name: node.name.clone(), // We might be able to move node into render_tree_node
namespace: node.namespace.clone(),
Expand Down
Loading