about summary refs log tree commit diff stats
path: root/src/layout
Commit message (Collapse)AuthorAgeFilesLines
* sixel: support transparencybptato2024-09-241-3/+1
| | | | | | | | | | | | | | | | | | Sixel can only represent transparency for fully transparent (alpha = 0) and fully opaque (alpha = 255) pixels, i.e. we would have to do blending ourselves to do this "properly". But what do you even blend? Background color? Images? Clearly you can't do text... So instead of going down the blending route, we now just approximate the 8-bit channel with Sixel's 1-bit channel and then patch it up with dither. It does look a bit weird, but it's not *that* bad, especially compared to the previous strategy of "blend with some color which hopefully happens to be the background color" (it rarely was). Note that this requires us to handle transparent images specially in term. That is, for opaque ones, we can leave out the "clear cells affected by image" part, but for transparent ones, we must clear the entire image every time.
* sixel: use inline background for blendingbptato2024-09-241-1/+3
| | | | still not really great, because inline background is a mess too
* layout: remove line-heightbptato2024-09-211-43/+13
| | | | | This was a bad idea that, despite my best efforts, never worked properly.
* Refactor img/*bptato2024-09-153-3/+3
| | | | | I've moved most image logic to adapter, so it doesn't really make sense to have this subdir anymore.
* renderdocument: fix image background coloringbptato2024-09-131-13/+16
| | | | special case it in paintBackground so that it doesn't look so ugly
* utils: add twtunibptato2024-09-082-30/+25
| | | | | | | | | | | | | | | | | | | std/unicode has the following issues: * Rune is an int32, which implies overflow checking. Also, it is distinct, so you have to convert it manually to do arithmetic. * QJS libunicode and Chagashi work with uint32, interfacing with these required pointless type conversions. * fastRuneAt is a template, meaning it's pasted into every call site. Also, it decodes to UCS-4, so it generates two branches that aren't even used. Overall this lead to quite some code bloat. * fastRuneAt and lastRune have frustratingly different interfaces. Writing code to handle both cases is error prone. * On older Nim versions which we still support, std/unicode takes strings, not openArray[char]'s. Replace it with "twtuni", which includes some improved versions of the few procedures from std/unicode that we actually use.
* canvas: move to separate CGI scriptbptato2024-09-013-4/+4
| | | | | | | | | | * stream: and passFd is now client-based, and accessible for buffers * Bitmap's width & height is now int, not uint64 * no more non-network Bitmap special case in the pager for canvas I just shoehorned it into the static image model, so it still doesn't render changes after page load. But at least now it doesn't crash the browser.
* layout: fix table height constraint typebptato2024-08-301-1/+9
| | | | | it's really min-height, not height; consistency is not CSS's strong suit...
* layout: fix whitespace weirdnessbptato2024-08-231-1/+3
| | | | | avoid adding whitespace to the previous atom if it's not on the current line
* winattrs: un-snakeifybptato2024-08-231-2/+2
|
* buffer, layout: small refactoringbptato2024-07-291-16/+15
|
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-1/+1
| | | | | | | | | * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase
* layout: merge neighboring wordsbptato2024-07-283-32/+28
| | | | 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-252-18/+26
| | | | It was broken for parent boxes with indefinite sizes.
* layout: min/max sizing fixesbptato2024-07-252-29/+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)
* renderdocument: fix clickable imagesbptato2024-07-121-0/+5
| | | | | | | | Paint the background with the current color, so that it gets associated with the owner styled node. (I didn't want to do this because it's slow, but otherwise image-mode gets very annoying to use.)
* renderdocument: clean up setTextbptato2024-07-061-100/+107
|
* layout: reduce copiesbptato2024-07-032-27/+35
| | | | | Text data is no longer stored separately in InlineFragments; instead, we now include refs to StyledNodes.
* layout: fix positioning bugbptato2024-07-021-4/+5
| | | | | top/left/right/bottom should only be used in renderdocument with position: absolute.
* renderdocument: avoid recursionbptato2024-06-301-9/+12
|
* 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-282-9/+25
| | | | | | | | | | | | | | | * 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-273-240/+201
| | | | | | | | | | | | | | | * 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-042-48/+130
| | | | | | 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.
* renderdocument: handle overlapping double width charsbptato2024-06-021-1/+6
| | | | | See attached test case; previously, this would result in a missing space in visual mode and a crash in dump mode.
* 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-013-292/+309
| | | | | | | 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-293-193/+205
|
* layout: get rid of InlineBoxBuilderbptato2024-05-283-109/+103
| | | | 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.