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

Use *const () to represent CompactLength and add implementation for 32 bit platforms #789

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ grid = ["alloc", "dep:grid"]
content_size = []
## Causes algorithms to stores detailed information of the nodes in TaffyTree, with only CSS Grid supporting this.
detailed_layout_info = []
## Use strict provenance APIs for pointer manipulation. Using this feature requires Rust 1.84 or higher.
strict_provenance = []

#! ### Taffy Tree

Expand Down
1 change: 1 addition & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yoga = ["dep:yoga", "dep:slotmap", "dep:ordered-float"]
yoga-super-deep = ["yoga"]
taffy03 = ["dep:taffy_03"]
content_size = ["taffy/content_size"]
strict_provenance = ["taffy/strict_provenance"]
small = []
large = []

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_tree_owned_partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl taffy::LayoutPartialTree for Node {
self.node_from_id_mut(node_id).layout = *layout
}

fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
0.0
}

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_tree_owned_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl LayoutPartialTree for StatelessLayoutTree {
unsafe { node_from_id_mut(node_id).unrounded_layout = *layout };
}

fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
0.0
}

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_tree_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl taffy::LayoutPartialTree for Tree {
self.node_from_id_mut(node_id).unrounded_layout = *layout;
}

fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
0.0
}

Expand Down
4 changes: 2 additions & 2 deletions src/compute/grid/explicit_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn compute_explicit_grid_size_in_axis(
style: &impl GridContainerStyle,
template: &[TrackSizingFunction],
inner_container_size: Size<Option<f32>>,
resolve_calc_value: impl Fn(u64, f32) -> f32,
resolve_calc_value: impl Fn(*const (), f32) -> f32,
axis: AbsoluteAxis,
) -> u16 {
// If template contains no tracks, then there are trivially zero explicit tracks
Expand Down Expand Up @@ -106,7 +106,7 @@ pub(crate) fn compute_explicit_grid_size_in_axis(
fn track_definite_value(
sizing_function: &NonRepeatedTrackSizingFunction,
parent_size: Option<f32>,
calc_resolver: impl Fn(u64, f32) -> f32,
calc_resolver: impl Fn(*const (), f32) -> f32,
) -> f32 {
let max_size = sizing_function.max.definite_value(parent_size, &calc_resolver);
let min_size = sizing_function.min.definite_value(parent_size, &calc_resolver);
Expand Down
2 changes: 1 addition & 1 deletion src/compute/grid/track_sizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where

/// Simple pass-through function to `LayoutPartialTreeExt::calc`
#[inline(always)]
fn calc(&self, val: u64, basis: f32) -> f32 {
fn calc(&self, val: *const (), basis: f32) -> f32 {
self.tree.calc(val, basis)
}

Expand Down
4 changes: 2 additions & 2 deletions src/compute/grid/types/grid_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl GridItem {
axis: AbstractAxis,
axis_tracks: &[GridTrack],
axis_parent_size: Option<f32>,
resolve_calc_value: &dyn Fn(u64, f32) -> f32,
resolve_calc_value: &dyn Fn(*const (), f32) -> f32,
) -> Option<f32> {
let spanned_tracks = &axis_tracks[self.track_range_excluding_lines(axis)];
let tracks_all_fixed = spanned_tracks.iter().all(|track| {
Expand All @@ -215,7 +215,7 @@ impl GridItem {
axis: AbstractAxis,
axis_tracks: &[GridTrack],
axis_parent_size: Option<f32>,
resolve_calc_value: &dyn Fn(u64, f32) -> f32,
resolve_calc_value: &dyn Fn(*const (), f32) -> f32,
) -> Option<f32> {
let spanned_tracks = &axis_tracks[self.track_range_excluding_lines(axis)];
let tracks_all_fixed = spanned_tracks.iter().all(|track| {
Expand Down
2 changes: 1 addition & 1 deletion src/compute/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use core::unreachable;
pub fn compute_leaf_layout<MeasureFunction>(
inputs: LayoutInput,
style: &impl CoreStyle,
resolve_calc_value: impl Fn(u64, f32) -> f32,
resolve_calc_value: impl Fn(*const (), f32) -> f32,
measure_function: MeasureFunction,
) -> LayoutOutput
where
Expand Down
Loading
Loading