summaryrefslogtreecommitdiff
path: root/src/library/image.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-22 12:42:02 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-22 12:42:02 +0100
commit2bf32c51bceb2f3a8b7ebea3d7c7d6d96757591b (patch)
tree3524388a7394dd35ccef10b89a7a034e6ae1ab60 /src/library/image.rs
parentc7e52f20483971a39f54c56700b31980f744a410 (diff)
Remove layout cache
Diffstat (limited to 'src/library/image.rs')
-rw-r--r--src/library/image.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/library/image.rs b/src/library/image.rs
index 05877126..000aec73 100644
--- a/src/library/image.rs
+++ b/src/library/image.rs
@@ -39,24 +39,24 @@ impl Layout for ImageNode {
vm: &mut Vm,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Constrained<Arc<Frame>>>> {
+ ) -> TypResult<Vec<Arc<Frame>>> {
let img = vm.images.get(self.0);
let pxw = img.width() as f64;
let pxh = img.height() as f64;
let px_ratio = pxw / pxh;
// Find out whether the image is wider or taller than the target size.
- let &Regions { current, expand, .. } = regions;
- let current_ratio = current.x / current.y;
- let wide = px_ratio > current_ratio;
+ let &Regions { first, expand, .. } = regions;
+ let region_ratio = first.x / first.y;
+ let wide = px_ratio > region_ratio;
// The space into which the image will be placed according to its fit.
let target = if expand.x && expand.y {
- current
- } else if expand.x || (!expand.y && wide && current.x.is_finite()) {
- Size::new(current.x, current.y.min(current.x.safe_div(px_ratio)))
- } else if current.y.is_finite() {
- Size::new(current.x.min(current.y * px_ratio), current.y)
+ first
+ } else if expand.x || (!expand.y && wide && first.x.is_finite()) {
+ Size::new(first.x, first.y.min(first.x.safe_div(px_ratio)))
+ } else if first.y.is_finite() {
+ Size::new(first.x.min(first.y * px_ratio), first.y)
} else {
Size::new(Length::pt(pxw), Length::pt(pxh))
};
@@ -91,7 +91,7 @@ impl Layout for ImageNode {
frame.link(url);
}
- Ok(vec![frame.constrain(Constraints::tight(regions))])
+ Ok(vec![Arc::new(frame)])
}
}