~alcinnz/CatTrap

406578a2c543935138d5a977dc164eb7046a09cc — Adrian Cochrane 1 year, 8 months ago 7bc6a4f
Switch inline nodes to inherit from parent rather than use default values.
1 files changed, 12 insertions(+), 11 deletions(-)

M Graphics/Layout/CSS.hs
M Graphics/Layout/CSS.hs => Graphics/Layout/CSS.hs +12 -11
@@ 168,7 168,7 @@ finalizeCSS root parent self@StyleTree {
    style = self'@CSSBox { display = Grid, inner = val }, children = childs
  } = LayoutFlow val (finalizeBox self' font_) [
        finalizeGrid (gridStyles self') font_ (map cellStyles $ map style childs)
            (finalizeChilds root font_ childs)]
            (finalizeChilds root font_ (inner self') childs)]
  where
    font_ = pattern2font (font self') (font' self') parent root
finalizeCSS root parent self@StyleTree {


@@ 189,28 189,29 @@ finalizeCSS root parent self@StyleTree {
    font_ = pattern2font (font self') (font' self') parent root
finalizeCSS root parent self@StyleTree {
    style = self'@CSSBox { inner = val }, children = childs
  } = LayoutFlow val (finalizeBox self' font_) (finalizeChilds root font_ childs)
  } = LayoutFlow val (finalizeBox self' font_) (finalizeChilds root font_ val childs)
  where
    font_ = pattern2font (font self') (font' self') parent root
finalizeCSS' sysfont self@StyleTree { style = self' } =
    finalizeCSS (pattern2font (font self') (font' self') sysfont sysfont) sysfont self

finalizeChilds :: PropertyParser x => Font' -> Font' -> [StyleTree (CSSBox x)] ->
finalizeChilds :: PropertyParser x => Font' -> Font' -> x -> [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')
finalizeChilds root parent style' (StyleTree { style = CSSBox { display = None } }:childs) =
    finalizeChilds root parent style' childs
finalizeChilds root parent style' childs@(child:childs')
    | isInlineTree childs, Just self <- finalizeParagraph (flattenTree childs) parent =
        -- FIXME propagate display properties, how to handle the hierarchy.
        -- NOTE: Playing around in firefox, it appears the CSS borders should cover
        -- their entire span, doubling up on borders where needed.
        [LayoutInline temp parent self (repeat temp)]
        [LayoutInline (inherit style') parent self (repeat $ inherit style')]
    | (inlines@(_:_), blocks) <- spanInlines childs,
        Just self <- finalizeParagraph (flattenTree inlines) parent  =
            LayoutInline temp parent self (repeat temp) : finalizeChilds root parent blocks
            LayoutInline (inherit style') parent self (repeat $ inherit style') :
                finalizeChilds root parent style' blocks
    | (StyleTree { style = CSSBox { display = Inline } }:childs') <- childs =
        finalizeChilds root parent childs' -- Inline's all whitespace...
    | otherwise = finalizeCSS root parent child : finalizeChilds root parent childs'
        finalizeChilds root parent style' childs' -- Inline's all whitespace...
    | otherwise = finalizeCSS root parent child : finalizeChilds root parent style' childs'
  where
    isInlineTree = all isInlineTree0
    isInlineTree0 StyleTree { style = CSSBox { display = Inline }, children = childs } =


@@ 227,7 228,7 @@ finalizeChilds root parent childs@(child:childs')
    flattenTree (child:childs) =
        buildParagraph (inlineStyles $ style child) `concatParagraph` flattenTree childs
    flattenTree [] = ParagraphBuilder "" []
finalizeChilds _ _ [] = []
finalizeChilds _ _ _ [] = []

finalizeBox self@CSSBox { cssBox = box } font_ =
    mapY' (flip finalizeLength font_) $ mapX' (flip finalizeLength font_) box