From 1ad65cf4051ddb92a63442600cb78e40a131ee1d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 2 Mar 2020 19:53:50 +0100 Subject: [PATCH] Simplify the `BaseFontLoader.isFontLoadingAPISupported` getter It's no longer necessary to special-case this getter in the `GenericFontLoader` case, since the GENERIC build hasn't been using `mozPrintCallback` for years now (furthermore Firefox 63 is really old as well). --- src/display/font_loader.js | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index b44f77f33..f2a568aca 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -113,9 +113,9 @@ class BaseFontLoader { unreachable("Abstract method `_queueLoadingCallback`."); } - // eslint-disable-next-line getter-return get isFontLoadingAPISupported() { - unreachable("Abstract method `isFontLoadingAPISupported`."); + const supported = typeof document !== "undefined" && !!document.fonts; + return shadow(this, "isFontLoadingAPISupported", supported); } // eslint-disable-next-line getter-return @@ -136,14 +136,6 @@ class BaseFontLoader { let FontLoader; if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { FontLoader = class MozcentralFontLoader extends BaseFontLoader { - get isFontLoadingAPISupported() { - return shadow( - this, - "isFontLoadingAPISupported", - typeof document !== "undefined" && !!document.fonts - ); - } - get isSyncFontLoadingSupported() { return shadow(this, "isSyncFontLoadingSupported", true); } @@ -161,24 +153,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { this.loadTestFontId = 0; } - get isFontLoadingAPISupported() { - let supported = typeof document !== "undefined" && !!document.fonts; - - if ( - (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) && - supported && - typeof navigator !== "undefined" - ) { - // The Firefox Font Loading API does not work with `mozPrintCallback` - // prior to version 63; see https://bugzilla.mozilla.org/show_bug.cgi?id=1473742 - const m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); - if (m && m[1] < 63) { - supported = false; - } - } - return shadow(this, "isFontLoadingAPISupported", supported); - } - get isSyncFontLoadingSupported() { let supported = false; if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {