HTML-in-Canvas

39 dannyobrien 19 8/2/2025, 10:26:47 PM github.com ↗

Comments (19)

BobbyTables2 · 51m ago
I suppose all we need to do now is to compile a browser into WASM and run that browser inside a canvas element of the main browser…
sangeeth96 · 7m ago
How about an entire OS with IE? https://copy.sh/v86/?profile=windows2000
SeanAnderson · 1h ago
I read the title and said "shut the fuck up, don't do that." but then I read the rationale and it's fair. It's true there is no layout engine inside canvas, and that is a pain, but I'm not sure it's such a pain as to invite this recursive hell.
nine_k · 40m ago
One of the more senior engineers I worked with told me: "Every real-life data structure I encountered was tree-like".

It would be easiest to just ask the browser to render a fragment of HTML onto a canvas, or onto some invisible bitmap, like you can with most other UI toolkits.

mook · 23m ago
Yeah, that's already available in Firefox for chrome/extensions, but not allowed for the web due to fingerprinting and other security risks. For example, rendering an iframe of your bank account…

https://searchfox.org/mozilla-central/rev/f691af5143ebd97034...

monster_truck · 37m ago
They would never do this because of fingerprinting, which is already the cause of most of the reasons we cannot 'just' do a lot of things, unfortunately.

E: And the infamous other half: malware. A bit over a decade ago malware devs started using canvas to do things like hide fragments inside of bitmap data in seemingly harmless ads and then a second script would extract and assemble it to evade detection.

teaearlgraycold · 41m ago
You could disallow recursion.
charcircuit · 1m ago
This is really useful for being able to use standard web technology with webxr.
codelikeawolf · 1h ago
I immediately got "Pimp My Ride" vibes. Yo dawg, I heard you like HTML so I put HTML inside the canvas inside the HTML.
ttoinou · 1h ago
Soon we’re gonna need Canvas rendering inside of HTML-in-Canvas
bastawhiz · 39m ago
It should already work if the nested canvas uses the same approach. It's not cyclic, though. To make cyclic canvases work, you need to manually draw the parent canvas to a nested canvas.
mmastrac · 1h ago
hyperhello · 1h ago
I see reliable rich text editing as more of a priority.
turnsout · 11m ago
Sad to say, but the first thing I thought was "oh good, a new fingerprinting target."
tantalor · 1h ago
Waterluvian · 1h ago
45kb gzipped is pretty beefy but incredibly small when you consider just what it takes to make this work today. If I understand correctly, it’s basically a DOM and CSS renderer.
kizer · 1h ago
There's a bunch of CSS, etc. not supported by that. It would be great to have access to a native API to get bitmaps of the DOM.
masswerk · 1h ago
Well, a fingerprinting dream…

Meaning, no way, just for the security aspect.

deadbabe · 14m ago
true horror is finding every element of the HTML page your on has been rendered in a Canvas