about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-17 22:51:32 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-17 22:51:32 +0100
commitb13d739c4d11ea0f75d90e58656074371a2be684 (patch)
treee66749cef5536f450263b762bb6e71cce636b29a /src/css
parent5171f62993d7ced5d598de24ba8c600a3f62f2ce (diff)
downloadchawan-b13d739c4d11ea0f75d90e58656074371a2be684.tar.gz
layout: add floats
yay!!!!

* Add support for float: left, float: right

Also, misc stuff:
* Add support for display: flow-root
* Set line width to the maximum allowed width on line wrap
* Various refactorings

Still todo: support clear
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cascade.nim4
-rw-r--r--src/css/values.nim7
2 files changed, 7 insertions, 4 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index c0900394..448c1df1 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -146,9 +146,9 @@ func calcPresentationalHints(element: Element): CSSComputedValues =
   template map_table_align =
     case element.attr("align").toLowerAscii()
     of "left":
-     set_cv "margin-right", CSSLengthAuto #TODO should be float: left
+     set_cv "float", FLOAT_LEFT
     of "right":
-      set_cv "margin-left", CSSLengthAuto #TODO should be float: right
+      set_cv "float", FLOAT_RIGHT
     of "center":
       set_cv "margin-left", CSSLengthAuto #TODO should be inline-start
       set_cv "margin-right", CSSLengthAuto #TODO should be inline-end
diff --git a/src/css/values.nim b/src/css/values.nim
index 6a02f5ba..4d7c3e28 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -58,7 +58,8 @@ type
     DISPLAY_INLINE_BLOCK, DISPLAY_TABLE, DISPLAY_INLINE_TABLE,
     DISPLAY_TABLE_ROW_GROUP, DISPLAY_TABLE_HEADER_GROUP,
     DISPLAY_TABLE_FOOTER_GROUP, DISPLAY_TABLE_COLUMN_GROUP, DISPLAY_TABLE_ROW,
-    DISPLAY_TABLE_COLUMN, DISPLAY_TABLE_CELL, DISPLAY_TABLE_CAPTION
+    DISPLAY_TABLE_COLUMN, DISPLAY_TABLE_CELL, DISPLAY_TABLE_CAPTION,
+    DISPLAY_FLOW_ROOT
 
   CSSWhitespace* = enum
     WHITESPACE_NORMAL, WHITESPACE_NOWRAP, WHITESPACE_PRE, WHITESPACE_PRE_LINE,
@@ -777,6 +778,7 @@ func cssDisplay(cval: CSSComponentValue): Result[CSSDisplay, string] =
     "table-header-group": DISPLAY_TABLE_HEADER_GROUP,
     "table-footer-group": DISPLAY_TABLE_FOOTER_GROUP,
     "table-caption": DISPLAY_TABLE_CAPTION,
+    "flow-root": DISPLAY_FLOW_ROOT,
     "none": DISPLAY_NONE
   }
   return cssIdent(DisplayMap, cval)
@@ -1469,7 +1471,8 @@ func buildComputedValues*(builder: CSSComputedValuesBuilder): CSSComputedValues
         result[prop] = getDefault(prop)
   if result{"float"} != FLOAT_NONE:
     case result{"display"}
-    of DISPLAY_BLOCK, DISPLAY_TABLE, DISPLAY_LIST_ITEM, DISPLAY_NONE:
+    of DISPLAY_BLOCK, DISPLAY_TABLE, DISPLAY_LIST_ITEM, DISPLAY_NONE,
+        DISPLAY_FLOW_ROOT:
        #TODO flex, grid
       discard
       {.linearScanEnd.}