Merge pull request #13021 from Snuffleupagus/createObjectURL-rm-shadow
Remove the, strictly unnecessary, closure and variable shadowing from `createObjectURL`
This commit is contained in:
commit
061637d3f4
@ -940,32 +940,27 @@ function createPromiseCapability() {
|
|||||||
return capability;
|
return capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
const createObjectURL = (function createObjectURLClosure() {
|
function createObjectURL(data, contentType = "", forceDataSchema = false) {
|
||||||
|
if (URL.createObjectURL && !forceDataSchema) {
|
||||||
|
return URL.createObjectURL(new Blob([data], { type: contentType }));
|
||||||
|
}
|
||||||
// Blob/createObjectURL is not available, falling back to data schema.
|
// Blob/createObjectURL is not available, falling back to data schema.
|
||||||
const digits =
|
const digits =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
|
|
||||||
// eslint-disable-next-line no-shadow
|
let buffer = `data:${contentType};base64,`;
|
||||||
return function createObjectURL(data, contentType, forceDataSchema = false) {
|
for (let i = 0, ii = data.length; i < ii; i += 3) {
|
||||||
if (!forceDataSchema && URL.createObjectURL) {
|
const b1 = data[i] & 0xff;
|
||||||
const blob = new Blob([data], { type: contentType });
|
const b2 = data[i + 1] & 0xff;
|
||||||
return URL.createObjectURL(blob);
|
const b3 = data[i + 2] & 0xff;
|
||||||
}
|
const d1 = b1 >> 2,
|
||||||
|
d2 = ((b1 & 3) << 4) | (b2 >> 4);
|
||||||
let buffer = `data:${contentType};base64,`;
|
const d3 = i + 1 < ii ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64;
|
||||||
for (let i = 0, ii = data.length; i < ii; i += 3) {
|
const d4 = i + 2 < ii ? b3 & 0x3f : 64;
|
||||||
const b1 = data[i] & 0xff;
|
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
|
||||||
const b2 = data[i + 1] & 0xff;
|
}
|
||||||
const b3 = data[i + 2] & 0xff;
|
return buffer;
|
||||||
const d1 = b1 >> 2,
|
}
|
||||||
d2 = ((b1 & 3) << 4) | (b2 >> 4);
|
|
||||||
const d3 = i + 1 < ii ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64;
|
|
||||||
const d4 = i + 2 < ii ? b3 & 0x3f : 64;
|
|
||||||
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
AbortException,
|
AbortException,
|
||||||
|
@ -701,7 +701,11 @@ class PDFPageView {
|
|||||||
const actualSizeViewport = this.viewport.clone({ scale: CSS_UNITS });
|
const actualSizeViewport = this.viewport.clone({ scale: CSS_UNITS });
|
||||||
const promise = pdfPage.getOperatorList().then(opList => {
|
const promise = pdfPage.getOperatorList().then(opList => {
|
||||||
ensureNotCancelled();
|
ensureNotCancelled();
|
||||||
const svgGfx = new SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
|
const svgGfx = new SVGGraphics(
|
||||||
|
pdfPage.commonObjs,
|
||||||
|
pdfPage.objs,
|
||||||
|
/* forceDataSchema = */ viewerCompatibilityParams.disableCreateObjectURL
|
||||||
|
);
|
||||||
return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
|
return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
|
||||||
ensureNotCancelled();
|
ensureNotCancelled();
|
||||||
this.svg = svg;
|
this.svg = svg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user