about summary refs log tree commit diff stats
path: root/src/css/cssvalues.nim
Commit message (Collapse)AuthorAgeFilesLines
* cascade: support nested variablesbptato2025-01-201-1/+0
| | | | ...and refactor applyValue in the process.
* cascade: collapse StyledNode tree into DOMbptato2025-01-201-3/+2
| | | | | We now compute styles on-demand, which is both more efficient and simpler than the convoluted tree diffing logic we previously used.
* dom, stylednode: move more fields, handle pseudo-element getComputedStylebptato2025-01-181-1/+11
|
* cssvalues: serialize quotes, add font-size, opacitybptato2025-01-161-30/+35
| | | | | | | | | | | | font-size isn't very useful, but some scripts assume it exists. opacity: 0 for now is special cased: it inhibits rendering of further boxes. This isn't quite right, as it should just behave as a pseudo visibility: hidden... nonetheless it's quite effective at hiding garbage. (Also, remove incorrect comment - it can be nil if the branch has no variables.)
* cascade: basic CSS variable supportbptato2025-01-161-113/+134
| | | | | | | | | | | 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().
* cssparser: enumize CSSFunction namebptato2025-01-151-5/+4
|
* css: refactor selector parsing & cascading, some work on variablesbptato2025-01-141-25/+80
| | | | | | | | | 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: set text-decoration to bit, vertical-align to wordbptato2025-01-121-27/+25
| | | | they fit into 8 and 64 bits respectively
* cssvalues: reduce CSSValues sizebptato2025-01-121-214/+266
| | | | | | | | | | | | | | | | * 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.)
* cssvalues, sheet: fix quotes parsing, misc cleanupbptato2025-01-121-77/+69
|
* cascade: collapse inited into one arraybptato2025-01-121-3/+8
| | | | less work for memset
* buffer: make iframes clickablebptato2025-01-091-1/+1
| | | | better than nothing
* cssparser, mediaquery: factor out tflagb, fix a media query bugbptato2025-01-071-13/+16
| | | | @media (grid: 1) works again.
* layout: get rid of flex-direction reverse hackbptato2025-01-071-0/+1
| | | | | This must not be handled by the tree builder, as that needlessly complicates tree caching.
* layout, render: establish absolute container with position: stickybptato2025-01-061-4/+0
| | | | We do not support sticky scrolling, but this much should still work.
* Unify PositionStaticLike, update todobptato2025-01-031-1/+0
| | | | | sticky, ruby, writing-mode: lots of complexity for little gain, and the fallback works just as well (if not better)
* dom, cssvalues: add getComputedStylebptato2024-12-301-36/+71
| | | | Only available in "app" mode.
* cssvalues: fix length shorthand parsingbptato2024-12-301-1/+1
|
* cssvalues: fix font-weight parsingbptato2024-12-291-2/+2
| | | | | | you can't bisearch an unsorted map... (also, turn on text styling for colored layout tests because it would have caught this)
* layout, render: implement overflow propertybptato2024-12-181-2/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* css: resolve units to px before layoutbptato2024-12-161-81/+75
| | | | Lets us skip a couple pointless multiplications/divisions during layout.
* css: CSSComputedValue -> CSSValuebptato2024-12-121-49/+49
| | | | | "Computed" was redundant; other types of values don't have a common type.
* cssvalues: optimize CSSComputedValues sizebptato2024-12-031-250/+239
| | | | | | | | 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.
* cssvalues: fix min-width/min-height autobptato2024-12-021-19/+18
| | | | | | so for max-width it's called "none", but for min-width it's "auto". why :(
* cascade, cssvalues: clean up a bit morebptato2024-12-021-32/+42
|
* css: misc refactoringbptato2024-12-021-50/+44
|
* dom: add support for @importbptato2024-12-011-4/+8
| | | | only the most basic form; no media queries yet
* twtstr: add mypairsbptato2024-11-281-5/+5
| | | | | This couldn't get into system.nim for technical reasons, but it's still pretty useful when iterating over non-mutable openArrays.
* cssvalues: reduce CSSComputedValue sizebptato2024-11-141-51/+59
| | | | | | | 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.)
* layout -> cssbptato2024-11-101-1/+1
| | | | as much as I wish it weren't, layout *is* css.
* renderdocument: basic stacking context supportbptato2024-11-091-1/+9
| | | | | negative z-index and inline positioning are still not respected, but better than nothing I guess.
* utils, types: merge some modulesbptato2024-11-031-1/+0
| | | | | * line, vector, matrix -> path * twtuni, charcategory -> twtstr
* css: add reverse video extensionbptato2024-10-151-0/+1
| | | | | | | | | | | | Called -cha-reverse. Mostly to solve the problem that code tags are indistinguishable from regular text - on a graphical browser this is normally served by monospace font, but we always use monospace... So now the default ua.css adds reverse video to code and xmp. pre remains as it was, because it means "preformatted", not "monospaced". Also, it would mess with our whatever-to-HTML converter output.
* color: reduce CellColor size, misc color refactoringbptato2024-10-061-14/+14
| | | | | | * split out CSSColor from CellColor; now CellColor is just 4 bytes (which helps reduce FormatCell size) * unify color function naming (still not perfect)
* layout: remove line-heightbptato2024-09-211-22/+5
| | | | | This was a bad idea that, despite my best efforts, never worked properly.
* Refactor img/*bptato2024-09-151-1/+1
| | | | | I've moved most image logic to adapter, so it doesn't really make sense to have this subdir anymore.
* utils: add twtunibptato2024-09-081-15/+16
| | | | | | | | | | | | | | | | | | | std/unicode has the following issues: * Rune is an int32, which implies overflow checking. Also, it is distinct, so you have to convert it manually to do arithmetic. * QJS libunicode and Chagashi work with uint32, interfacing with these required pointless type conversions. * fastRuneAt is a template, meaning it's pasted into every call site. Also, it decodes to UCS-4, so it generates two branches that aren't even used. Overall this lead to quite some code bloat. * fastRuneAt and lastRune have frustratingly different interfaces. Writing code to handle both cases is error prone. * On older Nim versions which we still support, std/unicode takes strings, not openArray[char]'s. Replace it with "twtuni", which includes some improved versions of the few procedures from std/unicode that we actually use.
* twtstr: type erase binarySearch instantiationbptato2024-09-061-5/+9
| | | | | | | | Do it like parseEnumNoCase0, so we no longer instantiate a gazillion different binary searches for the same type. While we're at it, make matchNameProduction's searchInMap use uint32 too.
* canvas: move to separate CGI scriptbptato2024-09-011-1/+1
| | | | | | | | | | * 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-4/+4
|
* cssvalues: fix broken vmin, vmaxbptato2024-08-231-2/+2
|
* cssvalues, color: use parseEnumNoCase morebptato2024-08-031-39/+18
|
* cssvalues, sheet: fix some more case sensitivity bugsbptato2024-08-021-2/+2
|
* cssvalues, twtstr, mediaquery: refactor & fixesbptato2024-08-021-28/+9
| | | | | | | * 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)
* cssvalues: fix parseDimensionValues bugbptato2024-07-271-9/+10
| | | | Whitespace-only dimension values no longer crash the parser.
* css: clean up a bitbptato2024-07-121-20/+3
|
* cssvalues: add "clear" to table wrapper boxbptato2024-06-111-1/+3
| | | | this one is weird but I'm sure the standard is technically right
* css: slightly optimize cascadebptato2024-06-021-72/+4
| | | | Parse rule values in sheet addRule, not during cascade.
* layout: add wrapper box for table caption + misc stuffbptato2024-05-241-15/+35
| | | | | | | | | Captions are no longer positioned inside tables, yay. Also, misc: * rename some things for consistency * clamp out of bounds rgb() values * remove inherited property lookup table
* layout, layoutunit: remove some automatic convertersbptato2024-05-221-5/+5
| | | | | I wish we didn't need any, but fixing this for integers would be too involved and the float64 one was causing problems now.