about summary refs log tree commit diff stats
path: root/src/layout/engine.nim
Commit message (Collapse)AuthorAgeFilesLines
* buffer, layout: small refactoringbptato2024-07-291-16/+15
|
* layout: merge neighboring wordsbptato2024-07-281-9/+27
| | | | Great performance win on large documents.
* layout: inline table fixesbptato2024-07-271-54/+154
| | | | | | | * properly wrap inline internal table boxes in inline-table (instead of block-level table) * fix missing baseline in table wrapper boxes * fix wrong wrapping of misparented table/row/row group children
* layout: position: relative, absolute fixesbptato2024-07-261-34/+52
| | | | | | | | | | * support position: absolute on flex items * proper top/bottom/left/right calculation for position: relative * push positioned flex box sizes to positioned stack Still not perfect: position: absolute should always resolve percentage sizes and top/bottom/left/right, meaning absolute layout needs to be delayed until its containing box is fully layouted.
* layout: fix incorrect absolute positioningbptato2024-07-251-7/+4
| | | | It was broken for parent boxes with indefinite sizes.
* layout: min/max sizing fixesbptato2024-07-251-28/+58
| | | | | | | * fix max size trumping min size * respect min-width/max-width/min-height/max-height for images * fix xminwidth calculation for percentage-sized images with an indefinite containing size
* layout: fix various flex column sizing bugsbptato2024-07-221-24/+58
| | | | | | * fix flex column item width not being stretched * set minimum flex column height to the layouted item's height (to avoid overlap)
* layout: reduce copiesbptato2024-07-031-26/+34
| | | | | Text data is no longer stored separately in InlineFragments; instead, we now include refs to StyledNodes.
* layout: flex padding/margin fixesbptato2024-06-301-2/+8
|
* layout: clamp image size to available spacebptato2024-06-291-5/+14
| | | | reduces images spilling out of their containers
* layout: fix image baselinebptato2024-06-291-6/+5
| | | | I doubt this is correct, but at least it's less broken than previously
* layout: fix text-align + padding coloringbptato2024-06-291-1/+2
|
* img, loader: add image resizing, misc fixesbptato2024-06-281-9/+21
| | | | | | | | | | | | | | | * resize images with stb_image_resize * use tee for output handle redirection (redirectToFile blocks) * cache original image files * accept lseek in sandbox * misc stbi fixes For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in size, not sure if it's worth the cost. (Either way, we can always switch later if needed, since the API is almost the same.) Next step: move sixel/kitty encoders to CGI, and cache their output in memory instead of the intermediate RGBA representation.
* layout: inline fixes & improvementsbptato2024-06-271-240/+194
| | | | | | | | | | | | | | | * fix text-align breaking down in the presence of floats * improve (and simplify) background color area painting This greatly simplifies inline layout by removing the additional text-align atom movement code and replacing it with a full re-layout when needed. That re-layout only occurs in (rare) cases where the text is likely to be relatively short anyway, so it's probably a win in any remotely realistic layout. This has also made it possible to at last merge the last three passes (horizontal/vertical alignment and background painting) and drop that weird synchronized tree + vector traversal.
* layout: simplifybptato2024-06-241-53/+44
|
* layout: avoid shrink-to-fit padding/margin overflowbptato2024-06-231-7/+12
|
* layout: get rid of incorrect hackbptato2024-06-231-1/+1
|
* layout: minor cleanupbptato2024-06-041-7/+4
|
* layout: track overflow sizebptato2024-06-041-41/+112
| | | | | | Not very useful yet; partial layouting and/or a new renderer is probably necessary to replace the current FormatCell-based node placement, otherwise it will be unbearably slow.
* layout: misc refactoringsbptato2024-06-021-209/+180
| | | | | * get rid of BlockGroup * unify BlockBox construction for flex, block, table
* layout: clean up inline tree constructionbptato2024-06-011-280/+289
| | | | | | | Much cleaner than the previous solution. Should also be somewhat less wasteful, as we no longer constantly rebuild the same tree with new branches.
* layout: dimSum -> sumbptato2024-06-011-22/+21
|
* layout: refactor resolveSizesbptato2024-06-011-140/+126
| | | | get rid of percHeight, unify min/max sizing, etc.
* layout: line box sizing fixesbptato2024-05-311-15/+11
| | | | | * do not use inline block computed values for wrapper fragment * fix minimum line box height calculation
* layout: fix a width sizing bugbptato2024-05-301-4/+1
| | | | | | | As expected, the mystery line was just hiding another bug. (In particular, indefinite containing size constraints were not denied in resolveContentWidth, so it only (accidentally) worked with stretched sizes.)
* layout: fix regressionbptato2024-05-301-0/+3
| | | | seems like this line is necessary after all
* layout: simplify percHeight handling, misc refactoringsbptato2024-05-301-67/+30
|
* layout: fix caption margin calculationbptato2024-05-301-19/+17
| | | | | | * merge caption sizing code path with layoutRootBlock * fix caption margins being disregarded * fix incorrect positioning of `caption-side: bottom'
* layout: improve baseline calculationbptato2024-05-301-56/+56
| | | | | * use current fragment's line height for percentage baselines * get rid of baseline calculating pass in verticalAlignLine
* layout: fix clear on blocks establishing new BFCsbptato2024-05-301-1/+4
| | | | | | | | | | | As per standard: > Adjoining vertical margins collapse, except: > [...] > If the top and bottom margins of an element with clearance are > adjoining, its margins collapse with the adjoining margins of > following siblings but that resulting margin does not collapse with > the bottom margin of the parent block.
* layout: misc refactoringsbptato2024-05-291-183/+182
|
* layout: get rid of InlineBoxBuilderbptato2024-05-281-91/+89
| | | | just merge it with InlineFragment
* layout: fix crash on inline tablesbptato2024-05-281-1/+1
|
* stylednode: remove `text' fieldbptato2024-05-281-5/+7
| | | | This avoids some unnecessary string copying.
* layout: remove BlockBoxBuidlerbptato2024-05-271-675/+574
| | | | | | | | | | Instead of allocating a separate object for each box, just re-use a single BlockBox on re-layouts. This means that now the (block-level) tree is built in its final form in the first pass. (Inline boxes remain the same as before for now.)
* layout: list item improvements, fix inner markersbptato2024-05-251-36/+41
| | | | | * fix list-style-position: inside * get rid of ListItemBoxBuilder
* layout: add wrapper box for table caption + misc stuffbptato2024-05-241-106/+141
| | | | | | | | | Captions are no longer positioned inside tables, yay. Also, misc: * rename some things for consistency * clamp out of bounds rgb() values * remove inherited property lookup table
* layout, layoutunit: remove some automatic convertersbptato2024-05-221-4/+5
| | | | | I wish we didn't need any, but fixing this for integers would be too involved and the float64 one was causing problems now.
* layout: simplifybptato2024-05-211-102/+76
| | | | removes elaborate table box type hierarchy that does nothing
* layout: fix inline tab expansionbptato2024-05-191-0/+1
|
* layout: fix BFC positioning in presence of floatsbptato2024-05-191-14/+56
| | | | | | | | | | | | | Previously, the following printed "2" instead of "12": <div style=float:left>1</div><div style=display:flow-root>2</div> This fixes the above problem in the laziest possible way: we relayout once in the smallest possible space the BFC fits in when floats exist. See the comment in the code for details. As a nice bonus, this also fixes tables overlapping with floated boxes, by pretending that they establish a BFC.
* css: stub overflowbptato2024-05-181-2/+3
| | | | | The renderer cannot handle it yet, but at least this fixes pages that expect overflow: hidden (etc.) to establish a new BFC.
* layout: fix maxFloatHeight checkbptato2024-05-181-5/+5
| | | | | Including our own position is a mistake, since the BFC starts from the inner box.
* layout: reuse box.positioned in positionAbsolutebptato2024-05-181-4/+4
|
* layout: relative positioning fixesbptato2024-05-181-75/+63
| | | | Fix percentage-based left/right etc.
* layout: slightly refactor table layoutbptato2024-05-181-27/+26
|
* css/values -> css/cssvaluesbptato2024-05-161-1/+1
| | | | for consistency
* luwrap: replace Nim unicode maps with libunicodebptato2024-05-091-3/+3
| | | | | | | | | | | | | | | | | Instead of using the built-in (and outdated, and buggy) tables, we now use libunicode from QJS. This shaves some bytes off the executable, though far less than I had imagined it would. Also, a surprising effect of this change: because libunicode's tables aren't glitched out, kanji properly gets classified as alpha. I found this greatly annoying because `w' in Japanese text would now jump through whole sentences. As a band-aid solution I added an extra Han category, but I wish we had a more robust solution that could differentiate between *all* scripts. TODO: I suspect that separately loading the tables for every rune in breaksViWordCat is rather inefficient. Using some context object (at least per operation) would probably be beneficial.
* layout: unify some code pathsbptato2024-05-091-222/+182
| | | | | | | Turn Offset, Size, etc. into arrays indexed by a DimensionType enum, and use it to unify code that only differs in the dimension it is computing for. (e.g. this lets us use the same code for flex row & column layouts.)
* layout: another table colwidth fixbptato2024-05-081-2/+8
| | | | | | Turns out we also have to *expand* column width, if the specified column width is too small *and* no unspecified column exists to take the rest of the place.