about summary refs log tree commit diff stats
path: root/src/css/layout.nim
Commit message (Collapse)AuthorAgeFilesLines
* cascade: collapse StyledNode tree into DOMbptato2025-01-201-18/+1
| | | | | We now compute styles on-demand, which is both more efficient and simpler than the convoluted tree diffing logic we previously used.
* css: reduce StyledNode usebptato2025-01-161-38/+45
| | | | | Eventually the tree should be collapsed into the DOM, and StyledNode should be created on the stack.
* layout: truncate inline-block margins as wellbptato2025-01-151-0/+4
|
* cssvalues: reduce CSSValues sizebptato2025-01-121-27/+28
| | | | | | | | | | | | | | | | * switch from float64 -> float32; other browsers use 32-bit floats too * specify integer size as 32-bit * use NetworkBitmap for background-image value (currently just an invalid dummy value) * remove "none" property & value types CSSValue's payload is always one word (plus another for the type tag). CSSValues keeps its size, but no longer has to heap-alloc + refcount word-sized CSSValues. (On 32-bit systems, CSSValues might actually be larger than before, but I expect it's still a net benefit with the removal of refcounting and the switch to 32-bit floats.)
* layout: remove needsReLayoutbptato2025-01-091-7/+3
| | | | we always do 2 passes
* buffer: make iframes clickablebptato2025-01-091-0/+4
| | | | better than nothing
* layout: clear intrinsic minimum block size on shrink-to-fit relayoutbptato2025-01-081-0/+1
| | | | starting to run out of test case names
* layout: get rid of flex-direction reverse hackbptato2025-01-071-47/+58
| | | | | This must not be handled by the tree builder, as that needlessly complicates tree caching.
* layout: wrap on inline floats that exceed the line's lengthbptato2025-01-061-4/+4
| | | | | | | In this case, it seems we have to wrap. (It's still not quite there; replace flow-root with inline-box to see another interesting bug...)
* layout, render: establish absolute container with position: stickybptato2025-01-061-10/+8
| | | | We do not support sticky scrolling, but this much should still work.
* layout: fix percentage margins in shrink-to-fitbptato2025-01-051-13/+17
| | | | | | | | Turns out this doesn't work like I thought it does... the second layout is always needed. This probably means that it's possible to layout absolutes during flow after all...
* layout: margin fixesbptato2025-01-051-15/+17
| | | | | | | | * respect flex item starting margin on main axis * pass left margin as offset input too -> fixes some sub-layout cache inconsistencies well, I *think* it does, but I haven't managed to find a case where it changes anything... either way, at least the code is prettier now
* layout: InnerBlockContext -> BlockBuilderContextbptato2025-01-041-65/+65
|
* layout: respect margin-top of root boxbptato2025-01-031-1/+1
|
* LayoutUnit -> LUnitbptato2025-01-031-94/+94
|
* layout: drop overflow trackingbptato2025-01-031-68/+10
| | | | | It's probably possible to do it in layout, but it's way too hard. Just do it in render.
* Unify PositionStaticLike, update todobptato2025-01-031-5/+0
| | | | | sticky, ruby, writing-mode: lots of complexity for little gain, and the fallback works just as well (if not better)
* layout: implement layoutFlexItem as layoutRootBlockbptato2025-01-021-16/+15
| | | | | | | This way, it benefits from sub-layout caching. Which is great because our flex layout likes to unnecessarily redo item layout... Also, we now account for the bottom margin in flex items.
* layout: cache sub-layoutsbptato2025-01-021-44/+22
| | | | | | | | Only root blocks for now; for non-roots, you'd have to cache exclusions too, and that is a fair bit harder. It isn't very noticable as an optimization, but it's a good first step towards a cached layout.
* layout: ignore general category Me, Mnbptato2025-01-021-1/+6
| | | | | | | | | | I'm not sure if this is the best way. On one hand, it probably breaks text in some languages that cannot be represented in normal form. On the other hand, some terminals may crash on such strange sequences (or worse). I'll just skip them for now, because it's marginally faster than returning 0 from width. We'll see if somebody complains.
* layout, dom: input rendering fixesbptato2025-01-011-1/+1
| | | | | * do not display submit/reset text with empty value * fix erroneous blank placement with white-space: pre on new line
* layout: fix regression in cd069a76ebptato2025-01-011-17/+13
|
* layout: prevent double-clear for flow rootsbptato2025-01-011-11/+20
| | | | I don't like the extra flag, but I don't see a better way.
* layout: add missing StyledNode ref to parent inline boxesbptato2025-01-011-1/+2
| | | | this broke gotoAnchor in some cases
* layout: absolute sizing fixesbptato2024-12-301-4/+16
|
* layout: fix position: relative for right, bottombptato2024-12-301-4/+2
| | | | | | | They are relative to the box's actual position, not that of the parent: > For relatively positioned boxes, the offset is with respect to the > bottom edge of the box itself.
* layout: fix an overflow bugbptato2024-12-301-1/+3
|
* layout: fix various padding bugsbptato2024-12-281-32/+26
| | | | | | | | They need some peculiar conditions to manifest, but the logic errors are clear: * padding contributing to intrinsic minimum size wasn't being clamped * inline padding was being applied twice
* layout: fix a flex sizing bugbptato2024-12-271-5/+4
| | | | | it has to accept percentage sizes too for intrinsic size clamping, it seems
* layout: improve intrinsic minimum size calculationbptato2024-12-261-83/+104
| | | | | It's a fair bit more accurate now on flex-heavy pages. Image sizing remains a broken mess.
* layout: resolve percentage width for auto table cellsbptato2024-12-211-9/+14
| | | | | It is still wrong in case the table is too small, but at least it fixes the regression from 0971ad85.
* box: InlineFragment -> InlineBoxbptato2024-12-201-105/+102
| | | | | | It was named "fragment" mainly because I added it back when there was still a separate InlineBox type and I needed another name. Now InlineBox is gone, and I'm tired of typing fragment.
* layout, render: image sizing fixes/workaroundsbptato2024-12-201-8/+12
| | | | | | | | * fix clip for image * switch back img's display to inline * fix image width calculation without specified width/height I'm not 100% sure if this is correct, but it certainly looks better.
* layout: apply padding to intrinsic minimum widthbptato2024-12-191-4/+3
|
* layout, render: implement overflow propertybptato2024-12-181-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Overflow pretty much requires scrollbars, but those wouldn't work in dump mode, plus of course they would be a pain to implement. So as a simple alternative: * overflow: hidden, clip works as per spec. * overflow: auto, overlay, scroll invert the intrinsic minimum size clamping logic instead of adding a scrollbar. What this concretely means, is that this <pre style="overflow: scroll; height: 1em"> test test test </pre> will, instead of creating a scroll container, just override the specified height. This hack works surprisingly well, because CSS pretty much requires setting height on scroll containers, so authors aren't incentivized to set height on the parent container too (because the contents are already sized appropriately). One issue left is how to deal with overflow: hidden ancestors. For now, I've made it so that it can spill for overflow-x, and always clips on overflow-y, because it's much less likely to bleed into other text horizontally than vertically. But there is definitely room for improvement, e.g. we could track space requested by scrolling children and expand parent boxes based on that.
* layout: propagate intrinsic minimum heightbptato2024-12-171-124/+152
| | | | | | | | | | | | Necessary for flex. Previously we just used the actual height, but that didn't account for boxes that size themselves depending on the available height (mainly just images for now). This also irons out intrinsic min width calculation somewhat, squashing several bugs. I hope it works well. It is a significant change in size calculation, so maybe there are still new bugs lurking.
* css: resolve units to px before layoutbptato2024-12-161-87/+80
| | | | Lets us skip a couple pointless multiplications/divisions during layout.
* layout: do not allow canpx for scFitContentbptato2024-12-151-2/+2
| | | | | The test case attached is undefined in CSS 2.1, but css-sizing-3 wants us to just ignore the width property (I think).
* layout: also propagate xminwidth from table captionbptato2024-12-151-0/+1
| | | | | | | this is necessary too, now that I think of it (well, table caption sizing is still half-broken, but that's a problem for another day...)
* layout: set table intrinsic min width to specified widthbptato2024-12-151-0/+3
|
* layout: do not trust specified table cell heightbptato2024-12-151-3/+4
| | | | | If the contents are larger than the specified cell height, then it is simply ignored.
* lunit: remove redundant codebptato2024-12-131-1/+1
| | | | | | using div instead of / is sort of weird, but it makes it clearer if we're dividing floats or layoutunits (and is already what the code uses).
* css: CSSComputedValue -> CSSValuebptato2024-12-121-50/+50
| | | | | "Computed" was redundant; other types of values don't have a common type.
* layout: small cleanupbptato2024-12-101-60/+60
|
* layout: override table cell width if its min width is greaterbptato2024-12-101-0/+2
| | | | We can do this now that xminwidth is more accurate.
* layout: proper min width clampingbptato2024-12-101-73/+70
| | | | better
* layout: another min width clamping hackbptato2024-12-101-20/+29
| | | | still not quite right, but it's slowly taking shape
* layout: another xminwidth kludgebptato2024-12-081-0/+4
| | | | yeah idk
* layout: round inline block padding to cellsbptato2024-12-071-1/+7
| | | | | Seems more compatible with websites that use smaller fonts + padding for styled code tags.
* pager, term: use cell offset with kitty imagesbptato2024-12-031-1/+1
| | | | | | | | Gets rid of rounding errors when positioning images. Theoretically this is possible with Sixel too, but as always, it's ten times as difficult to implement as with Kitty, so I'll leave it for later.