diff options
author | bptato <nincsnevem662@gmail.com> | 2022-07-16 14:14:06 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-07-16 14:15:52 +0200 |
commit | 8cd503c88693171f9887716440cdc110fdca2bb3 (patch) | |
tree | 7416b86ab677b8bf38c0bd89009991899e516660 /src/render | |
parent | 368794ad19514deb7397d4eb2f0e5b72862d28e5 (diff) | |
download | chawan-8cd503c88693171f9887716440cdc110fdca2bb3.tar.gz |
Use StyledNodes instead of passing the entire DOM to the layout engine
This moves pseudo element generation to the cascading phase. For now it also breaks style caching.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/renderdocument.nim | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index b01728dd..196c1496 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -3,6 +3,7 @@ import unicode import css/cascade import css/sheet +import css/stylednode import css/values import html/dom import io/cell @@ -249,10 +250,11 @@ proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockContext, x, y: int, te const css = staticRead"res/ua.css" let uastyle = css.parseStylesheet() -proc renderDocument*(document: Document, term: TermAttributes, userstyle: CSSStylesheet, layout: var Viewport): FlexibleGrid = - document.applyStylesheets(uastyle, userstyle) - layout.renderLayout(document) - result.setLen(0) - result.renderBlockContext(layout.root, 0, 0, term) - if result.len == 0: - result.addLine() +proc renderDocument*(document: Document, term: TermAttributes, userstyle: CSSStylesheet, layout: var Viewport, previousStyled: StyledNode): (FlexibleGrid, StyledNode) = + let styledNode = document.applyStylesheets(uastyle, userstyle, previousStyled) + result[1] = styledNode + layout.renderLayout(document, styledNode) + result[0].setLen(0) + result[0].renderBlockContext(layout.root, 0, 0, term) + if result[0].len == 0: + result[0].addLine() |