Merge pull request #14155 from mozilla/revert-13314-color-theme

Revert "For mozcentral use Firefox color theme instead of system theme." since `-moz-toolbar-prefers-color-scheme` was removed
This commit is contained in:
Tim van der Meij 2021-10-19 19:29:20 +02:00 committed by GitHub
commit ce86f9dfdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 16 deletions

View File

@ -270,12 +270,6 @@ function preprocessCSS(mode, source, destination) {
content = expandImports(content, source);
if (mode === "mozcentral") {
content = removePrefixed(content, hasPrefixedMozcentral);
// In the mozcentral version the color theme should be based on the Firefox
// theme instead of the system theme.
content = content.replace(
"prefers-color-scheme",
"-moz-toolbar-prefers-color-scheme"
);
}
fs.writeFileSync(destination, content);
}

View File

@ -431,23 +431,21 @@ const PDFViewerApplication = {
try {
const styleSheet = document.styleSheets[0];
const cssRules = styleSheet?.cssRules || [];
const mediaMatcher =
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? "-moz-toolbar-prefers-color-scheme"
: "prefers-color-scheme";
const mediaRule = `(${mediaMatcher}: dark)`;
const mediaRegex = new RegExp(
`^@media \\(${mediaMatcher}: dark\\) {\\n\\s*([\\w\\s-.,:;/\\\\{}()]+)\\n}$`
);
for (let i = 0, ii = cssRules.length; i < ii; i++) {
const rule = cssRules[i];
if (rule instanceof CSSMediaRule && rule.media?.[0] === mediaRule) {
if (
rule instanceof CSSMediaRule &&
rule.media?.[0] === "(prefers-color-scheme: dark)"
) {
if (cssTheme === ViewerCssTheme.LIGHT) {
styleSheet.deleteRule(i);
return;
}
// cssTheme === ViewerCssTheme.DARK
const darkRules = mediaRegex.exec(rule.cssText);
const darkRules =
/^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(
rule.cssText
);
if (darkRules?.[1]) {
styleSheet.deleteRule(i);
styleSheet.insertRule(darkRules[1], i);