diff options
author | bptato <nincsnevem662@gmail.com> | 2023-10-26 22:10:17 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-10-26 22:10:17 +0200 |
commit | 8b8b8084a3e599faf69fb33230bad07844378dc6 (patch) | |
tree | b0281ed095be9f9b2ad46634d94fd539e95fd7a2 /src/server/buffer.nim | |
parent | 77fe3c3e150c619f2f4623b0bb612a19ed682f9a (diff) | |
download | chawan-8b8b8084a3e599faf69fb33230bad07844378dc6.tar.gz |
renderdocument: slightly refactor, optimize addLines
Diffstat (limited to 'src/server/buffer.nim')
-rw-r--r-- | src/server/buffer.nim | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index 347fbed2..1a2b7e02 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -584,14 +584,23 @@ proc gotoAnchor*(buffer: Buffer): Opt[tuple[x, y: int]] {.proxy.} = return ok((format.pos, y)) return err() +const css = staticRead"res/ua.css" +let uastyle = css.parseStylesheet() +const quirk = css & staticRead"res/quirk.css" +let quirkstyle = quirk.parseStylesheet() + proc do_reshape(buffer: Buffer) = if buffer.ishtml: if buffer.viewport == nil: buffer.viewport = Viewport(window: buffer.attrs) - let ret = renderDocument(buffer.document, buffer.userstyle, - buffer.viewport, buffer.prevstyled) - buffer.lines = ret.grid - buffer.prevstyled = ret.styledRoot + let uastyle = if buffer.document.mode != QUIRKS: + uastyle + else: + quirkstyle + let styledRoot = buffer.document.applyStylesheets(uastyle, + buffer.userstyle, buffer.prevstyled) + buffer.lines = renderDocument(styledRoot, buffer.viewport, buffer.attrs) + buffer.prevstyled = styledRoot else: buffer.lines.renderStream(buffer.srenderer, buffer.available) buffer.available = 0 |