← All writing

Build a browser capability in layers.

A radius that stays attachedAn SVG circle’s radius attribute changes from 12 to 24. A retained typed value reflects the new radius without having to fetch a new value object.Circle radius12Before24AfterAttribute r24Typed value24
A radius that stays attachedChange the radius attribute from 12 to 24 and the same live SVG value reflects 24. The circles illustrate that relationship in the document model, not a browser rendering result.

How seven dependency-ordered contributions brought a typed SVG document model into Lightpanda.

Lightpanda: SVG prototype foundations

Lightpanda Browser engineering

At a glance

A capability is easier to review when each layer establishes the contract the next one needs.

A browser's graphics support is not just about whether an element exists on a page. Programs also need to identify its type, read and change its values, work with collections, ask geometry questions, and inspect text. Those behaviors form a platform contract that other software builds on.

For Lightpanda, I reworked a broad SVG prototype into seven dependency-ordered contributions. The stack moves from prototype inheritance through live values, collections, geometry, structural elements, resources, and text. All seven layers were merged. The useful story is how those layers made a substantial capability reviewable.

Make the foundation extensible.

The first layer derives SVG prototype chains at compile time. That foundation gives graphics and geometry elements the expected inheritance path without building another fixed-depth factory for every new interface. Identity matters because programs use inherited methods and type checks to decide how to interact with an element.

Seven plates assemble beneath the letter A. The first three foundations are highlighted: prototypes, live values and collections.

Build beneath the picture.Seven named strata assemble in dependency order. The foundation layers are highlighted beneath the same letterform.PrototypesLive valuesCollectionsGeometryStructureResourcesText metricsLive radius: 12 to 24Fallback text metricsIdentity → live values → collections
Build beneath the picture.

Seven layers of SVG document-model work. This is an anatomy, not a rendering demonstration.

Seven named strata assemble in dependency order. The foundation layers are highlighted beneath the same letterform.

Diagram key
Prototypes
Identity and inheritance.
Live values
Attribute-linked values.
Collections
Live lists.
Geometry
Paths, lengths, points and bounds.
Structure
Document organization.
Resources
Reusable graphics.
Text metrics
Fallback measurements.

Live values and collections then build on that identity. Their behavior needs to remain connected to the element rather than becoming a detached copy of its current attributes. Treating those contracts as their own layers gave review and testing a smaller, more coherent unit of work.

A layer establishes a contract for the next.
  1. Element identity
  2. Live attribute behavior
  3. Higher-level geometry and text

The later APIs rely on the meaning established below them, not just on a shared file layout.

The next layer is resources. I asked on LinkedIn why SVG resources are often harder to model than the shapes they style, on LinkedIn, opens in a new tab.

Keep geometry and text precise about what they provide.

The geometry work adds path parsing, length and point queries, and analytic fill bounds. Structural and resource elements extend the document model around that behavior. Each piece can be discussed in terms of a concrete API contract rather than a broad claim that graphics support is complete.

The plates spread apart but remain one document model. A curved connector joins the illustrated attribute to its live value.

A value belongs to a living model.The strata spread apart. A value remains connected to its source attribute, while geometry and text metrics stay separate.PrototypesLive valuesCollectionsGeometryStructureResourcesText metricsLive radius: 12 to 24Fallback text metricsConnected behavior, built on shared foundations
A value belongs to a living model.

Geometry and text build on typed values, attributes and collections with specific limits.

Same objectNew live behavior

In the illustration, the radius changes from 12 to 24 through a live value linked to its attribute. Shape geometry and fallback text metrics are separate capabilities; neither is a complete renderer.

The strata spread apart. A value remains connected to its source attribute, while geometry and text metrics stay separate.

Diagram key
Second marker and curved connectorLive values
Values stay attached to their attributes.
Third markerCollections
Lists stay connected to the document.
Middle markerGeometry
Paths, lengths, points and bounds build on those foundations.

The text layer provides typed elements and isolated deterministic fallback metrics without introducing a new font-shaping dependency. That boundary is deliberate. Fallback measurements are useful within their documented role; they are not interchangeable with a complete shaping and rendering stack.

Use the delivery shape to improve the design.

Splitting a broad change is valuable when the split follows dependency meaning. A foundation can be reviewed and merged before the behavior that depends on it. Reviewers can ask whether a layer is internally sound and whether its contract is sufficient for the next layer, instead of holding the entire capability in their heads at once.

The seven plates align again. Two separate measurement capabilities stay visible beside the letter.

Keep the capabilities distinct.The glass strata align. A geometry outline and a distinct text-metrics strip remain beside the letterform.PrototypesLive valuesCollectionsGeometryStructureResourcesText metricsLive radius: 12 to 24Fallback text metricsGeometry and fallback text measurements
Keep the capabilities distinct.

Geometry and fallback text metrics are specific capabilities, not a full browser renderer.

The glass strata align. A geometry outline and a distinct text-metrics strip remain beside the letterform.

Diagram key
Dashed outline attached to a letter plateGeometry
The bounds of the illustrated letter, not a claim about a full renderer.
Separate lower-right stripText metrics
Fallback text measurements, not a complete rendering system.

I use that approach when a system change spans several kinds of reasoning. It does not make the underlying work small. It makes the path through the work legible, and it gives a team useful checkpoints where they can refine the design without losing the overall direction.

I also wrote about the delivery shape itself, asking whether a pull request stack can double as an architectural drawing, on LinkedIn, opens in a new tab.

For a closer technical look
  • The layers are logically ordered: prototypes, scalars, collections, geometry, structure, resources, and text.
  • The geometry and text reviews document their repository and relevant Web Platform Test checks, including the scope of the fallback text backend.
  • Typed DOM behavior and analytic measurements are different responsibilities from painting a complete page.

What I take from it

Build and review SVG support in dependency order, keeping geometry, text metrics, and browser access as distinct responsibilities.