Merge pull request #16122 from Snuffleupagus/rm-onUnsupportedFeature
[api-minor] Remove the deprecated `onUnsupportedFeature` functionality (PR 15758 follow-up)
This commit is contained in:
commit
e5427ab11b
@ -27,7 +27,6 @@ import {
|
||||
stringToPDFString,
|
||||
stringToUTF8String,
|
||||
unreachable,
|
||||
UNSUPPORTED_FEATURES,
|
||||
Util,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
@ -220,15 +219,8 @@ class Page {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onSubStreamError(handler, reason, objId) {
|
||||
_onSubStreamError(reason, objId) {
|
||||
if (this.evaluatorOptions.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error(s) when reading one of the /Contents sub-streams -- sending
|
||||
// unsupported feature notification and allow parsing to continue.
|
||||
handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorContentSubStream,
|
||||
});
|
||||
}
|
||||
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
|
||||
return;
|
||||
}
|
||||
@ -238,7 +230,7 @@ class Page {
|
||||
/**
|
||||
* @returns {Promise<BaseStream>}
|
||||
*/
|
||||
getContentStream(handler) {
|
||||
getContentStream() {
|
||||
return this.pdfManager.ensure(this, "content").then(content => {
|
||||
if (content instanceof BaseStream) {
|
||||
return content;
|
||||
@ -246,7 +238,7 @@ class Page {
|
||||
if (Array.isArray(content)) {
|
||||
return new StreamsSequenceStream(
|
||||
content,
|
||||
this._onSubStreamError.bind(this, handler)
|
||||
this._onSubStreamError.bind(this)
|
||||
);
|
||||
}
|
||||
// Replace non-existent page content with empty content.
|
||||
@ -378,7 +370,7 @@ class Page {
|
||||
cacheKey,
|
||||
annotationStorage = null,
|
||||
}) {
|
||||
const contentStreamPromise = this.getContentStream(handler);
|
||||
const contentStreamPromise = this.getContentStream();
|
||||
const resourcesPromise = this.loadResources([
|
||||
"ColorSpace",
|
||||
"ExtGState",
|
||||
@ -528,7 +520,7 @@ class Page {
|
||||
sink,
|
||||
combineTextItems,
|
||||
}) {
|
||||
const contentStreamPromise = this.getContentStream(handler);
|
||||
const contentStreamPromise = this.getContentStream();
|
||||
const resourcesPromise = this.loadResources([
|
||||
"ExtGState",
|
||||
"Font",
|
||||
|
@ -28,7 +28,6 @@ import {
|
||||
shadow,
|
||||
stringToPDFString,
|
||||
TextRenderingMode,
|
||||
UNSUPPORTED_FEATURES,
|
||||
Util,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
@ -948,13 +947,6 @@ class PartialEvaluator {
|
||||
return;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error(s) in the TilingPattern -- sending unsupported feature
|
||||
// notification and allow rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorTilingPattern,
|
||||
});
|
||||
}
|
||||
warn(`handleTilingType - ignoring pattern: "${reason}".`);
|
||||
return;
|
||||
}
|
||||
@ -996,13 +988,6 @@ class PartialEvaluator {
|
||||
return translated;
|
||||
})
|
||||
.catch(reason => {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error in the font data -- sending unsupported feature
|
||||
// notification.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontLoadType3,
|
||||
});
|
||||
}
|
||||
return new TranslatedFont({
|
||||
loadedName: "g_font_error",
|
||||
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
||||
@ -1052,13 +1037,6 @@ class PartialEvaluator {
|
||||
);
|
||||
|
||||
if (this.options.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Missing setFont operator before text rendering operator -- sending
|
||||
// unsupported feature notification and allow rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontState,
|
||||
});
|
||||
}
|
||||
warn(`ensureStateFont: "${reason}".`);
|
||||
return;
|
||||
}
|
||||
@ -1216,12 +1194,6 @@ class PartialEvaluator {
|
||||
warn(`${partialMsg}.`);
|
||||
return errorFont();
|
||||
}
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Font not found -- sending unsupported feature notification.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontMissing,
|
||||
});
|
||||
}
|
||||
warn(`${partialMsg} -- attempting to fallback to a default font.`);
|
||||
|
||||
// Falling back to a default font to avoid completely broken rendering,
|
||||
@ -1340,12 +1312,6 @@ class PartialEvaluator {
|
||||
})
|
||||
.catch(reason => {
|
||||
// TODO fontCapability.reject?
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error in the font data -- sending unsupported feature notification.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontTranslate,
|
||||
});
|
||||
}
|
||||
warn(`loadFont - translateFont failed: "${reason}".`);
|
||||
|
||||
fontCapability.resolve(
|
||||
@ -1451,13 +1417,6 @@ class PartialEvaluator {
|
||||
return null;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error(s) in the ColorSpace -- sending unsupported feature
|
||||
// notification and allow rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorColorSpace,
|
||||
});
|
||||
}
|
||||
warn(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
|
||||
return null;
|
||||
}
|
||||
@ -1479,7 +1438,6 @@ class PartialEvaluator {
|
||||
shading,
|
||||
this.xref,
|
||||
resources,
|
||||
this.handler,
|
||||
this._pdfFunctionFactory,
|
||||
localColorSpaceCache
|
||||
);
|
||||
@ -1842,16 +1800,6 @@ class PartialEvaluator {
|
||||
return;
|
||||
}
|
||||
if (self.options.ignoreErrors) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("GENERIC")
|
||||
) {
|
||||
// Error(s) in the XObject -- sending unsupported feature
|
||||
// notification and allow rendering to continue.
|
||||
self.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorXObject,
|
||||
});
|
||||
}
|
||||
warn(`getOperatorList - ignoring XObject: "${reason}".`);
|
||||
return;
|
||||
}
|
||||
@ -2166,16 +2114,6 @@ class PartialEvaluator {
|
||||
return;
|
||||
}
|
||||
if (self.options.ignoreErrors) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("GENERIC")
|
||||
) {
|
||||
// Error(s) in the ExtGState -- sending unsupported feature
|
||||
// notification and allow parsing/rendering to continue.
|
||||
self.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorExtGState,
|
||||
});
|
||||
}
|
||||
warn(`getOperatorList - ignoring ExtGState: "${reason}".`);
|
||||
return;
|
||||
}
|
||||
@ -2223,14 +2161,6 @@ class PartialEvaluator {
|
||||
return;
|
||||
}
|
||||
if (self.options.ignoreErrors) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("GENERIC")
|
||||
) {
|
||||
self.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorMarkedContent,
|
||||
});
|
||||
}
|
||||
warn(
|
||||
`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`
|
||||
);
|
||||
@ -2281,13 +2211,6 @@ class PartialEvaluator {
|
||||
return;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error(s) in the OperatorList -- sending unsupported feature
|
||||
// notification and allow rendering to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorOperatorList,
|
||||
});
|
||||
}
|
||||
warn(
|
||||
`getOperatorList - ignoring errors during "${task.name}" ` +
|
||||
`task: "${reason}".`
|
||||
@ -3778,13 +3701,6 @@ class PartialEvaluator {
|
||||
return null;
|
||||
}
|
||||
if (this.options.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error in the ToUnicode data -- sending unsupported feature
|
||||
// notification and allow font parsing to continue.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontToUnicode,
|
||||
});
|
||||
}
|
||||
warn(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
|
||||
return null;
|
||||
}
|
||||
@ -4358,13 +4274,6 @@ class PartialEvaluator {
|
||||
]);
|
||||
} catch (reason) {
|
||||
if (evaluatorOptions.ignoreErrors) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
// Error in the font data -- sending unsupported feature
|
||||
// notification and allow glyph path building to continue.
|
||||
handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.errorFontBuildPath,
|
||||
});
|
||||
}
|
||||
warn(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`);
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import {
|
||||
info,
|
||||
shadow,
|
||||
unreachable,
|
||||
UNSUPPORTED_FEATURES,
|
||||
Util,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
@ -46,7 +45,6 @@ class Pattern {
|
||||
shading,
|
||||
xref,
|
||||
res,
|
||||
handler,
|
||||
pdfFunctionFactory,
|
||||
localColorSpaceCache
|
||||
) {
|
||||
@ -82,11 +80,6 @@ class Pattern {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
}
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.shadingPattern,
|
||||
});
|
||||
}
|
||||
warn(ex);
|
||||
return new DummyShading();
|
||||
}
|
||||
|
@ -582,8 +582,6 @@ function getDataProp(val) {
|
||||
class PDFDocumentLoadingTask {
|
||||
static #docId = 0;
|
||||
|
||||
#onUnsupportedFeature = null;
|
||||
|
||||
constructor() {
|
||||
this._capability = createPromiseCapability();
|
||||
this._transport = null;
|
||||
@ -618,28 +616,6 @@ class PDFDocumentLoadingTask {
|
||||
this.onProgress = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {function | null} The current callback used with unsupported
|
||||
* features.
|
||||
*/
|
||||
get onUnsupportedFeature() {
|
||||
return this.#onUnsupportedFeature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when an unsupported feature is used in the PDF document.
|
||||
* The callback receives an {@link UNSUPPORTED_FEATURES} argument.
|
||||
* @type {function}
|
||||
*/
|
||||
set onUnsupportedFeature(callback) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
deprecated(
|
||||
"The PDFDocumentLoadingTask onUnsupportedFeature property will be removed in the future."
|
||||
);
|
||||
this.#onUnsupportedFeature = callback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise for document loading task completion.
|
||||
* @type {Promise<PDFDocumentProxy>}
|
||||
@ -2361,7 +2337,6 @@ class WorkerTransport {
|
||||
this.loadingTask = loadingTask;
|
||||
this.commonObjs = new PDFObjects();
|
||||
this.fontLoader = new FontLoader({
|
||||
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
||||
ownerDocument: params.ownerDocument,
|
||||
styleElement: params.styleElement,
|
||||
});
|
||||
@ -2761,7 +2736,6 @@ class WorkerTransport {
|
||||
isEvalSupported: params.isEvalSupported,
|
||||
disableFontFace: params.disableFontFace,
|
||||
ignoreErrors: params.ignoreErrors,
|
||||
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
||||
fontRegistry,
|
||||
});
|
||||
|
||||
@ -2840,13 +2814,6 @@ class WorkerTransport {
|
||||
});
|
||||
});
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
messageHandler.on(
|
||||
"UnsupportedFeature",
|
||||
this._onUnsupportedFeature.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
messageHandler.on("FetchBuiltInCMap", data => {
|
||||
if (this.destroyed) {
|
||||
return Promise.reject(new Error("Worker was destroyed."));
|
||||
@ -2876,15 +2843,6 @@ class WorkerTransport {
|
||||
});
|
||||
}
|
||||
|
||||
_onUnsupportedFeature({ featureId }) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
if (this.destroyed) {
|
||||
return; // Ignore any pending requests if the worker was terminated.
|
||||
}
|
||||
this.loadingTask.onUnsupportedFeature?.(featureId);
|
||||
}
|
||||
}
|
||||
|
||||
getData() {
|
||||
return this.messageHandler.sendWithPromise("GetData", null);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -40,7 +40,6 @@ import {
|
||||
PermissionFlag,
|
||||
shadow,
|
||||
UnexpectedResponseException,
|
||||
UNSUPPORTED_FEATURES,
|
||||
Util,
|
||||
VerbosityLevel,
|
||||
} from "./shared/util.js";
|
||||
@ -116,7 +115,6 @@ export {
|
||||
shadow,
|
||||
SVGGraphics,
|
||||
UnexpectedResponseException,
|
||||
UNSUPPORTED_FEATURES,
|
||||
updateTextLayer,
|
||||
Util,
|
||||
VerbosityLevel,
|
||||
|
@ -346,32 +346,6 @@ const OPS = {
|
||||
constructPath: 91,
|
||||
};
|
||||
|
||||
const UNSUPPORTED_FEATURES =
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
|
||||
? {
|
||||
forms: "forms",
|
||||
javaScript: "javaScript",
|
||||
signatures: "signatures",
|
||||
smask: "smask",
|
||||
shadingPattern: "shadingPattern",
|
||||
errorTilingPattern: "errorTilingPattern",
|
||||
errorExtGState: "errorExtGState",
|
||||
errorXObject: "errorXObject",
|
||||
errorFontLoadType3: "errorFontLoadType3",
|
||||
errorFontState: "errorFontState",
|
||||
errorFontMissing: "errorFontMissing",
|
||||
errorFontTranslate: "errorFontTranslate",
|
||||
errorColorSpace: "errorColorSpace",
|
||||
errorOperatorList: "errorOperatorList",
|
||||
errorFontToUnicode: "errorFontToUnicode",
|
||||
errorFontLoadNative: "errorFontLoadNative",
|
||||
errorFontBuildPath: "errorFontBuildPath",
|
||||
errorFontGetPath: "errorFontGetPath",
|
||||
errorMarkedContent: "errorMarkedContent",
|
||||
errorContentSubStream: "errorContentSubStream",
|
||||
}
|
||||
: null;
|
||||
|
||||
const PasswordResponses = {
|
||||
NEED_PASSWORD: 1,
|
||||
INCORRECT_PASSWORD: 2,
|
||||
@ -1105,7 +1079,6 @@ export {
|
||||
UnexpectedResponseException,
|
||||
UnknownErrorException,
|
||||
unreachable,
|
||||
UNSUPPORTED_FEATURES,
|
||||
utf8StringToString,
|
||||
Util,
|
||||
VerbosityLevel,
|
||||
|
Loading…
x
Reference in New Issue
Block a user