about summary refs log tree commit diff stats
path: root/src/layout
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
|
* color: RGBAColor -> ARGBColorbptato2024-04-261-2/+2
|
* layout: fix image baselinebptato2024-04-261-2/+3
|
* Initial image supportbptato2024-04-253-18/+52
| | | | | | | | | | | | | | | | | * 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-172-288/+310
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* layout: fix list-item positioningbptato2024-04-162-3/+12
| | | | we also have to move the inner box offset to the parent
* layout: remove ListItemBox, handle inline-flex correctlybptato2024-04-153-91/+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
* renderdocument: do not layout with styledRoot == nilbptato2024-04-111-1/+4
| | | | it can happen when do_reshape is called before any parsing happens.
* 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-262-11/+17
| | | | | | 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-253-154/+180
| | | | | | | | | | | | | 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
* cell: update FormatFlag naming, remove useless templatesbptato2024-03-211-6/+6
|
* 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-142-2/+2
| | | | | | | | * 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-032-78/+69
| | | | | | * 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-282-10/+13
| | | | | 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-282-36/+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-252-3/+60
| | | | | | | | | 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.)
* Separate ANSI text decoding from main binarybptato2024-02-251-0/+437
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handling text/plain as ANSI colored text was problematic for two reasons: * You couldn't actually look at the real source of HTML pages or text files that used ANSI colors in the source. In general, I only want ANSI colors when piping something into my pager, not when viewing any random file. * More importantly, it introduced a separate rendering mode for plaintext documents, which resulted in the problem that only some buffers had DOMs. This made it impossible to add functionality that would operate on the buffer's DOM, to e.g. implement w3m's MARK_URL. Also, it locked us into the horribly inefficient line-based rendering model of entire documents. Now we solve the problem in two separate parts: * text/x-ansi is used automatically for documents received through stdin. A text/x-ansi handler ansi2html converts ANSI formatting to HTML. text/x-ansi is also used for .ans, .asc file extensions. * text/plain is a separate input mode in buffer, which places all text in a single <plaintext> tag. Crucially, this does not invoke the HTML parser; that would eat NUL characters, which we should avoid. One blind spot still remains: copiousoutput used to display ANSI colors, and now it doesn't. To solve this, users can put the x-ansioutput extension field to their mailcap entries, which behaves like x-htmloutput except it first pipes the output into ansi2html.
* 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.)