From 5c0e2aa912bd66499ffba3e8e3402349eb35b1e8 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 16 Mar 2023 16:42:05 +1300 Subject: [PATCH] Add support for display: none; --- Graphics/Layout/CSS.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Graphics/Layout/CSS.hs b/Graphics/Layout/CSS.hs index e5891c4..c3da204 100644 --- a/Graphics/Layout/CSS.hs +++ b/Graphics/Layout/CSS.hs @@ -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. -- 2.30.2