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/html | |
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/html')
-rw-r--r-- | src/html/dom.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 81504d56..2f36d81a 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -370,6 +370,10 @@ type bitmap*: Bitmap fetchStarted: bool + HTMLVideoElement* = ref object of HTMLElement + + HTMLAudioElement* = ref object of HTMLElement + jsDestructor(Navigator) jsDestructor(PluginArray) jsDestructor(MimeTypeArray) @@ -403,6 +407,8 @@ jsDestructor(HTMLTextAreaElement) jsDestructor(HTMLLabelElement) jsDestructor(HTMLCanvasElement) jsDestructor(HTMLImageElement) +jsDestructor(HTMLVideoElement) +jsDestructor(HTMLAudioElement) jsDestructor(Node) jsDestructor(NodeList) jsDestructor(HTMLCollection) @@ -2426,6 +2432,16 @@ func jsForm(this: HTMLButtonElement): HTMLFormElement {.jsfget: "form".} = func jsForm(this: HTMLTextAreaElement): HTMLFormElement {.jsfget: "form".} = return this.form +# <video> +func getSrc*(this: HTMLVideoElement|HTMLAudioElement): string = + var src = this.attr(atSrc) + if src == "": + for el in this.elements(TAG_SOURCE): + src = el.attr(atSrc) + if src != "": + break + src + func newText(document: Document, data: string): Text = return Text( document_internal: document, @@ -2542,6 +2558,10 @@ proc newHTMLElement*(document: Document, localName: CAtom, result = HTMLCanvasElement() of TAG_IMG: result = HTMLImageElement() + of TAG_VIDEO: + result = HTMLVideoElement() + of TAG_AUDIO: + result = HTMLAudioElement() of TAG_AREA: let area = HTMLAreaElement() let localName = document.toAtom(atRel) @@ -4127,6 +4147,8 @@ proc registerElements(ctx: JSContext, nodeCID: JSClassID) = register(HTMLLabelElement, TAG_LABEL) register(HTMLCanvasElement, TAG_CANVAS) register(HTMLImageElement, TAG_IMG) + register(HTMLVideoElement, TAG_VIDEO) + register(HTMLAudioElement, TAG_AUDIO) proc addDOMModule*(ctx: JSContext) = let eventTargetCID = ctx.getClass("EventTarget") |