From 9276603b49f3be41226fea47bb63f9d2f6baad8b Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 20 Sep 2023 11:54:26 +0200 Subject: px: convert to float first for percentage values px now converts to float64 before converting back to a layout unit when calculating percentage values. This should reduce overflow crashes somewhat. (The real solution would be to not crash on overflow, but that's a little more difficult problem to solve.) --- src/css/values.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/css/values.nim b/src/css/values.nim index cd27ce98..aa9feba0 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -408,7 +408,7 @@ func px*(l: CSSLength, window: WindowAttributes, p: LayoutUnit): LayoutUnit {.in of UNIT_CH: ch_to_px(l.num, window) of UNIT_IC: ic_to_px(l.num, window) of UNIT_EX: ex_to_px(l.num, window) - of UNIT_PERC: p * l.num / 100 + of UNIT_PERC: toLayoutUnit(toFloat64(p) * l.num / 100) of UNIT_PX: toLayoutUnit(l.num) of UNIT_CM: toLayoutUnit(l.num * 37.8) of UNIT_MM: toLayoutUnit(l.num * 3.78) -- cgit 1.4.1-2-gfad0