render: DOM to layout tree and per-node geometry
Walk a live DomTree, compute each element's style (tag UA defaults plus inline style), build a taffy layout tree, and return border-box geometry keyed by NodeId. Block/flex structure, explicit sizes, and the box model are correct; text nodes do not yet contribute to size (inline/text layout lands with the paint phase). This completes the layout core: a real DOM now produces real geometry, pure Rust, behind the opt-in render crate. JS exposure is next.
This commit is contained in:
1 parent
5ed34ea8d4
commit
f0f9b048d0
3 files changed
+132
-1
No files matched your search
@@ -16,6 +16,9 @@ use taffy::prelude::*;
|
||||
mod style;
|
||||
pub use style::compute_style;
|
||||
|
||||
mod dom;
|
||||
pub use dom::{layout_dom, DomLayout};
|
||||
|
||||
/// An axis-aligned rectangle in CSS pixels, relative to the containing block.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||
pub struct Rect {
|
||||
@@ -125,7 +128,7 @@ fn read_node(tree: &TaffyTree, id: NodeId) -> NodeRect {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_taffy_style(style: &LayoutStyle) -> Style {
|
||||
pub(crate) fn to_taffy_style(style: &LayoutStyle) -> Style {
|
||||
let mut s = Style::DEFAULT;
|
||||
s.display = match style.display {
|
||||
Display::Block => taffy::style::Display::Block,
|
||||
|
||||
Reference in new issue
Block a user