diff options
| author | bptato <nincsnevem662@gmail.com> | 2025-01-23 00:23:45 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2025-01-23 00:48:31 +0100 |
| commit | 7862eb840ad1964484352cdfa5458edda413fe0d (patch) | |
| tree | a1d55a74e3f93d7a05c59aee15b6c8ee285a749e /src/css/layout.nim | |
| parent | 6c90f68a129cd0129c2b5574c7ad8cd436c523df (diff) | |
| download | chawan-7862eb840ad1964484352cdfa5458edda413fe0d.tar.gz | |
cssvalues: quick hack to make simple calc() expressions work
Most calc calls I've seen look something like "calc(100% - 2em)",
i.e. just a percentage value offset by a pixel value.
As it happens, we also had 24 bits available in CSSLength objects
because of padding. Just enough to smuggle in that offset :)
Very limited of course, but it does fix layout on a couple of websites.
Diffstat (limited to 'src/css/layout.nim')
| -rw-r--r-- | src/css/layout.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index 3cc65578..84b11c48 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -123,13 +123,13 @@ func canpx(l: CSSLength; sc: SizeConstraint): bool = func px(l: CSSLength; p: LUnit): LUnit {.inline.} = if l.u != clPerc: return l.num.toLUnit() - return (p.toFloat32() * l.num / 100).toLUnit() + return (p.toFloat32() * l.num / 100 + float32(l.addpx)).toLUnit() func px(l: CSSLength; p: SizeConstraint): LUnit {.inline.} = if l.u != clPerc: return l.num.toLUnit() if p.t == scStretch: - return (p.u.toFloat32() * l.num / 100).toLUnit() + return (p.u.toFloat32() * l.num / 100 + float32(l.addpx)).toLUnit() return 0 func stretchOrMaxContent(l: CSSLength; sc: SizeConstraint): SizeConstraint = |