about summary refs log tree commit diff stats
path: root/src/css/cascade.nim
Commit message (Collapse)AuthorAgeFilesLines
* dom: add inline SVG supportbptato2024-12-201-0/+9
|
* layout, render: implement overflow propertybptato2024-12-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Overflow pretty much requires scrollbars, but those wouldn't work in dump mode, plus of course they would be a pain to implement. So as a simple alternative: * overflow: hidden, clip works as per spec. * overflow: auto, overlay, scroll invert the intrinsic minimum size clamping logic instead of adding a scrollbar. What this concretely means, is that this <pre style="overflow: scroll; height: 1em"> test test test </pre> will, instead of creating a scroll container, just override the specified height. This hack works surprisingly well, because CSS pretty much requires setting height on scroll containers, so authors aren't incentivized to set height on the parent container too (because the contents are already sized appropriately). One issue left is how to deal with overflow: hidden ancestors. For now, I've made it so that it can spill for overflow-x, and always clips on overflow-y, because it's much less likely to bleed into other text horizontally than vertically. But there is definitely room for improvement, e.g. we could track space requested by scrolling children and expand parent boxes based on that.
* match: refactor a bitbptato2024-12-171-1/+1
| | | | | Now we use the node index to optimize next/subsequent sibling combinators.
* default(T) -> T.default, add some strict defsbptato2024-12-171-6/+6
|
* css: resolve units to px before layoutbptato2024-12-161-22/+23
| | | | Lets us skip a couple pointless multiplications/divisions during layout.
* dom, css: fix case-insensitive class/id/attr matchingbptato2024-12-151-10/+6
| | | | Uses an additional lower-case map for O(1) case-insensitive comparisons.
* cascade: misc cleanupbptato2024-12-141-6/+3
|
* css: CSSComputedValue -> CSSValuebptato2024-12-121-5/+5
| | | | | "Computed" was redundant; other types of values don't have a common type.
* cascade: add cellspacingbptato2024-12-031-0/+7
|
* cssvalues: optimize CSSComputedValues sizebptato2024-12-031-18/+27
| | | | | | | | Roughly halves the object's size, and gets rid of a large number of allocations. It could be compressed further into a bitmap, but I'm not sure if it's worth the complexity.
* cascade, cssvalues: clean up a bit morebptato2024-12-021-36/+34
|
* css: misc refactoringbptato2024-12-021-2/+2
|
* cascade: allow presentational hints with styling=falsebptato2024-11-291-2/+2
| | | | They are UA style.
* cascade: apply buffer.styling to inline stylesbptato2024-11-271-8/+11
| | | | it's author style too
* match, stylednode: remove generics, refactorbptato2024-11-191-3/+4
| | | | | | Turns out the generics weren't really needed in the first place. Also, StyledNode is now 16 bytes smaller.
* js: reorganize modules, update docsbptato2024-11-151-1/+1
| | | | | | | most of it has already been moved to monoucha, and the rest fits better in other directories. also, move urimethodmap to config
* cssvalues: reduce CSSComputedValue sizebptato2024-11-141-6/+3
| | | | | | | far from perfect, but it's something. (ideally, we should store enums in a bitmap instead of allocating a GC'ed property for each of them.)
* cascade: adjust prefers-color-scheme based on terminal backgroundbptato2024-11-101-1/+1
| | | | also, default link color is now blue for light terminal backgrounds
* layout -> cssbptato2024-11-101-1/+1
| | | | as much as I wish it weren't, layout *is* css.
* Clean up forward declarations a bitbptato2024-10-271-2/+3
|
* dom: html -> documentElementbptato2024-10-101-1/+1
| | | | it's effectively a dupe, except html wouldn't work in XML
* color: reduce CellColor size, misc color refactoringbptato2024-10-061-3/+3
| | | | | | * split out CSSColor from CellColor; now CellColor is just 4 bytes (which helps reduce FormatCell size) * unify color function naming (still not perfect)
* cascade: add missing nil checkbptato2024-09-021-1/+1
|
* canvas: move to separate CGI scriptbptato2024-09-011-7/+9
| | | | | | | | | | * 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.
* winattrs: un-snakeifybptato2024-08-231-2/+2
|
* cssvalues, twtstr, mediaquery: refactor & fixesbptato2024-08-021-11/+5
| | | | | | | * cssvalues, twtstr: unify enum parsing code paths, parse enums by bisearch instead of hash tables * mediaquery: refactor (long overdue), fix range comparison syntax parsing, make ident comparisons case-insensitive (as they should be)
* css: hash attribute namesbptato2024-07-291-3/+22
|
* cascade: move some presentational hints to ua.cssbptato2024-07-291-66/+0
|
* cascade: add some presentational hintsbptato2024-07-271-3/+7
| | | | | | * top/middle/bottom for img, remove redundant display: block for floats (they get blockified anyway) * map align for p too, not just div
* css: clean up a bitbptato2024-07-121-11/+7
|
* cascade: reduce allocationsbptato2024-07-101-57/+42
| | | | | | | Just use the previous tree when possible. The child list is still reconstructed, but at least we no longer alloc every single node again at every single restyle.
* cascade: fix style cachingbptato2024-07-091-3/+7
| | | | the invalid flag must be toggled after styling
* css, html: fix CSS dependency invalidationbptato2024-07-031-3/+6
|
* cascade: support align=left, align=right on imgbptato2024-06-291-2/+14
|
* img, loader: add image resizing, misc fixesbptato2024-06-281-2/+3
| | | | | | | | | | | | | | | * 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.
* misc cleanupsbptato2024-06-221-2/+1
|
* css: slightly optimize cascadebptato2024-06-021-41/+109
| | | | Parse rule values in sheet addRule, not during cascade.
* stylednode: remove `text' fieldbptato2024-05-281-4/+6
| | | | This avoids some unnecessary string copying.
* css/values -> css/cssvaluesbptato2024-05-161-1/+1
| | | | for consistency
* cascade: avoid empty ::before/::afterbptato2024-05-051-3/+2
| | | | | If `content' is empty, then generating before/after pseudo-elements is wrong.
* color: separate out JS convertersbptato2024-05-051-0/+1
| | | | | ansi2html depends on color, but we definitely do not want to link it to QJS, so the converters must be moved into a separate module.
* css, dom: simplify ident parsing, canvas fixesbptato2024-05-011-10/+16
| | | | | | | | * add CSSStyleDeclaration setter * move ident maps directly into enums * more complete CSSComputedValue stringifier * turn canvas into a pseudo-image in cascade * set canvas to inline-block
* Initial image supportbptato2024-04-251-1/+5
| | | | | | | | | | | | | | | | | * 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
* Update code stylebptato2024-04-171-95/+100
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* catom: at -> satbptato2024-03-211-18/+18
| | | | just for consistency
* rudimentary support for <video>, <audio>bptato2024-03-131-0/+14
| | | | | we just treat them as img tags. lazy, but works suprisingly well -- so long as the server sends us a Content-Type, anyway.
* catom: merge TagType with AttrTypebptato2024-03-041-0/+1
| | | | | it's inefficient and pointless to treat them differently, so just derive a new enum from TagType with a macro
* Allow non-RGB colors in CSSbptato2024-02-241-3/+3
| | | | | | | | | | | The -cha-ansi color type now sets ANSI colors in CSS. Also, color correction etc. has been improved a bit: * don't completely reset output state in processFormat for new colors * defaultColor is now separated from ANSI color type 0 * bright ANSI colors are no longer replaced with bold + dark variant * replaced ANSI color map to match xterm defaults
* css: reduce CSSComputedValue sizebptato2024-02-171-6/+2
| | | | | | | The `t' field was completely redundant, as it's already included in the CSSComputedValues index. + removed some unused functions
* layout: use html/body bgcolor as canvas bgcolorbptato2024-02-171-0/+5
| | | | | | This is required by the standard. (Without this, lots of websites have incorrect background colors, because they set the body height to 100% of the viewport.)