about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-11 17:19:23 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-11 17:31:17 +0100
commitcea337a78c6dca00bf37e60b4b2792faf28aeffe (patch)
tree6365e3f0a2230f4e9053e268585a15840bae4c8b /src/css
parent7dae490a675df89031a56950f7b496c112a156c9 (diff)
downloadchawan-cea337a78c6dca00bf37e60b4b2792faf28aeffe.tar.gz
Support vertical-align on td
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cascade.nim15
-rw-r--r--src/css/values.nim6
2 files changed, 17 insertions, 4 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index 273ba4cb..6484d39e 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -1,6 +1,7 @@
 import algorithm
 import options
 import streams
+import strutils
 import sugar
 
 import css/cssparser
@@ -96,15 +97,27 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     let c = parseLegacyColor(element.attr("bgcolor"))
     if c.isSome:
       set_cv(PROPERTY_BACKGROUND_COLOR, color, c.get)
+  template map_valign =
+    case element.attr("valign").toLowerAscii()
+    of "top": set_cv(PROPERTY_VERTICAL_ALIGN, verticalalign, CSSVerticalAlign(keyword: VERTICAL_ALIGN_TOP))
+    of "middle": set_cv(PROPERTY_VERTICAL_ALIGN, verticalalign, CSSVerticalAlign(keyword: VERTICAL_ALIGN_MIDDLE))
+    of "bottom": set_cv(PROPERTY_VERTICAL_ALIGN, verticalalign, CSSVerticalAlign(keyword: VERTICAL_ALIGN_BOTTOM))
+    of "baseline": set_cv(PROPERTY_VERTICAL_ALIGN, verticalalign, CSSVerticalAlign(keyword: VERTICAL_ALIGN_BASELINE))
 
   case element.tagType
-  of TAG_TABLE, TAG_TD, TAG_TH:
+  of TAG_TABLE:
     map_height_nozero
     map_width_nozero
     map_bgcolor
+  of TAG_TD, TAG_TH:
+    map_height_nozero
+    map_width_nozero
+    map_bgcolor
+    map_valign
   of TAG_THEAD, TAG_TBODY, TAG_TFOOT, TAG_TR:
     map_height
     map_bgcolor
+    map_valign
   of TAG_COL:
     map_width
   of TAG_BODY:
diff --git a/src/css/values.nim b/src/css/values.nim
index 9b9d9820..49cb6b1b 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -464,9 +464,9 @@ func cssWordSpacing(cval: CSSComponentValue): CSSLength =
 
 func getToken(cval: CSSComponentValue): CSSToken = (CSSToken)cval
 
-func cssGlobal*(cval: CSSComponentValue): CSSGlobalValueType =
-  if isToken(cval):
-    let tok = getToken(cval)
+func cssGlobal*(d: CSSDeclaration): CSSGlobalValueType =
+  if d.value.len > 0 and isToken(d.value[0]):
+    let tok = getToken(d.value[0])
     if tok.tokenType == CSS_IDENT_TOKEN:
       case tok.value
       of "inherit": return VALUE_INHERIT