reparent

fun reparent(handle: ScopeHandle, parent: ScopeHandle?)

Moves the frame handle refers to under parent — or makes it a root, for null — in place, keeping its position, its contents and its switches. For a caller whose frame has moved but whose declaration has not: a composition relinked under the surface now hosting it, a surface adopted after its content was pushed, a movableContentOf subtree relocated under a different parent. Re-pushing instead would change the frame's identity and orphan any frames still pointing to it as their parent. See resolveScope for how the link is used.

A parent that is this frame itself, or one of its descendants, cannot describe a real nesting and is refused: the frame becomes a root instead (see the note in acceptableParent).

Moving a frame and changing what it says takes two calls, reparent and update, each publishing a snapshot. Unlike setScreenMasked's pair, no order makes the one in between true of the frame: a lock-free reader of current can see, for an instant, the new lineage with the old contents or the reverse.

A no-op (and no snapshot churn) if the link is unchanged, the handle was already removed, or it belongs to another stack.