Fix the linting errors, from the Prettier auto-formatting, that ESLint --fix
couldn't handle
This patch makes the follow changes: - Remove no longer necessary inline `// eslint-disable-...` comments. - Fix `// eslint-disable-...` comments that Prettier moved down, thus causing new linting errors. - Concatenate strings which now fit on just one line. - Fix comments that are now too long. - Finally, and most importantly, adjust comments that Prettier moved down, since the new positions often is confusing or outright wrong.
This commit is contained in:
parent
de36b2aaba
commit
a63f7ad486
@ -16,9 +16,7 @@
|
||||
"use strict";
|
||||
|
||||
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFPageView) {
|
||||
alert(
|
||||
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
|
||||
);
|
||||
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
|
||||
}
|
||||
|
||||
// The workerSrc property shall be specified.
|
||||
|
@ -16,9 +16,7 @@
|
||||
"use strict";
|
||||
|
||||
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
|
||||
alert(
|
||||
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
|
||||
);
|
||||
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
|
||||
}
|
||||
|
||||
// The workerSrc property shall be specified.
|
||||
@ -55,8 +53,8 @@ document.addEventListener("pagesinit", function() {
|
||||
// We can use pdfViewer now, e.g. let's change default scale.
|
||||
pdfViewer.currentScaleValue = "page-width";
|
||||
|
||||
// We can try searching for things.
|
||||
if (SEARCH_FOR) {
|
||||
// We can try search for things
|
||||
pdfFindController.executeCommand("find", { query: SEARCH_FOR });
|
||||
}
|
||||
});
|
||||
|
@ -16,9 +16,7 @@
|
||||
"use strict";
|
||||
|
||||
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFSinglePageViewer) {
|
||||
alert(
|
||||
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
|
||||
);
|
||||
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
|
||||
}
|
||||
|
||||
// The workerSrc property shall be specified.
|
||||
@ -55,8 +53,8 @@ document.addEventListener("pagesinit", function() {
|
||||
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
|
||||
pdfSinglePageViewer.currentScaleValue = "page-width";
|
||||
|
||||
// We can try searching for things.
|
||||
if (SEARCH_FOR) {
|
||||
// We can try search for things
|
||||
pdfFindController.executeCommand("find", { query: SEARCH_FOR });
|
||||
}
|
||||
});
|
||||
|
@ -16,9 +16,7 @@
|
||||
"use strict";
|
||||
|
||||
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
|
||||
alert(
|
||||
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
|
||||
);
|
||||
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
|
||||
}
|
||||
|
||||
// The workerSrc property shall be specified.
|
||||
|
2
external/builder/builder.js
vendored
2
external/builder/builder.js
vendored
@ -120,7 +120,7 @@ function preprocess(inFilename, outFilename, defines) {
|
||||
var line;
|
||||
var state = STATE_NONE;
|
||||
var stack = [];
|
||||
var control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/; // eslint-disable-next-line max-len
|
||||
var control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
|
||||
var lineNumber = 0;
|
||||
var loc = function() {
|
||||
return fs.realpathSync(inFilename) + ":" + lineNumber;
|
||||
|
10
gulpfile.js
10
gulpfile.js
@ -208,7 +208,6 @@ function createWebpackConfig(defines, output) {
|
||||
// `web-streams-polyfill` (already using a transpiled file), and
|
||||
// `src/core/{glyphlist,unicode}.js` (Babel is too slow for those)
|
||||
// should be excluded from processing.
|
||||
// eslint-disable-next-line max-len
|
||||
exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/,
|
||||
options: {
|
||||
presets: skipBabel ? undefined : ["@babel/preset-env"],
|
||||
@ -425,7 +424,7 @@ function createTestSource(testsName, bot) {
|
||||
"Browser manifest file test/" + PDF_BROWSERS + " does not exist."
|
||||
);
|
||||
console.log(
|
||||
"Copy and adjust the example in " + "test/resources/browser_manifests."
|
||||
"Copy and adjust the example in test/resources/browser_manifests."
|
||||
);
|
||||
this.emit("error", new Error("Missing manifest file"));
|
||||
return null;
|
||||
@ -476,7 +475,7 @@ function makeRef(done, bot) {
|
||||
"Browser manifest file test/" + PDF_BROWSERS + " does not exist."
|
||||
);
|
||||
console.log(
|
||||
"Copy and adjust the example in " + "test/resources/browser_manifests."
|
||||
"Copy and adjust the example in test/resources/browser_manifests."
|
||||
);
|
||||
done(new Error("Missing manifest file"));
|
||||
return;
|
||||
@ -669,7 +668,7 @@ gulp.task("locale", function() {
|
||||
gulp.dest(VIEWER_LOCALE_OUTPUT)
|
||||
),
|
||||
gulp
|
||||
.src(L10N_DIR + "/{" + locales.join(",") + "}" + "/viewer.properties", {
|
||||
.src(L10N_DIR + "/{" + locales.join(",") + "}/viewer.properties", {
|
||||
base: L10N_DIR,
|
||||
})
|
||||
.pipe(gulp.dest(VIEWER_LOCALE_OUTPUT)),
|
||||
@ -1142,7 +1141,6 @@ gulp.task(
|
||||
babelPluginReplaceNonWebPackRequire,
|
||||
],
|
||||
}).code;
|
||||
// eslint-disable-next-line max-len
|
||||
var removeCjsSrc = /^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
|
||||
content = content.replace(
|
||||
removeCjsSrc,
|
||||
@ -1679,7 +1677,7 @@ gulp.task(
|
||||
console.log();
|
||||
console.log("Done. Push with");
|
||||
console.log(
|
||||
" cd " + DIST_DIR + "; " + "git push --tags " + DIST_REPO_URL + " master"
|
||||
" cd " + DIST_DIR + "; git push --tags " + DIST_REPO_URL + " master"
|
||||
);
|
||||
console.log();
|
||||
done();
|
||||
|
@ -401,8 +401,8 @@ class IdentityCMap extends CMap {
|
||||
return 0x10000;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line getter-return
|
||||
get isIdentityCMap() {
|
||||
// eslint-disable-line getter-return
|
||||
unreachable("should not access .isIdentityCMap");
|
||||
}
|
||||
}
|
||||
|
@ -591,8 +591,7 @@ class PDFDocument {
|
||||
ch = stream.getByte();
|
||||
} while (isSpace(ch));
|
||||
let str = "";
|
||||
while (ch >= 0x20 && ch <= 0x39) {
|
||||
// < '9'
|
||||
while (ch >= /* Space = */ 0x20 && ch <= /* '9' = */ 0x39) {
|
||||
str += String.fromCharCode(ch);
|
||||
ch = stream.getByte();
|
||||
}
|
||||
@ -622,8 +621,7 @@ class PDFDocument {
|
||||
const MAX_PDF_VERSION_LENGTH = 12;
|
||||
let version = "",
|
||||
ch;
|
||||
while ((ch = stream.getByte()) > 0x20) {
|
||||
// Space
|
||||
while ((ch = stream.getByte()) > /* Space = */ 0x20) {
|
||||
if (version.length >= MAX_PDF_VERSION_LENGTH) {
|
||||
break;
|
||||
}
|
||||
|
@ -524,8 +524,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
])
|
||||
.then(
|
||||
function() {
|
||||
// Only add the dependency once we know that the native JPEG decoding
|
||||
// succeeded, to ensure that rendering will always complete.
|
||||
// Only add the dependency once we know that the native JPEG
|
||||
// decoding succeeded, to ensure that rendering will always
|
||||
// complete.
|
||||
operatorList.addDependency(objId);
|
||||
args = [objId, w, h];
|
||||
|
||||
@ -755,7 +756,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
return translated;
|
||||
})
|
||||
.catch(reason => {
|
||||
// Error in the font data -- sending unsupported feature notification.
|
||||
// Error in the font data -- sending unsupported feature
|
||||
// notification.
|
||||
this.handler.send("UnsupportedFeature", {
|
||||
featureId: UNSUPPORTED_FEATURES.font,
|
||||
});
|
||||
@ -2160,9 +2162,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use a new `StateManager` to prevent incorrect positioning of
|
||||
// textItems *after* the Form XObject, since errors in the data
|
||||
// can otherwise prevent `restore` operators from executing.
|
||||
// Use a new `StateManager` to prevent incorrect positioning
|
||||
// of textItems *after* the Form XObject, since errors in the
|
||||
// data can otherwise prevent `restore` operators from
|
||||
// executing.
|
||||
// NOTE: Only an issue when `options.ignoreErrors === true`.
|
||||
let currentState = stateManager.state.clone();
|
||||
let xObjStateManager = new StateManager(currentState);
|
||||
|
@ -929,9 +929,8 @@ var Font = (function FontClosure() {
|
||||
return true;
|
||||
}
|
||||
// ... obviously some fonts violate that part of the specification,
|
||||
// please refer to the comment in |Type1Font| below.
|
||||
// please refer to the comment in |Type1Font| below (pfb file header).
|
||||
if (header[0] === 0x80 && header[1] === 0x01) {
|
||||
// pfb file header.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1085,7 +1084,6 @@ var Font = (function FontClosure() {
|
||||
var ranges = [];
|
||||
var length = codes.length;
|
||||
for (var n = 0; n < length; ) {
|
||||
// eslint-disable-line space-in-parens
|
||||
var start = codes[n].fontCharCode;
|
||||
var codeIndices = [codes[n].glyphId];
|
||||
++n;
|
||||
|
@ -142,7 +142,7 @@ var PDFImage = (function PDFImageClosure() {
|
||||
}
|
||||
if (width < 1 || height < 1) {
|
||||
throw new FormatError(
|
||||
`Invalid image width: ${width} or ` + `height: ${height}`
|
||||
`Invalid image width: ${width} or height: ${height}`
|
||||
);
|
||||
}
|
||||
this.width = width;
|
||||
@ -617,11 +617,11 @@ var PDFImage = (function PDFImageClosure() {
|
||||
var drawWidth = this.drawWidth;
|
||||
var drawHeight = this.drawHeight;
|
||||
var imgData = {
|
||||
// other fields are filled in below
|
||||
width: drawWidth,
|
||||
height: drawHeight,
|
||||
kind: 0,
|
||||
data: null,
|
||||
// Other fields are filled in below.
|
||||
};
|
||||
|
||||
var numComps = this.numComps;
|
||||
|
@ -31,8 +31,8 @@ let JpegStream = (function JpegStreamClosure() {
|
||||
// Note: this seems to mainly affect inline images.
|
||||
let ch;
|
||||
while ((ch = stream.getByte()) !== -1) {
|
||||
// Find the first byte of the SOI marker (0xFFD8).
|
||||
if (ch === 0xff) {
|
||||
// Find the first byte of the SOI marker (0xFFD8).
|
||||
stream.skip(-1); // Reset the stream position to the SOI.
|
||||
break;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable no-multi-spaces */
|
||||
|
||||
import { assert, BaseException, warn } from "../shared/util";
|
||||
|
||||
@ -149,7 +148,6 @@ var JpegImage = (function JpegImageClosure() {
|
||||
var nextByte = data[offset++];
|
||||
if (nextByte) {
|
||||
if (nextByte === 0xdc && parseDNLMarker) {
|
||||
// DNL == 0xFFDC
|
||||
offset += 2; // Skip data length.
|
||||
const scanLines = (data[offset++] << 8) | data[offset++];
|
||||
if (scanLines > 0 && scanLines !== frame.scanLines) {
|
||||
@ -159,7 +157,6 @@ var JpegImage = (function JpegImageClosure() {
|
||||
);
|
||||
}
|
||||
} else if (nextByte === 0xd9) {
|
||||
// EOI == 0xFFD9
|
||||
throw new EOIMarkerError(
|
||||
"Found EOI marker (0xFFD9) while parsing scan data"
|
||||
);
|
||||
@ -746,14 +743,12 @@ var JpegImage = (function JpegImageClosure() {
|
||||
var huffmanTablesAC = [],
|
||||
huffmanTablesDC = [];
|
||||
var fileMarker = readUint16();
|
||||
if (fileMarker !== 0xffd8) {
|
||||
// SOI (Start of Image)
|
||||
if (fileMarker !== /* SOI (Start of Image) = */ 0xffd8) {
|
||||
throw new JpegError("SOI not found");
|
||||
}
|
||||
|
||||
fileMarker = readUint16();
|
||||
markerLoop: while (fileMarker !== 0xffd9) {
|
||||
// EOI (End of image)
|
||||
markerLoop: while (fileMarker !== /* EOI (End of Image) = */ 0xffd9) {
|
||||
var i, j, l;
|
||||
switch (fileMarker) {
|
||||
case 0xffe0: // APP0 (Application Specific)
|
||||
@ -776,6 +771,7 @@ var JpegImage = (function JpegImageClosure() {
|
||||
var appData = readDataBlock();
|
||||
|
||||
if (fileMarker === 0xffe0) {
|
||||
// 'JFIF\x00'
|
||||
if (
|
||||
appData[0] === 0x4a &&
|
||||
appData[1] === 0x46 &&
|
||||
@ -783,7 +779,6 @@ var JpegImage = (function JpegImageClosure() {
|
||||
appData[3] === 0x46 &&
|
||||
appData[4] === 0
|
||||
) {
|
||||
// 'JFIF\x00'
|
||||
jfif = {
|
||||
version: { major: appData[5], minor: appData[6] },
|
||||
densityUnits: appData[7],
|
||||
@ -800,6 +795,7 @@ var JpegImage = (function JpegImageClosure() {
|
||||
}
|
||||
// TODO APP1 - Exif
|
||||
if (fileMarker === 0xffee) {
|
||||
// 'Adobe'
|
||||
if (
|
||||
appData[0] === 0x41 &&
|
||||
appData[1] === 0x64 &&
|
||||
@ -807,7 +803,6 @@ var JpegImage = (function JpegImageClosure() {
|
||||
appData[3] === 0x62 &&
|
||||
appData[4] === 0x65
|
||||
) {
|
||||
// 'Adobe'
|
||||
adobe = {
|
||||
version: (appData[5] << 8) | appData[6],
|
||||
flags0: (appData[7] << 8) | appData[8],
|
||||
|
@ -404,7 +404,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
break;
|
||||
case 0xff53: // Coding style component (COC)
|
||||
throw new Error(
|
||||
"Codestream code 0xFF53 (COC) is " + "not implemented"
|
||||
"Codestream code 0xFF53 (COC) is not implemented"
|
||||
);
|
||||
default:
|
||||
throw new Error("Unknown codestream code: " + code.toString(16));
|
||||
|
@ -813,12 +813,13 @@ const specialChars = [
|
||||
];
|
||||
|
||||
function toHexDigit(ch) {
|
||||
if (ch >= 0x30 && ch <= 0x39) {
|
||||
// '0'-'9'
|
||||
if (ch >= /* '0' = */ 0x30 && ch /* '9' = */ <= 0x39) {
|
||||
return ch & 0x0f;
|
||||
}
|
||||
if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
|
||||
// 'A'-'F', 'a'-'f'
|
||||
if (
|
||||
(ch >= /* 'A' = */ 0x41 && ch <= /* 'F' = */ 0x46) ||
|
||||
(ch >= /* 'a' = */ 0x61 && ch <= /* 'f' = */ 0x66)
|
||||
) {
|
||||
return (ch & 0x0f) + 9;
|
||||
}
|
||||
return -1;
|
||||
@ -862,35 +863,29 @@ class Lexer {
|
||||
let divideBy = 0; // Different from 0 if it's a floating point value.
|
||||
let sign = 0;
|
||||
|
||||
if (ch === 0x2d) {
|
||||
// '-'
|
||||
if (ch === /* '-' = */ 0x2d) {
|
||||
sign = -1;
|
||||
ch = this.nextChar();
|
||||
|
||||
if (ch === 0x2d) {
|
||||
// '-'
|
||||
if (ch === /* '-' = */ 0x2d) {
|
||||
// Ignore double negative (this is consistent with Adobe Reader).
|
||||
ch = this.nextChar();
|
||||
}
|
||||
} else if (ch === 0x2b) {
|
||||
// '+'
|
||||
} else if (ch === /* '+' = */ 0x2b) {
|
||||
sign = 1;
|
||||
ch = this.nextChar();
|
||||
}
|
||||
if (ch === 0x0a || ch === 0x0d) {
|
||||
// LF, CR
|
||||
if (ch === /* LF = */ 0x0a || ch === /* CR = */ 0x0d) {
|
||||
// Ignore line-breaks (this is consistent with Adobe Reader).
|
||||
do {
|
||||
ch = this.nextChar();
|
||||
} while (ch === 0x0a || ch === 0x0d);
|
||||
}
|
||||
if (ch === 0x2e) {
|
||||
// '.'
|
||||
if (ch === /* '.' = */ 0x2e) {
|
||||
divideBy = 10;
|
||||
ch = this.nextChar();
|
||||
}
|
||||
if (ch < 0x30 || ch > 0x39) {
|
||||
// '0' - '9'
|
||||
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
|
||||
if (
|
||||
divideBy === 10 &&
|
||||
sign === 0 &&
|
||||
@ -911,8 +906,7 @@ class Lexer {
|
||||
let powerValueSign = 1;
|
||||
|
||||
while ((ch = this.nextChar()) >= 0) {
|
||||
if (0x30 <= ch && ch <= 0x39) {
|
||||
// '0' - '9'
|
||||
if (ch >= /* '0' = */ 0x30 && ch <= /* '9' = */ 0x39) {
|
||||
const currentDigit = ch - 0x30; // '0'
|
||||
if (eNotation) {
|
||||
// We are after an 'e' or 'E'.
|
||||
@ -924,30 +918,25 @@ class Lexer {
|
||||
}
|
||||
baseValue = baseValue * 10 + currentDigit;
|
||||
}
|
||||
} else if (ch === 0x2e) {
|
||||
// '.'
|
||||
} else if (ch === /* '.' = */ 0x2e) {
|
||||
if (divideBy === 0) {
|
||||
divideBy = 1;
|
||||
} else {
|
||||
// A number can have only one dot.
|
||||
break;
|
||||
}
|
||||
} else if (ch === 0x2d) {
|
||||
// '-'
|
||||
} else if (ch === /* '-' = */ 0x2d) {
|
||||
// Ignore minus signs in the middle of numbers to match
|
||||
// Adobe's behavior.
|
||||
warn("Badly formatted number: minus sign in the middle");
|
||||
} else if (ch === 0x45 || ch === 0x65) {
|
||||
// 'E', 'e'
|
||||
} else if (ch === /* 'E' = */ 0x45 || ch === /* 'e' = */ 0x65) {
|
||||
// 'E' can be either a scientific notation or the beginning of a new
|
||||
// operator.
|
||||
ch = this.peekChar();
|
||||
if (ch === 0x2b || ch === 0x2d) {
|
||||
// '+', '-'
|
||||
if (ch === /* '+' = */ 0x2b || ch === /* '-' = */ 0x2d) {
|
||||
powerValueSign = ch === 0x2d ? -1 : 1;
|
||||
this.nextChar(); // Consume the sign character.
|
||||
} else if (ch < 0x30 || ch > 0x39) {
|
||||
// '0' - '9'
|
||||
} else if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
|
||||
// The 'E' must be the beginning of a new operator.
|
||||
break;
|
||||
}
|
||||
@ -1020,23 +1009,21 @@ class Lexer {
|
||||
case 0x29: // ')'
|
||||
strBuf.push(String.fromCharCode(ch));
|
||||
break;
|
||||
case 0x30:
|
||||
case 0x31:
|
||||
case 0x32:
|
||||
case 0x33: // '0'-'3'
|
||||
case 0x34:
|
||||
case 0x35:
|
||||
case 0x36:
|
||||
case 0x37: // '4'-'7'
|
||||
case 0x30: // '0'
|
||||
case 0x31: // '1'
|
||||
case 0x32: // '2'
|
||||
case 0x33: // '3'
|
||||
case 0x34: // '4'
|
||||
case 0x35: // '5'
|
||||
case 0x36: // '6'
|
||||
case 0x37: // '7'
|
||||
let x = ch & 0x0f;
|
||||
ch = this.nextChar();
|
||||
charBuffered = true;
|
||||
if (ch >= 0x30 && ch <= 0x37) {
|
||||
// '0'-'7'
|
||||
if (ch >= /* '0' = */ 0x30 && ch <= /* '7' = */ 0x37) {
|
||||
x = (x << 3) + (ch & 0x0f);
|
||||
ch = this.nextChar();
|
||||
if (ch >= 0x30 && ch <= 0x37) {
|
||||
// '0'-'7'
|
||||
if (ch >= /* '0' = */ 0x30 && ch /* '7' = */ <= 0x37) {
|
||||
charBuffered = false;
|
||||
x = (x << 3) + (ch & 0x0f);
|
||||
}
|
||||
@ -1044,8 +1031,7 @@ class Lexer {
|
||||
strBuf.push(String.fromCharCode(x));
|
||||
break;
|
||||
case 0x0d: // CR
|
||||
if (this.peekChar() === 0x0a) {
|
||||
// LF
|
||||
if (this.peekChar() === /* LF = */ 0x0a) {
|
||||
this.nextChar();
|
||||
}
|
||||
break;
|
||||
@ -1076,8 +1062,7 @@ class Lexer {
|
||||
strBuf.length = 0;
|
||||
|
||||
while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
|
||||
if (ch === 0x23) {
|
||||
// '#'
|
||||
if (ch === /* '#' = */ 0x23) {
|
||||
ch = this.nextChar();
|
||||
if (specialChars[ch]) {
|
||||
warn(
|
||||
@ -1129,8 +1114,7 @@ class Lexer {
|
||||
if (ch < 0) {
|
||||
warn("Unterminated hex string");
|
||||
break;
|
||||
} else if (ch === 0x3e) {
|
||||
// '>'
|
||||
} else if (ch === /* '>' = */ 0x3e) {
|
||||
this.nextChar();
|
||||
break;
|
||||
} else if (specialChars[ch] === 1) {
|
||||
@ -1169,12 +1153,10 @@ class Lexer {
|
||||
return EOF;
|
||||
}
|
||||
if (comment) {
|
||||
if (ch === 0x0a || ch === 0x0d) {
|
||||
// LF, CR
|
||||
if (ch === /* LF = */ 0x0a || ch === /* CR = */ 0x0d) {
|
||||
comment = false;
|
||||
}
|
||||
} else if (ch === 0x25) {
|
||||
// '%'
|
||||
} else if (ch === /* '%' = */ 0x25) {
|
||||
comment = true;
|
||||
} else if (specialChars[ch] !== 1) {
|
||||
break;
|
||||
@ -1184,19 +1166,19 @@ class Lexer {
|
||||
|
||||
// Start reading a token.
|
||||
switch (ch | 0) {
|
||||
case 0x30:
|
||||
case 0x31:
|
||||
case 0x32:
|
||||
case 0x33:
|
||||
case 0x34: // '0'-'4'
|
||||
case 0x35:
|
||||
case 0x36:
|
||||
case 0x37:
|
||||
case 0x38:
|
||||
case 0x39: // '5'-'9'
|
||||
case 0x2b:
|
||||
case 0x2d:
|
||||
case 0x2e: // '+', '-', '.'
|
||||
case 0x30: // '0'
|
||||
case 0x31: // '1'
|
||||
case 0x32: // '2'
|
||||
case 0x33: // '3'
|
||||
case 0x34: // '4'
|
||||
case 0x35: // '5'
|
||||
case 0x36: // '6'
|
||||
case 0x37: // '7'
|
||||
case 0x38: // '8'
|
||||
case 0x39: // '9'
|
||||
case 0x2b: // '+'
|
||||
case 0x2d: // '-'
|
||||
case 0x2e: // '.'
|
||||
return this.getNumber();
|
||||
case 0x28: // '('
|
||||
return this.getString();
|
||||
@ -1280,16 +1262,13 @@ class Lexer {
|
||||
skipToNextLine() {
|
||||
let ch = this.currentChar;
|
||||
while (ch >= 0) {
|
||||
if (ch === 0x0d) {
|
||||
// CR
|
||||
if (ch === /* CR = */ 0x0d) {
|
||||
ch = this.nextChar();
|
||||
if (ch === 0x0a) {
|
||||
// LF
|
||||
if (ch === /* LF = */ 0x0a) {
|
||||
this.nextChar();
|
||||
}
|
||||
break;
|
||||
} else if (ch === 0x0a) {
|
||||
// LF
|
||||
} else if (ch === /* LF = */ 0x0a) {
|
||||
this.nextChar();
|
||||
break;
|
||||
}
|
||||
@ -1323,7 +1302,7 @@ class Linearization {
|
||||
const hint = hints[index];
|
||||
if (!(Number.isInteger(hint) && hint > 0)) {
|
||||
throw new Error(
|
||||
`Hint (${index}) in the linearization dictionary ` + "is invalid."
|
||||
`Hint (${index}) in the linearization dictionary is invalid.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable no-multi-spaces */
|
||||
|
||||
import {
|
||||
assert,
|
||||
|
@ -190,8 +190,7 @@ class PostScriptLexer {
|
||||
if (ch === 0x0a || ch === 0x0d) {
|
||||
comment = false;
|
||||
}
|
||||
} else if (ch === 0x25) {
|
||||
// '%'
|
||||
} else if (ch === /* '%' = */ 0x25) {
|
||||
comment = true;
|
||||
} else if (!isSpace(ch)) {
|
||||
break;
|
||||
@ -199,19 +198,19 @@ class PostScriptLexer {
|
||||
ch = this.nextChar();
|
||||
}
|
||||
switch (ch | 0) {
|
||||
case 0x30:
|
||||
case 0x31:
|
||||
case 0x32:
|
||||
case 0x33:
|
||||
case 0x34: // '0'-'4'
|
||||
case 0x35:
|
||||
case 0x36:
|
||||
case 0x37:
|
||||
case 0x38:
|
||||
case 0x39: // '5'-'9'
|
||||
case 0x2b:
|
||||
case 0x2d:
|
||||
case 0x2e: // '+', '-', '.'
|
||||
case 0x30: // '0'
|
||||
case 0x31: // '1'
|
||||
case 0x32: // '2'
|
||||
case 0x33: // '3'
|
||||
case 0x34: // '4'
|
||||
case 0x35: // '5'
|
||||
case 0x36: // '6'
|
||||
case 0x37: // '7'
|
||||
case 0x38: // '8'
|
||||
case 0x39: // '9'
|
||||
case 0x2b: // '+'
|
||||
case 0x2d: // '-'
|
||||
case 0x2e: // '.'
|
||||
return new PostScriptToken(
|
||||
PostScriptTokenTypes.NUMBER,
|
||||
this.getNumber()
|
||||
@ -229,8 +228,9 @@ class PostScriptLexer {
|
||||
strBuf[0] = String.fromCharCode(ch);
|
||||
|
||||
while (
|
||||
(ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z'
|
||||
((ch >= 0x41 && ch <= 0x5a) || (ch >= 0x61 && ch <= 0x7a))
|
||||
(ch = this.nextChar()) >= 0 &&
|
||||
((ch >= /* 'A' = */ 0x41 && ch <= /* 'Z' = */ 0x5a) ||
|
||||
(ch >= /* 'a' = */ 0x61 && ch <= /* 'z' = */ 0x7a))
|
||||
) {
|
||||
strBuf.push(String.fromCharCode(ch));
|
||||
}
|
||||
@ -253,11 +253,10 @@ class PostScriptLexer {
|
||||
|
||||
while ((ch = this.nextChar()) >= 0) {
|
||||
if (
|
||||
(ch >= 0x30 && ch <= 0x39) || // '0'-'9'
|
||||
ch === 0x2d ||
|
||||
ch === 0x2e
|
||||
(ch >= /* '0' = */ 0x30 && ch <= /* '9' = */ 0x39) ||
|
||||
ch === /* '-' = */ 0x2d ||
|
||||
ch === /* '.' = */ 0x2e
|
||||
) {
|
||||
// '-', '.'
|
||||
strBuf.push(String.fromCharCode(ch));
|
||||
} else {
|
||||
break;
|
||||
|
@ -1098,19 +1098,19 @@ var AsciiHexStream = (function AsciiHexStreamClosure() {
|
||||
for (var i = 0, ii = bytes.length; i < ii; i++) {
|
||||
var ch = bytes[i],
|
||||
digit;
|
||||
if (ch >= 0x30 && ch <= 0x39) {
|
||||
// '0'-'9'
|
||||
if (ch >= /* '0' = */ 0x30 && ch <= /* '9' = */ 0x39) {
|
||||
digit = ch & 0x0f;
|
||||
} else if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
|
||||
// 'A'-'Z', 'a'-'z'
|
||||
} else if (
|
||||
(ch >= /* 'A' = */ 0x41 && ch <= /* 'Z' = */ 0x46) ||
|
||||
(ch >= /* 'a' = */ 0x61 && ch <= /* 'z' = */ 0x66)
|
||||
) {
|
||||
digit = (ch & 0x0f) + 9;
|
||||
} else if (ch === 0x3e) {
|
||||
// '>'
|
||||
} else if (ch === /* '>' = */ 0x3e) {
|
||||
this.eof = true;
|
||||
break;
|
||||
} else {
|
||||
// probably whitespace
|
||||
continue; // ignoring
|
||||
// Probably whitespace, ignoring.
|
||||
continue;
|
||||
}
|
||||
if (firstDigit < 0) {
|
||||
firstDigit = digit;
|
||||
|
@ -385,8 +385,8 @@ var Type1Parser = (function Type1ParserClosure() {
|
||||
return (
|
||||
(code >= 48 && code <= 57) || // '0'-'9'
|
||||
(code >= 65 && code <= 70) || // 'A'-'F'
|
||||
(code >= 97 && code <= 102)
|
||||
); // 'a'-'f'
|
||||
(code >= 97 && code <= 102) // 'a'-'f'
|
||||
);
|
||||
}
|
||||
|
||||
function decrypt(data, key, discardNumber) {
|
||||
@ -521,8 +521,7 @@ var Type1Parser = (function Type1ParserClosure() {
|
||||
if (ch === 0x0a || ch === 0x0d) {
|
||||
comment = false;
|
||||
}
|
||||
} else if (ch === 0x25) {
|
||||
// '%'
|
||||
} else if (ch === /* '%' = */ 0x25) {
|
||||
comment = true;
|
||||
} else if (!isSpace(ch)) {
|
||||
break;
|
||||
|
@ -52,8 +52,7 @@ function mapSpecialUnicodeValues(code) {
|
||||
return 0;
|
||||
} else if (code >= 0xf600 && code <= 0xf8ff) {
|
||||
return getSpecialPUASymbols()[code] || code;
|
||||
} else if (code === 0x00ad) {
|
||||
// softhyphen
|
||||
} else if (code === /* softhyphen = */ 0x00ad) {
|
||||
return 0x002d; // hyphen
|
||||
}
|
||||
return code;
|
||||
|
@ -527,8 +527,9 @@ var WorkerMessageHandler = {
|
||||
|
||||
sink.error(reason);
|
||||
|
||||
// TODO: Should `reason` be re-thrown here (currently that casues
|
||||
// "Uncaught exception: ..." messages in the console)?
|
||||
// TODO: Should `reason` be re-thrown here (currently that
|
||||
// casues "Uncaught exception: ..." messages in the
|
||||
// console)?
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -381,8 +381,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
typeof PDFJSDev !== "undefined" && !PDFJSDev.test("TESTING")
|
||||
? PDFJSDev.eval("BUNDLE_VERSION")
|
||||
: null,
|
||||
// Only send the required properties, and *not* the entire object.
|
||||
source: {
|
||||
// Only send the required properties, and *not* the entire object.
|
||||
data: source.data,
|
||||
url: source.url,
|
||||
password: source.password,
|
||||
@ -1087,8 +1087,8 @@ class PDFPageProxy {
|
||||
|
||||
const internalRenderTask = new InternalRenderTask({
|
||||
callback: complete,
|
||||
// Only include the required properties, and *not* the entire object.
|
||||
params: {
|
||||
// Include the required properties, and *not* the entire object.
|
||||
canvasContext,
|
||||
viewport,
|
||||
transform,
|
||||
@ -1641,8 +1641,8 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("GENERIC") &&
|
||||
// eslint-disable-next-line no-undef
|
||||
isNodeJS &&
|
||||
// eslint-disable-next-line no-undef
|
||||
typeof __non_webpack_require__ === "function"
|
||||
) {
|
||||
// Since bundlers, such as Webpack, cannot be told to leave `require`
|
||||
|
@ -113,18 +113,18 @@ class BaseFontLoader {
|
||||
unreachable("Abstract method `_queueLoadingCallback`.");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line getter-return
|
||||
get isFontLoadingAPISupported() {
|
||||
// eslint-disable-line getter-return
|
||||
unreachable("Abstract method `isFontLoadingAPISupported`.");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line getter-return
|
||||
get isSyncFontLoadingSupported() {
|
||||
// eslint-disable-line getter-return
|
||||
unreachable("Abstract method `isSyncFontLoadingSupported`.");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line getter-return
|
||||
get _loadTestFont() {
|
||||
// eslint-disable-line getter-return
|
||||
unreachable("Abstract method `_loadTestFont`.");
|
||||
}
|
||||
|
||||
@ -225,8 +225,8 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
|
||||
get _loadTestFont() {
|
||||
const getLoadTestFont = function() {
|
||||
// This is a CFF font with 1 glyph for '.' that fills its entire width and
|
||||
// height.
|
||||
// This is a CFF font with 1 glyph for '.' that fills its entire width
|
||||
// and height.
|
||||
return atob(
|
||||
"T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA" +
|
||||
"FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA" +
|
||||
|
@ -125,8 +125,8 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
function deflateSync(literals) {
|
||||
if (!isNodeJS) {
|
||||
// zlib is certainly not available outside of Node.js. We can either use
|
||||
// the pako library for client-side DEFLATE compression, or use the canvas
|
||||
// API of the browser to obtain a more optimal PNG file.
|
||||
// the pako library for client-side DEFLATE compression, or use the
|
||||
// canvas API of the browser to obtain a more optimal PNG file.
|
||||
return deflateSyncUncompressed(literals);
|
||||
}
|
||||
try {
|
||||
|
@ -248,7 +248,8 @@ if (
|
||||
return;
|
||||
}
|
||||
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
|
||||
// The `URL` constructor is assumed to be available in the extension builds.
|
||||
// The `URL` constructor is assumed to be available in the extension
|
||||
// builds.
|
||||
return;
|
||||
}
|
||||
globalThis.URL = require("core-js/web/url");
|
||||
|
@ -73,7 +73,7 @@ function readCharstringEncoding(aString) {
|
||||
var charstringTokens = [];
|
||||
|
||||
var count = aString.length;
|
||||
for (var i = 0; i < count; ) { // eslint-disable-line space-in-parens
|
||||
for (var i = 0; i < count; ) {
|
||||
var value = aString[i++] | 0;
|
||||
var token = null;
|
||||
|
||||
|
@ -9,7 +9,7 @@ const gitIgnore = "test/pdfs/.gitignore";
|
||||
if (process.argv.length < 3) {
|
||||
console.log("\nUsage: node add_test.js FILE\n");
|
||||
console.log(
|
||||
" Add a PDF as a reference test. FILE must be located in " + `${pdfFolder}`
|
||||
` Add a PDF as a reference test. FILE must be located in ${pdfFolder}`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -277,8 +277,8 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var Driver = (function DriverClosure() {
|
||||
// eslint-disable-line no-unused-vars
|
||||
/**
|
||||
* @constructs Driver
|
||||
* @param {DriverOptions} options
|
||||
|
@ -19,8 +19,8 @@
|
||||
var base64alphabet =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function decodeFontData(base64) {
|
||||
// eslint-disable-line no-unused-vars
|
||||
var result = [];
|
||||
|
||||
var bits = 0,
|
||||
@ -68,8 +68,8 @@ function encodeFontData(data) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function ttx(data, callback) {
|
||||
// eslint-disable-line no-unused-vars
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/ttx");
|
||||
|
||||
@ -89,8 +89,8 @@ function ttx(data, callback) {
|
||||
xhr.send(encodedData);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function verifyTtxOutput(output) {
|
||||
// eslint-disable-line no-unused-vars
|
||||
var m = /^<error>(.*?)<\/error>/.exec(output);
|
||||
if (m) {
|
||||
throw m[1];
|
||||
|
@ -889,8 +889,8 @@ function main() {
|
||||
} else if (!options.browser && !options.browserManifestFile) {
|
||||
startServer();
|
||||
} else if (options.unitTest) {
|
||||
// Allows linked PDF files in unit-tests as well.
|
||||
ensurePDFsDownloaded(function() {
|
||||
// Allows linked PDF files in unit-tests.
|
||||
startUnitTest("/test/unit/unit_test.html", "unit");
|
||||
});
|
||||
} else if (options.fontTest) {
|
||||
|
@ -124,8 +124,8 @@ describe("core_utils", function() {
|
||||
const dict = new Dict();
|
||||
let currentDict = dict;
|
||||
let parentDict = null;
|
||||
// Exceed the loop limit of 100.
|
||||
for (let i = 0; i < 150; i++) {
|
||||
// Exceeds the loop limit of 100.
|
||||
parentDict = new Dict();
|
||||
currentDict.set("Parent", parentDict);
|
||||
currentDict = parentDict;
|
||||
|
@ -89,7 +89,7 @@ describe("crypto", function() {
|
||||
it("should pass RFC 1321 test #6", function() {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv" + "wxyz0123456789"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
);
|
||||
result = calculateMD5(input, 0, input.length);
|
||||
expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
|
||||
@ -209,12 +209,12 @@ describe("crypto", function() {
|
||||
var key, input, result, expected, cipher;
|
||||
key = hex2binary("0123456789abcdef");
|
||||
input = hex2binary(
|
||||
"123456789abcdef0123456789abcdef0123456789abcdef0123" + "45678"
|
||||
"123456789abcdef0123456789abcdef0123456789abcdef012345678"
|
||||
);
|
||||
cipher = new ARCFourCipher(key);
|
||||
result = cipher.encryptBlock(input);
|
||||
expected = hex2binary(
|
||||
"66a0949f8af7d6891f7f832ba833c00c892ebe30143ce287" + "40011ecf"
|
||||
"66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf"
|
||||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
@ -226,18 +226,18 @@ describe("crypto", function() {
|
||||
input = stringToBytes("abc");
|
||||
result = calculateSHA256(input, 0, input.length);
|
||||
expected = hex2binary(
|
||||
"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C" + "B410FF61F20015AD"
|
||||
"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"
|
||||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
it("should properly hash a multiblock input", function() {
|
||||
var input, result, expected;
|
||||
input = stringToBytes(
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno" + "mnopnopq"
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||
);
|
||||
result = calculateSHA256(input, 0, input.length);
|
||||
expected = hex2binary(
|
||||
"248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167" + "F6ECEDD419DB06C1"
|
||||
"248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1"
|
||||
);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ describe("parser", function() {
|
||||
|
||||
it("should skip to the end of stream if the EI marker is not found", function() {
|
||||
const string =
|
||||
"q 1 0 0 1 0 0 cm BI /W 10 /H 10 /BPC 1 " + "/F /A85 ID abc123~> Q";
|
||||
"q 1 0 0 1 0 0 cm BI /W 10 /H 10 /BPC 1 /F /A85 ID abc123~> Q";
|
||||
const input = new StringStream(string);
|
||||
const parser = new Parser({
|
||||
lexer: new Lexer(input),
|
||||
@ -320,7 +320,7 @@ describe("parser", function() {
|
||||
return Linearization.create(stream2);
|
||||
}).toThrow(
|
||||
new Error(
|
||||
'The "E" parameter in the linearization ' + "dictionary is invalid."
|
||||
'The "E" parameter in the linearization dictionary is invalid.'
|
||||
)
|
||||
);
|
||||
|
||||
@ -343,7 +343,7 @@ describe("parser", function() {
|
||||
return Linearization.create(stream3);
|
||||
}).toThrow(
|
||||
new Error(
|
||||
'The "O" parameter in the linearization ' + "dictionary is invalid."
|
||||
'The "O" parameter in the linearization dictionary is invalid.'
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -368,7 +368,7 @@ describe("parser", function() {
|
||||
expect(function() {
|
||||
return Linearization.create(stream1);
|
||||
}).toThrow(
|
||||
new Error("Hint array in the linearization dictionary " + "is invalid.")
|
||||
new Error("Hint array in the linearization dictionary is invalid.")
|
||||
);
|
||||
|
||||
// The hint array should contain two, or four, elements.
|
||||
@ -389,7 +389,7 @@ describe("parser", function() {
|
||||
expect(function() {
|
||||
return Linearization.create(stream2);
|
||||
}).toThrow(
|
||||
new Error("Hint array in the linearization dictionary " + "is invalid.")
|
||||
new Error("Hint array in the linearization dictionary is invalid.")
|
||||
);
|
||||
|
||||
// The hint array should not contain zero.
|
||||
@ -410,7 +410,7 @@ describe("parser", function() {
|
||||
expect(function() {
|
||||
return Linearization.create(stream3);
|
||||
}).toThrow(
|
||||
new Error("Hint (2) in the linearization dictionary " + "is invalid.")
|
||||
new Error("Hint (2) in the linearization dictionary is invalid.")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
27
web/app.js
27
web/app.js
@ -1103,7 +1103,8 @@ let PDFViewerApplication = {
|
||||
`${values.scrollLeft},${values.scrollTop}`;
|
||||
|
||||
rotation = parseInt(values.rotation, 10);
|
||||
// Always let user preferences take precedence over the view history.
|
||||
// Always let user preferences take precedence over the view
|
||||
// history.
|
||||
if (sidebarView === SidebarView.UNKNOWN) {
|
||||
sidebarView = values.sidebarView | 0;
|
||||
}
|
||||
@ -1135,11 +1136,13 @@ let PDFViewerApplication = {
|
||||
pdfViewer.focus();
|
||||
}
|
||||
|
||||
// For documents with different page sizes, once all pages are resolved,
|
||||
// ensure that the correct location becomes visible on load.
|
||||
// For documents with different page sizes, once all pages are
|
||||
// resolved, ensure that the correct location becomes visible on
|
||||
// load.
|
||||
// (To reduce the risk, in very large and/or slow loading documents,
|
||||
// that the location changes *after* the user has started interacting
|
||||
// with the viewer, wait for either `pagesPromise` or a timeout.)
|
||||
// that the location changes *after* the user has started
|
||||
// interacting with the viewer, wait for either `pagesPromise` or
|
||||
// a timeout.)
|
||||
await Promise.race([
|
||||
pagesPromise,
|
||||
new Promise(resolve => {
|
||||
@ -1283,8 +1286,9 @@ let PDFViewerApplication = {
|
||||
// Ghostscript can produce invalid 'dc:title' Metadata entries:
|
||||
// - The title may be "Untitled" (fixes bug 1031612).
|
||||
// - The title may contain incorrectly encoded characters, which thus
|
||||
// looks broken, hence we ignore the Metadata entry when it contains
|
||||
// characters from the Specials Unicode block (fixes bug 1605526).
|
||||
// looks broken, hence we ignore the Metadata entry when it
|
||||
// contains characters from the Specials Unicode block
|
||||
// (fixes bug 1605526).
|
||||
if (
|
||||
metadataTitle !== "Untitled" &&
|
||||
!/[\uFFF0-\uFFFF]/g.test(metadataTitle)
|
||||
@ -1481,7 +1485,7 @@ let PDFViewerApplication = {
|
||||
.get(
|
||||
"printing_not_supported",
|
||||
null,
|
||||
"Warning: Printing is not fully supported by " + "this browser."
|
||||
"Warning: Printing is not fully supported by this browser."
|
||||
)
|
||||
.then(printMessage => {
|
||||
this.error(printMessage);
|
||||
@ -2555,14 +2559,13 @@ function webViewerKeyDown(evt) {
|
||||
(curElement && curElement.isContentEditable)
|
||||
) {
|
||||
// Make sure that the secondary toolbar is closed when Escape is pressed.
|
||||
if (evt.keyCode !== 27) {
|
||||
// 'Esc'
|
||||
if (evt.keyCode !== /* Esc = */ 27) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No control key pressed at all.
|
||||
if (cmd === 0) {
|
||||
// no control key pressed at all.
|
||||
let turnPage = 0,
|
||||
turnOnlyIfPageFit = false;
|
||||
switch (evt.keyCode) {
|
||||
@ -2680,8 +2683,8 @@ function webViewerKeyDown(evt) {
|
||||
}
|
||||
}
|
||||
|
||||
// shift-key
|
||||
if (cmd === 4) {
|
||||
// shift-key
|
||||
switch (evt.keyCode) {
|
||||
case 13: // enter key
|
||||
case 32: // spacebar
|
||||
|
@ -22,7 +22,7 @@ import { GenericL10n } from "./genericl10n";
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||
throw new Error(
|
||||
'Module "pdfjs-web/chromecom" shall not be used outside ' + "CHROME build."
|
||||
'Module "pdfjs-web/chromecom" shall not be used outside CHROME build.'
|
||||
);
|
||||
}
|
||||
|
||||
@ -178,11 +178,9 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
|
||||
// Use Chrome's definition of UI language instead of PDF.js's #lang=...,
|
||||
// because the shown string should match the UI at chrome://extensions.
|
||||
// These strings are from chrome/app/resources/generated_resources_*.xtb.
|
||||
/* eslint-disable no-unexpected-multiline */
|
||||
let i18nFileAccessLabel = PDFJSDev.json(
|
||||
"$ROOT/web/chrome-i18n-allow-access-to-file-urls.json"
|
||||
)[chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()];
|
||||
/* eslint-enable no-unexpected-multiline */
|
||||
|
||||
if (i18nFileAccessLabel) {
|
||||
document.getElementById(
|
||||
|
@ -217,7 +217,7 @@ class MozL10n {
|
||||
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
|
||||
// when using the `Ctrl + 0` keyboard shortcut.
|
||||
if (
|
||||
type === "zoomreset" && // eslint-disable-next-line max-len
|
||||
type === "zoomreset" &&
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE
|
||||
) {
|
||||
return;
|
||||
|
@ -119,8 +119,7 @@ class OverlayManager {
|
||||
* @private
|
||||
*/
|
||||
_keyDown(evt) {
|
||||
if (this._active && evt.keyCode === 27) {
|
||||
// Esc key.
|
||||
if (this._active && evt.keyCode === /* Esc = */ 27) {
|
||||
this._closeThroughCaller();
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ class PasswordPrompt {
|
||||
this.submitButton.addEventListener("click", this.verify.bind(this));
|
||||
this.cancelButton.addEventListener("click", this.close.bind(this));
|
||||
this.input.addEventListener("keydown", e => {
|
||||
if (e.keyCode === 13) {
|
||||
// Enter key
|
||||
if (e.keyCode === /* Enter = */ 13) {
|
||||
this.verify();
|
||||
}
|
||||
});
|
||||
|
@ -95,8 +95,8 @@ class PDFAttachmentViewer {
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
// In the Chrome extension, the URL is rewritten using the history API
|
||||
// in viewer.js, so an absolute URL must be generated.
|
||||
// eslint-disable-next-line no-undef
|
||||
viewerUrl =
|
||||
// eslint-disable-next-line no-undef
|
||||
chrome.runtime.getURL("/content/web/viewer.html") +
|
||||
"?file=" +
|
||||
encodeURIComponent(blobUrl + "#" + filename);
|
||||
|
@ -86,9 +86,8 @@ class PDFCursorTools {
|
||||
}
|
||||
};
|
||||
|
||||
switch (
|
||||
tool // Enable the new cursor tool.
|
||||
) {
|
||||
// Enable the new cursor tool.
|
||||
switch (tool) {
|
||||
case CursorTool.SELECT:
|
||||
disableActiveTool();
|
||||
break;
|
||||
|
@ -202,13 +202,13 @@ class PDFFindController {
|
||||
this._pageMatches = [];
|
||||
this._pageMatchesLength = [];
|
||||
this._state = null;
|
||||
// Currently selected match.
|
||||
this._selected = {
|
||||
// Currently selected match.
|
||||
pageIdx: -1,
|
||||
matchIdx: -1,
|
||||
};
|
||||
// Where the find algorithm currently is in the document.
|
||||
this._offset = {
|
||||
// Where the find algorithm currently is in the document.
|
||||
pageIdx: null,
|
||||
matchIdx: null,
|
||||
wrapped: false,
|
||||
|
@ -352,8 +352,8 @@ class PDFHistory {
|
||||
let newUrl;
|
||||
if (this._updateUrl && destination && destination.hash) {
|
||||
const baseUrl = document.location.href.split("#")[0];
|
||||
// Prevent errors in Firefox.
|
||||
if (!baseUrl.startsWith("file://")) {
|
||||
// Prevent errors in Firefox.
|
||||
newUrl = `${baseUrl}#${destination.hash}`;
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +215,8 @@ class PDFPageView {
|
||||
|
||||
update(scale, rotation) {
|
||||
this.scale = scale || this.scale;
|
||||
// The rotation may be zero.
|
||||
if (typeof rotation !== "undefined") {
|
||||
// The rotation may be zero.
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,8 @@ window.addEventListener(
|
||||
) {
|
||||
window.print();
|
||||
|
||||
// The (browser) print dialog cannot be prevented from being shown in IE11.
|
||||
// The (browser) print dialog cannot be prevented from being shown in
|
||||
// IE11.
|
||||
event.preventDefault();
|
||||
if (event.stopImmediatePropagation) {
|
||||
event.stopImmediatePropagation();
|
||||
|
@ -389,8 +389,8 @@ class PDFSidebar {
|
||||
removeNotification(view);
|
||||
return;
|
||||
}
|
||||
// Remove all sidebar notifications on reset.
|
||||
for (view in SidebarView) {
|
||||
// Remove all sidebar notifications on reset.
|
||||
removeNotification(SidebarView[view]);
|
||||
}
|
||||
|
||||
|
@ -250,11 +250,11 @@ class Toolbar {
|
||||
const width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
|
||||
select.setAttribute(
|
||||
"style",
|
||||
"min-width: " + (width + SCALE_SELECT_PADDING) + "px;"
|
||||
`min-width: ${width + SCALE_SELECT_PADDING}px;`
|
||||
);
|
||||
container.setAttribute(
|
||||
"style",
|
||||
"min-width: " + width + "px; " + "max-width: " + width + "px;"
|
||||
`min-width: ${width}px; max-width: ${width}px;`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user