about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-11-24 20:03:21 +0100
committerbptato <nincsnevem662@gmail.com>2022-11-24 20:03:21 +0100
commit896489a6c500e28f13d0237ab691622cb5c5114f (patch)
tree91b92da01bc126c2489a3dd083df5f9de06927c6 /src/css
parentee930b0f5a587768d340c4204cf1f2e9fb818c89 (diff)
downloadchawan-896489a6c500e28f13d0237ab691622cb5c5114f.tar.gz
Avoid forking child processes from the main process
Caveat: this breaks piped streams.
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cascade.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index 200a83af..bb4872fd 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -98,6 +98,7 @@ proc applyDeclarations(pseudo: PseudoElem, styledParent: StyledNode, ua, user: D
     result = styledParent.newStyledElement(pseudo, builder.buildComputedValues())
 
 func applyMediaQuery(ss: CSSStylesheet): CSSStylesheet =
+  if ss == nil: return nil
   result = ss
   for mq in ss.mq_list:
     if mq.query.applies():
@@ -105,7 +106,8 @@ func applyMediaQuery(ss: CSSStylesheet): CSSStylesheet =
 
 func calcRules(styledNode: StyledNode, ua, user: CSSStylesheet, author: seq[CSSStylesheet]): tuple[uadecls, userdecls: DeclarationList, authordecls: seq[DeclarationList]] =
   result.uadecls = calcRules(styledNode, ua)
-  result.userdecls = calcRules(styledNode, user)
+  if user != nil:
+    result.userdecls = calcRules(styledNode, user)
   for rule in author:
     result.authordecls.add(calcRules(styledNode, rule))