@@ -53,12 +53,19 @@ interface LayoutShifts {
5353 renderFrameImplCreateChildFrameEvents : readonly Types . Events . RenderFrameImplCreateChildFrame [ ] ;
5454 domLoadingEvents : readonly Types . Events . DomLoading [ ] ;
5555 layoutImageUnsizedEvents : readonly Types . Events . LayoutImageUnsized [ ] ;
56- beginRemoteFontLoadEvents : readonly Types . Events . BeginRemoteFontLoad [ ] ;
56+ remoteFonts : readonly RemoteFont [ ] ;
5757 scoreRecords : readonly ScoreRecord [ ] ;
5858 // TODO(crbug/41484172): should be readonly
5959 backendNodeIds : Protocol . DOM . BackendNodeId [ ] ;
6060}
6161
62+ interface RemoteFont {
63+ display : string ;
64+ url ?: string ;
65+ name ?: string ;
66+ beginRemoteFontLoadEvent : Types . Events . BeginRemoteFontLoad ;
67+ }
68+
6269// This represents the maximum #time we will allow a cluster to go before we
6370// reset it.
6471export const MAX_CLUSTER_DURATION = Helpers . Timing . milliToMicro ( Types . Timing . Milli ( 5000 ) ) ;
@@ -84,7 +91,7 @@ const styleRecalcInvalidationEvents: Types.Events.StyleRecalcInvalidationTrackin
8491const renderFrameImplCreateChildFrameEvents : Types . Events . RenderFrameImplCreateChildFrame [ ] = [ ] ;
8592const domLoadingEvents : Types . Events . DomLoading [ ] = [ ] ;
8693const layoutImageUnsizedEvents : Types . Events . LayoutImageUnsized [ ] = [ ] ;
87- const beginRemoteFontLoadEvents : Types . Events . BeginRemoteFontLoad [ ] = [ ] ;
94+ const remoteFonts : RemoteFont [ ] = [ ] ;
8895
8996const backendNodeIds = new Set < Protocol . DOM . BackendNodeId > ( ) ;
9097
@@ -124,7 +131,7 @@ export function reset(): void {
124131 renderFrameImplCreateChildFrameEvents . length = 0 ;
125132 layoutImageUnsizedEvents . length = 0 ;
126133 domLoadingEvents . length = 0 ;
127- beginRemoteFontLoadEvents . length = 0 ;
134+ remoteFonts . length = 0 ;
128135 backendNodeIds . clear ( ) ;
129136 clusters . length = 0 ;
130137 sessionMaxScore = 0 ;
@@ -162,7 +169,18 @@ export function handleEvent(event: Types.Events.Event): void {
162169 layoutImageUnsizedEvents . push ( event ) ;
163170 }
164171 if ( Types . Events . isBeginRemoteFontLoad ( event ) ) {
165- beginRemoteFontLoadEvents . push ( event ) ;
172+ remoteFonts . push ( {
173+ display : event . args . display ,
174+ url : event . args . url ,
175+ beginRemoteFontLoadEvent : event ,
176+ } ) ;
177+ }
178+ if ( Types . Events . isRemoteFontLoaded ( event ) ) {
179+ for ( const remoteFont of remoteFonts ) {
180+ if ( remoteFont . url === event . args . url ) {
181+ remoteFont . name = event . args . name ;
182+ }
183+ }
166184 }
167185 if ( Types . Events . isPaintImage ( event ) ) {
168186 paintImageEvents . push ( event ) ;
@@ -259,7 +277,7 @@ export async function finalize(): Promise<void> {
259277 renderFrameImplCreateChildFrameEvents . sort ( ( a , b ) => a . ts - b . ts ) ;
260278 domLoadingEvents . sort ( ( a , b ) => a . ts - b . ts ) ;
261279 layoutImageUnsizedEvents . sort ( ( a , b ) => a . ts - b . ts ) ;
262- beginRemoteFontLoadEvents . sort ( ( a , b ) => a . ts - b . ts ) ;
280+ remoteFonts . sort ( ( a , b ) => a . beginRemoteFontLoadEvent . ts - b . beginRemoteFontLoadEvent . ts ) ;
263281 paintImageEvents . sort ( ( a , b ) => a . ts - b . ts ) ;
264282
265283 // Each function transforms the data used by the next, as such the invoke order
@@ -514,7 +532,7 @@ export function data(): LayoutShifts {
514532 renderFrameImplCreateChildFrameEvents,
515533 domLoadingEvents,
516534 layoutImageUnsizedEvents,
517- beginRemoteFontLoadEvents ,
535+ remoteFonts ,
518536 scoreRecords,
519537 // TODO(crbug/41484172): change the type so no need to clone
520538 backendNodeIds : [ ...backendNodeIds ] ,
0 commit comments