From d47a72b2a4c7701284cd8b7a2e6b8abf83927315 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 2 Nov 2023 16:40:29 +1300 Subject: [PATCH] Support colspan on column elements. --- Graphics/Layout/CSS.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Graphics/Layout/CSS.hs b/Graphics/Layout/CSS.hs index c85b1b8..1990cf6 100644 --- a/Graphics/Layout/CSS.hs +++ b/Graphics/Layout/CSS.hs @@ -230,8 +230,8 @@ finalizeTable root parent val opts childs = LayoutGrid val grid cells' childs' decorateCol (StyleTree self@CSSBox { display = TableColumn } _:rest) h col = buildDecor self col 1 0 h:decorateCol rest h (succ col) decorateCol (StyleTree self@CSSBox { display = TableColumnGroup } childs:rest) - h col = buildDecor self col (countCols childs) 0 h: - decorateCol (childs ++ rest) h (col + countCols childs) + h col = buildDecor self col (countCols' childs self) 0 h: + decorateCol (childs ++ rest) h (col + countCols' childs self) decorateCol (_:rest) h col = decorateCol rest h col decorateCol [] _ _ = [] @@ -243,8 +243,16 @@ finalizeTable root parent val opts childs = LayoutGrid val grid cells' childs' | d `elem` [TableCaption, TableColumn, TableColumnGroup] = countRows rest | otherwise = succ $ countRows $ dropWhile (not . isRowGroup) rest countRows [] = 0 - countCols (StyleTree CSSBox { display = TableColumn } _:rest) = - succ $ countCols rest + countCols' cols@(_:_) _ = countCols cols + countCols' _ CSSBox { tableOptions = TableOptions { colspan = x } } = x + countCols (StyleTree CSSBox { + display = TableColumn, + tableOptions = TableOptions { colspan = x } + } _:rest) = x + countCols rest + countCols (StyleTree CSSBox { + display = TableColumnGroup, + tableOptions = TableOptions { colspan = x } + } []:rest) = x + countCols rest countCols (StyleTree CSSBox { display = TableColumnGroup } childs:rest) = countCols childs + countCols rest countCols (_:rest) = countCols rest -- 2.30.2