Execution — bi-09-paint
Steps extracted from CONCEPTS.md. Read the concepts first; this file is the doing.
Record results in observation.md; tick checkpoints in verification.md.
6. Lab — mini-browser M10–M11
- Display list. Walk your layout tree in paint order and emit display items
(
{type, rect, color, …}). Do not draw yet. - Stacking contexts. Implement
z-indexand at least one property that creates a stacking context. Prove ordering with a test case that changes when you remove the stacking-context rule. - Property trees. Add a transform tree. Represent a translated subtree as a node reference rather than by baking coordinates into items.
- Raster. Draw the display list to a canvas.
- The payoff experiment. Animate a subtree two ways: (a) by changing layout position and re-recording, (b) by changing only a transform node. Measure both. Report how much of the pipeline each skips.
- Hit testing. Implement reverse-paint-order hit testing and find a case where it disagrees with DOM order.
Deliverable: the stage-5 measurement, plus a written statement of exactly which stages were skipped in case (b) and why they could be skipped.
7. Failure Lab
- Bake transforms into display items. Re-run the stage-5 experiment. Show that the cheap path is now impossible. This is the strongest possible argument for property trees.
- Break paint order. Paint in DOM order instead. Find markup that renders wrong.
- Invalidate too little. Skip paint invalidation for a property that needs it; produce a stale-pixels bug.
- Layer explosion. Put
will-change: transformon 5,000 elements. Measure memory. Explain why the "optimisation" lost.
8. Debugging Exercise
- DevTools: enable paint flashing and layer borders. Find one change that repaints and one that does not.
- Compare a
top-animated element with atransform-animated one in a Perfetto trace. Name the stages present in one and absent in the other. - Find a hit-test bug you can only explain via stacking contexts.
- In the checkout, find where a property-tree-only change avoids repaint. Quote the condition.