Skip to content

Commit

Permalink
Convert compute code to work with mutable measurables
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Aug 23, 2023
1 parent 831698d commit e26c020
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/compute/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::util::debug::NODE_LOGGER;
/// Perform full layout on a leaf node
pub(crate) fn perform_layout<Context>(
style: &Style,
measurable: Option<&impl Measurable<Context = Context>>,
measurable: Option<&mut impl Measurable<Context = Context>>,
known_dimensions: Size<Option<f32>>,
parent_size: Size<Option<f32>>,
available_space: Size<AvailableSpace>,
Expand All @@ -27,7 +27,7 @@ pub(crate) fn perform_layout<Context>(
/// Measure a leaf node's size
pub(crate) fn measure_size<Context>(
style: &Style,
measurable: Option<&impl Measurable<Context = Context>>,
measurable: Option<&mut impl Measurable<Context = Context>>,
known_dimensions: Size<Option<f32>>,
parent_size: Size<Option<f32>>,
available_space: Size<AvailableSpace>,
Expand All @@ -40,7 +40,7 @@ pub(crate) fn measure_size<Context>(
/// Compute the size of a leaf node (node with no children)
pub fn compute<Context>(
style: &Style,
measurable: Option<&impl Measurable<Context = Context>>,
measurable: Option<&mut impl Measurable<Context = Context>>,
known_dimensions: Size<Option<f32>>,
parent_size: Size<Option<f32>>,
available_space: Size<AvailableSpace>,
Expand Down
4 changes: 2 additions & 2 deletions src/compute/taffy_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn compute_node_layout<Measure: Measurable>(
(_, false) => match run_mode {
RunMode::PerformLayout => leaf::perform_layout(
&tree.nodes[node_key].style,
tree.nodes[node_key].needs_measure.then(|| &tree.measure_funcs[node_key]),
tree.nodes[node_key].needs_measure.then(|| &mut tree.measure_funcs[node_key]),
known_dimensions,
parent_size,
available_space,
Expand All @@ -239,7 +239,7 @@ fn compute_node_layout<Measure: Measurable>(
),
RunMode::ComputeSize => leaf::measure_size(
&tree.nodes[node_key].style,
tree.nodes[node_key].needs_measure.then(|| &tree.measure_funcs[node_key]),
tree.nodes[node_key].needs_measure.then(|| &mut tree.measure_funcs[node_key]),
known_dimensions,
parent_size,
available_space,
Expand Down

0 comments on commit e26c020

Please sign in to comment.