Merge pull request #15286 from Snuffleupagus/rm-deprecated

[api-major] Remove (most of) the remaining `deprecated` code
This commit is contained in:
Tim van der Meij 2022-08-28 19:21:45 +02:00 committed by GitHub
commit 86370bd5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 180 deletions

View File

@ -710,28 +710,6 @@ class PDFDocumentProxy {
constructor(pdfInfo, transport) {
this._pdfInfo = pdfInfo;
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: {} };
},
});
}
}
/**
@ -973,12 +951,20 @@ class PDFDocumentProxy {
/**
* @returns {Promise<Uint8Array>} A promise that is resolved with a
* {Uint8Array} that has the raw data from the PDF.
* {Uint8Array} containing the raw data of the PDF document.
*/
getData() {
return this._transport.getData();
}
/**
* @returns {Promise<Uint8Array>} A promise that is resolved with a
* {Uint8Array} containing the full data of the saved document.
*/
saveDocument() {
return this._transport.saveDocument();
}
/**
* @returns {Promise<{ length: number }>} A promise that is resolved when the
* document's data is loaded. It is resolved with an {Object} that contains
@ -1026,23 +1012,6 @@ class PDFDocumentProxy {
return this._transport.loadingTask;
}
/**
* @returns {Promise<Uint8Array>} A promise that is resolved with a
* {Uint8Array} containing the full data of the saved document.
*/
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();
}
/**
* @returns {Promise<Object<string, Array<Object>> | null>} A promise that is
* resolved with an {Object} containing /AcroForm field data for the JS
@ -1172,8 +1141,6 @@ class PDFDocumentProxy {
* The default value is `AnnotationMode.ENABLE`.
* @property {Array<any>} [transform] - Additional transform, applied just
* 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
* when creating canvases. The default value is {new DOMCanvasFactory()}.
* @property {Object | string} [background] - Background to use for the canvas.
@ -1343,34 +1310,6 @@ class PDFPageProxy {
intentArgs.renderingIntent
);
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;
}
@ -1408,7 +1347,6 @@ class PDFPageProxy {
intent = "display",
annotationMode = AnnotationMode.ENABLE,
transform = null,
imageLayer = null,
canvasFactory = null,
background = null,
optionalContentConfigPromise = null,
@ -1416,33 +1354,6 @@ class PDFPageProxy {
pageColors = 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) {
this._stats.time("Overall");
}
@ -1529,7 +1440,6 @@ class PDFPageProxy {
canvasContext,
viewport,
transform,
imageLayer,
background,
},
objs: this.objs,
@ -2360,14 +2270,6 @@ class PDFWorker {
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.
@ -2911,6 +2813,25 @@ class WorkerTransport {
return this.messageHandler.sendWithPromise("GetData", null);
}
saveDocument() {
if (this.annotationStorage.size <= 0) {
warn(
"saveDocument called while `annotationStorage` is empty, " +
"please use the getData-method instead."
);
}
return this.messageHandler
.sendWithPromise("SaveDocument", {
isPureXfa: !!this._htmlForXfa,
numPages: this._numPages,
annotationStorage: this.annotationStorage.serializable,
filename: this._fullReader?.filename ?? null,
})
.finally(() => {
this.annotationStorage.resetModified();
});
}
getPage(pageNumber) {
if (
!Number.isInteger(pageNumber) ||
@ -2971,19 +2892,6 @@ class WorkerTransport {
});
}
saveDocument() {
return this.messageHandler
.sendWithPromise("SaveDocument", {
isPureXfa: !!this._htmlForXfa,
numPages: this._numPages,
annotationStorage: this.annotationStorage.serializable,
filename: this._fullReader?.filename ?? null,
})
.finally(() => {
this.annotationStorage.resetModified();
});
}
getFieldObjects() {
return (this._getFieldObjectsPromise ||=
this.messageHandler.sendWithPromise("GetFieldObjects", null));
@ -3332,15 +3240,13 @@ class InternalRenderTask {
this.stepper.init(this.operatorList);
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
}
const { canvasContext, viewport, transform, imageLayer, background } =
this.params;
const { canvasContext, viewport, transform, background } = this.params;
this.gfx = new CanvasGraphics(
canvasContext,
this.commonObjs,
this.objs,
this.canvasFactory,
imageLayer,
optionalContentConfig,
this.annotationCanvasMap,
this.pageColors

View File

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

View File

@ -698,15 +698,6 @@ class ProgressBar {
#visible = true;
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);
this.#classList = bar.classList;
}