From 8b8b8084a3e599faf69fb33230bad07844378dc6 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 26 Oct 2023 22:10:17 +0200 Subject: renderdocument: slightly refactor, optimize addLines --- src/server/buffer.nim | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/server/buffer.nim') 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 -- cgit 1.4.1-2-gfad0