@@ -85,12 +85,6 @@ const ViewOnLoad = {
8585 INITIAL : 1 ,
8686} ;
8787
88- const ViewerCssTheme = {
89- AUTOMATIC : 0 , // Default value.
90- LIGHT : 1 ,
91- DARK : 2 ,
92- } ;
93-
9488class DefaultExternalServices {
9589 constructor ( ) {
9690 throw new Error ( "Cannot initialize DefaultExternalServices." ) ;
@@ -233,7 +227,6 @@ const PDFViewerApplication = {
233227 if ( AppOptions . get ( "pdfBugEnabled" ) ) {
234228 await this . _parseHashParams ( ) ;
235229 }
236- this . _forceCssTheme ( ) ;
237230
238231 // Ensure that the `L10n`-instance has been initialized before creating
239232 // e.g. the various viewer components.
@@ -347,47 +340,6 @@ const PDFViewerApplication = {
347340 }
348341 } ,
349342
350- /**
351- * @private
352- */
353- _forceCssTheme ( ) {
354- const cssTheme = AppOptions . get ( "viewerCssTheme" ) ;
355- if (
356- cssTheme === ViewerCssTheme . AUTOMATIC ||
357- ! Object . values ( ViewerCssTheme ) . includes ( cssTheme )
358- ) {
359- return ;
360- }
361- try {
362- const styleSheet = document . styleSheets [ 0 ] ;
363- const cssRules = styleSheet ?. cssRules || [ ] ;
364- for ( let i = 0 , ii = cssRules . length ; i < ii ; i ++ ) {
365- const rule = cssRules [ i ] ;
366- if (
367- rule instanceof CSSMediaRule &&
368- rule . media ?. [ 0 ] === "(prefers-color-scheme: dark)"
369- ) {
370- if ( cssTheme === ViewerCssTheme . LIGHT ) {
371- styleSheet . deleteRule ( i ) ;
372- return ;
373- }
374- // cssTheme === ViewerCssTheme.DARK
375- const darkRules =
376- / ^ @ m e d i a \( p r e f e r s - c o l o r - s c h e m e : d a r k \) { \n \s * ( [ \w \s - . , : ; / \\ { } ( ) ] + ) \n } $ / . exec (
377- rule . cssText
378- ) ;
379- if ( darkRules ?. [ 1 ] ) {
380- styleSheet . deleteRule ( i ) ;
381- styleSheet . insertRule ( darkRules [ 1 ] , i ) ;
382- }
383- return ;
384- }
385- }
386- } catch ( reason ) {
387- console . error ( `_forceCssTheme: "${ reason ?. message } ".` ) ;
388- }
389- } ,
390-
391343 /**
392344 * @private
393345 */
0 commit comments