~alcinnz/CatTrap

5c0e2aa912bd66499ffba3e8e3402349eb35b1e8 — Adrian Cochrane 1 year, 8 months ago 55c1e70
Add support for display: none;
1 files changed, 6 insertions(+), 1 deletions(-)

M Graphics/Layout/CSS.hs
M Graphics/Layout/CSS.hs => Graphics/Layout/CSS.hs +6 -1
@@ 28,7 28,7 @@ data CSSBox a = CSSBox {
data BoxSizing = BorderBox | ContentBox
noborder = Border (0,"px") (0,"px") (0,"px") (0,"px")

data Display = Block | Grid | Inline | Table |
data Display = Block | Grid | Inline | Table | None |
    TableRow | TableHeaderGroup | TableRowGroup | TableFooterGroup | TableCell |
    TableColumn | TableColumnGroup | TableCaption deriving Eq
rowContainer CSSBox { display = d } =


@@ 114,6 114,7 @@ instance PropertyParser a => PropertyParser (CSSBox a) where
        Just self { cssBox = box { B.min = (B.min box) { block = x } } }

    longhand _ self "display" [Ident "block"] = Just self { display = Block }
    longhand _ self "display" [Ident "none"] = Just self { display = None }
    longhand _ self "display" [Ident "grid"] = Just self { display = Grid }
    longhand _ self "display" [Ident "table"] = Just self { display = Table }
    longhand CSSBox { display = Table } self "display" [Ident "table-row-group"] =


@@ 161,6 162,8 @@ instance PropertyParser a => PropertyParser (CSSBox a) where

finalizeCSS :: PropertyParser x => Font' -> Font' -> StyleTree (CSSBox x) ->
        LayoutItem Length Length x
finalizeCSS root parent StyleTree { style = self'@CSSBox { display = None } } =
    LayoutFlow (inner self') lengthBox []
finalizeCSS root parent self@StyleTree {
    style = self'@CSSBox { display = Grid, inner = val }, children = childs
  } = LayoutFlow val (finalizeBox self' font_) [


@@ 194,6 197,8 @@ finalizeCSS' sysfont self@StyleTree { style = self' } =

finalizeChilds :: PropertyParser x => Font' -> Font' -> [StyleTree (CSSBox x)] ->
        [LayoutItem Length Length x]
finalizeChilds root parent (StyleTree { style = CSSBox { display = None } }:childs) =
    finalizeChilds root parent childs
finalizeChilds root parent childs@(child:childs')
    | isInlineTree childs =
        -- FIXME propagate display properties, how to handle the hierarchy.