diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-23 15:30:28 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-23 15:30:28 +0200 |
| commit | 363836a28e4c8877b7c5203ed4ce595a59731802 (patch) | |
| tree | 0f376023f81e3db69a3c1641a0db4136a7b7d3a8 | |
| parent | f2193307c48055e54d4d1b5eca43bf0189699d40 (diff) | |
Fix layout panic in rounded rectangle
Fixes #1216 both by hardening the rounded rectangle against negative size and by ensuring that the negative size doesn't occur in the first place for this case.
| -rw-r--r-- | library/src/layout/flow.rs | 5 | ||||
| -rw-r--r-- | src/geom/rounded.rs | 2 | ||||
| -rw-r--r-- | tests/ref/bugs/clamp-panic.png | bin | 0 -> 274 bytes | |||
| -rw-r--r-- | tests/typ/bugs/clamp-panic.typ | 3 |
4 files changed, 9 insertions, 1 deletions
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs index a21f8142..5e01f51d 100644 --- a/library/src/layout/flow.rs +++ b/library/src/layout/flow.rs @@ -243,6 +243,11 @@ impl<'a> FlowLayouter<'a> { block: &Content, styles: StyleChain, ) -> SourceResult<()> { + // Skip directly if regino is already full. + if self.regions.is_full() { + self.finish_region()?; + } + // Placed elements that are out of flow produce placed items which // aren't aligned later. if let Some(placed) = block.to::<PlaceElem>() { diff --git a/src/geom/rounded.rs b/src/geom/rounded.rs index f445dfcb..24b52448 100644 --- a/src/geom/rounded.rs +++ b/src/geom/rounded.rs @@ -52,7 +52,7 @@ fn stroke_segments( let mut connection = Connection::default(); let mut path = Path::new(); let mut always_continuous = true; - let max_radius = size.x.min(size.y) / 2.0; + let max_radius = size.x.min(size.y).max(Abs::zero()) / 2.0; for side in [Side::Top, Side::Right, Side::Bottom, Side::Left] { let continuous = stroke.get_ref(side) == stroke.get_ref(side.next_cw()); diff --git a/tests/ref/bugs/clamp-panic.png b/tests/ref/bugs/clamp-panic.png Binary files differnew file mode 100644 index 00000000..c0c4912e --- /dev/null +++ b/tests/ref/bugs/clamp-panic.png diff --git a/tests/typ/bugs/clamp-panic.typ b/tests/typ/bugs/clamp-panic.typ new file mode 100644 index 00000000..5f167c76 --- /dev/null +++ b/tests/typ/bugs/clamp-panic.typ @@ -0,0 +1,3 @@ +#set page(height: 20pt, margin: 0pt) +#v(22pt) +#block(fill: red, width: 100%, height: 10pt, radius: 4pt) |
