Linora

0507. Frame clipping by instance ranges and scissor rectangles

Status: Proposed (2026-11-28, EN2), requested by ED1 for the frame tool (CLIP_CONTENT on by default, as in Figma). Not implemented in wave 3 (scope held at the wave-3 goals); a tested prototype of this design existed and can be rebuilt from this record. Until then CLIP_CONTENT renders unclipped.

Context

A frame with CLIP_CONTENT (NodeFlag.CLIP) must clip everything below it to its box, rotation included. Hit tests and marquee must skip the clipped-away parts, so a click never lands on hidden overflow. Constraints:

Decision

  1. A clipping frame’s descendants are one contiguous instance range in paint order (pre-order): [own end, subtree end). DocSync keeps the list of clipping frames, updated from created, deleted and VISIBILITY-changed nodes (clipContent is a VISIBILITY prop). It is a few entries, nothing per node.
  2. Clip segments (clip.ts, ClipState), rebuilt only when the scene, the selection or the clip list changed:
    • each visible, laid-out frame gives its range and world box;
    • nested frames intersect their boxes with the enclosing ones and cut the enclosing range into pieces;
    • the result is sorted, non-overlapping segments [start, end) -> box.
  3. Drawing. With segments present, the renderer splits each run of real instances at segment edges and draws the parts inside a segment with gl.scissor set to the box in device pixels. While a drag preview moves a selected clipping frame, its box moves by the same affine. The shader and the instance format do not change. Without clipping frames, draw takes the unchanged path.
  4. LOD. A chunk whose clipped instances may reach outside their box (its bounds exceed the box) is never drawn as impostors, because impostors cannot be scissored per instance. Chunks fully inside their box keep LOD.
  5. Queries. hitTest drops instances of a segment when the point is outside its box. queryRect clips each instance’s bounds by its box first; chunks with clipped content that may overflow take the per-instance path instead of the owners-only one.
  6. Not yet: rotated clipping frames. A frame whose own rotation or an ancestor’s is not 0 is drawn and hit unclipped: a scissor is axis-aligned. A shader variant with a clip quad (like VS_REMOTE, used only for those draws) is the follow-up.

Alternatives

Consequences