diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-10-31 18:00:28 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-10-31 18:38:16 +0100 |
| commit | 2fa73721c6ddaa3a497d58f83e987e75194f300c (patch) | |
| tree | 2ad3d9f9bc99b503f753395f9b4a19b38b28e448 /src/layout/box.nim | |
| parent | 8782fc0591b9aa72a4b61885cc2520afa2b60477 (diff) | |
| download | chawan-2fa73721c6ddaa3a497d58f83e987e75194f300c.tar.gz | |
layout: refactor flow and fix some bugs in the process
* factor out `margin' field from box state
* get rid of RootInlineFragment
* `nested' -> `children'
* get rid of repositionChildren pass; now we handle relative positioning
and -cha-center/-cha-right separately
* cha-center, cha-right no longer applies to floats
* use consistent naming scheme for tests
* fix float bottom margin strut not being flushed
* fix inline floats changing non-fit-content width
Diffstat (limited to 'src/layout/box.nim')
| -rw-r--r-- | src/layout/box.nim | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim index 26b0687b..af61b88a 100644 --- a/src/layout/box.nim +++ b/src/layout/box.nim @@ -27,24 +27,20 @@ type of iatImage: bmp*: NetworkBitmap - RootInlineFragmentState* = object + BoxLayoutState* = object # offset relative to parent offset*: Offset # padding size size*: Size # overflow relative to offset overflow*: Overflow - # minimum content width + # minimum content width (usually shortest word) xminwidth*: LayoutUnit - # baseline of the first line box + # baseline of the first line box of all descendants firstBaseline*: LayoutUnit - # baseline of the last line box + # baseline of the last line box of all descendants baseline*: LayoutUnit - RootInlineFragment* = ref object - fragment*: InlineFragment # root fragment - state*: RootInlineFragmentState - SplitType* = enum stSplitStart, stSplitEnd @@ -83,27 +79,12 @@ type RelativeRect* = array[DimensionType, Span] - BlockBoxLayoutState* = object - # offset relative to parent - offset*: Offset - # padding size - size*: Size - margin*: RelativeRect #TODO get rid of this? - # overflow relative to offset - overflow*: Overflow - # minimum content width (usually shortest word) - xminwidth*: LayoutUnit - # baseline of the first line box of all descendants - firstBaseline*: LayoutUnit - # baseline of the last line box of all descendants - baseline*: LayoutUnit - BlockBox* = ref object - state*: BlockBoxLayoutState + state*: BoxLayoutState computed*: CSSComputedValues node*: StyledNode - inline*: RootInlineFragment - nested*: seq[BlockBox] + inline*: InlineFragment + children*: seq[BlockBox] func offset*(x, y: LayoutUnit): Offset = return [dtHorizontal: x, dtVertical: y] |