about summary refs log tree commit diff stats
path: root/src/css/layout.nim
Commit message (Collapse)AuthorAgeFilesLines
* layout: remove obsolete todobptato7 days1-1/+0
|
* Eliminate some superfluous copiesbptato13 days1-1/+1
|
* Enable ProveInit warningbptato2025-05-101-0/+1
| | | | It has caught some minor bugs.
* layout, csstree: build stacking contexts together with treebptato2025-05-031-29/+15
| | | | | | | | 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: simplify resolveBoundsbptato2025-04-231-31/+19
| | | | | Not entirely sure what the px check for the mi[dtHorizontal].send assingment was for; tests still pass after removing it.
* layout, render: fix positioning of absolute flex item descendantsbptato2025-04-101-34/+1
| | | | | | | | Always placing boxes relative to their parent *seems* prettier, but the implementation was broken and I can't come up with a sane working one. So we're back to just special casing position: absolute in render. Sad, but at least it works. (I think it's also a bit more efficient.)
* layout: always treat flex items as positioned boxesbptato2025-04-071-37/+41
| | | | | it still isn't really correct, they aren't supposed to behave as absolute positioning containers...
* layout: factor out canClear flagbptato2025-04-071-19/+14
| | | | ugly hack that is no longer needed
* layout: fix cleared floats not flushing previous exclusionsbptato2025-04-061-3/+14
| | | | | | | Well, I was trying to reproduce *another* float bug when I accidentally stumbled upon this... The fix is somewhat ugly, but not as bad as I expected.
* layout: correct table-caption width calculationbptato2025-04-031-35/+59
| | | | It's surprisingly tricky.
* layout: remove DisplayBlockLike checkbptato2025-03-281-4/+1
| | | | Doesn't seem to be necessary anymore.
* layout: refactorbptato2025-03-281-617/+577
| | | | | | * layoutBlockChild has two branches less * better separation of code into individual layouts; layout() is now the main entry point for inner layout
* layout: reimplement list items with out-of-flow markersbptato2025-03-271-28/+11
| | | | | | | | Instead of generating a separate container box for list items, just set the marker's display to an internal value that is treated specially. This fixes a bug where position: relative would not register the correct block as the positioned ancestor.
* layout: eliminate pointless flex relayoutsbptato2025-03-151-5/+12
|
* layout: implement cross auto margins in flexbptato2025-03-141-21/+43
| | | | | Also removes the computation of underflow on the end margin for blocks; as far as I can tell, this was never used.
* layout: small cleanupbptato2025-03-111-11/+9
|
* layout: shim grid as flow-rootbptato2025-03-111-2/+12
| | | | | | | | | | Pros: basic display on pages that depend on grid being implemented to display anything at all. Cons: breaks pages that have a fallback layout for UAs that can't do grid. (In practice, such pages must be rare - CSS for layout is painful enough that nobody in their right mind will spend time on implementing a fallback layout for the same DOM.)
* layout: revert marginBottom removalbptato2025-03-081-26/+12
| | | | | | 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-28/+34
| | | | | | 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: adjust table cell height to fill rowsbptato2025-03-031-9/+8
| | | | | | Achieved by generating an anonymous flow root child for the contents and positioning that. (Not the cell contents directly - that wouldn't work because of inline child boxes.)
* layout: fix nested fixed boxesbptato2025-02-181-5/+10
|
* layout: implement negative z-indexbptato2025-02-181-43/+64
| | | | Ugly, but works. I think.
* box: use singly linked list instead of seq for childrenbptato2025-02-171-20/+25
| | | | | | | | | | 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-37/+61
| | | | | | | | | | | | 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.)
* layout: skip Cf charactersbptato2025-02-151-1/+2
| | | | We cannot handle these yet.
* dom: store pseudo-element computed values in a seqbptato2025-02-141-1/+0
| | | | | A map isn't so bad with three pointers, but it won't be viable once we start adding more pseudo-elements.
* csstree, cssvalues: add non-numeric counters, japanese-formalbptato2025-02-141-3/+3
| | | | plus refactor a bit
* csstree, layout: more refactoringbptato2025-02-131-248/+161
| | | | | Base InlineBox is a fair bit smaller now, and (most) strings are cached using RefString.
* layout: separate out tree construction logicbptato2025-02-121-434/+58
| | | | | | | | | | | | | | | For now, the skeleton remains in layout. Eventually it should be lazily constructed during the actual layout pass (thereby making layout "single-pass" (sometimes :p)) The end goal is to do it all in styledNode.children, so that caching can be as simple as "next box = find next matching cached box ?? make new". This does mean that the internal structure of cached boxes will always have to be reconstructed, but I don't see a better way. (I suppose it still remains possible to optimize out the unnecessary layout pass when only a repaint is needed (e.g. color change) by modifying computed values in-place.)
* layout: respect intrinsic minimum width of table cellsbptato2025-02-091-1/+4
|
* layout: refactor tree building phasebptato2025-02-091-253/+151
| | | | | | | * remove inlineGroup - it was completely pointless now, and was the cause of some whitespace collapsing bugs * fix a float bug made visible by the above change * fix non-standard list item counter behavior
* layout: fix nested float positioningbptato2025-02-081-2/+0
| | | | | | | | | | Setting the width to max-content was supposed to be an optimization, but it seems max-content has some issues when interacting with floats. Arguably this is just hiding the bug, but my attempt to fix max-content was not successful... (That is to say, I suspect floats still behave strangely in tables.)
* layout: fix some pre whitespace bugsbptato2025-02-081-62/+63
|
* layout: fix firstBaseline bugbptato2025-02-081-1/+1
|
* layout: unify BlockBox and InlineBox, refactor buildingbptato2025-02-071-371/+373
| | | | | | | | | | | | | | * 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: round out small list-item margins and paddingbptato2025-02-041-8/+16
| | | | | They can be especially distracting when the rounding error fluctuates between items.
* layout: merge addOuterBlock with layoutBlock, refactorbptato2025-02-041-478/+571
| | | | | | | | | | | Having to initLine after every block hurts... I've added a mechanism to at least eliminate cleared floats, but I wish we just didn't init the line :/ (I tried making it lazy, but I couldn't get it to work elegantly.) I've also added some comments about flow, and moved around code so that related layouts are mostly in the same place.
* layout: eliminate InlineAtombptato2025-02-031-174/+170
| | | | | | | | | * 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: inline background fixes & simplificationbptato2025-02-031-132/+67
| | | | | Eliminates two superfluous line box alignment passes, and fixes some vertical-align bugs.
* layout: fix list item layoutbptato2025-02-031-14/+6
| | | | The content should clear.
* dom, layout: fix empty canvas cache idsbptato2025-02-011-1/+1
| | | | ok now I understand why I made shareCachedItem crash...
* layout: fix absolute sizing order with floatsbptato2025-01-301-3/+9
| | | | | Also removed the redundant pushPositioned/popPositioned calls in popPositioned.
* layout: fix flow roots in inline boxes not respecting floatsbptato2025-01-281-104/+92
| | | | Also, some more work on the unification of inline & block layouts.
* layout: fix some float margin resolution bugsbptato2025-01-281-34/+21
|
* layout: unify InlineContext with FlowStatebptato2025-01-271-547/+538
|
* layout: remove obsolete comment, improve struct packingbptato2025-01-261-12/+8
|
* layout: various float fixes in inline contextsbptato2025-01-261-136/+139
| | | | | | | | | | | | | * reinit line after outer block height is known * do not set wrap in finishLine preceding outer block layout * attach pending inline floats to line boxes * unify flow a bit more The last two points mean that we now (mostly) handle inline floats like block floats, which is great because only the latter ever worked properly. (Well, margin resolution still needs work...)
* layout: small cleanupbptato2025-01-261-67/+41
|
* layout: do not generate anonymous inline boxesbptato2025-01-251-269/+314
| | | | | | | | | | | | | | | | 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...)
* layout: always use computed from StyledNodebptato2025-01-251-74/+69
|