noteslearnings

What if I took on the browser’s work?

I wondered whether browser rendering structures could serve other outputs. Following Canvas revealed the difference between drawing something and making it interactive.

Watching Life of a Pixel made me wonder how much I would need to take on if I implemented the browser’s work myself. If I preserved object structure, calculated layout, and generated drawing commands, could the same model output to Canvas, SVG, or another device?

Following this question helped me understand why document structure, layout results, and drawing commands are separated. Paint records what to draw, and Raster turns those commands into pixels. Separating what is represented from how it is output leaves room to connect another output. Of course, devices differ in color, coordinates, and update behavior, so those differences still need an agreed way to be handled.

Thinking about Canvas raised another question. Does drawing a rectangle that looks like a button make it a button? Determining which object contains a clicked coordinate, providing keyboard focus, and supporting accessibility remain separate tasks. I began to see how much of the work normally handled by the browser I would be taking on.

I also wondered whether having a tree would let me update only the changed parts. But adding text to a paragraph can change its parent’s height and the positions of later paragraphs. Looking only at the changed node’s children is not enough. Preserving structure and tracking the effects of change are separate tasks.

These questions stayed with me longer than memorizing the browser’s stages. If I made a small renderer, which representations and interactions would I need? Which results could I reuse, and which changes would require recalculation? Defining that scope should make the actual work clearer.

Lecture: Life of a Pixel video and slides, Steve Kobes