about summary refs log tree commit diff stats
path: root/src/css/box.nim
Commit message (Collapse)AuthorAgeFilesLines
* layout, csstree: build stacking contexts together with treebptato2025-05-031-8/+41
| | | | | | | | We often redo sub-layouts in layout, and this makes stacking contexts very hard to build reliably there. This fixes a bug where positioned descendants of flex items would sometimes mysteriously disappear.
* layout: revert marginBottom removalbptato2025-03-081-0/+3
| | | | | | It made cached layout inconsistent with uncached layout. (I'm not sure if this is actually observable; either way, it's a bad idea to rely on this.)
* layout: fix bottom margin handling for root blocksbptato2025-03-071-2/+0
| | | | | | I've also refactored the code a bit, so it's both easier to understand and more efficient. (In particular, BlockLayoutState no longer has to store marginBottom.)
* layout: implement negative z-indexbptato2025-02-181-0/+34
| | | | Ugly, but works. I think.
* box: use singly linked list instead of seq for childrenbptato2025-02-171-1/+8
| | | | | | | | | | Mainly because the seq was hindering further improvements. I don't expect performance or memory usage to change much; leaf nodes now store one pointer more, but parent nodes no longer pay for the overhead of a seq. (FWIW, other browsers seem to be using linked lists for this, too.)
* layout: position absolute boxes relative to their parentbptato2025-02-161-0/+1
| | | | | | | | | | | | Also fixes an invisible bug where inline-block child absolutes were queued multiple times. This adds a pointer to the parent box for CSSBox objects, which isn't great, but the alternatives (maintaining an explicit stack or adding another tree traversal) were overly complex and/or too inefficient. On the flip side, now it should be possible to do both stacking contexts (with negative z-index) and overflow tracking in layout. (I think.)
* csstree, cssvalues: add non-numeric counters, japanese-formalbptato2025-02-141-1/+1
| | | | plus refactor a bit
* csstree, layout: more refactoringbptato2025-02-131-42/+29
| | | | | Base InlineBox is a fair bit smaller now, and (most) strings are cached using RefString.
* box: abstract over tree traversalbptato2025-02-081-0/+16
|
* layout: unify BlockBox and InlineBox, refactor buildingbptato2025-02-071-23/+21
| | | | | | | | | | | | | | * normalize flow baseline computation * fix various margin collapsing bugs * eliminate inlineStack * eliminate push* * derive BlockBox and InlineBox from CSSBox This removes a pointer from BlockBox, and adds a pointer to both BlockBox and InlineBox (type field). A net loss, but it makes the code more manageable. Plus, inline groups now need one less allocation, so overall it's not that bad.
* layout: eliminate InlineAtombptato2025-02-031-13/+18
| | | | | | | | | * For boxes, we now use the box in InlineBox. * For images, wrap bmp in an InlineImage type that stores offset + size. * For text, wrap strings into TextRun objects (an offset + a string). (Ideally, TextRuns shouldn't copy at all, but that's a problem for another time.)
* layout: do not generate anonymous inline boxesbptato2025-01-251-4/+0
| | | | | | | | | | | | | | | | Anonymous inline boxes were blocking progress on layout caching, so they are now gone. Instead, we handle them in layoutInline (which meanwhile has spaghettified to beyond comprehension... now it's a special case of inner BlockBox (kind of?) - incredibly, it still passes tests :P) This seems to match what major browsers do as well; some test cases were updated to reflect the "improved" rendering this brings. Next I'd like to remove anonymous table boxes by generating them in cascade. Then it should be straightforward enough to at least reuse flow roots on relayout. (And clean up flow layout...)
* css: reduce StyledNode usebptato2025-01-161-4/+4
| | | | | Eventually the tree should be collapsed into the DOM, and StyledNode should be created on the stack.
* layout: margin fixesbptato2025-01-051-0/+3
| | | | | | | | * 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
* LayoutUnit -> LUnitbptato2025-01-031-27/+27
|
* layout: drop overflow trackingbptato2025-01-031-4/+0
| | | | | It's probably possible to do it in layout, but it's way too hard. Just do it in render.
* layout: cache sub-layoutsbptato2025-01-021-2/+31
| | | | | | | | 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.
* box: InlineFragment -> InlineBoxbptato2024-12-201-14/+14
| | | | | | 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: propagate intrinsic minimum heightbptato2024-12-171-2/+2
| | | | | | | | | | | | 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: CSSComputedValue -> CSSValuebptato2024-12-121-2/+2
| | | | | "Computed" was redundant; other types of values don't have a common type.
* buffer: fix broken gotoAnchor behaviorbptato2024-11-121-0/+5
| | | | | | | | | | | | | | | | | 23beebe6 introduced a regression that broke gotoAnchor. This fixes that, plus a couple other long-standing gotoAnchor bugs: * If no anchor is found, do not dupe the buffer. Desktop browsers still add a history entry, while w3m prints an error. I've copied the latter because it makes more sense as a user, but this will have to be refined for the navigation API at some point. * If the anchor *is* found, then always jump to it, even if it's not visible. This was a limitation of relying on the line array, so now we rely on the box tree instead. (Sooner or later, the former must go anyway.) Also, fix `U' reload not restoring the position (hopefully this time for good).
* layout -> cssbptato2024-11-101-0/+159
| | | | as much as I wish it weren't, layout *is* css.
* Another failed attempt at the layout enginebptato2021-11-071-50/+0
|
* Add RowBox structurebptato2021-10-031-1/+6
|
* Rewrite renderer (still non-functional)bptato2021-08-281-2/+8
|
* Some refactoringbptato2021-08-101-33/+2
|
* Implement CSS display none in box renderer etc.bptato2021-08-081-1/+0
| | | | | Other changes being bugfixes and a temporary implementation of "view source"
* Reorganize importsbptato2021-08-071-3/+2
|
* HTML display with highly broken box modelbptato2021-08-061-0/+72