Skip to content

Commit 8d2a036

Browse files
authored
Use *const () to represent CompactLength and add implementation for 32 bit platforms (#789)
* Use *const() to represent CompactLength and add implementation for 32 bit platforms Signed-off-by: Nico Burns <[email protected]> * Add strict_provenance feature * Add strict_provenance feature to benchmarks * Fix serde impls for CompactLength Signed-off-by: Nico Burns <[email protected]> --------- Signed-off-by: Nico Burns <[email protected]>
1 parent 9da7a72 commit 8d2a036

15 files changed

+327
-99
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ grid = ["alloc", "dep:grid"]
5757
content_size = []
5858
## Causes algorithms to stores detailed information of the nodes in TaffyTree, with only CSS Grid supporting this.
5959
detailed_layout_info = []
60+
## Use strict provenance APIs for pointer manipulation. Using this feature requires Rust 1.84 or higher.
61+
strict_provenance = []
6062

6163
#! ### Taffy Tree
6264

benches/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ yoga = ["dep:yoga", "dep:slotmap", "dep:ordered-float"]
2727
yoga-super-deep = ["yoga"]
2828
taffy03 = ["dep:taffy_03"]
2929
content_size = ["taffy/content_size"]
30+
strict_provenance = ["taffy/strict_provenance"]
3031
small = []
3132
large = []
3233

examples/custom_tree_owned_partial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl taffy::LayoutPartialTree for Node {
146146
self.node_from_id_mut(node_id).layout = *layout
147147
}
148148

149-
fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
149+
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
150150
0.0
151151
}
152152

examples/custom_tree_owned_unsafe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl LayoutPartialTree for StatelessLayoutTree {
143143
unsafe { node_from_id_mut(node_id).unrounded_layout = *layout };
144144
}
145145

146-
fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
146+
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
147147
0.0
148148
}
149149

examples/custom_tree_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl taffy::LayoutPartialTree for Tree {
152152
self.node_from_id_mut(node_id).unrounded_layout = *layout;
153153
}
154154

155-
fn resolve_calc_value(&self, _val: u64, _basis: f32) -> f32 {
155+
fn resolve_calc_value(&self, _val: *const (), _basis: f32) -> f32 {
156156
0.0
157157
}
158158

src/compute/grid/explicit_grid.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) fn compute_explicit_grid_size_in_axis(
1414
style: &impl GridContainerStyle,
1515
template: &[TrackSizingFunction],
1616
inner_container_size: Size<Option<f32>>,
17-
resolve_calc_value: impl Fn(u64, f32) -> f32,
17+
resolve_calc_value: impl Fn(*const (), f32) -> f32,
1818
axis: AbsoluteAxis,
1919
) -> u16 {
2020
// If template contains no tracks, then there are trivially zero explicit tracks
@@ -106,7 +106,7 @@ pub(crate) fn compute_explicit_grid_size_in_axis(
106106
fn track_definite_value(
107107
sizing_function: &NonRepeatedTrackSizingFunction,
108108
parent_size: Option<f32>,
109-
calc_resolver: impl Fn(u64, f32) -> f32,
109+
calc_resolver: impl Fn(*const (), f32) -> f32,
110110
) -> f32 {
111111
let max_size = sizing_function.max.definite_value(parent_size, &calc_resolver);
112112
let min_size = sizing_function.min.definite_value(parent_size, &calc_resolver);

src/compute/grid/track_sizing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ where
110110

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

src/compute/grid/types/grid_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl GridItem {
189189
axis: AbstractAxis,
190190
axis_tracks: &[GridTrack],
191191
axis_parent_size: Option<f32>,
192-
resolve_calc_value: &dyn Fn(u64, f32) -> f32,
192+
resolve_calc_value: &dyn Fn(*const (), f32) -> f32,
193193
) -> Option<f32> {
194194
let spanned_tracks = &axis_tracks[self.track_range_excluding_lines(axis)];
195195
let tracks_all_fixed = spanned_tracks.iter().all(|track| {
@@ -215,7 +215,7 @@ impl GridItem {
215215
axis: AbstractAxis,
216216
axis_tracks: &[GridTrack],
217217
axis_parent_size: Option<f32>,
218-
resolve_calc_value: &dyn Fn(u64, f32) -> f32,
218+
resolve_calc_value: &dyn Fn(*const (), f32) -> f32,
219219
) -> Option<f32> {
220220
let spanned_tracks = &axis_tracks[self.track_range_excluding_lines(axis)];
221221
let tracks_all_fixed = spanned_tracks.iter().all(|track| {

src/compute/leaf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use core::unreachable;
1515
pub fn compute_leaf_layout<MeasureFunction>(
1616
inputs: LayoutInput,
1717
style: &impl CoreStyle,
18-
resolve_calc_value: impl Fn(u64, f32) -> f32,
18+
resolve_calc_value: impl Fn(*const (), f32) -> f32,
1919
measure_function: MeasureFunction,
2020
) -> LayoutOutput
2121
where

0 commit comments

Comments
 (0)