You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The release number or commit hash of the version you're using:
Commit: 02453b2
Note: I went back to commits from almost a year ago and the issue seems present there too, so I don't think this is a regression.
Platform
What platform are you using taffy on? e.g. Rust, Android, IOS, JavaScript/TypeScript
Language: Rust
OS: Windows
What you did
The steps you took to uncover this bug:
I observed the bug happening in my custom gui framework, so I made a small example in html and then made an equivalent taffy version to get a minimally reproducible example.
Please provide a runnable code snippet or link to an example that demonstrates the problem if you can:
HTML:
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>
body {
margin: 0;
}
body, body * {
display: flex;
}
</style></head><body><div><imgsrc="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Red_Panda_%2824986761703%29.jpg/440px-Red_Panda_%2824986761703%29.jpg" />
</div></body></html>
Rust:
use taffy::geometry::Size;pubstructImageContext{pubwidth:f32,pubheight:f32,}pubfnimage_measure_function(known_dimensions: taffy::geometry::Size<Option<f32>>,image_context:&ImageContext,) -> taffy::geometry::Size<f32>{match(known_dimensions.width, known_dimensions.height){(Some(width),Some(height)) => Size{ width, height },(Some(width),None) => Size{ width,height:(width / image_context.width)* image_context.height},(None,Some(height)) => Size{width:(height / image_context.height)* image_context.width, height },(None,None) => Size{width: image_context.width,height: image_context.height},}}use taffy::prelude::*;enumNodeContext{Image(ImageContext),}fnmeasure_function(known_dimensions: taffy::geometry::Size<Option<f32>>,available_space: taffy::geometry::Size<taffy::style::AvailableSpace>,node_context:Option<&mutNodeContext>,) -> Size<f32>{ifletSize{width:Some(width),height:Some(height)} = known_dimensions {returnSize{ width, height };}match node_context {None => Size::ZERO,Some(NodeContext::Image(image_context)) => image_measure_function(known_dimensions, image_context),}}fnmain() -> Result<(), taffy::TaffyError>{letmut taffy:TaffyTree<NodeContext> = TaffyTree::new();let image_node = taffy
.new_leaf_with_context(Style{display:Display::Flex,
..Default::default()},NodeContext::Image(ImageContext{width:440.0,height:291.0}))?;let image_container = taffy.new_with_children(Style{display:Display::Flex,
..Default::default()},&[image_node],)?;let body = taffy.new_with_children(Style{display:Display::Flex,
..Default::default()},&[image_container],)?;// Compute layout and print result
taffy.compute_layout_with_measure(
body,Size{// Let window size = (1280, 720).width:AvailableSpace::Definite(1280.0),height:AvailableSpace::Definite(720.0),},// Note: this closure is a FnMut closure and can be used to borrow external context for the duration of layout// For example, you may wish to borrow a global font registry and pass it into your text measuring function
|known_dimensions, available_space, _node_id, node_context, _style| {measure_function(known_dimensions, available_space, node_context)},)?;
taffy.print_tree(body);Ok(())}
What went wrong
What were you expecting:
I expect the resulting node sizes in the taffy tree to be close/identical to what the html node sizes listed below are.
Other information that can be used to further reproduce or isolate the problem.
This commonly includes:
I observed that max width was ignored as well. If I change the image container to be display block, then the max size is respected, but this may just be a side effect of the bug.
taffy
versionThe release number or commit hash of the version you're using:
Commit: 02453b2
Note: I went back to commits from almost a year ago and the issue seems present there too, so I don't think this is a regression.
Platform
What platform are you using
taffy
on? e.g. Rust, Android, IOS, JavaScript/TypeScriptLanguage: Rust
OS: Windows
What you did
The steps you took to uncover this bug:
I observed the bug happening in my custom gui framework, so I made a small example in html and then made an equivalent taffy version to get a minimally reproducible example.
Please provide a runnable code snippet or link to an example that demonstrates the problem if you can:
HTML:
Rust:
What went wrong
What were you expecting:
I expect the resulting node sizes in the taffy tree to be close/identical to what the html node sizes listed below are.
Additional information
Other information that can be used to further reproduce or isolate the problem.
This commonly includes:
I observed that max width was ignored as well. If I change the image container to be display block, then the max size is respected, but this may just be a side effect of the bug.
Debug logs when running the above taffy example:
Images from my gui:
Shrinking the window height here:
The below image shows an overflow, but the max width here is 1.0 / 100%:
The text was updated successfully, but these errors were encountered: