[api-major] Remove (most of) the remaining deprecated code

There's three notable exceptions here:
 - The `saveDocument` one is converted into a permanent `warn`, since it still works when the `annotationStorage` is empty although it's (obviously) less efficient than `getData`.
 - The `fallbackWorkerSrc` functionality (for browsers), since just removing it would risk too much third-party breakage.
 - The SVG back-end, since a final decision is yet to be made. (It might be completely removed, or left as-is in an essentially "frozen" state.)
This commit is contained in:
Jonas Jenwald 2022-08-04 12:33:18 +02:00
parent d3005603e1
commit 78f24e5535
3 changed files with 14 additions and 158 deletions

View File

@ -710,28 +710,6 @@ class PDFDocumentProxy {
constructor(pdfInfo, transport) { constructor(pdfInfo, transport) {
this._pdfInfo = pdfInfo; this._pdfInfo = pdfInfo;
this._transport = transport; this._transport = transport;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
Object.defineProperty(this, "fingerprint", {
get() {
deprecated(
"`PDFDocumentProxy.fingerprint`, " +
"please use `PDFDocumentProxy.fingerprints` instead."
);
return this.fingerprints[0];
},
});
Object.defineProperty(this, "getStats", {
value: async () => {
deprecated(
"`PDFDocumentProxy.getStats`, " +
"please use the `PDFDocumentProxy.stats`-getter instead."
);
return this.stats || { streamTypes: {}, fontTypes: {} };
},
});
}
} }
/** /**
@ -984,15 +962,6 @@ class PDFDocumentProxy {
* {Uint8Array} containing the full data of the saved document. * {Uint8Array} containing the full data of the saved document.
*/ */
saveDocument() { saveDocument() {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this._transport.annotationStorage.size <= 0
) {
deprecated(
"saveDocument called while `annotationStorage` is empty, " +
"please use the getData-method instead."
);
}
return this._transport.saveDocument(); return this._transport.saveDocument();
} }
@ -1172,8 +1141,6 @@ class PDFDocumentProxy {
* The default value is `AnnotationMode.ENABLE`. * The default value is `AnnotationMode.ENABLE`.
* @property {Array<any>} [transform] - Additional transform, applied just * @property {Array<any>} [transform] - Additional transform, applied just
* before viewport transform. * before viewport transform.
* @property {Object} [imageLayer] - An object that has `beginLayout`,
* `endLayout` and `appendImage` functions.
* @property {Object} [canvasFactory] - The factory instance that will be used * @property {Object} [canvasFactory] - The factory instance that will be used
* when creating canvases. The default value is {new DOMCanvasFactory()}. * when creating canvases. The default value is {new DOMCanvasFactory()}.
* @property {Object | string} [background] - Background to use for the canvas. * @property {Object | string} [background] - Background to use for the canvas.
@ -1343,34 +1310,6 @@ class PDFPageProxy {
intentArgs.renderingIntent intentArgs.renderingIntent
); );
this._annotationPromises.set(intentArgs.cacheKey, promise); this._annotationPromises.set(intentArgs.cacheKey, promise);
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
promise = promise.then(annotations => {
for (const annotation of annotations) {
if (annotation.titleObj !== undefined) {
Object.defineProperty(annotation, "title", {
get() {
deprecated(
"`title`-property on annotation, please use `titleObj` instead."
);
return annotation.titleObj.str;
},
});
}
if (annotation.contentsObj !== undefined) {
Object.defineProperty(annotation, "contents", {
get() {
deprecated(
"`contents`-property on annotation, please use `contentsObj` instead."
);
return annotation.contentsObj.str;
},
});
}
}
return annotations;
});
}
} }
return promise; return promise;
} }
@ -1408,7 +1347,6 @@ class PDFPageProxy {
intent = "display", intent = "display",
annotationMode = AnnotationMode.ENABLE, annotationMode = AnnotationMode.ENABLE,
transform = null, transform = null,
imageLayer = null,
canvasFactory = null, canvasFactory = null,
background = null, background = null,
optionalContentConfigPromise = null, optionalContentConfigPromise = null,
@ -1416,33 +1354,6 @@ class PDFPageProxy {
pageColors = null, pageColors = null,
printAnnotationStorage = null, printAnnotationStorage = null,
}) { }) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
if (arguments[0]?.renderInteractiveForms !== undefined) {
deprecated(
"render no longer accepts the `renderInteractiveForms`-option, " +
"please use the `annotationMode`-option instead."
);
if (
arguments[0].renderInteractiveForms === true &&
annotationMode === AnnotationMode.ENABLE
) {
annotationMode = AnnotationMode.ENABLE_FORMS;
}
}
if (arguments[0]?.includeAnnotationStorage !== undefined) {
deprecated(
"render no longer accepts the `includeAnnotationStorage`-option, " +
"please use the `annotationMode`-option instead."
);
if (
arguments[0].includeAnnotationStorage === true &&
annotationMode === AnnotationMode.ENABLE
) {
annotationMode = AnnotationMode.ENABLE_STORAGE;
}
}
}
if (this._stats) { if (this._stats) {
this._stats.time("Overall"); this._stats.time("Overall");
} }
@ -1529,7 +1440,6 @@ class PDFPageProxy {
canvasContext, canvasContext,
viewport, viewport,
transform, transform,
imageLayer,
background, background,
}, },
objs: this.objs, objs: this.objs,
@ -2360,14 +2270,6 @@ class PDFWorker {
return shadow(this, "_setupFakeWorkerGlobal", loader()); return shadow(this, "_setupFakeWorkerGlobal", loader());
} }
} }
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
PDFWorker.getWorkerSrc = function () {
deprecated(
"`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead."
);
return this.workerSrc;
};
}
/** /**
* For internal use only. * For internal use only.
@ -2912,6 +2814,12 @@ class WorkerTransport {
} }
saveDocument() { saveDocument() {
if (this.annotationStorage.size <= 0) {
warn(
"saveDocument called while `annotationStorage` is empty, " +
"please use the getData-method instead."
);
}
return this.messageHandler return this.messageHandler
.sendWithPromise("SaveDocument", { .sendWithPromise("SaveDocument", {
isPureXfa: !!this._htmlForXfa, isPureXfa: !!this._htmlForXfa,
@ -3332,15 +3240,13 @@ class InternalRenderTask {
this.stepper.init(this.operatorList); this.stepper.init(this.operatorList);
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint(); this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
} }
const { canvasContext, viewport, transform, imageLayer, background } = const { canvasContext, viewport, transform, background } = this.params;
this.params;
this.gfx = new CanvasGraphics( this.gfx = new CanvasGraphics(
canvasContext, canvasContext,
this.commonObjs, this.commonObjs,
this.objs, this.objs,
this.canvasFactory, this.canvasFactory,
imageLayer,
optionalContentConfig, optionalContentConfig,
this.annotationCanvasMap, this.annotationCanvasMap,
this.pageColors this.pageColors

View File

@ -13,13 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
import {
deprecated,
getCurrentTransform,
getCurrentTransformInverse,
getRGB,
PixelsPerInch,
} from "./display_utils.js";
import { import {
FeatureTest, FeatureTest,
FONT_IDENTITY_MATRIX, FONT_IDENTITY_MATRIX,
@ -33,6 +26,12 @@ import {
Util, Util,
warn, warn,
} from "../shared/util.js"; } from "../shared/util.js";
import {
getCurrentTransform,
getCurrentTransformInverse,
getRGB,
PixelsPerInch,
} from "./display_utils.js";
import { import {
getShadingPattern, getShadingPattern,
PathType, PathType,
@ -1024,7 +1023,6 @@ class CanvasGraphics {
commonObjs, commonObjs,
objs, objs,
canvasFactory, canvasFactory,
imageLayer,
optionalContentConfig, optionalContentConfig,
annotationCanvasMap, annotationCanvasMap,
pageColors pageColors
@ -1042,7 +1040,6 @@ class CanvasGraphics {
this.commonObjs = commonObjs; this.commonObjs = commonObjs;
this.objs = objs; this.objs = objs;
this.canvasFactory = canvasFactory; this.canvasFactory = canvasFactory;
this.imageLayer = imageLayer;
this.groupStack = []; this.groupStack = [];
this.processingType3 = null; this.processingType3 = null;
// Patterns are painted relative to the initial page/form transform, see // Patterns are painted relative to the initial page/form transform, see
@ -1183,13 +1180,6 @@ class CanvasGraphics {
this.viewportScale = viewport.scale; this.viewportScale = viewport.scale;
this.baseTransform = getCurrentTransform(this.ctx); this.baseTransform = getCurrentTransform(this.ctx);
if (this.imageLayer) {
deprecated(
"The `imageLayer` functionality will be removed in the future."
);
this.imageLayer.beginLayout();
}
} }
executeOperatorList( executeOperatorList(
@ -1300,10 +1290,6 @@ class CanvasGraphics {
cache.clear(); cache.clear();
} }
this._cachedBitmapsMap.clear(); this._cachedBitmapsMap.clear();
if (this.imageLayer) {
this.imageLayer.endLayout();
}
} }
_scaleImage(img, inverseTransform) { _scaleImage(img, inverseTransform) {
@ -3057,7 +3043,7 @@ class CanvasGraphics {
imgData.interpolate imgData.interpolate
); );
const [rWidth, rHeight] = drawImageAtIntegerCoords( drawImageAtIntegerCoords(
ctx, ctx,
scaled.img, scaled.img,
0, 0,
@ -3069,20 +3055,6 @@ class CanvasGraphics {
width, width,
height height
); );
if (this.imageLayer) {
const [left, top] = Util.applyTransform(
[0, -height],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({
imgData,
left,
top,
width: rWidth,
height: rHeight,
});
}
this.compose(); this.compose();
this.restore(); this.restore();
} }
@ -3115,19 +3087,6 @@ class CanvasGraphics {
1, 1,
1 1
); );
if (this.imageLayer) {
const [left, top] = Util.applyTransform(
[entry.x, entry.y],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({
imgData,
left,
top,
width: w,
height: h,
});
}
ctx.restore(); ctx.restore();
} }
this.compose(); this.compose();

View File

@ -699,15 +699,6 @@ class ProgressBar {
#visible = true; #visible = true;
constructor(id) { constructor(id) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
arguments.length > 1
) {
throw new Error(
"ProgressBar no longer accepts any additional options, " +
"please use CSS rules to modify its appearance instead."
);
}
const bar = document.getElementById(id); const bar = document.getElementById(id);
this.#classList = bar.classList; this.#classList = bar.classList;
} }