about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-11 19:29:28 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-11 19:29:28 +0100
commitfca4ef9b8fabebb3a9173293908ee9b56acc9cc5 (patch)
treee8891433f9a5a3d80223670aa86d1cf53a3f12b0 /src/css
parentcea337a78c6dca00bf37e60b4b2792faf28aeffe (diff)
downloadchawan-fca4ef9b8fabebb3a9173293908ee9b56acc9cc5.tar.gz
Add div align
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cascade.nim9
-rw-r--r--src/css/values.nim3
2 files changed, 11 insertions, 1 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index 6484d39e..cfcbd724 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -103,8 +103,15 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     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))
+  template map_align =
+    case element.attr("align").toLowerAscii()
+    of "center", "middle": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_CENTER)
+    of "left": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_LEFT)
+    of "right": set_cv(PROPERTY_TEXT_ALIGN, textalign, TEXT_ALIGN_CHA_RIGHT)
 
   case element.tagType
+  of TAG_DIV:
+    map_align
   of TAG_TABLE:
     map_height_nozero
     map_width_nozero
@@ -114,10 +121,12 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
     map_width_nozero
     map_bgcolor
     map_valign
+    map_align
   of TAG_THEAD, TAG_TBODY, TAG_TFOOT, TAG_TR:
     map_height
     map_bgcolor
     map_valign
+    map_align
   of TAG_COL:
     map_width
   of TAG_BODY:
diff --git a/src/css/values.nim b/src/css/values.nim
index 49cb6b1b..5bf9c2d1 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -81,7 +81,8 @@ type
 
   CSSTextAlign* = enum
     TEXT_ALIGN_START, TEXT_ALIGN_END, TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT,
-    TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY, TEXT_ALIGN_CHA_CENTER
+    TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY, TEXT_ALIGN_CHA_CENTER,
+    TEXT_ALIGN_CHA_LEFT, TEXT_ALIGN_CHA_RIGHT
 
   CSSListStylePosition* = enum
     LIST_STYLE_POSITION_OUTSIDE, LIST_STYLE_POSITION_INSIDE