about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-08-10 15:19:32 +0200
committerbptato <nincsnevem662@gmail.com>2021-08-10 15:19:32 +0200
commita5f7da0428fdb74d9691cd6d589047478f422898 (patch)
tree0bbea58202a8f509c83378a4b57bbe419131c7d5 /src/css
parent3d24875924b088e5d771e4b901f692659c5281c0 (diff)
downloadchawan-a5f7da0428fdb74d9691cd6d589047478f422898.tar.gz
Some refactoring
Diffstat (limited to 'src/css')
-rw-r--r--src/css/box.nim35
-rw-r--r--src/css/cssparser.nim5
2 files changed, 4 insertions, 36 deletions
diff --git a/src/css/box.nim b/src/css/box.nim
index 3b74380a..0994dca0 100644
--- a/src/css/box.nim
+++ b/src/css/box.nim
@@ -1,6 +1,7 @@
 import unicode
 
 import utils/twtstr
+import io/cell
 
 type
   CSSRect* = object
@@ -20,7 +21,7 @@ type
 
   CSSInlineBox* = ref CSSInlineBoxObj
   CSSInlineBoxObj = object of CSSBox
-    nextpart: CSSInlineBox
+    nextpart*: CSSInlineBox
 
   CSSBlockBox* = ref CSSBlockBoxObj
   CSSBlockBoxObj = object of CSSBox
@@ -36,35 +37,3 @@ proc `+=`(a: var CSSRect, b: CSSRect) =
 
 func size*(box: CSSBox): tuple[w: int, h: int] =
   return (box.innerEdge.x2 - box.innerEdge.x1, box.innerEdge.y2 - box.innerEdge.x1)
-
-func boxesForText*(text: seq[Rune], width: int, height: int, lx: int, x: int, y: int): seq[CSSInlineBox] =
-  result.add(CSSInlineBox())
-  var w = x
-  var sx = x
-  var sy = y
-  var i = 0
-  while i < text.len and sy < height:
-    let cw = text[i].width()
-    if w + cw > width:
-      result[^1].innerEdge.x1 = sx
-      result[^1].innerEdge.x2 = sx + w
-      result[^1].innerEdge.y1 = sy
-      result[^1].innerEdge.y2 = sy + 1
-      sx = lx
-      inc sy
-      w = 0
-
-      result[^2].nextpart = result[^1]
-      result.add(CSSInlineBox())
-
-    result[^1].content &= text[i]
-    w += cw
-    inc i
-
-  if result.len > 1:
-    result[^2].nextpart = result[^1]
-  if w > 0:
-    result[^1].innerEdge.x1 = sx
-    result[^1].innerEdge.x2 = sx + w
-    result[^1].innerEdge.y1 = sy
-    result[^1].innerEdge.y2 = sy + 1
diff --git a/src/css/cssparser.nim b/src/css/cssparser.nim
index afbdf413..fac1bce8 100644
--- a/src/css/cssparser.nim
+++ b/src/css/cssparser.nim
@@ -1,6 +1,5 @@
-# CSS tokenizer and parser. The tokenizer is a mess, and may or may not work
-# correctly. The parser should work, though the outputted object model is
-# questionable at best.
+# CSS tokenizer and parser. It kinda works, though certain less specific
+# details of the specification might have been implemented incorrectly.
 
 import unicode
 import streams