@@ -274,54 +274,6 @@ async function LoadImageElement(BrowserWindow: typeof window, SourceUrl: string)
274274 return ImageElement
275275}
276276
277- async function RasterizeSvgDataUrlToPngDataUrl (
278- BrowserWindow : typeof window ,
279- HostElement : HTMLElement ,
280- SourceUrl : string ,
281- ) : Promise < string > {
282- const { Width, Height } = GetSvgRasterSize ( BrowserWindow , HostElement )
283- const CacheKey = `${ Width } x${ Height } __${ SourceUrl } `
284-
285- const Cached = RasterizedSvgCache . get ( CacheKey )
286- if ( Cached ) return Cached
287-
288- const Pending = ( async ( ) => {
289- const SvgMarkup = DecodeSvgDataUrl ( BrowserWindow , SourceUrl )
290- const PreparedSvgMarkup = PrepareSvgMarkupForRasterize ( BrowserWindow , SvgMarkup , Width , Height )
291-
292- const SvgBlobUrl = BrowserWindow . URL . createObjectURL (
293- new BrowserWindow . Blob ( [ PreparedSvgMarkup ] , { type : 'image/svg+xml' } )
294- )
295-
296- try {
297- const ImageElement = await LoadImageElement ( BrowserWindow , SvgBlobUrl )
298-
299- const Canvas = BrowserWindow . document . createElement ( 'canvas' )
300- Canvas . width = Width
301- Canvas . height = Height
302-
303- const Context2D = Canvas . getContext ( '2d' , { willReadFrequently : true } )
304- if ( ! Context2D ) throw new Error ( '2D context unavailable' )
305-
306- Context2D . clearRect ( 0 , 0 , Width , Height )
307- Context2D . drawImage ( ImageElement , 0 , 0 , Width , Height )
308-
309- return Canvas . toDataURL ( 'image/png' )
310- } finally {
311- BrowserWindow . URL . revokeObjectURL ( SvgBlobUrl )
312- }
313- } ) ( )
314-
315- RasterizedSvgCache . set ( CacheKey , Pending )
316-
317- try {
318- return await Pending
319- } catch ( ErrorValue ) {
320- RasterizedSvgCache . delete ( CacheKey )
321- throw ErrorValue
322- }
323- }
324-
325277function IsSvgMimeType ( MimeType : string | null ) : boolean {
326278 return typeof MimeType === 'string' && / ^ i m a g e \/ s v g \+ x m l (?: \s * ; | $ ) / i. test ( MimeType )
327279}
0 commit comments