diff options
author | bptato <nincsnevem662@gmail.com> | 2021-11-16 19:23:31 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-11-19 21:52:19 +0100 |
commit | cd28af13fc6753792b3b9571abba5943f90d021e (patch) | |
tree | 5b7c829f70fe8bf81b11b959c1ea92e34db125d5 /src/layout | |
parent | bbd416f5ffba5ba5e5d41869042cef1f85323146 (diff) | |
download | chawan-cd28af13fc6753792b3b9571abba5943f90d021e.tar.gz |
Various performance optimizations (...part two)
Diffstat (limited to 'src/layout')
-rw-r--r-- | src/layout/box.nim | 4 | ||||
-rw-r--r-- | src/layout/engine.nim | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim index bee93363..07bc5f5b 100644 --- a/src/layout/box.nim +++ b/src/layout/box.nim @@ -1,5 +1,3 @@ -import unicode - import types/enums import css/style import html/dom @@ -50,7 +48,7 @@ type fontstyle*: CSSFontStyle fontweight*: int textdecoration*: CSSTextDecoration - runes*: seq[Rune] + str*: string nodes*: seq[Node] CSSInlineBox* = ref CSSInlineBoxObj diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 506770b9..71dab4c2 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -84,8 +84,10 @@ proc processInlineBox(parent: CSSBox, str: string): CSSBox = rowbox.setup(ibox.cssvalues, ibox.bcontext.nodes) var r: Rune while i < str.len: + var rw = 0 case str[i] of ' ', '\n', '\t': + rw = 1 inc i let wsr = ibox.cssvalues[PROPERTY_WHITESPACE].whitespace if ibox.context.whitespace: @@ -113,12 +115,13 @@ proc processInlineBox(parent: CSSBox, str: string): CSSBox = else: ibox.context.whitespace = false fastRuneAt(str, i, r) + rw = r.width() if rowbox.width + r.width() > ibox.width: inlineWrap(ibox, rowi, fromx, rowbox) - rowbox.width += r.width() - rowbox.runes.add(r) - if rowbox.runes.len > 0: + rowbox.width += rw + rowbox.str &= $r + if rowbox.str.len > 0: ibox.content.add(rowbox) ibox.context.fromx = fromx + rowbox.width ibox.context.conty = true |