Anchoring promoted portal children to a `<model>` on visionOS
Component: WebCore Model Element | 42cec75
Source/WebCore/Modules/model-element/SpatialPortalController.cpp
Source/WebCore/rendering/RenderLayer.cpp
A spatial portal (spatial: portal) hosts 3D content. Its <model> elements are rendered out of process by the Model process through ModelProcessModelPlayerProxy, which owns a RealityKit-style scene graph. Promoted children are ordinary DOM elements whose layers are hoisted into that scene graph under a hosted-layer container. WebContent's SpatialPortalController resolves each child's layout and anchor state and pushes it over the ModelPlayer IPC.
This commit lets a promoted child anchor to a <model> in the same portal, or to a named entity inside it, using position-anchor plus position-context: anchor. position-anchor alone remains ordinary CSS anchor positioning. WebContent resolves the CSS anchor name, plus an optional #placement suffix naming an entity, into a NodeIdentifier and a placement string, and sends them via the new setPromotedChildAnchor message. The Model process re-parents the child's entity under the anchor (falling back to the host root if the placement is unknown). It reports transforms back through didUpdateAnchoredPortalChildTransforms, and RenderLayer::hostedPortalContentProjection uses them for hit testing. The child follows its anchor but is not scaled by it. A sublayer reset in setPortalHostedLayers/updatePortalSceneLayerHierarchy detaches the child, and updateAnchorParenting re-attaches it.
Significance
Page-controlled anchor names and layout timing now drive scene-graph parenting in the Model process, and computed transforms flow back into WebContent hit testing. That makes this a new bidirectional cross-process surface for the spatial-portal pipeline.
Audit directions
A compromised WebContent can send arbitrary values for all three setPromotedChildAnchor fields: the child root NodeIdentifier, the optional anchor NodeIdentifier, and the placement string. The validation therefore lives on the receiving side, in ModelProcessModelPlayerProxy.mm, and has to be read in the full patch. Check whether each identifier is validated, and whether a forged message can reference a player, child or entity that is gone or belongs to another portal or page.
Ordering around updatePortalChildAnchoring, updatePortalSceneLayerHierarchy and setPortalHostedLayers deserves attention because sublayer resets detach anchored children. Any path that skips the re-attach could leave stale or dangling entity references.
Other areas to probe:
- entity lookup by placement string, including duplicate names, the missing-placement fallback, and races with anchor removal or model reload;
- NaN, infinite or huge values in the returned transforms that WebContent feeds into hit testing;
- teardown in
SpatialPortalController::deleteModelPlayer, which clearsm_promotedChildAnchors; - anchor cycles and self-anchoring.