about summary refs log tree commit diff stats
path: root/src/layout
Commit message (Collapse)AuthorAgeFilesLines
* layout -> cssbptato2024-11-104-4078/+0
| | | | as much as I wish it weren't, layout *is* css.
* layout: improve image sizingbptato2024-11-091-24/+16
| | | | | fixes a bug where only setting max-height and width would not re-scale the image
* renderdocument: basic stacking context supportbptato2024-11-091-14/+42
| | | | | negative z-index and inline positioning are still not respected, but better than nothing I guess.
* layout: adjust fixed positioningbptato2024-11-091-2/+12
| | | | | | | | | | | | | | | | | | In CSS, `position: fixed' either a) moves the box on scroll (with `@media screen'), or b) repeats the box on every page (with `@media print'). a) would completely mess up our document model, and even if it didn't, the renderer couldn't handle a redraw on every single scroll. b) sounds better, but still doesn't work because it's incompatible with `@media screen' semantics. e.g. in a) I can read text despite any banner on the bottom of the screen, because the box moves when I scroll, but in b), the same box will obscure some text on every single page. So instead, make the `position: fixed' containing box width: max(:root.width, 100vw); height: max(:root.height, 100vh)). This is completely non-standard, but at least both TOC-like fixed boxes *and* banners are placed somewhere that makes some sense.
* layout: fix a few more flex sizing bugsbptato2024-11-091-61/+84
| | | | | | | | * fix min-width, max-width, etc. not being accounted for properly on the main axis * fix fit-content sizing being overridden for flex items * fix baseline not being set * somewhat unrelated: fix firstBaseline not being set for block boxes
* layout: fix initial flex item width calculationbptato2024-11-081-13/+32
| | | | | | | | | | | | | | | Before, the initial layout of a flex item would have inherited the parent's sizing constraint. This almost worked, except when a descendant of a flex item with an unspecified width would resolve its percentage against this incorrectly inherited width - per standard, this must resolve to auto. Also, the shrink case was wrong, because it did not scale the unit to the respective widths; the standard mandates this as well. Hopefully I got it right this time. Finally, this fixes positioned inline container blocks not being set as the absolute container.
* utils, types: merge some modulesbptato2024-11-032-2/+1
| | | | | * line, vector, matrix -> path * twtuni, charcategory -> twtstr
* renderdocument: recurse in renderBlockBoxbptato2024-11-031-54/+47
| | | | Looks like this no longer overflows the stack.
* layout: fix a small table bugbptato2024-11-021-2/+2
|
* layout: remove inline roundingbptato2024-11-022-6/+2
| | | | | | | | | It broke styles like "margin-top: -5px; padding-top: 5px", because the margin would be taken as-is, and the padding rounded to 0. Now they cancel each other out again. (I think I had added this to reduce error caused by line-height, but we don't have line-height anymore.)
* layout: fix yet another inline float bugbptato2024-11-011-1/+4
| | | | | | | | | you can't just set the BFC offset to your own offset when the BFC's origin is your inner offset. (in block layout, this is addressed by initBlockPositionStates & co, but we don't call that for inline because the offset is already resolved there anyway. so this is a special case)
* layout: simplify a bit, fix some inline float bugsbptato2024-11-012-113/+77
| | | | | | | | | | | | | | * simplify "positioned" value calculation: - don't include it in ResolvedSizes, since it's unused in most layouts - resolvePositioned for both absolute and relative positioning - use "size" instead of "space" for absolute positioning - include parent width in layout so that renderdocument does not have to account for it * return bottom margins as regular return values instead of var * fix child bottom margins being discarded in inline floats * fix inline float not including the parent block position in its BFC position
* layout: refactor flow and fix some bugs in the processbptato2024-10-313-351/+318
| | | | | | | | | | | | * factor out `margin' field from box state * get rid of RootInlineFragment * `nested' -> `children' * get rid of repositionChildren pass; now we handle relative positioning and -cha-center/-cha-right separately * cha-center, cha-right no longer applies to floats * use consistent naming scheme for tests * fix float bottom margin strut not being flushed * fix inline floats changing non-fit-content width
* layout: fix margin resolution for absolutely positioned boxesbptato2024-10-281-6/+10
|
* layout: implement position: fixedbptato2024-10-282-16/+18
| | | | just a special case of position: absolute
* layout: fix nested absolute positioning, refactor initial size resolutionbptato2024-10-252-109/+113
| | | | | | | | | | Nested position: absolute was broken, so fix it. Also, it makes no sense to dispatch inside layoutBlockChild when we know the expected resolution algorithm upon calling it anyway, so now we do that statically. Finally, fix some bugs in position: absolute size resolution.
* layout: remove questionable use of newSeqUninitializedbptato2024-10-211-5/+2
|
* layout: fix inline float + position: absolute bugbptato2024-10-161-5/+6
| | | | | As per standard, float "only applies to elements that [...] are not absolutely positioned."
* css: add reverse video extensionbptato2024-10-151-0/+2
| | | | | | | | | | | | Called -cha-reverse. Mostly to solve the problem that code tags are indistinguishable from regular text - on a graphical browser this is normally served by monospace font, but we always use monospace... So now the default ua.css adds reverse video to code and xmp. pre remains as it was, because it means "preformatted", not "monospaced". Also, it would mess with our whatever-to-HTML converter output.
* layout: fix float positioning in inline contextsbptato2024-10-151-60/+120
| | | | | | also fixes a bug in the previous commit where whitespacenum would be reset on absolute positioning + missing absolute margin handling without top/left/etc.
* layout: correct `position: absolute' (FINALLY)bptato2024-10-152-157/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a) resolution of `position: absolute' percentage sizes with an indefinite containing block size (wait what?), and b) positioning of `position: absolute' inner block boxes inside inline boxes. a) is possible because `position: absolute' does not affect its parent's layout. I would love to have a long talk with whoever thought that specifying it like this is a good idea. You know, just because you can... anyways, shockingly enough, this was still the more straightforward part. b) forced me to change the box tree to allow blocks inside inlines, which is ugly, but no big deal. Two questions then remained: 1. *where* to put such boxes, and 2. *how large* these boxes should be; this is hardly obvious since an inline box does not have an unambiguous width or height. Of course the CSS standard, never too eager to fulfill my basic expectations, says nothing about this (other than "it's not defined"). So I first tried to reverse engineer what Gecko does, and after hours of pain and suffering I realized... that it's broken LOL https://bugzilla.mozilla.org/show_bug.cgi?id=489100 Therefore I ended up (partially) copying Blink behavior, which, while equally nonsensical as Gecko (and of course divergent), at least does not change after a partial layout. Thank you LayoutNG for saving my sanity. As for the practical benefits: this fixes the bug where Invidious [video] tags wouldn't show up. Hey, it's something! Still left to-do: `position: absolute' for `display: inline' boxes.
* layout, pager: preserve tabs on display, selection & outputbptato2024-10-101-6/+13
| | | | | | | | | | | | Substitute tabs with one of eight PUA characters based on their width, and convert them back in the pager: * TUI mode always prints spaces, but now handles tabs appropriately on cursor movement * dump mode tries to preserve hard tabs, but uses soft tabs when that is not possible (e.g. tabs after a margin, tab with background color, etc) * selection mode always outputs hard tabs.
* layout: small cleanupbptato2024-10-071-14/+11
| | | | the length check is not needed, we do that outside the loop already
* color: reduce CellColor size, misc color refactoringbptato2024-10-061-11/+19
| | | | | | * split out CSSColor from CellColor; now CellColor is just 4 bytes (which helps reduce FormatCell size) * unify color function naming (still not perfect)
* layout: fix floats overriding margin/paddingbptato2024-10-051-2/+3
|
* container: fix control char displaybptato2024-09-281-4/+4
| | | | | | Also, kill twidth and its friends; we haven't been using it for a while now. (In the future, a solution with PUA chars might be worth exploring.)
* layout: fix wrong padding offsetsbptato2024-09-272-54/+44
| | | | + some misc refactorings
* 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
|