diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-13 16:17:40 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-13 16:19:15 +0100 |
commit | 2a2234053a7c4b3cb4012c314083aa8477e695f9 (patch) | |
tree | 5e7bcaeada2c82719cea808e7f856b1998bb362e /src/server | |
parent | 9ee1dd6e5167d9c2054dee5f9241e3bba286706f (diff) | |
download | chawan-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.nim | 29 |
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 "" |