about summary refs log tree commit diff stats
path: root/src/layout/engine.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-18 18:07:34 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-18 18:07:34 +0200
commit94b0da6e67261331779a6bb2414ffb481cd91f35 (patch)
tree6a588a94464f52136fc21dd2675ea5fb40e06feb /src/layout/engine.nim
parentd6000870dbf2f110c3903e03833151cce1d9759a (diff)
downloadchawan-94b0da6e67261331779a6bb2414ffb481cd91f35.tar.gz
Fix list-item counter display
Diffstat (limited to 'src/layout/engine.nim')
-rw-r--r--src/layout/engine.nim12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index bdff8c64..5f3c5337 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -627,10 +627,7 @@ proc getMarkerBox(computed: CSSComputedValues, listItemCounter: int): MarkerBoxB
   result.computed = computed.copyProperties()
   result.computed.setDisplay(DISPLAY_INLINE)
 
-  if result.computed{"display"} == DISPLAY_LIST_ITEM:
-    result.ordinalvalue = listItemCounter
-  else:
-    result.ordinalvalue = 1
+  result.ordinalvalue = listItemCounter
   if computed{"list-style-position"} == LIST_STYLE_POSITION_INSIDE:
     result.inside = true
   result.text.add(computed{"list-style-type"}.listMarker(result.ordinalvalue))
@@ -662,7 +659,7 @@ template flush_ibox() =
     blockgroup.add(ibox)
     ibox = nil
 
-proc generateInlineBoxes(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup: var seq[BoxBuilder], viewport: Viewport)
+proc generateInlineBoxes(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup: var seq[BoxBuilder], viewport: Viewport, listItemCounter: var int)
 
 proc generateFromElem(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup: var seq[BoxBuilder], viewport: Viewport, ibox: var InlineBoxBuilder, listItemCounter: var int) =
   if styledNode.node != nil:
@@ -685,7 +682,7 @@ proc generateFromElem(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup:
     inc listItemCounter
   of DISPLAY_INLINE:
     flush_ibox
-    box.generateInlineBoxes(styledNode, blockgroup, viewport)
+    box.generateInlineBoxes(styledNode, blockgroup, viewport, listItemCounter)
   of DISPLAY_INLINE_BLOCK:
     flush_ibox
     let childbox = getInlineBlockBox(styledNode.computed)
@@ -694,9 +691,8 @@ proc generateFromElem(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup:
   else:
     discard #TODO
 
-proc generateInlineBoxes(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup: var seq[BoxBuilder], viewport: Viewport) =
+proc generateInlineBoxes(box: BlockBoxBuilder, styledNode: StyledNode, blockgroup: var seq[BoxBuilder], viewport: Viewport, listItemCounter: var int) =
   var ibox: InlineBoxBuilder = nil
-  var listItemCounter = 1 # ordinal value of current list
 
   for child in styledNode.children:
     case child.t