Skip to content

Make low-level layout algorithm functions public #434

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

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::tree::{LayoutTree, NodeId};
use crate::debug::NODE_LOGGER;

/// The public interface to Taffy's Flexbox algorithm implementation
pub(crate) struct FlexboxAlgorithm;
pub struct FlexboxAlgorithm;
impl LayoutAlgorithm for FlexboxAlgorithm {
const NAME: &'static str = "FLEXBOX";

Expand Down
2 changes: 1 addition & 1 deletion src/compute/grid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod types;
mod util;

/// The public interface to Taffy's CSS Grid algorithm implementation
pub(crate) struct CssGridAlgorithm;
pub struct CssGridAlgorithm;
impl LayoutAlgorithm for CssGridAlgorithm {
const NAME: &'static str = "CSS GRID";

Expand Down
2 changes: 1 addition & 1 deletion src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn compute_layout(
}

/// A common interface that all Taffy layout algorithms conform to
pub(crate) trait LayoutAlgorithm {
pub trait LayoutAlgorithm {
/// The name of the algorithm (mainly used for debug purposes)
const NAME: &'static str;

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ mod resolve;
mod sys;

pub use crate::compute::compute_layout;
#[cfg(feature = "flexbox")]
pub use crate::compute::flexbox::FlexboxAlgorithm;
#[cfg(feature = "grid")]
pub use crate::compute::grid::CssGridAlgorithm;
pub use crate::compute::LayoutAlgorithm;
pub use crate::node::Taffy;
6 changes: 6 additions & 0 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ use slotmap::{DefaultKey, Key, KeyData};
/// and u64 if needed.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct NodeId(u64);
impl NodeId {
/// Create a new NodeId from a u64 value
pub const fn new(val: u64) -> Self {
Self(val)
}
}

impl From<u64> for NodeId {
#[inline]
Expand Down