# wicg/html-in-canvas architecture

> Architecture diagram of the GitHub repository wicg/html-in-canvas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wicg/html-in-canvas
- Repository: https://github.com/wicg/html-in-canvas

## Overview

HTML-in-Canvas is a living proposal for rendering laid-out HTML content into 2D and 3D canvases; it is not an implementation repository. The documented workflow opts DOM descendants into drawable layout, snapshots them through paint events, draws snapshots into canvas or textures, and optionally synchronizes their geometry back to DOM hit testing and accessibility. The README also describes worker transfer and asynchronous geometry updates. The tree contains illustrative examples, but no source excerpts were provided, so their internal behavior and connections are not inferred.

Main entry points: [`README.md`](https://github.com/wicg/html-in-canvas/blob/main/README.md) (Geometry updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_layout["DOM Layout"]
  node_canvas_content["Canvas content mode<br/>[README.md]"]
  node_drawable["Drawable subtree<br/>[README.md]"]
end

subgraph group_render["Snapshots and Rendering"]
  node_paint["Paint events<br/>[README.md]"]
  node_request_paint["requestPaint<br/>[README.md]"]
  node_snapshot["Element snapshots<br/>[README.md]"]
  node_draw_apis["Canvas draw APIs<br/>[README.md]"]
  node_element_image["ElementImage capture<br/>[README.md]"]
  node_webgl_webgpu["WebGL and WebGPU<br/>[README.md]"]
end

subgraph group_sync["Geometry and Interaction"]
  node_geometry["Geometry updates<br/>[README.md]"]
  node_hit_testing["Hit testing<br/>[README.md]"]
  node_accessibility["Accessibility geometry<br/>[README.md]"]
  node_worker["Worker transfer<br/>[README.md]"]
end

subgraph group_examples["Examples"]
  node_html_examples["HTML demos"]
  node_webgpu_demo["WebGPU jelly slider"]
end

node_author(("Web author"))

node_author -->|"opts in"| node_canvas_content
node_canvas_content -->|"lays out"| node_drawable
node_drawable -->|"records"| node_snapshot
node_paint -->|"exposes updates"| node_snapshot
node_author -->|"requests repaint"| node_request_paint
node_request_paint -->|"schedules"| node_paint
node_author -->|"draws snapshots"| node_draw_apis
node_draw_apis -->|"draws"| node_snapshot
node_draw_apis -->|"updates automatically"| node_geometry
node_author -->|"captures snapshot"| node_element_image
node_element_image -->|"transfers to"| node_worker
node_author -->|"draws to texture"| node_webgl_webgpu
node_author -->|"updates explicitly"| node_geometry
node_geometry -->|"sets hit-test state"| node_hit_testing
node_geometry -->|"updates geometry"| node_accessibility

click node_canvas_content "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_drawable "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_paint "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_request_paint "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_snapshot "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_draw_apis "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_element_image "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_webgl_webgpu "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_geometry "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_hit_testing "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_accessibility "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_worker "https://github.com/wicg/html-in-canvas/blob/main/README.md"
click node_html_examples "https://github.com/wicg/html-in-canvas/tree/main/Examples"
click node_webgpu_demo "https://github.com/wicg/html-in-canvas/tree/main/Examples/webgpu-jelly-slider"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_canvas_content,node_drawable toneBlue
class node_paint,node_request_paint,node_snapshot,node_draw_apis,node_element_image,node_webgl_webgpu toneAmber
class node_geometry,node_hit_testing,node_accessibility,node_worker toneMint
class node_html_examples,node_webgpu_demo toneRose
class node_author toneIndigo
```

## Components

### DOM Layout

- [Canvas content mode](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Drawable subtree](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`

### Snapshots and Rendering

- [Paint events](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [requestPaint](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Element snapshots](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Canvas draw APIs](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [ElementImage capture](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [WebGL and WebGPU](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`

### Geometry and Interaction

- [Geometry updates](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Hit testing](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Accessibility geometry](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`
- [Worker transfer](https://github.com/wicg/html-in-canvas/blob/main/README.md): `README.md`

### Examples

- [HTML demos](https://github.com/wicg/html-in-canvas/tree/main/Examples): `Examples`
- [WebGPU jelly slider](https://github.com/wicg/html-in-canvas/tree/main/Examples/webgpu-jelly-slider): `Examples/webgpu-jelly-slider`

### Other components

- **Web author**

## Connections

- Web author → Canvas content mode: opts in (evidence: `README.md`)
- Canvas content mode → Drawable subtree: lays out (evidence: `README.md`)
- Drawable subtree → Element snapshots: records (evidence: `README.md`)
- Paint events → Element snapshots: exposes updates (evidence: `README.md`)
- Web author → requestPaint: requests repaint (evidence: `README.md`)
- requestPaint → Paint events: schedules (evidence: `README.md`)
- Web author → Canvas draw APIs: draws snapshots (evidence: `README.md`)
- Canvas draw APIs → Element snapshots: draws (evidence: `README.md`)
- Canvas draw APIs → Geometry updates: updates automatically (evidence: `README.md`)
- Web author → ElementImage capture: captures snapshot (evidence: `README.md`)
- ElementImage capture → Worker transfer: transfers to (evidence: `README.md`)
- Web author → WebGL and WebGPU: draws to texture (evidence: `README.md`)
- Web author → Geometry updates: updates explicitly (evidence: `README.md`)
- Geometry updates → Hit testing: sets hit-test state (evidence: `README.md`)
- Geometry updates → Accessibility geometry: updates geometry (evidence: `README.md`)
