diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-04-06 12:25:55 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-04-06 12:26:39 +0200 |
| commit | f9b9be16f96d01ffb0587f65c8c32da9e9e4b3f5 (patch) | |
| tree | 08395e4627bc669d2c6780f8e4885185d390d86b /library/src/layout/container.rs | |
| parent | 23a884a67f4afde7541e4c39f22ff275f939a8f5 (diff) | |
Fix box and block sizing
Diffstat (limited to 'library/src/layout/container.rs')
| -rw-r--r-- | library/src/layout/container.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index 166d6c09..ef5fbe5d 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -132,6 +132,9 @@ impl Layout for BoxElem { let pod = Regions::one(size, expand); let mut frame = body.layout(vt, styles, pod)?.into_frame(); + // Enforce correct size. + *frame.size_mut() = expand.select(size, frame.size()); + // Apply baseline shift. let shift = self.baseline(styles).relative_to(frame.height()); if !shift.is_zero() { @@ -377,10 +380,17 @@ impl Layout for BlockElem { pod.last = None; } - body.layout(vt, styles, pod)?.into_frames() + let mut frames = body.layout(vt, styles, pod)?.into_frames(); + for (frame, &height) in frames.iter_mut().zip(&heights) { + *frame.size_mut() = + expand.select(Size::new(size.x, height), frame.size()); + } + frames } else { let pod = Regions::one(size, expand); - body.layout(vt, styles, pod)?.into_frames() + let mut frames = body.layout(vt, styles, pod)?.into_frames(); + *frames[0].size_mut() = expand.select(size, frames[0].size()); + frames }; // Clip the contents |
