Detailed layout info cleanup (#774)
* Fix doc link
* Add CI check for flex + detailed_layout_info
* Improve doc comment on set_detailed_grid_info
* Don't inline docs on DetailedGridInto into
* Add getter for detailed_layout_into to `TaffyTree`
717471c1093c3097f92883c2a422a451b4b6af72 · by Nico Burns · 2025-01-03T09:05:13Z (1 year ago) · parent 859cd5182 · browse the tree at this commit
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 944bbc480..2a20c91d7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -136,6 +136,17 @@ jobs:
- run: cargo build --no-default-features --features grid,detailed_layout_info,std,taffy_tree
- run: cargo test --tests --no-default-features --features grid,detailed_layout_info,std,taffy_tree
+ # With detailed layout info
+ test-features-flex-detailed-info:
+ name: "Test Suite [std + flexbox + detailed_layout_info]"
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ - run: cargo build --no-default-features --features flexbox,detailed_layout_info,std
+ - run: cargo build --no-default-features --features flexbox,detailed_layout_info,std,taffy_tree
+ - run: cargo test --tests --no-default-features --features flexbox,detailed_layout_info,std,taffy_tree
+
# With alloc feature
test-features-grid-with-alloc:
diff --git a/src/lib.rs b/src/lib.rs
index a86d80176..15443ddae 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -103,7 +103,6 @@ pub use crate::compute::compute_flexbox_layout;
#[doc(inline)]
pub use crate::compute::compute_grid_layout;
#[cfg(feature = "detailed_layout_info")]
-#[doc(inline)]
pub use crate::compute::detailed_info::*;
#[doc(inline)]
pub use crate::compute::{
diff --git a/src/tree/layout.rs b/src/tree/layout.rs
index 06166c79e..445c2ed71 100644
--- a/src/tree/layout.rs
+++ b/src/tree/layout.rs
@@ -349,7 +349,7 @@ impl Layout {
#[cfg(feature = "detailed_layout_info")]
#[derive(Debug, Clone, PartialEq)]
pub enum DetailedLayoutInfo {
- /// Enum variant for [`DetailedGridInfo`]
+ /// Enum variant for [`DetailedGridInfo`](crate::compute::grid::DetailedGridInfo)
#[cfg(feature = "grid")]
Grid(Box<crate::compute::grid::DetailedGridInfo>),
/// For node that hasn't had any detailed information yet
diff --git a/src/tree/taffy_tree.rs b/src/tree/taffy_tree.rs
index 9cb38a8de..774b32187 100644
--- a/src/tree/taffy_tree.rs
+++ b/src/tree/taffy_tree.rs
@@ -817,6 +817,15 @@ impl<NodeContext> TaffyTree<NodeContext> {
&self.nodes[node.into()].unrounded_layout
}
+ /// Get the "detailed layout info" for a node.
+ ///
+ /// Currently this is only implemented for CSS Grid containers where it contains
+ /// the computed size of each grid track and the computed placement of each grid item
+ #[cfg(feature = "detailed_layout_info")]
+ pub fn detailed_layout_info(&mut self, node_id: NodeId) -> &DetailedLayoutInfo {
+ &self.nodes[node_id.into()].detailed_layout_info
+ }
+
/// Marks the layout of this node and its ancestors as outdated
///
/// WARNING: this may stack-overflow if the tree contains a cycle
diff --git a/src/tree/traits.rs b/src/tree/traits.rs
index 05b0f7da2..c59b28976 100644
--- a/src/tree/traits.rs
+++ b/src/tree/traits.rs
@@ -274,6 +274,9 @@ pub trait LayoutGridContainer: LayoutPartialTree {
fn get_grid_child_style(&self, child_node_id: NodeId) -> Self::GridItemStyle<'_>;
/// Set the node's detailed grid information
+ ///
+ /// Implementing this method is optional. Doing so allows you to access details about the the grid such as
+ /// the computed size of each grid track and the computed placement of each grid item.
#[cfg(feature = "detailed_layout_info")]
fn set_detailed_grid_info(&mut self, _node_id: NodeId, _detailed_grid_info: DetailedGridInfo) {
debug_log!("LayoutGridContainer::set_detailed_grid_info called");