Skip to content

Commit

Permalink
Merge branch 'main' into jm/document-feature-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns authored Jun 30, 2024
2 parents 93f5865 + cd73db3 commit ddff4c4
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub fn compute_flexbox_layout(tree: &mut impl LayoutPartialTree, node: NodeId, i
}
}

debug_log!("FLEX: single-pass");
debug_log!("FLEX:", dbg:style.flex_direction);
compute_preliminary(tree, node, LayoutInput { known_dimensions: styled_based_known_dimensions, ..inputs })
}

Expand Down Expand Up @@ -658,6 +658,7 @@ fn determine_flex_base_size(
)
.with_cross(dir, cross_axis_available_space);

debug_log!("COMPUTE CHILD BASE SIZE:");
break 'flex_basis tree.measure_child_size(
child.node,
child_known_dimensions,
Expand Down Expand Up @@ -708,6 +709,7 @@ fn determine_flex_base_size(
let min_content_main_size = {
let child_available_space = Size::MIN_CONTENT.with_cross(dir, cross_axis_available_space);

debug_log!("COMPUTE CHILD MIN SIZE:");
tree.measure_child_size(
child.node,
child_known_dimensions,
Expand Down Expand Up @@ -918,11 +920,26 @@ fn determine_container_main_size(

let child_available_space = available_space.with_cross(dir, cross_axis_available_space);

// Known dimensions for child sizing
let child_known_dimensions = {
let mut ckd = item.size.with_main(dir, None);
if item.align_self == AlignSelf::Stretch && ckd.cross(dir).is_none() {
ckd.set_cross(
dir,
cross_axis_available_space
.into_option()
.maybe_sub(item.margin.cross_axis_sum(dir)),
);
}
ckd
};

// Either the min- or max- content size depending on which constraint we are sizing under.
// TODO: Optimise by using already computed values where available
debug_log!("COMPUTE CHILD BASE SIZE (for intrinsic main size):");
let content_main_size = tree.measure_child_size(
item.node,
Size::NONE,
child_known_dimensions,
constants.node_inner_size,
child_available_space,
SizingMode::InherentSize,
Expand Down
4 changes: 3 additions & 1 deletion src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ where
// First we check if we have a cached result for the given input
let cache_entry = tree.get_cache_mut(node).get(known_dimensions, available_space, run_mode);
if let Some(cached_size_and_baselines) = cache_entry {
debug_log!("CACHE", dbg:cached_size_and_baselines.size);
debug_log_node!(known_dimensions, inputs.parent_size, available_space, run_mode, inputs.sizing_mode);
debug_log!("RESULT (CACHED)", dbg:cached_size_and_baselines.size);
debug_pop_node!();
return cached_size_and_baselines;
}

debug_log_node!(known_dimensions, inputs.parent_size, available_space, run_mode, inputs.sizing_mode);

let computed_size_and_baselines = compute_uncached(tree, node, inputs);

// Cache result
Expand Down
23 changes: 23 additions & 0 deletions test_fixtures/flex/blitz_issue_88.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Test description
</title>
</head>
<body>

<div id="test-root" style="display: block; color: white; width: 600px;">
<div style="display: flex; flex-direction: column; justify-content: start;">
<div style="display: flex; flex-grow: 1;">
<div style="display: block; flex-basis: 0; flex-grow: 1;">
HHHH&ZeroWidthSpace;HHHH&ZeroWidthSpace;HHHH&ZeroWidthSpace;HHHH&ZeroWidthSpace;HHHH
</div>
</div>
</div>
</div>

</body>
</html>
148 changes: 148 additions & 0 deletions tests/generated/flex/blitz_issue_88.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/generated/flex/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ddff4c4

Please sign in to comment.