about summary refs log tree commit diff stats
path: root/src/css/render.nim
Commit message (Collapse)AuthorAgeFilesLines
* render: fix formatting being lost outside boxes with bgcolorbptato2025-01-171-21/+20
| | | | | | An ancient bug, but the fix seems to be quite simple: stop confusing the last X position before the existing string on the line with the last X position that the new string occupies.
* render: simplify some pointless delete/insert callsbptato2025-01-171-8/+4
|
* render: overprint existing text when painting backgroundsbptato2025-01-161-9/+29
| | | | | | | | Even if we don't do some z-ordering correctly, it's no excuse to paint boxes incorrectly. It's also extremely annoying when I try to use a menu and text bleeds into the drop-down window.
* css: reduce StyledNode usebptato2025-01-161-10/+10
| | | | | Eventually the tree should be collapsed into the DOM, and StyledNode should be created on the stack.
* cssvalues: serialize quotes, add font-size, opacitybptato2025-01-161-4/+7
| | | | | | | | | | | | 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.)
* cssvalues: reduce CSSValues sizebptato2025-01-121-1/+1
| | | | | | | | | | | | | | | | * 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.)
* layout, render: establish absolute container with position: stickybptato2025-01-061-5/+5
| | | | We do not support sticky scrolling, but this much should still work.
* LayoutUnit -> LUnitbptato2025-01-031-3/+3
|
* lunit: use saturation arithmeticbptato2024-12-231-5/+1
| | | | | | | I'm not a fan, because it hides bugs. But working around the overflow errors is starting to get unwieldy. On 32-bit systems, we try to use compiler intrinsics as Nim does.
* box: InlineFragment -> InlineBoxbptato2024-12-201-24/+24
| | | | | | It was named "fragment" mainly because I added it back when there was still a separate InlineBox type and I needed another name. Now InlineBox is gone, and I'm tired of typing fragment.
* layout, render: image sizing fixes/workaroundsbptato2024-12-201-4/+4
| | | | | | | | * fix clip for image * switch back img's display to inline * fix image width calculation without specified width/height I'm not 100% sure if this is correct, but it certainly looks better.
* layout, render: implement overflow propertybptato2024-12-181-100/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+2
| | | | Lets us skip a couple pointless multiplications/divisions during layout.
* css: CSSComputedValue -> CSSValuebptato2024-12-121-1/+1
| | | | | "Computed" was redundant; other types of values don't have a common type.
* render: apply visibility to inline boxesbptato2024-12-101-21/+23
|
* pager, term: use cell offset with kitty imagesbptato2024-12-031-2/+10
| | | | | | | | Gets rid of rounding errors when positioning images. Theoretically this is possible with Sixel too, but as always, it's ten times as difficult to implement as with Kitty, so I'll leave it for later.
* cssvalues: reduce CSSComputedValue sizebptato2024-11-141-4/+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.)
* buffer: fix broken gotoAnchor behaviorbptato2024-11-121-5/+6
| | | | | | | | | | | | | | | | | 23beebe6 introduced a regression that broke gotoAnchor. This fixes that, plus a couple other long-standing gotoAnchor bugs: * If no anchor is found, do not dupe the buffer. Desktop browsers still add a history entry, while w3m prints an error. I've copied the latter because it makes more sense as a user, but this will have to be refined for the navigation API at some point. * If the anchor *is* found, then always jump to it, even if it's not visible. This was a limitation of relying on the line array, so now we rely on the box tree instead. (Sooner or later, the former must go anyway.) Also, fix `U' reload not restoring the position (hopefully this time for good).
* layout -> cssbptato2024-11-101-0/+465
as much as I wish it weren't, layout *is* css.