about summary refs log tree commit diff stats
path: root/src/layout/engine.nim
Commit message (Collapse)AuthorAgeFilesLines
...
* layout: small cleanupbptato2024-05-081-39/+34
|
* layout: resize over-constrained table columnsbptato2024-05-081-12/+24
| | | | | | | | | If the total specified column width is larger than the table's allowed width, we now resize them proportionally to the specified width. This is quite important because many tables set the width to e.g. 50% for "give me half of the table", instead of its true meaning "give me half of the page".
* layout: table cell resizing fixesbptato2024-05-051-24/+29
|
* layout: fix float size in table cells; remove redundant positioningbptato2024-04-271-7/+14
|
* layout: fix image baselinebptato2024-04-261-2/+3
|
* Initial image supportbptato2024-04-251-6/+20
| | | | | | | | | | | | | | | | | * png: add missing filters, various decoder fixes * term: fix kitty response interpretation, add support for kitty image detection * buffer, pager: initial image display support Emphasis on "initial"; it only "works" with kitty output and PNG input. Also, it's excruciatingly slow, and repaints images way too often. Left undocumented intentionally it for now, until it actually becomes useful. In the meantime, adventurous users can find out themselves why: [[siteconf]] url = "https://.*" images = true
* layout: do not use parent computed values in root fragmentbptato2024-04-211-19/+11
| | | | | | * use rootProperties so the root fragment does not color its children * assert if the root gets inline blocks; this can (hopefully) no longer happen.
* layout: slightly refactor layoutInlinebptato2024-04-211-40/+42
|
* layout: flex item margin fixesbptato2024-04-201-25/+34
| | | | Still far from perfect, but it's an improvement.
* layout: fix double padding in flexbptato2024-04-201-2/+4
| | | | | | | | sizes.space regulates content-box width, in which padding is not included, so we must to subtract padding here. (Neither is margin, but margin is applied by outer layout, in this case flex itself, so it's not relevant here. Not to say it isn't broken...)
* layout: fix a list style positioning bugbptato2024-04-201-2/+2
| | | | | | If we are going to move out the child's offset, then we must also tell the child where it starts so it can behave correctly when it encounters exclusions.
* layout: float sizing fixesbptato2024-04-191-8/+21
| | | | | | | | | | | Turns out our shrink-to-fit emulation was inadequate: it assumed all floats are positioned on a separate line, which is the *opposite* of what we want, as that would be the behavior of min-content. Now we instead sum together the width of all floats and the widest non-floating child, and then clamp that to the target fitContent width. This correctly gives us max-content width in the first pass, still without having to actually position the floats.
* layout: accept inline-flex in iflushbptato2024-04-171-1/+1
|
* Update code stylebptato2024-04-171-278/+300
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* layout: fix list-item positioningbptato2024-04-161-3/+5
| | | | we also have to move the inner box offset to the parent
* layout: remove ListItemBox, handle inline-flex correctlybptato2024-04-151-78/+65
| | | | | This allows us to unify BlockBox instantiation and block-level inner layout calls.
* layout: height fixesbptato2024-04-121-41/+22
| | | | | | * fix percHeight not being passed down properly * simplify addTableCaption; get rid of hack that turned caption outer height into inner height
* layout: slightly hacky flex-basis implementationbptato2024-04-091-2/+21
| | | | | | | | it's better than nothing. I suppose. (Two-value flex syntax is encouraged even by the standard, so it gets used a lot, and that sets 0, not flex-basis: auto, so not having flex-basis breaks too many things.)
* css, layout: flexbox fixesbptato2024-04-061-6/+2
| | | | | | | * do not re-resolve FlexPendingItem sizes; it's pointless and it breaks percentage sizes * fix some bugs in `flex' shorthand parsing * add `flex-flow' shorthand
* layout: clean up resolveSizesbptato2024-04-051-80/+74
|
* Initial flexbox supportbptato2024-04-051-125/+379
| | | | | | | | | Still far from being fully standards-compliant, or even complete, but it seems to work slightly less horribly than having no flexbox support at all on sites that do use it. (Also includes various refactorings in layout to make it possible at all to add flexbox.)
* layout: add missing min/max heights to absolute sizesbptato2024-03-301-1/+3
|
* layout: fix various table cell sizing bugsbptato2024-03-301-47/+35
| | | | | | | | | | It seems I never properly converted the table cell (pre-)sizing code to use SizeConstraints, so it was still in a half-working state where it broke down e.g. on nested tables. * move auto check to canpx * simplify convoluted and broken table cell size calculation into something that actually works
* layout: fix float positioning with marginsbptato2024-03-301-1/+1
| | | | | | | | | | | | | | | Here we are restricting the float to the same width constraint as its parent, so we must add offset.x both when the float is larger than this constraint *and* when the float fits into the constraint. An example of what this fixes: <div style="padding-left: 10em; background: green"> <div style="float: right; background: red"> wat ^ previously the float was positioned as if the padding had been on the *right*, because it did not take into account offset.x.
* layout: fix another infinite loopbptato2024-03-261-2/+2
| | | | | | | aaaaa (this was even worse than the previous one, of course caused by the fix...)
* layout: avoid infinite loop in line wrappingbptato2024-03-261-11/+10
| | | | it would get into an infinite loop with line-height: 0 and floats
* layout: also round line height for painting backgroundsbptato2024-03-261-3/+2
| | | | | it's pointless to do otherwise, and results in inconsistencies between line positioning and background coloring.
* layout: ensure lines are not higher than they must bebptato2024-03-261-11/+14
| | | | | | This is still a more conservative approach than completely disabling line-height. It seems to work better than preserving rounded line-height in all cases, anyway.
* layout: optimize inline background areasbptato2024-03-261-18/+51
| | | | | | | Instead of adding a new area for every single line, extend already existing areas when possible. (This was my original plan but I got lazy.)
* layout: rework inline box area modelbptato2024-03-251-105/+160
| | | | | | | | | | | | | Specifying the background area as three LayoutUnit pairs sounds clever, but breaks down for text-align: center. * store line Y offset in LineBox - this is necessary to pass down areas we need to paint * refactor addHorizontalLine loop; remove mystery "If necessary, update ictx's width" line that used to be labeled "TODO this seems meaningless" and indeed seems meaningless now (I am prepared to deeply regret this later) * replace broken & convoluted startOffset/endOffset/size with a simple seq of offsets + sizes
* layout: table column size fixesbptato2024-03-161-33/+20
| | | | | | | * remove unnecessarily duplicated code (probably a copy-paste error) * apply UNIT_PERC computed widths for table cells too (just base it on sizes the table receives) * remove unnecessary parameters in some procs
* Move around some modulesbptato2024-03-141-1/+1
| | | | | | | | * extern -> gone, runproc absorbed by pager, others moved into io/ * display -> local/ (where else would we display?) * xhr -> html/ * move out WindowAttributes from term, so we don't depend on local from server
* layout: remove word-spacingbptato2024-03-131-4/+1
| | | | this was a bad idea
* rudimentary support for <video>, <audio>bptato2024-03-131-0/+4
| | | | | we just treat them as img tags. lazy, but works suprisingly well -- so long as the server sends us a Content-Type, anyway.
* strwidth, renderdocument: small refactoringbptato2024-03-031-5/+8
| | | | | | * put attrs pointer in state * simplify width() * use unsigned int as ptint to avoid UB
* layout: add whitespace width to end offset's x positionbptato2024-03-021-0/+4
| | | | | | | | so that e.g. a<span style="background-color: red"> </span>b makes the span width exactly one space.
* layout: fix float exclusion of other floatsbptato2024-03-021-2/+2
| | | | | | | | | | | | | | | > The right outer edge of a left-floating box may not be to the right > of the left outer edge of any right-floating box that is next to > it. Analogous rules hold for right-floating elements. says the standard therefore it does not really matter where the beginning of the float is; if it's float: left, then `left' must be set to the right edge, and if it's float: right, then `right' must be set to the left edge. (this was breaking some negative margin float abominations such that floats were suddenly overlapping and that's certainly not what we want)
* css: remove caption-side: left, right, fix caption-side: bottombptato2024-03-011-16/+1
| | | | | | | | left/right never really worked correctly, is non-standard, and the only browser that supported it (Firefox) removed it years ago. bottom was adding the table width to its offset instead of the height, that is now fixed.
* layout: reduce useless empty lines in inline boxesbptato2024-02-291-10/+17
| | | | | | | | | | | | | | If we are going to round things in layout, let's do it properly. Adding fake height has negative utility (things get more annoying to read), so now we don't. TODO: finding the correct positioning of the baseline after adding padding is an open question. Probably have to revise the algorithm somewhat to get it right. (This should also fix the bug where error correction would make inline box backgrounds shift into unrelated text, causing much confusion for the reader.)
* layout: round atom offsets toobptato2024-02-281-10/+10
| | | | | it is useful to round them so that they don't get positioned somewhere in the middle of a line (which is rounded to the same precision as well)
* layout: improve/simplify line box error correctionbptato2024-02-281-31/+17
| | | | | | | | | | | | The previous retrofitting of the old renderdocument error correction usually worked, but it still had a horrible flaw in that it assumed that all line boxes are of equal height. So if error was lower for some line than another, it would move *all* lines by a somewhat lower error, and that resulted in overlapping lines. Now we do something much simpler: in flushLine, round each line's height downwards before moving on to the next line. This gets rid of any blanks inbetween lines, and also works much better with cleared floats.
* Fix tab size bug on double tabsbptato2024-02-271-4/+4
| | | | | | | | | | It is in fact quite simple to calculate: charwidth is the width of printing characters until now, and whitespacenum the number of (non-flushed) spaces. So we just have to subtract this from the target width to get the number of spaces missing from the next tab stop. (Of course, it gets much harder to understand when the whole thing is formatted as a convoluted multi-line equation...)
* term: improve pixels-per-column/line detectionbptato2024-02-251-1/+1
| | | | | | | | | Some terminal emulators (AKA vte) refuse to set ws_xpixel and ws_ypixel in the TIOCGWINSZ ioctl, so we now query for CSI 14 t as well. (Also CSI 18 t for good measure, just in case we can't ioctl for some reason.) Also added some fallback (optionally forced) config values for width, height, ppc, and ppl. (This is especially useful in dump mode.)
* layout: make it compile attempt 2bptato2024-02-241-2/+2
| | | | aaaaaa
* layout: make it compilebptato2024-02-241-2/+2
| | | | :/
* layout: make position: fixed, sticky act like staticbptato2024-02-241-7/+8
| | | | | | | | It's better to not implement them at all than to implement them badly. (In particular, making fixed act like absolute breaks horribly on websites that actually use it. Fixing it is not really possible without changinge the way we currently draw things to the screen.)
* layout: remove justifybptato2024-02-221-20/+1
| | | | | | | | | | | | | | | | | | The way `justify' was implemented just made text annoying to read. (The algorithm of distributing spacing evenly does not really work on a cell-based screen because of rounding errors.) CSS 2.1 says: > Conforming user agents may interpret the value 'justify' as 'left' or > 'right', depending on whether the element's default writing direction > is left-to-right or right-to-left, respectively. Since we have no bidi yet, just interpret it as `left'. Maybe in the future we could add an implementation that tries to align line box lengths instead of their contents, but this will probably be difficult to get right.
* layout: do not apply error correction to first linebptato2024-02-221-5/+4
| | | | | | The first line is already ignored in the calculations, but it was still being re-positioned in positionAtoms, which made lines overlap in some cases.
* layout: only reset charwidth on non-word atomsbptato2024-02-161-1/+1
| | | | | | | | charwidth is specifically intended to represent the width of all characters until the current one, so resetting it for words makes no sense. Originally it was reset for all atoms *except* words; 9fdea97d simplified the code incorrectly (flipped the logic) and thus introduced a regression.
* layout: avoid wrapping on dash inside double-width linesbptato2024-02-161-0/+4
| | | | | Without this we were wrapping on the last dash (if any) inside CJK sentences.