Prototype web renderer: still renderer¶
Part of the prototype web renderer.
renderPrototypeStill(spec, {frame, orientation, posture, mode, screen, locale, textSize, chromeless}) in
src/features/prototype/web/webStill.ts draws the spec as a still screen and returns an element
tree plus unsupportedNodes and stack (the outermost stack’s screens in key order, its
start and the screen drawn). It renders on
the host, so the page’s script only switches between views it was given and never runs spec logic.
- Input. The spec after component expansion, with its own
stateanddata. A stack shows itsstartscreen; the outermost stack (the first one drawn) showsscreeninstead when it has that screen. No action, timer orrequestruns. - Text. String-table translations resolve first, in the caller’s
locale(BCP 47, canonicalized; defaulten-US). An invalid tag is aPrototypeWebInputError, surfaced to clients as anActionableErrorwith the same message. Then{data:/pointer}placeholders bind (a missing or non-scalar value is empty), then repeat items. Last come a bare{key}, which reads spec state, and{derived:name}, which reads a top-levelderiveentry. Text binds once, in that order: the renderer shields every inserted data or repeat value until binding ends, so it never reads one again as a placeholder. Nested conditions with typed operands and state keys bind through the devices’ own field walk (mapBindableFields). A spans-only text node renders each span with its own text style. Asecureorpasswordtext field shows its value masked. Formatting uses the locale,UTCand a caller-supplied clock (default 0), so derived relative times are fixed. - Repeats. Repeat placeholders bind each object item (a literal
itemsarray or a data pointer), including the repeat’s ownderivefields. As on devices, the renderer skips scalar items before assigning indices. A repeat draws at most 200 items, except alist, which draws up to the list contract limit (2,000) capped by itsmaxItems, as devices do. A 2,000-row list of plain list items is about 0.7 MB of markup, inside the page budget. A page whose kept start screens exceed it fails the build as described under Budget. - Platform state. The frame decides
/device/os,/device/widthClassand/device/posturefrom the active panel in the drawn orientation. On AndroidwidthClassiscompact,mediumorexpandedat the contract’s 600 and 840 dp breakpoints. On iOS it isregularon a tablet (smallest side 600 dp or more) or a phone at least 896 dp wide, elsecompact. On Android anopenedfold isflatand ahalf_openedonetabletop(horizontal hinge) orbook(vertical hinge); without a fold, and always on iOS, posture is missing. Other/platformpointers stay undecided. The{platform:/pointer}text binds with the data pass: a decided value inserts (missing is empty) and an undecided placeholder stays literal. - Conditions.
visibleWhenevaluateskeycomparisons and decidedplatformpointers withall,anyandnotagainst spec and platform state. Parts the still cannot decide (datapointers, undecidedplatformpointers, unknown keys, validity, string operators) stay undecided throughall,anyandnot. Only an undecided whole condition counts as true, so the still never hides a node on a guess. - Window. An explicit
window.layoutDirectionsets the content’sdir(the frame is never mirrored). Without one, a locale whose script is written right to left setsrtl, as a device in that locale does. An explicit script subtag decides; otherwise CLDR’s likely subtags give the script the tag implies. Arabic (includingar-XBandpa-PK), Hebrew, Persian, Urdu, Syriac and N’Ko are written right to left. Any other locale leaves the page’s direction. In either casestart/endsafe-area edges read the inset on the matching physical side. Fullscreen fills the screen, and a fullscreen or sheet root fills its window on each axis it leaves unsized, as on devices. A sheet spans the screen width,heightdp tall at itsedge. A floating window sits at itsgravity, moved by itsoffset. - Style precedence. A control’s default styling applies first and the spec’s own style wins.
The
styleWhenentries whose condition holds merge overstylein authored order. The still does not apply an entry it cannot decide. ThetextStylevalue resolves to the Material 3 type scale before explicittextSize,fontWeightandlineHeight. - Layout. Rows, columns, cards and scrolls (reversed when
reverse, so they open at the end) are flex lines. They start-align children on the cross axis unlessstyle.alignmentsays otherwise, as both devices do. A box is a one-cell grid aligned bystyle.alignment, and stack screens fill the stack. These map to CSS:fill(inside a box grid, only on its own axis),{dp},weight, padding (logical start and end), corner radius, border, elevation and alpha. Per-corner radii are logical, so RTL mirrors them. Each dp is 1 CSS px. - Style polish. A
gradientpaints over the background across the whole node. A linear angle is clockwise from left-to-right (CSS’s angle plus 90), and a radial one is centred and reaches the corners. Stop positions apply only when every stop has one, made non-decreasing. Theshadowsentries map tobox-shadowwith the authored blur as the CSS blur (sigma b/2), andelevationtakes itsshadowColortint. A gradient border and inner shadows are absolutely placed layers after the node’s children. They paint over the content, inside its bounds, as Compose draws them. - Glass. A
surface: "glass"node is a capsule unlesscornerRadiusshapes it. The iOS skin blurs and saturates the backdrop under a translucent tint (else white) with a light rim. The Android skin draws the tonal fill (the tint, elsesurfaceContainer, at 0.85); an authored background keeps its colour. Theios.glassGroupnode draws nothing of its own. - Scroll fades. The
scroll.fadeEdgesstyle is a mask on the trailing edge only (the leading one in areversescroll), since a still opens at the scroll’s start. Horizontal start and end mirror in RTL. The still cannot measure overflow, so it hands the mask to the page as--fade-mask. A scroll-driven animation on ascroll(self)timeline applies it. That timeline is inactive while the content fits, so only an overflowing scroll fades, as Android draws a fade only while it can scroll forward. It depends on layout, not time, so screenshots stay deterministic. A browser without scroll-driven animations always fades. - Links and fallbacks. The
linkifystyle splits the resolved text into plain runs and onedata-linkspan per match in itsstyle. The still marks a span withonTapthe same way; links get no style of their own, as on Android. Azoomableimage draws at 1x. A node withstyle.shaderdraws without it, as a device without shader support does, and the still lists it with reasonshaderFallback. - Typography.
theme.typographyscales every type-scale role and sets its family, as the native theme does. - System text size.
textSizeis the device’s text setting, refused on the other platform’s frame. On Android,fontScale(0.85 to 2) maps every sp value (size, line height, letter spacing) through Android 14’s non-linearFontScaleConverterFactorytables, interpolating between neighbouring tables and linear below 1.03, as Compose does. On iOS,contentSize(thesimctl ui content_sizenames,extra-smalltoaccessibility-extra-extra-extra-large) scales every size and line height by the body style’s point size over 17, asUIFontMetrics.default.scaledValuedoes, and leaves letter spacing. It applies aftertheme.typography, to text roles, explicit sizes, the 14 sp default and the fixed text of controls (app bar title, field label, caption and lines, list item text). Icons and the device chrome do not scale. The default size (1,large) renders the same bytes as none. - Colour. Theme roles resolve from the Material 3 baseline, then the roles a
theme.colors.seedderives, then the explicit overrides. The seed roles are the HSL approximation both devices share (prototypeSeedScheme.ts, Android’sprototypeSeedColorScheme, the iOS agent’sseedScheme), rounded to 8-bit channels as Compose stores them. Adevicesource has no device scheme to read, so it falls through to the seed or the baseline, as iOS and Android below API 31 do. The accessibility lint still treats a seed or device scheme as unknown. Both devices paint nothing behind a window, so the app below shows through; the still has no app below, so the screen paints the theme’sbackgroundrole (elsesurface). - Mode. The still resolves light or dark in the devices’ order. An explicit
theme.modecomes first. With no mode, the luminance of the flattheme.colors.background(elsesurface) override decides, then that of the first opaque hex background on the root’s leading chain. The leading chain follows the first child that draws in place, so a hidden node or a closed sheet is passed over: a pager’s current page, a scroll’schild, a stack’s drawn screen. The chain skips role and{light, dark}backgrounds. Last come the caller’smode, then light. Atheme.mode: "system"value goes straight to the caller’s. As on Android, an authored colour of the resolved mode’s polarity replacesbackground,surfaceandsurfaceContainer/Low/High/Highestunless a seed or device source derives the scheme. Role overrides still win over it.