about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-22 16:56:20 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-22 16:56:20 +0200
commit2822dbed8b2011aa02cf43fc2f40d25e4950911f (patch)
tree288c6d02e4bfecd115f30f232ad3383e92c35805 /src/css
parent1f4560cafd51874ee7a71d1e099e0a1d5a1e4947 (diff)
downloadchawan-2822dbed8b2011aa02cf43fc2f40d25e4950911f.tar.gz
layout, layoutunit: remove some automatic converters
I wish we didn't need any, but fixing this for integers would be too
involved and the float64 one was causing problems now.
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cssvalues.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/css/cssvalues.nim b/src/css/cssvalues.nim
index 8751ba50..ec51e5de 100644
--- a/src/css/cssvalues.nim
+++ b/src/css/cssvalues.nim
@@ -585,18 +585,18 @@ func inherited(t: CSSPropertyType): bool =
   return InheritedArray[t]
 
 func em_to_px(em: float64; window: WindowAttributes): LayoutUnit =
-  em * float64(window.ppl)
+  (em * float64(window.ppl)).toLayoutUnit()
 
 func ch_to_px(ch: float64; window: WindowAttributes): LayoutUnit =
-  ch * float64(window.ppc)
+  (ch * float64(window.ppc)).toLayoutUnit()
 
 # 水 width, we assume it's 2 chars
 func ic_to_px(ic: float64; window: WindowAttributes): LayoutUnit =
-  ic * float64(window.ppc) * 2
+  (ic * float64(window.ppc) * 2).toLayoutUnit()
 
 # x-letter height, we assume it's em/2
 func ex_to_px(ex: float64; window: WindowAttributes): LayoutUnit =
-  ex * float64(window.ppc) / 2
+  (ex * float64(window.ppc) / 2).toLayoutUnit()
 
 func px*(l: CSSLength; window: WindowAttributes; p: LayoutUnit): LayoutUnit
     {.inline.} =
@@ -927,7 +927,7 @@ func parseANSI(value: openArray[CSSComponentValue]): Opt[CellColor] =
     return err()
   let tok = CSSToken(value[i])
   if tok.tokenType == cttNumber:
-    if tok.nvalue notin 0..255:
+    if tok.tflagb != tflagbInteger or int(tok.nvalue) notin 0..255:
       return err() # invalid numeric ANSI color
     return ok(ANSIColor(tok.nvalue).cellColor())
   elif tok.tokenType == cttIdent: