[api-minor] Remove the deprecated onUnsupportedFeature functionality (PR 15758 follow-up)

This was deprecated in PR 15758, which has now been included in three official PDF.js releases.
While PR 15880 did limit the bundle-size impact of this functionality on e.g. the Firefox PDF Viewer, it still leads to some unnecessary "bloat" that these changes remove.
Furthermore, with this being deprecated there'd also be no effort put into e.g. extending the `UNSUPPORTED_FEATURES` list when handling future error cases.
This commit is contained in:
Jonas Jenwald 2023-03-07 09:42:04 +01:00
parent e11371c75f
commit 2f3dcc2327
7 changed files with 5 additions and 201 deletions

View file

@ -19,20 +19,15 @@ import {
FeatureTest,
shadow,
string32,
UNSUPPORTED_FEATURES,
warn,
} from "../shared/util.js";
import { isNodeJS } from "../shared/is_node.js";
class FontLoader {
constructor({
onUnsupportedFeature,
ownerDocument = globalThis.document,
styleElement = null, // For testing only.
}) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this._onUnsupportedFeature = onUnsupportedFeature;
}
this._document = ownerDocument;
this.nativeFontFaces = [];
@ -90,11 +85,6 @@ class FontLoader {
try {
await nativeFontFace.loaded;
} catch (ex) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this._onUnsupportedFeature({
featureId: UNSUPPORTED_FEATURES.errorFontLoadNative,
});
}
warn(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
// When font loading failed, fall back to the built-in font renderer.
@ -332,7 +322,6 @@ class FontFaceObject {
isEvalSupported = true,
disableFontFace = false,
ignoreErrors = false,
onUnsupportedFeature,
fontRegistry = null,
}
) {
@ -344,9 +333,6 @@ class FontFaceObject {
this.isEvalSupported = isEvalSupported !== false;
this.disableFontFace = disableFontFace === true;
this.ignoreErrors = ignoreErrors === true;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this._onUnsupportedFeature = onUnsupportedFeature;
}
this.fontRegistry = fontRegistry;
}
@ -409,11 +395,6 @@ class FontFaceObject {
if (!this.ignoreErrors) {
throw ex;
}
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this._onUnsupportedFeature({
featureId: UNSUPPORTED_FEATURES.errorFontGetPath,
});
}
warn(`getPathGenerator - ignoring character: "${ex}".`);
return (this.compiledGlyphs[character] = function (c, size) {