Account for formatting changes in Prettier version 2.3.0
With the exception of one tweaked `eslint-disable` comment, in `web/generic_scripting.js`, this patch was generated automatically using `gulp lint --fix`. Please find additional information at: - https://github.com/prettier/prettier/releases/tag/2.3.0 - https://prettier.io/blog/2021/05/09/2.3.0.html
This commit is contained in:
parent
30908451b4
commit
8943bcd3c3
3
external/builder/builder.js
vendored
3
external/builder/builder.js
vendored
@ -122,7 +122,8 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
let line;
|
let line;
|
||||||
let state = STATE_NONE;
|
let state = STATE_NONE;
|
||||||
const stack = [];
|
const stack = [];
|
||||||
const control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
|
const control =
|
||||||
|
/^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
|
||||||
|
|
||||||
while ((line = readLine()) !== null) {
|
while ((line = readLine()) !== null) {
|
||||||
++lineNumber;
|
++lineNumber;
|
||||||
|
3
external/cmapscompress/parse.js
vendored
3
external/cmapscompress/parse.js
vendored
@ -36,7 +36,8 @@ exports.parseAdobeCMap = function (content) {
|
|||||||
if (m) {
|
if (m) {
|
||||||
result.usecmap = m[1];
|
result.usecmap = m[1];
|
||||||
}
|
}
|
||||||
const re = /(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
|
const re =
|
||||||
|
/(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
|
||||||
while ((m = re.exec(body))) {
|
while ((m = re.exec(body))) {
|
||||||
const lines = m[3].toLowerCase().split("\n");
|
const lines = m[3].toLowerCase().split("\n");
|
||||||
|
|
||||||
|
12
gulpfile.js
12
gulpfile.js
@ -756,8 +756,8 @@ gulp.task("cmaps", function (done) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const compressCmaps = require("./external/cmapscompress/compress.js")
|
const compressCmaps =
|
||||||
.compressCmaps;
|
require("./external/cmapscompress/compress.js").compressCmaps;
|
||||||
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
|
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -1415,7 +1415,8 @@ function buildLibHelper(bundleDefines, inputStream, outputDir) {
|
|||||||
babelPluginReplaceNonWebPackRequire,
|
babelPluginReplaceNonWebPackRequire,
|
||||||
],
|
],
|
||||||
}).code;
|
}).code;
|
||||||
const removeCjsSrc = /^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
|
const removeCjsSrc =
|
||||||
|
/^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
|
||||||
content = content.replace(removeCjsSrc, (all, prefix, interop, suffix) => {
|
content = content.replace(removeCjsSrc, (all, prefix, interop, suffix) => {
|
||||||
return prefix + suffix;
|
return prefix + suffix;
|
||||||
});
|
});
|
||||||
@ -2176,9 +2177,8 @@ gulp.task(
|
|||||||
let reason = process.env.PDFJS_UPDATE_REASON;
|
let reason = process.env.PDFJS_UPDATE_REASON;
|
||||||
// Attempt to work-around the broken link, see https://github.com/mozilla/pdf.js/issues/10391
|
// Attempt to work-around the broken link, see https://github.com/mozilla/pdf.js/issues/10391
|
||||||
if (typeof reason === "string") {
|
if (typeof reason === "string") {
|
||||||
const reasonParts = /^(See )(mozilla\/pdf\.js)@tags\/(v\d+\.\d+\.\d+)\s*$/.exec(
|
const reasonParts =
|
||||||
reason
|
/^(See )(mozilla\/pdf\.js)@tags\/(v\d+\.\d+\.\d+)\s*$/.exec(reason);
|
||||||
);
|
|
||||||
|
|
||||||
if (reasonParts) {
|
if (reasonParts) {
|
||||||
reason =
|
reason =
|
||||||
|
@ -1589,11 +1589,8 @@ class WidgetAnnotation extends Annotation {
|
|||||||
"Expected `_defaultAppearanceData` to have been set."
|
"Expected `_defaultAppearanceData` to have been set."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const {
|
const { localResources, appearanceResources, acroFormResources } =
|
||||||
localResources,
|
this._fieldResources;
|
||||||
appearanceResources,
|
|
||||||
acroFormResources,
|
|
||||||
} = this._fieldResources;
|
|
||||||
|
|
||||||
const fontName =
|
const fontName =
|
||||||
this.data.defaultAppearanceData &&
|
this.data.defaultAppearanceData &&
|
||||||
|
@ -3205,9 +3205,8 @@ class PartialEvaluator {
|
|||||||
// text-extraction. For simple fonts, containing encoding information,
|
// text-extraction. For simple fonts, containing encoding information,
|
||||||
// use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
|
// use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
|
||||||
if (!properties.composite && properties.hasEncoding) {
|
if (!properties.composite && properties.hasEncoding) {
|
||||||
properties.fallbackToUnicode = this._buildSimpleFontToUnicode(
|
properties.fallbackToUnicode =
|
||||||
properties
|
this._buildSimpleFontToUnicode(properties);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(properties.toUnicode);
|
return Promise.resolve(properties.toUnicode);
|
||||||
|
@ -999,12 +999,14 @@ class Font {
|
|||||||
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
||||||
}
|
}
|
||||||
if (/Arial-?Black/i.test(name)) {
|
if (/Arial-?Black/i.test(name)) {
|
||||||
const SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
|
const SupplementalGlyphMapForArialBlack =
|
||||||
|
getSupplementalGlyphMapForArialBlack();
|
||||||
for (const charCode in SupplementalGlyphMapForArialBlack) {
|
for (const charCode in SupplementalGlyphMapForArialBlack) {
|
||||||
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
||||||
}
|
}
|
||||||
} else if (/Calibri/i.test(name)) {
|
} else if (/Calibri/i.test(name)) {
|
||||||
const SupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri();
|
const SupplementalGlyphMapForCalibri =
|
||||||
|
getSupplementalGlyphMapForCalibri();
|
||||||
for (const charCode in SupplementalGlyphMapForCalibri) {
|
for (const charCode in SupplementalGlyphMapForCalibri) {
|
||||||
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
|
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
|
||||||
}
|
}
|
||||||
@ -1801,22 +1803,7 @@ class Font {
|
|||||||
// glyf table cannot be empty -- redoing the glyf and loca tables
|
// glyf table cannot be empty -- redoing the glyf and loca tables
|
||||||
// to have single glyph with one point
|
// to have single glyph with one point
|
||||||
const simpleGlyph = new Uint8Array([
|
const simpleGlyph = new Uint8Array([
|
||||||
0,
|
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0,
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
49,
|
|
||||||
0,
|
|
||||||
]);
|
]);
|
||||||
for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
|
for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
|
||||||
itemEncode(locaData, j, simpleGlyph.length);
|
itemEncode(locaData, j, simpleGlyph.length);
|
||||||
@ -2707,9 +2694,8 @@ class Font {
|
|||||||
return charCode | 0;
|
return charCode | 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newMapping.charCodeToGlyphId[
|
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
|
||||||
newMapping.nextAvailableFontCharCode
|
glyphId;
|
||||||
] = glyphId;
|
|
||||||
return newMapping.nextAvailableFontCharCode++;
|
return newMapping.nextAvailableFontCharCode++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +117,8 @@ function mapStyle(styleStr) {
|
|||||||
style.transform = newValue;
|
style.transform = newValue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
style[
|
style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] =
|
||||||
key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())
|
newValue;
|
||||||
] = newValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
|
@ -3070,13 +3070,8 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||||||
this.stepper.init(this.operatorList);
|
this.stepper.init(this.operatorList);
|
||||||
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
|
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
|
||||||
}
|
}
|
||||||
const {
|
const { canvasContext, viewport, transform, imageLayer, background } =
|
||||||
canvasContext,
|
this.params;
|
||||||
viewport,
|
|
||||||
transform,
|
|
||||||
imageLayer,
|
|
||||||
background,
|
|
||||||
} = this.params;
|
|
||||||
|
|
||||||
this.gfx = new CanvasGraphics(
|
this.gfx = new CanvasGraphics(
|
||||||
canvasContext,
|
canvasContext,
|
||||||
|
@ -141,15 +141,13 @@ class PDFFetchStreamReader {
|
|||||||
const getResponseHeader = name => {
|
const getResponseHeader = name => {
|
||||||
return response.headers.get(name);
|
return response.headers.get(name);
|
||||||
};
|
};
|
||||||
const {
|
const { allowRangeRequests, suggestedLength } =
|
||||||
allowRangeRequests,
|
validateRangeRequestCapabilities({
|
||||||
suggestedLength,
|
getResponseHeader,
|
||||||
} = validateRangeRequestCapabilities({
|
isHttp: this._stream.isHttp,
|
||||||
getResponseHeader,
|
rangeChunkSize: this._rangeChunkSize,
|
||||||
isHttp: this._stream.isHttp,
|
disableRange: this._disableRange,
|
||||||
rangeChunkSize: this._rangeChunkSize,
|
});
|
||||||
disableRange: this._disableRange,
|
|
||||||
});
|
|
||||||
|
|
||||||
this._isRangeSupported = allowRangeRequests;
|
this._isRangeSupported = allowRangeRequests;
|
||||||
// Setting right content length.
|
// Setting right content length.
|
||||||
|
@ -305,15 +305,13 @@ class PDFNetworkStreamFullRequestReader {
|
|||||||
const getResponseHeader = name => {
|
const getResponseHeader = name => {
|
||||||
return fullRequestXhr.getResponseHeader(name);
|
return fullRequestXhr.getResponseHeader(name);
|
||||||
};
|
};
|
||||||
const {
|
const { allowRangeRequests, suggestedLength } =
|
||||||
allowRangeRequests,
|
validateRangeRequestCapabilities({
|
||||||
suggestedLength,
|
getResponseHeader,
|
||||||
} = validateRangeRequestCapabilities({
|
isHttp: this._manager.isHttp,
|
||||||
getResponseHeader,
|
rangeChunkSize: this._rangeChunkSize,
|
||||||
isHttp: this._manager.isHttp,
|
disableRange: this._disableRange,
|
||||||
rangeChunkSize: this._rangeChunkSize,
|
});
|
||||||
disableRange: this._disableRange,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (allowRangeRequests) {
|
if (allowRangeRequests) {
|
||||||
this._isRangeSupported = true;
|
this._isRangeSupported = true;
|
||||||
|
@ -330,15 +330,13 @@ class PDFNodeStreamFullReader extends BaseFullReader {
|
|||||||
// here: https://nodejs.org/api/http.html#http_message_headers.
|
// here: https://nodejs.org/api/http.html#http_message_headers.
|
||||||
return this._readableStream.headers[name.toLowerCase()];
|
return this._readableStream.headers[name.toLowerCase()];
|
||||||
};
|
};
|
||||||
const {
|
const { allowRangeRequests, suggestedLength } =
|
||||||
allowRangeRequests,
|
validateRangeRequestCapabilities({
|
||||||
suggestedLength,
|
getResponseHeader,
|
||||||
} = validateRangeRequestCapabilities({
|
isHttp: stream.isHttp,
|
||||||
getResponseHeader,
|
rangeChunkSize: this._rangeChunkSize,
|
||||||
isHttp: stream.isHttp,
|
disableRange: this._disableRange,
|
||||||
rangeChunkSize: this._rangeChunkSize,
|
});
|
||||||
disableRange: this._disableRange,
|
|
||||||
});
|
|
||||||
|
|
||||||
this._isRangeSupported = allowRangeRequests;
|
this._isRangeSupported = allowRangeRequests;
|
||||||
// Setting right content length.
|
// Setting right content length.
|
||||||
|
@ -52,14 +52,7 @@ if (
|
|||||||
|
|
||||||
const convertImgDataToPng = (function () {
|
const convertImgDataToPng = (function () {
|
||||||
const PNG_HEADER = new Uint8Array([
|
const PNG_HEADER = new Uint8Array([
|
||||||
0x89,
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
||||||
0x50,
|
|
||||||
0x4e,
|
|
||||||
0x47,
|
|
||||||
0x0d,
|
|
||||||
0x0a,
|
|
||||||
0x1a,
|
|
||||||
0x0a,
|
|
||||||
]);
|
]);
|
||||||
const CHUNK_WRAPPER_SIZE = 12;
|
const CHUNK_WRAPPER_SIZE = 12;
|
||||||
|
|
||||||
|
@ -75,8 +75,12 @@ function getAscent(fontFamily, ctx) {
|
|||||||
ctx.strokeStyle = "red";
|
ctx.strokeStyle = "red";
|
||||||
ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
|
ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
|
||||||
ctx.strokeText("g", 0, 0);
|
ctx.strokeText("g", 0, 0);
|
||||||
let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE)
|
let pixels = ctx.getImageData(
|
||||||
.data;
|
0,
|
||||||
|
0,
|
||||||
|
DEFAULT_FONT_SIZE,
|
||||||
|
DEFAULT_FONT_SIZE
|
||||||
|
).data;
|
||||||
descent = 0;
|
descent = 0;
|
||||||
for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
|
for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
|
||||||
if (pixels[i] > 0) {
|
if (pixels[i] > 0) {
|
||||||
|
@ -284,7 +284,8 @@ class Util extends PDFObject {
|
|||||||
seconds: oDate.getSeconds(),
|
seconds: oDate.getSeconds(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
|
const patterns =
|
||||||
|
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
|
||||||
return cFormat.replace(patterns, function (match, pattern) {
|
return cFormat.replace(patterns, function (match, pattern) {
|
||||||
if (pattern in handlers) {
|
if (pattern in handlers) {
|
||||||
return handlers[pattern](data);
|
return handlers[pattern](data);
|
||||||
@ -517,7 +518,8 @@ class Util extends PDFObject {
|
|||||||
|
|
||||||
// escape the string
|
// escape the string
|
||||||
const escapedFormat = cFormat.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
|
const escapedFormat = cFormat.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
|
||||||
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
|
const patterns =
|
||||||
|
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
const re = escapedFormat.replace(
|
const re = escapedFormat.replace(
|
||||||
|
@ -100,6 +100,7 @@ if (
|
|||||||
if (isReadableStreamSupported) {
|
if (isReadableStreamSupported) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
|
globalThis.ReadableStream =
|
||||||
|
require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ function rewriteWebArchiveUrl(url) {
|
|||||||
// Web Archive URLs need to be transformed to add `if_` after the ID.
|
// Web Archive URLs need to be transformed to add `if_` after the ID.
|
||||||
// Without this, an HTML page containing an iframe with the PDF file
|
// Without this, an HTML page containing an iframe with the PDF file
|
||||||
// will be served instead (issue 8920).
|
// will be served instead (issue 8920).
|
||||||
var webArchiveRegex = /(^https?:\/\/web\.archive\.org\/web\/)(\d+)(\/https?:\/\/.+)/g;
|
var webArchiveRegex =
|
||||||
|
/(^https?:\/\/web\.archive\.org\/web\/)(\d+)(\/https?:\/\/.+)/g;
|
||||||
var urlParts = webArchiveRegex.exec(url);
|
var urlParts = webArchiveRegex.exec(url);
|
||||||
if (urlParts) {
|
if (urlParts) {
|
||||||
return urlParts[1] + (urlParts[2] + "if_") + urlParts[3];
|
return urlParts[1] + (urlParts[2] + "if_") + urlParts[3];
|
||||||
|
@ -422,7 +422,8 @@ var Driver = (function DriverClosure() {
|
|||||||
loadingTask.promise.then(
|
loadingTask.promise.then(
|
||||||
doc => {
|
doc => {
|
||||||
task.pdfDoc = doc;
|
task.pdfDoc = doc;
|
||||||
task.optionalContentConfigPromise = doc.getOptionalContentConfig();
|
task.optionalContentConfigPromise =
|
||||||
|
doc.getOptionalContentConfig();
|
||||||
|
|
||||||
this._nextPage(task, failure);
|
this._nextPage(task, failure);
|
||||||
},
|
},
|
||||||
@ -600,9 +601,8 @@ var Driver = (function DriverClosure() {
|
|||||||
}
|
}
|
||||||
annotationLayerCanvas.width = viewport.width;
|
annotationLayerCanvas.width = viewport.width;
|
||||||
annotationLayerCanvas.height = viewport.height;
|
annotationLayerCanvas.height = viewport.height;
|
||||||
var annotationLayerContext = annotationLayerCanvas.getContext(
|
var annotationLayerContext =
|
||||||
"2d"
|
annotationLayerCanvas.getContext("2d");
|
||||||
);
|
|
||||||
annotationLayerContext.clearRect(
|
annotationLayerContext.clearRect(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -843,8 +843,8 @@ function unitTestPostHandler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startBrowser(browserName, startUrl = "") {
|
async function startBrowser(browserName, startUrl = "") {
|
||||||
const revisions = require("puppeteer/lib/cjs/puppeteer/revisions.js")
|
const revisions =
|
||||||
.PUPPETEER_REVISIONS;
|
require("puppeteer/lib/cjs/puppeteer/revisions.js").PUPPETEER_REVISIONS;
|
||||||
const wantedRevision =
|
const wantedRevision =
|
||||||
browserName === "chrome" ? revisions.chromium : revisions.firefox;
|
browserName === "chrome" ? revisions.chromium : revisions.firefox;
|
||||||
|
|
||||||
|
@ -230,24 +230,10 @@ describe("annotation", function () {
|
|||||||
|
|
||||||
it("should process quadpoints in the standard order", function () {
|
it("should process quadpoints in the standard order", function () {
|
||||||
rect = [10, 10, 20, 20];
|
rect = [10, 10, 20, 20];
|
||||||
dict.set("QuadPoints", [
|
dict.set(
|
||||||
10,
|
"QuadPoints",
|
||||||
20,
|
[10, 20, 20, 20, 10, 10, 20, 10, 11, 19, 19, 19, 11, 11, 19, 11]
|
||||||
20,
|
);
|
||||||
20,
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
20,
|
|
||||||
10,
|
|
||||||
11,
|
|
||||||
19,
|
|
||||||
19,
|
|
||||||
19,
|
|
||||||
11,
|
|
||||||
11,
|
|
||||||
19,
|
|
||||||
11,
|
|
||||||
]);
|
|
||||||
expect(getQuadPoints(dict, rect)).toEqual([
|
expect(getQuadPoints(dict, rect)).toEqual([
|
||||||
[
|
[
|
||||||
{ x: 10, y: 20 },
|
{ x: 10, y: 20 },
|
||||||
|
@ -1066,12 +1066,8 @@ describe("api", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("gets metadata", async function () {
|
it("gets metadata", async function () {
|
||||||
const {
|
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||||
info,
|
await pdfDocument.getMetadata();
|
||||||
metadata,
|
|
||||||
contentDispositionFilename,
|
|
||||||
contentLength,
|
|
||||||
} = await pdfDocument.getMetadata();
|
|
||||||
|
|
||||||
expect(info.Title).toEqual("Basic API Test");
|
expect(info.Title).toEqual("Basic API Test");
|
||||||
// Custom, non-standard, information dictionary entries.
|
// Custom, non-standard, information dictionary entries.
|
||||||
@ -1096,12 +1092,8 @@ describe("api", function () {
|
|||||||
buildGetDocumentParams("tracemonkey.pdf")
|
buildGetDocumentParams("tracemonkey.pdf")
|
||||||
);
|
);
|
||||||
const pdfDoc = await loadingTask.promise;
|
const pdfDoc = await loadingTask.promise;
|
||||||
const {
|
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||||
info,
|
await pdfDoc.getMetadata();
|
||||||
metadata,
|
|
||||||
contentDispositionFilename,
|
|
||||||
contentLength,
|
|
||||||
} = await pdfDoc.getMetadata();
|
|
||||||
|
|
||||||
expect(info.Creator).toEqual("TeX");
|
expect(info.Creator).toEqual("TeX");
|
||||||
expect(info.Producer).toEqual("pdfeTeX-1.21a");
|
expect(info.Producer).toEqual("pdfeTeX-1.21a");
|
||||||
@ -1132,12 +1124,8 @@ describe("api", function () {
|
|||||||
it("gets metadata, with missing PDF header (bug 1606566)", async function () {
|
it("gets metadata, with missing PDF header (bug 1606566)", async function () {
|
||||||
const loadingTask = getDocument(buildGetDocumentParams("bug1606566.pdf"));
|
const loadingTask = getDocument(buildGetDocumentParams("bug1606566.pdf"));
|
||||||
const pdfDoc = await loadingTask.promise;
|
const pdfDoc = await loadingTask.promise;
|
||||||
const {
|
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||||
info,
|
await pdfDoc.getMetadata();
|
||||||
metadata,
|
|
||||||
contentDispositionFilename,
|
|
||||||
contentLength,
|
|
||||||
} = await pdfDoc.getMetadata();
|
|
||||||
|
|
||||||
// The following are PDF.js specific, non-standard, properties.
|
// The following are PDF.js specific, non-standard, properties.
|
||||||
expect(info.PDFFormatVersion).toEqual(null);
|
expect(info.PDFFormatVersion).toEqual(null);
|
||||||
@ -1445,13 +1433,12 @@ describe("api", function () {
|
|||||||
docBaseUrl: "qwerty.pdf",
|
docBaseUrl: "qwerty.pdf",
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(
|
const invalidDocBaseUrlPromise =
|
||||||
function (pdfDoc) {
|
invalidDocBaseUrlLoadingTask.promise.then(function (pdfDoc) {
|
||||||
return pdfDoc.getPage(1).then(function (pdfPage) {
|
return pdfDoc.getPage(1).then(function (pdfPage) {
|
||||||
return pdfPage.getAnnotations();
|
return pdfPage.getAnnotations();
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const [
|
const [
|
||||||
defaultAnnotations,
|
defaultAnnotations,
|
||||||
@ -1804,7 +1791,8 @@ describe("api", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("multiple render() on the same canvas", async function () {
|
it("multiple render() on the same canvas", async function () {
|
||||||
const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
|
const optionalContentConfigPromise =
|
||||||
|
pdfDocument.getOptionalContentConfig();
|
||||||
|
|
||||||
const viewport = page.getViewport({ scale: 1 });
|
const viewport = page.getViewport({ scale: 1 });
|
||||||
const canvasAndCtx = CanvasFactory.create(
|
const canvasAndCtx = CanvasFactory.create(
|
||||||
|
@ -27,9 +27,8 @@ function getTopLeftPixel(canvasContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("custom canvas rendering", function () {
|
describe("custom canvas rendering", function () {
|
||||||
const transparentGetDocumentParams = buildGetDocumentParams(
|
const transparentGetDocumentParams =
|
||||||
"transparent.pdf"
|
buildGetDocumentParams("transparent.pdf");
|
||||||
);
|
|
||||||
|
|
||||||
let CanvasFactory;
|
let CanvasFactory;
|
||||||
let loadingTask;
|
let loadingTask;
|
||||||
|
24
web/app.js
24
web/app.js
@ -1497,12 +1497,8 @@ const PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _initializeMetadata(pdfDocument) {
|
async _initializeMetadata(pdfDocument) {
|
||||||
const {
|
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||||
info,
|
await pdfDocument.getMetadata();
|
||||||
metadata,
|
|
||||||
contentDispositionFilename,
|
|
||||||
contentLength,
|
|
||||||
} = await pdfDocument.getMetadata();
|
|
||||||
|
|
||||||
if (pdfDocument !== this.pdfDocument) {
|
if (pdfDocument !== this.pdfDocument) {
|
||||||
return; // The document was closed while the metadata resolved.
|
return; // The document was closed while the metadata resolved.
|
||||||
@ -1782,7 +1778,8 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
forceRendering() {
|
forceRendering() {
|
||||||
this.pdfRenderingQueue.printing = !!this.printService;
|
this.pdfRenderingQueue.printing = !!this.printService;
|
||||||
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
|
this.pdfRenderingQueue.isThumbnailViewEnabled =
|
||||||
|
this.pdfSidebar.isThumbnailViewVisible;
|
||||||
this.pdfRenderingQueue.renderHighestPriority();
|
this.pdfRenderingQueue.renderHighestPriority();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1818,8 +1815,8 @@ const PDFViewerApplication = {
|
|||||||
const pagesOverview = this.pdfViewer.getPagesOverview();
|
const pagesOverview = this.pdfViewer.getPagesOverview();
|
||||||
const printContainer = this.appConfig.printContainer;
|
const printContainer = this.appConfig.printContainer;
|
||||||
const printResolution = AppOptions.get("printResolution");
|
const printResolution = AppOptions.get("printResolution");
|
||||||
const optionalContentConfigPromise = this.pdfViewer
|
const optionalContentConfigPromise =
|
||||||
.optionalContentConfigPromise;
|
this.pdfViewer.optionalContentConfigPromise;
|
||||||
|
|
||||||
const printService = PDFPrintServiceFactory.instance.createPrintService(
|
const printService = PDFPrintServiceFactory.instance.createPrintService(
|
||||||
this.pdfDocument,
|
this.pdfDocument,
|
||||||
@ -2422,7 +2419,8 @@ function webViewerUpdateViewarea(evt) {
|
|||||||
location.pdfOpenParams
|
location.pdfOpenParams
|
||||||
);
|
);
|
||||||
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
|
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
|
||||||
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href =
|
||||||
|
href;
|
||||||
|
|
||||||
// Show/hide the loading indicator in the page number input element.
|
// Show/hide the loading indicator in the page number input element.
|
||||||
const currentPage = PDFViewerApplication.pdfViewer.getPageView(
|
const currentPage = PDFViewerApplication.pdfViewer.getPageView(
|
||||||
@ -2684,10 +2682,8 @@ function setZoomDisabledTimeout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function webViewerWheel(evt) {
|
function webViewerWheel(evt) {
|
||||||
const {
|
const { pdfViewer, supportedMouseWheelZoomModifierKeys } =
|
||||||
pdfViewer,
|
PDFViewerApplication;
|
||||||
supportedMouseWheelZoomModifierKeys,
|
|
||||||
} = PDFViewerApplication;
|
|
||||||
|
|
||||||
if (pdfViewer.isInPresentationMode) {
|
if (pdfViewer.isInPresentationMode) {
|
||||||
return;
|
return;
|
||||||
|
@ -184,9 +184,8 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
|
|||||||
)[chrome.i18n.getUILanguage?.()];
|
)[chrome.i18n.getUILanguage?.()];
|
||||||
|
|
||||||
if (i18nFileAccessLabel) {
|
if (i18nFileAccessLabel) {
|
||||||
document.getElementById(
|
document.getElementById("chrome-file-access-label").textContent =
|
||||||
"chrome-file-access-label"
|
i18nFileAccessLabel;
|
||||||
).textContent = i18nFileAccessLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = document.getElementById("chrome-link-to-extensions-page");
|
const link = document.getElementById("chrome-link-to-extensions-page");
|
||||||
|
@ -18,14 +18,9 @@ import { getPdfFilenameFromUrl, loadScript } from "pdfjs-lib";
|
|||||||
async function docPropertiesLookup(pdfDocument) {
|
async function docPropertiesLookup(pdfDocument) {
|
||||||
const url = "",
|
const url = "",
|
||||||
baseUrl = url.split("#")[0];
|
baseUrl = url.split("#")[0];
|
||||||
/* eslint-disable prefer-const */
|
// eslint-disable-next-line prefer-const
|
||||||
let {
|
let { info, metadata, contentDispositionFilename, contentLength } =
|
||||||
info,
|
await pdfDocument.getMetadata();
|
||||||
metadata,
|
|
||||||
contentDispositionFilename,
|
|
||||||
contentLength,
|
|
||||||
} = await pdfDocument.getMetadata();
|
|
||||||
/* eslint-enable prefer-const */
|
|
||||||
|
|
||||||
if (!contentLength) {
|
if (!contentLength) {
|
||||||
const { length } = await pdfDocument.getDownloadInfo();
|
const { length } = await pdfDocument.getDownloadInfo();
|
||||||
|
@ -181,7 +181,8 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Fetch the default optional content configuration...
|
// Fetch the default optional content configuration...
|
||||||
const optionalContentConfig = await this._pdfDocument.getOptionalContentConfig();
|
const optionalContentConfig =
|
||||||
|
await this._pdfDocument.getOptionalContentConfig();
|
||||||
|
|
||||||
this.eventBus.dispatch("optionalcontentconfig", {
|
this.eventBus.dispatch("optionalcontentconfig", {
|
||||||
source: this,
|
source: this,
|
||||||
|
@ -365,10 +365,14 @@ class PDFPageView {
|
|||||||
const width = this.viewport.width;
|
const width = this.viewport.width;
|
||||||
const height = this.viewport.height;
|
const height = this.viewport.height;
|
||||||
const div = this.div;
|
const div = this.div;
|
||||||
target.style.width = target.parentNode.style.width = div.style.width =
|
target.style.width =
|
||||||
Math.floor(width) + "px";
|
target.parentNode.style.width =
|
||||||
target.style.height = target.parentNode.style.height = div.style.height =
|
div.style.width =
|
||||||
Math.floor(height) + "px";
|
Math.floor(width) + "px";
|
||||||
|
target.style.height =
|
||||||
|
target.parentNode.style.height =
|
||||||
|
div.style.height =
|
||||||
|
Math.floor(height) + "px";
|
||||||
// The canvas may have been originally rotated; rotate relative to that.
|
// The canvas may have been originally rotated; rotate relative to that.
|
||||||
const relativeRotation =
|
const relativeRotation =
|
||||||
this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
|
this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
|
||||||
@ -579,17 +583,18 @@ class PDFPageView {
|
|||||||
|
|
||||||
if (this.annotationLayerFactory) {
|
if (this.annotationLayerFactory) {
|
||||||
if (!this.annotationLayer) {
|
if (!this.annotationLayer) {
|
||||||
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(
|
this.annotationLayer =
|
||||||
div,
|
this.annotationLayerFactory.createAnnotationLayerBuilder(
|
||||||
pdfPage,
|
div,
|
||||||
/* annotationStorage = */ null,
|
pdfPage,
|
||||||
this.imageResourcesPath,
|
/* annotationStorage = */ null,
|
||||||
this.renderInteractiveForms,
|
this.imageResourcesPath,
|
||||||
this.l10n,
|
this.renderInteractiveForms,
|
||||||
/* enableScripting */ null,
|
this.l10n,
|
||||||
/* hasJSActionsPromise = */ null,
|
/* enableScripting */ null,
|
||||||
/* mouseState = */ null
|
/* hasJSActionsPromise = */ null,
|
||||||
);
|
/* mouseState = */ null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this._renderAnnotationLayer();
|
this._renderAnnotationLayer();
|
||||||
}
|
}
|
||||||
@ -632,9 +637,8 @@ class PDFPageView {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
||||||
this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(
|
this.structTreeLayer =
|
||||||
pdfPage
|
this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.setAttribute("data-loaded", true);
|
div.setAttribute("data-loaded", true);
|
||||||
|
@ -313,9 +313,8 @@ class PDFThumbnailView {
|
|||||||
// the `draw` and `setImage` methods (fixes issue 8233).
|
// the `draw` and `setImage` methods (fixes issue 8233).
|
||||||
// NOTE: To primarily avoid increasing memory usage too much, but also to
|
// NOTE: To primarily avoid increasing memory usage too much, but also to
|
||||||
// reduce downsizing overhead, we purposely limit the up-scaling factor.
|
// reduce downsizing overhead, we purposely limit the up-scaling factor.
|
||||||
const { ctx, canvas, transform } = this._getPageDrawContext(
|
const { ctx, canvas, transform } =
|
||||||
DRAW_UPSCALE_FACTOR
|
this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
|
||||||
);
|
|
||||||
const drawViewport = this.viewport.clone({
|
const drawViewport = this.viewport.clone({
|
||||||
scale: DRAW_UPSCALE_FACTOR * this.scale,
|
scale: DRAW_UPSCALE_FACTOR * this.scale,
|
||||||
});
|
});
|
||||||
|
@ -317,13 +317,8 @@ class TextLayerBuilder {
|
|||||||
if (!this.renderingDone) {
|
if (!this.renderingDone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {
|
const { findController, matches, pageIdx, textContentItemsStr, textDivs } =
|
||||||
findController,
|
this;
|
||||||
matches,
|
|
||||||
pageIdx,
|
|
||||||
textContentItemsStr,
|
|
||||||
textDivs,
|
|
||||||
} = this;
|
|
||||||
let clearedUntilDivIdx = -1;
|
let clearedUntilDivIdx = -1;
|
||||||
|
|
||||||
// Clear all current matches.
|
// Clear all current matches.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user