about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-20 21:20:55 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-20 21:22:02 +0200
commite2b52fdf1def543a7199a4f0aa639e65afb22463 (patch)
tree4b2c1124041f344e709a9a51f14710fc88994ec9
parent8756b053abda176204fc02957d0f6614771e35a8 (diff)
downloadchawan-e2b52fdf1def543a7199a4f0aa639e65afb22463.tar.gz
Throw out unused cells() functions
They were an artifact of the previous layout engine, and are not needed
anymore.
-rw-r--r--src/css/values.nim31
-rw-r--r--src/layout/engine.nim20
2 files changed, 2 insertions, 49 deletions
diff --git a/src/css/values.nim b/src/css/values.nim
index e78af603..fc7e035f 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -235,37 +235,6 @@ macro `{}=`*(vals: CSSComputedValues, s: string, v: typed): untyped =
 func inherited(t: CSSPropertyType): bool =
   return InheritedArray[t]
 
-func px(n: float64, d: int): int {.inline.} =
-  return int(n / float(d))
-
-func cells*(l: CSSLength, d: int, term: TermAttributes, p: Option[int], o: bool): int =
-  let w = term.width_px
-  let h = term.height_px
-  case l.unit
-  of UNIT_EM, UNIT_REM:
-    if o: int(l.num * term.cell_ratio) #horizontal
-    else: int(l.num) #vertical
-  of UNIT_CH:
-    if o: int(l.num) #horizontal
-    else: int(l.num / term.cell_ratio) #vertical
-  of UNIT_IC:
-    if o: int(l.num * term.cell_ratio) #horizontal
-    else: int(l.num) #vertical
-  of UNIT_EX: # x-letter height, we assume it's em/2
-    if o: int(l.num / 2) #horizontal
-    else: int(l.num / term.cell_ratio / 2) #vertical
-  of UNIT_PERC: int(p.get / 100 * l.num)
-  of UNIT_PX: px(l.num, d)
-  of UNIT_CM: px(l.num * 37.8, d)
-  of UNIT_MM: px(l.num * 3.78, d)
-  of UNIT_IN: px(l.num * 96, d)
-  of UNIT_PC: px(l.num * 96 / 6, d)
-  of UNIT_PT: px(l.num * 96 / 72, d)
-  of UNIT_VW: px(w / 100 * l.num, d)
-  of UNIT_VH: px(h / 100 * l.num, d)
-  of UNIT_VMIN: px(min(w, h) / 100 * l.num, d)
-  of UNIT_VMAX: px(max(w, h) / 100 * l.num, d)
-
 func em_to_px(em: float64, term: TermAttributes): int =
   int(em * float64(term.ppl))
 
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index cb53c85e..d194deba 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -10,22 +10,8 @@ import layout/box
 import utils/twtstr
 
 # Build phase
-
-# p is what to use for percentage values
-func cells_in(l: CSSLength, state: Viewport, d: int, p: Option[int], o: bool): int =
-  return cells(l, d, state.term, p, o)
-
-func cells_w(l: CSSLength, state: Viewport, p: int): int =
-  return l.cells_in(state, state.term.ppc, p.some, true)
-
-func cells_h(l: CSSLength, state: Viewport, p: Option[int]): int =
-  return l.cells_in(state, state.term.ppl, p, false)
-
-func cells_h(l: CSSLength, state: Viewport, p: int): int =
-  return l.cells_in(state, state.term.ppl, p.some, false)
-
-func px(l: CSSLength, state: Viewport, p = 0): int {.inline.} =
-  return px(l, state.term, p)
+func px(l: CSSLength, viewport: Viewport, p = 0): int {.inline.} =
+  return px(l, viewport.term, p)
 
 type InlineState = object
   ictx: InlineContext
@@ -57,7 +43,6 @@ func computeShift(ictx: InlineContext, computed: CSSComputedValues): int =
       let spacing = computed{"word-spacing"}
       if spacing.auto:
         return ictx.cellwidth * ictx.whitespacenum
-      #return spacing.cells_w(ictx.viewport, 0)
       return spacing.px(ictx.viewport) * ictx.whitespacenum
   return 0
 
@@ -363,7 +348,6 @@ proc preferredDimensions(computed: CSSComputedValues, viewport: Viewport, width:
 
   let pheight = computed{"height"}
   if not pheight.auto:
-    #bctx.compheight = pheight.cells_h(bctx.viewport, height).some
     if pheight.unit != UNIT_PERC:
       result.compheight = pheight.px(viewport).some
     elif height.issome: