about summary refs log tree commit diff stats
path: root/src/server/buffer.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/buffer.nim')
-rw-r--r--src/server/buffer.nim17
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