about summary refs log tree commit diff stats
path: root/src/css
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/css
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/css')
-rw-r--r--src/css/cascade.nim14
-rw-r--r--src/css/selectorparser.nim3
-rw-r--r--src/css/values.nim2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index 257d2ef0..f7a3ede3 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -380,6 +380,16 @@ proc applyRulesFrameInvalid(frame: CascadeFrame, ua, user: CSSStylesheet,
       let styledText = styledParent.newStyledReplacement(content)
       styledText.pseudo = pseudo
       styledParent.children.add(styledText)
+    of PSEUDO_VIDEO:
+      let content = CSSContent(t: CONTENT_VIDEO)
+      let styledText = styledParent.newStyledReplacement(content)
+      styledText.pseudo = pseudo
+      styledParent.children.add(styledText)
+    of PSEUDO_AUDIO:
+      let content = CSSContent(t: CONTENT_AUDIO)
+      let styledText = styledParent.newStyledReplacement(content)
+      styledText.pseudo = pseudo
+      styledParent.children.add(styledText)
     of PSEUDO_NEWLINE:
       let content = CSSContent(t: CONTENT_NEWLINE)
       let styledText = styledParent.newStyledReplacement(content)
@@ -477,6 +487,10 @@ proc appendChildren(styledStack: var seq[CascadeFrame], frame: CascadeFrame,
     styledStack.stackAppend(frame, styledChild, PSEUDO_TEXTAREA_TEXT, idx)
   elif elem.tagType == TAG_IMG or elem.tagType == TAG_IMAGE:
     styledStack.stackAppend(frame, styledChild, PSEUDO_IMAGE, idx)
+  elif elem.tagType == TAG_VIDEO:
+    styledStack.stackAppend(frame, styledChild, PSEUDO_VIDEO, idx)
+  elif elem.tagType == TAG_AUDIO:
+    styledStack.stackAppend(frame, styledChild, PSEUDO_AUDIO, idx)
   elif elem.tagType == TAG_BR:
     styledStack.stackAppend(frame, styledChild, PSEUDO_NEWLINE, idx)
   else:
diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim
index ca691050..da74c6ed 100644
--- a/src/css/selectorparser.nim
+++ b/src/css/selectorparser.nim
@@ -14,7 +14,8 @@ type
   PseudoElem* = enum
     PSEUDO_NONE, PSEUDO_BEFORE, PSEUDO_AFTER,
     # internal
-    PSEUDO_INPUT_TEXT, PSEUDO_TEXTAREA_TEXT, PSEUDO_IMAGE, PSEUDO_NEWLINE
+    PSEUDO_INPUT_TEXT, PSEUDO_TEXTAREA_TEXT, PSEUDO_IMAGE, PSEUDO_NEWLINE,
+    PSEUDO_VIDEO, PSEUDO_AUDIO
 
   PseudoClass* = enum
     PSEUDO_FIRST_CHILD, PSEUDO_LAST_CHILD, PSEUDO_ONLY_CHILD, PSEUDO_HOVER,
diff --git a/src/css/values.nim b/src/css/values.nim
index 6533c7f1..dd3c96ea 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -173,7 +173,7 @@ type
   CSSContentType* = enum
     CONTENT_STRING, CONTENT_OPEN_QUOTE, CONTENT_CLOSE_QUOTE,
     CONTENT_NO_OPEN_QUOTE, CONTENT_NO_CLOSE_QUOTE, CONTENT_IMAGE,
-    CONTENT_NEWLINE
+    CONTENT_VIDEO, CONTENT_AUDIO, CONTENT_NEWLINE
 
   CSSFloat* = enum
     FLOAT_NONE, FLOAT_LEFT, FLOAT_RIGHT