From 8cd503c88693171f9887716440cdc110fdca2bb3 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 16 Jul 2022 14:14:06 +0200 Subject: 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. --- src/css/stylednode.nim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/css/stylednode.nim (limited to 'src/css/stylednode.nim') diff --git a/src/css/stylednode.nim b/src/css/stylednode.nim new file mode 100644 index 00000000..d6293187 --- /dev/null +++ b/src/css/stylednode.nim @@ -0,0 +1,18 @@ +import css/values +import html/dom + +# Container to hold a style and a node. +# Pseudo elements are implemented using StyledNode objects without nodes. +type + StyledType* = enum + STYLED_ELEMENT, STYLED_TEXT + + StyledNode* = ref object + case t*: StyledType + of STYLED_ELEMENT: + pseudo*: PseudoElem + computed*: CSSComputedValues + of STYLED_TEXT: + text*: string + node*: Node + children*: seq[StyledNode] -- cgit 1.4.1-2-gfad0