about summary refs log tree commit diff stats
path: root/src/server
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-13 16:17:40 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-13 16:19:15 +0100
commit2a2234053a7c4b3cb4012c314083aa8477e695f9 (patch)
tree5e7bcaeada2c82719cea808e7f856b1998bb362e /src/server
parent9ee1dd6e5167d9c2054dee5f9241e3bba286706f (diff)
downloadchawan-2a2234053a7c4b3cb4012c314083aa8477e695f9.tar.gz
rudimentary support for <video>, <audio>
we just treat them as img tags. lazy, but works suprisingly well -- so
long as the server sends us a Content-Type, anyway.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/buffer.nim29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index 9e2b726e..e4af4232 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -354,13 +354,28 @@ proc getClickHover(styledNode: StyledNode): string =
 proc getImageHover(styledNode: StyledNode): string =
   var styledNode = styledNode
   while styledNode != nil:
-    if styledNode.t == STYLED_ELEMENT and styledNode.node of HTMLImageElement:
-      let image = HTMLImageElement(styledNode.node)
-      let src = image.attr(atSrc)
-      if src != "":
-        let url = image.document.parseURL(src)
-        if url.isSome:
-          return $url.get
+    if styledNode.t == STYLED_ELEMENT:
+      if styledNode.node of HTMLImageElement:
+        let image = HTMLImageElement(styledNode.node)
+        let src = image.attr(atSrc)
+        if src != "":
+          let url = image.document.parseURL(src)
+          if url.isSome:
+            return $url.get
+      elif styledNode.node of HTMLVideoElement:
+        let video = HTMLVideoElement(styledNode.node)
+        let src = video.getSrc()
+        if src != "":
+          let url = video.document.parseURL(src)
+          if url.isSome:
+            return $url.get
+      elif styledNode.node of HTMLAudioElement:
+        let audio = HTMLAudioElement(styledNode.node)
+        let src = audio.getSrc()
+        if src != "":
+          let url = audio.document.parseURL(src)
+          if url.isSome:
+            return $url.get
     styledNode = styledNode.parent
   ""