diff options
author | bptato <nincsnevem662@gmail.com> | 2024-07-03 17:25:51 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-07-03 17:34:44 +0200 |
commit | 73c6bf9a5bf1e72e8cc2f8792fdb926d66c069ea (patch) | |
tree | 16d06deef991b7d67e9aca1c084b68609bf82e68 /src/css | |
parent | fb68da21497d5bda9057afaf34947258f8c425cb (diff) | |
download | chawan-73c6bf9a5bf1e72e8cc2f8792fdb926d66c069ea.tar.gz |
layout: reduce copies
Text data is no longer stored separately in InlineFragments; instead, we now include refs to StyledNodes.
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/stylednode.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/css/stylednode.nim b/src/css/stylednode.nim index 0fcdb6ad..dc90856d 100644 --- a/src/css/stylednode.nim +++ b/src/css/stylednode.nim @@ -55,8 +55,8 @@ type # replaced elements: quotes, or (TODO) markers, images content*: CSSContent -func textData*(styledNode: StyledNode): string = - return Text(styledNode.node).data +template textData*(styledNode: StyledNode): string = + CharacterData(styledNode.node).data # For debugging func `$`*(node: StyledNode): string = @@ -166,6 +166,9 @@ func newStyledElement*(parent: StyledNode; pseudo: PseudoElem; func newStyledText*(parent: StyledNode; text: Text): StyledNode = return StyledNode(t: stText, node: text, parent: parent) +func newStyledText*(text: string): StyledNode = + return StyledNode(t: stText, node: CharacterData(data: text)) + func newStyledReplacement*(parent: StyledNode; content: CSSContent): StyledNode = return StyledNode(t: stReplacement, parent: parent, content: content) |