Skip to content

Commit 50f52b4

Browse files
Merge pull request #17222 from Snuffleupagus/rm-viewerCssTheme
Remove the `viewerCssTheme`-option, since it's partially broken
2 parents 87c83ab + d46578e commit 50f52b4

File tree

3 files changed

+0
-64
lines changed

3 files changed

+0
-64
lines changed

extensions/chromium/preferences_schema.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
{
22
"type": "object",
33
"properties": {
4-
"viewerCssTheme": {
5-
"title": "Theme",
6-
"description": "The theme to use.\n0 = Use system theme.\n1 = Light theme.\n2 = Dark theme.",
7-
"type": "integer",
8-
"enum": [
9-
0,
10-
1,
11-
2
12-
],
13-
"default": 2
14-
},
154
"showPreviousViewOnLoad": {
165
"description": "DEPRECATED. Set viewOnLoad to 1 to disable showing the last page/position on load.",
176
"type": "boolean",

web/app.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
9488
class 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-
/^@media \(prefers-color-scheme: dark\) {\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
*/

web/app_options.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ const defaultOptions = {
218218
value: 1,
219219
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
220220
},
221-
viewerCssTheme: {
222-
/** @type {number} */
223-
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME") ? 2 : 0,
224-
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
225-
},
226221
viewOnLoad: {
227222
/** @type {boolean} */
228223
value: 0,

0 commit comments

Comments
 (0)