~alcinnz/CatTrap

d47a72b2a4c7701284cd8b7a2e6b8abf83927315 — Adrian Cochrane 1 year, 22 days ago 878e686
Support colspan on column elements.
1 files changed, 12 insertions(+), 4 deletions(-)

M Graphics/Layout/CSS.hs
M Graphics/Layout/CSS.hs => Graphics/Layout/CSS.hs +12 -4
@@ 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