about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/config.nim11
-rw-r--r--src/html/dom.nim5
-rw-r--r--src/html/env.nim3
-rw-r--r--src/local/pager.nim7
-rw-r--r--src/server/buffer.nim2
5 files changed, 22 insertions, 6 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 8783cb89..4e9d1517 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -59,6 +59,7 @@ type
     scripting*: Option[bool]
     document_charset*: seq[Charset]
     images*: Option[bool]
+    styling*: Option[bool]
     stylesheet*: Option[string]
     proxy*: Option[URL]
     default_headers*: TableRef[string, string]
@@ -140,12 +141,20 @@ type
   ProtocolConfig* = ref object
     form_request*: FormRequestType
 
+  BufferSectionConfig* = object
+    styling* {.jsgetset.}: bool
+    scripting* {.jsgetset.}: bool
+    images* {.jsgetset.}: bool
+    cookie* {.jsgetset.}: bool
+    referer_from* {.jsgetset.}: bool
+
   Config* = ref object
     jsctx: JSContext
     jsvfns*: seq[JSValueFunction]
     configdir {.jsget.}: string
     `include` {.jsget.}: seq[ChaPathResolved]
     start* {.jsget.}: StartConfig
+    buffer* {.jsget.}: BufferSectionConfig
     search* {.jsget.}: SearchConfig
     css* {.jsget.}: CSSConfig
     encoding* {.jsget.}: EncodingConfig
@@ -169,6 +178,7 @@ jsDestructor(EncodingConfig)
 jsDestructor(ExternalConfig)
 jsDestructor(NetworkConfig)
 jsDestructor(DisplayConfig)
+jsDestructor(BufferSectionConfig)
 jsDestructor(Config)
 
 converter toStr*(p: ChaPathResolved): string {.inline.} =
@@ -833,4 +843,5 @@ proc addConfigModule*(ctx: JSContext) =
   ctx.registerType(ExternalConfig)
   ctx.registerType(NetworkConfig)
   ctx.registerType(DisplayConfig)
+  ctx.registerType(BufferSectionConfig, name = "BufferConfig")
   ctx.registerType(Config)
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 503bdf27..bb5128dc 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -87,6 +87,7 @@ type
     factory*: CAtomFactory
     loadingResourcePromises*: seq[EmptyPromise]
     images*: bool
+    styling*: bool
     # ID of the next image
     imageId: int
 
@@ -2245,7 +2246,7 @@ func referrerpolicy(element: HTMLScriptElement): Option[ReferrerPolicy] =
   return strictParseEnum[ReferrerPolicy](element.attr(satReferrerpolicy))
 
 proc sheets*(document: Document): seq[CSSStylesheet] =
-  if document.cachedSheetsInvalid:
+  if document.cachedSheetsInvalid and document.window.styling:
     document.cachedSheets.setLen(0)
     for elem in document.html.descendants:
       if elem of HTMLStyleElement:
@@ -2860,7 +2861,7 @@ var appliesFwdDecl*: proc(mqlist: MediaQueryList; window: Window): bool
 # see https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet
 #TODO make this somewhat compliant with ^this
 proc loadResource(window: Window; link: HTMLLinkElement) =
-  if satStylesheet notin link.relList:
+  if not window.styling or satStylesheet notin link.relList:
     return
   if link.fetchStarted:
     return
diff --git a/src/html/env.nim b/src/html/env.nim
index 0a90007f..0751d12f 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -236,7 +236,7 @@ proc runJSJobs*(window: Window) =
     let ctx = r.error
     ctx.writeException(window.console.err)
 
-proc newWindow*(scripting, images: bool; selector: Selector[int];
+proc newWindow*(scripting, images, styling: bool; selector: Selector[int];
     attrs: WindowAttributes; factory: CAtomFactory; navigate: proc(url: URL);
     loader: FileLoader; url: URL): Window =
   let err = newDynFileStream(stderr)
@@ -246,6 +246,7 @@ proc newWindow*(scripting, images: bool; selector: Selector[int];
     navigator: Navigator(),
     loader: loader,
     images: images,
+    styling: styling,
     settings: EnvironmentSettings(
       scripting: scripting,
       origin: url.origin
diff --git a/src/local/pager.nim b/src/local/pager.nim
index cd0df216..cdc08422 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -1074,10 +1074,11 @@ proc applySiteconf(pager: Pager; url: var URL; charsetOverride: Charset;
   let ctx = pager.jsctx
   var res = BufferConfig(
     userstyle: pager.config.css.stylesheet,
-    referer_from: false,
-    scripting: false,
+    referer_from: pager.config.buffer.referer_from,
+    scripting: pager.config.buffer.scripting,
     charsets: pager.config.encoding.document_charset,
-    images: false,
+    images: pager.config.buffer.images,
+    styling: pager.config.buffer.styling,
     isdump: pager.config.start.headless,
     charsetOverride: charsetOverride,
     protocol: pager.config.protocol
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index f14cda60..d84bc29c 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -134,6 +134,7 @@ type
   BufferConfig* = object
     userstyle*: string
     referer_from*: bool
+    styling*: bool
     scripting*: bool
     images*: bool
     isdump*: bool
@@ -870,6 +871,7 @@ proc setHTML(buffer: Buffer) =
   buffer.window = newWindow(
     buffer.config.scripting,
     buffer.config.images,
+    buffer.config.styling,
     buffer.selector,
     buffer.attrs,
     factory,