about summary refs log tree commit diff stats
path: root/src/layout
Commit message (Collapse)AuthorAgeFilesLines
* 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.)
* 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.
* layout: skip newlines between full-width charactersbptato2024-02-111-0/+19
| | | | | | Crucially, *only* between full-width characters. So "あ\nあ" is rendered as "ああ", but "あ\na" remains "あ a" (with a space inbetween).
* twtstr: misc refactoringsbptato2024-02-091-0/+1
| | | | | | * move out half width <-> full width converters * snake_case -> camelCase * improve toScreamingSnakeCase slicing
* layout: more consistent namingbptato2024-01-291-79/+41
|
* layout: consider inline positioning for absolute blocksbptato2024-01-292-19/+15
| | | | | When an absolute block is a descendant of an inline box, its positioned ancestor must be set to that box.
* Use std/* imports everywherebptato2024-01-071-4/+4
|
* Various fixesbptato2023-12-131-0/+1
| | | | | | | * Makefile: fix parallel build, add new binaries to install target * twtstr: split out libunicode-related stuff to luwrap * config: quote default gopher2html URL env var for unquote * adapter/: get rid of types/url dependency, use CURL url in all cases
* break up twtstr somewhatbptato2023-12-131-0/+1
| | | | | Avoid computing e.g. charwidth data for http which does not need it at all.
* layout: rounding error correction fixesbptato2023-12-111-2/+6
| | | | | * start from 1 * divide by total - 1, since we are counting the rounding error between each line
* css: add text-transformbptato2023-12-111-3/+21
| | | | | | | Probably not fully correct, but it's a good start. Includes proprietary extension -cha-half-width, which converts full-width characters to half-width ones.
* layout: do not resolve floats if grandparent position is resolvedbptato2023-12-101-2/+2
| | | | | | | | | | Instead, position them at the end of their block's layout pass. Without this, they could be positioned too early, as the grandparent's position being resolved does not guarantee that the parent's position has already been resolved as well. (Unlike the comment suggests, flushMargins is not appropriate there.)
* layout: fix rounding error correctionbptato2023-12-101-11/+8
| | | | | * Actually calculate rounding error * Skip a loop over lines by accumulating rounding error in finishLine
* layout: rewrite inline box handlingbptato2023-11-272-395/+475
| | | | | | | | | | | We now have real inline boxes. * Fix nesting of inline boxes * Represent inline boxes with a hierarchical RootInlineFragment -> InlineFragment tree * Get rid of inline padding hack * Get rid of ComputedFormat * Paint inline box backgrounds properly
* layout: clamp size constraints to min/max sizes for floatsbptato2023-11-231-7/+12
|
* layout: add clear, etc.bptato2023-11-231-35/+91
| | | | | | * Add clear CSS property * Fix some margin resolution bugs * Apply min-height, max-height to inner inline outer block boxes
* layout: simplify max width/height calculationbptato2023-11-211-41/+43
| | | | No need for the options.
* layout: fix some sizing bugsbptato2023-11-211-103/+124
| | | | | | | | * Merged float and inline-block size calculation * Set min-height, max-height for floats * Fix incorrect positioning of inline atoms with margins * Respect box-sizing in more places * Do not flush remaining margins in layoutRootBlock as top margin
* css: add box-sizingbptato2023-11-211-12/+39
|
* layout: move charwidth into LineBoxStatebptato2023-11-171-9/+8
|
* layout: add floatsbptato2023-11-171-218/+555
| | | | | | | | | | | | | yay!!!! * Add support for float: left, float: right Also, misc stuff: * Add support for display: flow-root * Set line width to the maximum allowed width on line wrap * Various refactorings Still todo: support clear
* layout: refactor flow margin propagation, sizingbptato2023-11-122-610/+619
| | | | | | | | | * Blocks are now positioned before their text contents would be layouted * Untangle calcAvailableSpaceSizes's results from BlockBox * Move a couple of objects from box -> engine * Use Size in a few more places * Set display to block if float is not none
* layout: refactor block layoutingbptato2023-10-281-151/+165
| | | | merge positionBlocks with buildBlocks
* layout: refactorbptato2023-10-282-273/+278
| | | | | | * remove Viewport reference from BlockBox * Viewport -> LayoutState (call it what it really is) * move more stuff from box -> engine
* buffer: remove viewport referencebptato2023-10-282-12/+12
| | | | | Viewport at this point is basically just the layout state, so it makes no sense to store it in buffer.
* layout/engine: refactor inline atoms etc.bptato2023-10-262-227/+240
|
* layout/engine: reformatbptato2023-10-261-26/+45
|
* layout/engine: add table row group/caption to anon tablebptato2023-10-261-0/+2
| | | | bugfix, bugfix...
* reduce new() usagebptato2023-10-251-27/+34
|
* Remove trailing spacesbptato2023-10-231-1/+1
|
* WindowAttributes: refactorbptato2023-10-192-2/+2
| | | | | | * rename module (window -> winattrs, to avoid conflict with env/window) * do not use result * remove unused cell_ratio