@@ -140,19 +140,25 @@ const SELECTED_TRAIT = 1n << 3n;
140140const KEYBOARD_FOCUS_TRAIT = 1n << 21n ;
141141
142142/**
143- * A WebKit page — Safari's, or a `WKWebView`'s — lives in a WebContent process and reaches UIKit's
144- * tree as an `AXRemoteElement` under the web view, with its children in that other process. The
145- * guest reader snapshots one process, so it delivers that element as a leaf (#2484). Such a leaf
146- * is opaque when it sits under a `WebView`-typed ancestor and its frame reaches the viewport: the
147- * page is on screen and the tree does not describe it. A leaf whose frame is zero-area or off
148- * screen hosts nothing the capture can miss; one that reports no frame at all is refused, because
149- * nothing proves it is empty. Remote elements outside a web view are not classified here — no
150- * capture has shown one — and content truncated away above the web view stays disclosed as
151- * truncation, not as a boundary.
143+ * Two hosts put another process's UI into this one's tree as an `AXRemoteElement`, with the
144+ * children in that other process:
145+ *
146+ * - a WebKit page — Safari's, or a `WKWebView`'s — lives in a WebContent process under the web
147+ * view (#2484);
148+ * - a scene-hosted remote view controller, such as a share or action extension presented over the
149+ * host app, lives in the extension's process under a `_UISceneHostingView`.
150+ *
151+ * The guest reader snapshots one process, so it delivers that element as a leaf. Such a leaf is
152+ * opaque when it sits under one of those hosts and its frame reaches the viewport: the content is
153+ * on screen and the tree does not describe it. A leaf whose frame is zero-area or off screen hosts
154+ * nothing the capture can miss; one that reports no frame at all is refused, because nothing proves
155+ * it is empty. Remote elements under any other host are not classified here — no capture has shown
156+ * one — and content truncated away above the host stays disclosed as truncation, not as a boundary.
152157 */
153158const REMOTE_ELEMENT_CLASS = 'AXRemoteElement' ;
154159const EMPTY_RECT : Rect = { x : 0 , y : 0 , width : 0 , height : 0 } ;
155160const WEB_VIEW_TYPE = 'WebView' ;
161+ const SCENE_HOSTING_VIEW_CLASS = '_UISceneHostingView' ;
156162
157163export function decodeSnapshotBridgeTree (
158164 tree : unknown ,
@@ -164,7 +170,7 @@ export function decodeSnapshotBridgeTree(
164170 throw snapshotSourceError ( 'malformed-tree' , 'guest-tree-root-invalid' ) ;
165171 }
166172 const nodes : RawSnapshotNode [ ] = [ ] ;
167- const webHostedRemoteLeaves : ( Rect | undefined ) [ ] = [ ] ;
173+ const hostedRemoteLeaves : ( Rect | undefined ) [ ] = [ ] ;
168174 let maxTraversalDepth = 0 ;
169175 for ( const root of roots ) {
170176 visitNode ( root , undefined , 0 , false ) ;
@@ -198,7 +204,7 @@ export function decodeSnapshotBridgeTree(
198204 nodes,
199205 maxTraversalDepth,
200206 viewport,
201- opaqueRemoteElements : webHostedRemoteLeaves . filter ( ( rect ) => isOpaqueRemoteLeaf ( rect , viewport ) )
207+ opaqueRemoteElements : hostedRemoteLeaves . filter ( ( rect ) => isOpaqueRemoteLeaf ( rect , viewport ) )
202208 . length ,
203209 unresolvedCoordinateSpaceWindows : countUnresolvedCoordinateSpaceWindows ( nodes , viewport ) ,
204210 } ;
@@ -207,7 +213,7 @@ export function decodeSnapshotBridgeTree(
207213 value : Record < string , unknown > ,
208214 parentIndex : number | undefined ,
209215 depth : number ,
210- underWebView : boolean ,
216+ underRemoteHost : boolean ,
211217 ) : void {
212218 if ( nodes . length >= limits . maxNodes ) {
213219 throw snapshotSourceError ( 'malformed-tree' , 'node-limit-exceeded' , {
@@ -227,13 +233,13 @@ export function decodeSnapshotBridgeTree(
227233 const node = nodeFacts ( value , index , parentIndex , depth ) ;
228234 nodes . push ( node ) ;
229235 maxTraversalDepth = Math . max ( maxTraversalDepth , depth ) ;
230- if ( isWebHostedRemoteLeaf ( node , children . length , underWebView ) ) {
231- webHostedRemoteLeaves . push ( node . rect ) ;
236+ if ( isHostedRemoteLeaf ( node , children . length , underRemoteHost ) ) {
237+ hostedRemoteLeaves . push ( node . rect ) ;
232238 }
233- const hostsWeb = underWebView || node . type === WEB_VIEW_TYPE ;
239+ const hostsRemote = underRemoteHost || isRemoteContentHost ( node ) ;
234240 for ( const child of children ) {
235241 if ( ! isRecord ( child ) ) throw snapshotSourceError ( 'malformed-tree' , 'child-invalid' ) ;
236- visitNode ( child , index , depth + 1 , hostsWeb ) ;
242+ visitNode ( child , index , depth + 1 , hostsRemote ) ;
237243 }
238244 }
239245}
@@ -299,12 +305,16 @@ function elementTypeName(
299305 return ELEMENT_TYPE_NAMES [ automationType ] ?? 'Other' ;
300306}
301307
302- function isWebHostedRemoteLeaf (
308+ function isRemoteContentHost ( node : RawSnapshotNode ) : boolean {
309+ return node . type === WEB_VIEW_TYPE || node . role === SCENE_HOSTING_VIEW_CLASS ;
310+ }
311+
312+ function isHostedRemoteLeaf (
303313 node : RawSnapshotNode ,
304314 childCount : number ,
305- underWebView : boolean ,
315+ underRemoteHost : boolean ,
306316) : boolean {
307- return underWebView && node . role === REMOTE_ELEMENT_CLASS && childCount === 0 ;
317+ return underRemoteHost && node . role === REMOTE_ELEMENT_CLASS && childCount === 0 ;
308318}
309319
310320function isOpaqueRemoteLeaf ( rect : Rect | undefined , viewport : IosViewportEvidence ) : boolean {
0 commit comments