about summary refs log tree commit diff stats
path: root/src/css/cascade.nim
Commit message (Collapse)AuthorAgeFilesLines
* cascade: support nested variablesbptato2025-01-201-77/+77
| | | | ...and refactor applyValue in the process.
* cascade: collapse StyledNode tree into DOMbptato2025-01-201-279/+120
| | | | | We now compute styles on-demand, which is both more efficient and simpler than the convoluted tree diffing logic we previously used.
* dom: CSSStyleDeclaration improvementsbptato2025-01-191-1/+1
| | | | Now getComputedStyle works with pseudo-elements too.
* cascade: simplify RuleListMapbptato2025-01-181-42/+31
| | | | it can be a value type again
* dom, stylednode: move more fields, handle pseudo-element getComputedStylebptato2025-01-181-17/+18
|
* cascade: basic CSS variable supportbptato2025-01-161-36/+141
| | | | | | | | | | | and once again, there was light... Well, it barely works, but it's enough to get colors back on most sites. Nested variables aren't supported for now, and shorthand expansion only "works" for `background' (it's a hack). Props to the W3C for introducing the C preprocessor to CSS - I was starting to confuse it with JSSS after calc().
* cascade, stylednode: remove parent field from StyledNodebptato2025-01-151-106/+118
| | | | | | | | Now StyledNode has an "element" reference, which refers to the element it was derived from. This reduces the object's size, removes the need for casting around the "node" field, and also gets rid of a pointless cycle.
* cascade: fix hasValues filterbptato2025-01-141-6/+5
|
* css: refactor selector parsing & cascading, some work on variablesbptato2025-01-141-123/+92
| | | | | | | | | Untangled some nested arrays to reduce the number of intermediary seqs in cascade, and collapsed the two rule def sorts into just one (per pseudo element). This should make cascading somewhat faster. Also, we now parse variables, but they aren't resolved yet. Probably a seq won't cut it for var lookup...
* cssvalues: reduce CSSValues sizebptato2025-01-121-10/+14
| | | | | | | | | | | | | | | | * switch from float64 -> float32; other browsers use 32-bit floats too * specify integer size as 32-bit * use NetworkBitmap for background-image value (currently just an invalid dummy value) * remove "none" property & value types CSSValue's payload is always one word (plus another for the type tag). CSSValues keeps its size, but no longer has to heap-alloc + refcount word-sized CSSValues. (On 32-bit systems, CSSValues might actually be larger than before, but I expect it's still a net benefit with the removal of refcounting and the switch to 32-bit floats.)
* cascade: collapse inited into one arraybptato2025-01-121-29/+22
| | | | less work for memset
* ua.css: improve select renderingbptato2025-01-091-0/+5
| | | | | | | | | Regular select is now rendered as flex, and does not wrap. This gets rid of the pointless whitespace before/after options. multiple still looks weird, but maybe a bit less? Probably we should just render it with pseudo-checkboxes, and drop the special mode from select.nim.
* buffer: make iframes clickablebptato2025-01-091-0/+5
| | | | better than nothing
* env: add media query matchingbptato2025-01-061-52/+1
| | | | | | | In lite mode, it uses default window attributes. Incidentally, this also untangles media query matching from cascade, saving us a forward declaration hack (yay!)
* dom: DOMTokenList fixes/improvementsbptato2025-01-051-1/+1
|
* cascade: prevent blockification for non-inline absolute boxesbptato2024-12-301-4/+8
| | | | The standard says we should blockify. Alas, the standard is lying.
* cascade: inline presentational hint calculationbptato2024-12-301-19/+19
| | | | no need to alloc a seq for this
* dom, cssvalues: add getComputedStylebptato2024-12-301-1/+4
| | | | Only available in "app" mode.
* env: do not copy attrs, fix screen on clientbptato2024-12-281-5/+5
| | | | Now screen.width etc. works in the pager too.
* buffer: add "app" scripting modebptato2024-12-261-1/+2
| | | | | | | | | | For APIs that cannot be implemented in a privacy-friendly manner. As a start, I've added accurate screen size queries; getComputedStyle, getBoundingClientRect, etc. should follow. (We have a harmless getComputedStyle already, but it's broken.) Probably, things like JS-based scroll belong in here too, but I'm not sure yet. (Perhaps autofocus should be reused instead?)
* cascade: actually, it should be inline-blockbptato2024-12-201-1/+1
| | | | what was I expecting
* cascade: blockify on position: absolute or fixedbptato2024-12-201-4/+4
| | | | | | | | | | | | | | Welp, turns out I was overthinking it. CSS does not support inline position: absolute at all, it just blockifies. That does leave us with the question of "why does inline-block behave differently than block?" Especially because both in Gecko and Blink, getComputedStyle for absolute inline-blocks gives me "block", not "inline-block", and yet there is the same difference in rendering when I change the CSS. I first thought it's a quirks mode issue, but standards mode doesn't affect it. Wat.
* 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
|