mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-06 07:05:48 +02:00
Merge pull request #20657 from Snuffleupagus/unicorn-prefer-class-fields
Enable the `unicorn/prefer-class-fields` ESLint plugin rule
This commit is contained in:
commit
1d6307f5d4
@ -148,6 +148,7 @@ export default [
|
|||||||
"unicorn/prefer-array-index-of": "error",
|
"unicorn/prefer-array-index-of": "error",
|
||||||
"unicorn/prefer-array-some": "error",
|
"unicorn/prefer-array-some": "error",
|
||||||
"unicorn/prefer-at": "error",
|
"unicorn/prefer-at": "error",
|
||||||
|
"unicorn/prefer-class-fields": "error",
|
||||||
"unicorn/prefer-classlist-toggle": "error",
|
"unicorn/prefer-classlist-toggle": "error",
|
||||||
"unicorn/prefer-date-now": "error",
|
"unicorn/prefer-date-now": "error",
|
||||||
"unicorn/prefer-dom-node-append": "error",
|
"unicorn/prefer-dom-node-append": "error",
|
||||||
|
|||||||
@ -1462,14 +1462,17 @@ class Annotation {
|
|||||||
* Contains all data regarding an annotation's border style.
|
* Contains all data regarding an annotation's border style.
|
||||||
*/
|
*/
|
||||||
class AnnotationBorderStyle {
|
class AnnotationBorderStyle {
|
||||||
constructor() {
|
width = 1;
|
||||||
this.width = 1;
|
|
||||||
this.rawWidth = 1;
|
rawWidth = 1;
|
||||||
this.style = AnnotationBorderStyleType.SOLID;
|
|
||||||
this.dashArray = [3];
|
style = AnnotationBorderStyleType.SOLID;
|
||||||
this.horizontalCornerRadius = 0;
|
|
||||||
this.verticalCornerRadius = 0;
|
dashArray = [3];
|
||||||
}
|
|
||||||
|
horizontalCornerRadius = 0;
|
||||||
|
|
||||||
|
verticalCornerRadius = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the width.
|
* Set the width.
|
||||||
|
|||||||
@ -991,24 +991,31 @@ class CFFParser {
|
|||||||
|
|
||||||
// Compact Font Format
|
// Compact Font Format
|
||||||
class CFF {
|
class CFF {
|
||||||
constructor() {
|
header = null;
|
||||||
this.header = null;
|
|
||||||
this.names = [];
|
|
||||||
this.topDict = null;
|
|
||||||
this.strings = new CFFStrings();
|
|
||||||
this.globalSubrIndex = null;
|
|
||||||
|
|
||||||
// The following could really be per font, but since we only have one font
|
names = [];
|
||||||
// store them here.
|
|
||||||
this.encoding = null;
|
|
||||||
this.charset = null;
|
|
||||||
this.charStrings = null;
|
|
||||||
this.fdArray = [];
|
|
||||||
this.fdSelect = null;
|
|
||||||
|
|
||||||
this.isCIDFont = false;
|
topDict = null;
|
||||||
this.charStringCount = 0;
|
|
||||||
}
|
strings = new CFFStrings();
|
||||||
|
|
||||||
|
globalSubrIndex = null;
|
||||||
|
|
||||||
|
// The following could really be per font, but since we only have one font
|
||||||
|
// store them here.
|
||||||
|
encoding = null;
|
||||||
|
|
||||||
|
charset = null;
|
||||||
|
|
||||||
|
charStrings = null;
|
||||||
|
|
||||||
|
fdArray = [];
|
||||||
|
|
||||||
|
fdSelect = null;
|
||||||
|
|
||||||
|
isCIDFont = false;
|
||||||
|
|
||||||
|
charStringCount = 0;
|
||||||
|
|
||||||
duplicateFirstGlyph() {
|
duplicateFirstGlyph() {
|
||||||
// Browsers will not display a glyph at position 0. Typically glyph 0 is
|
// Browsers will not display a glyph at position 0. Typically glyph 0 is
|
||||||
|
|||||||
@ -32,9 +32,11 @@ import { calculateSHA256 } from "./calculate_sha256.js";
|
|||||||
import { DecryptStream } from "./decrypt_stream.js";
|
import { DecryptStream } from "./decrypt_stream.js";
|
||||||
|
|
||||||
class ARCFourCipher {
|
class ARCFourCipher {
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
b = 0;
|
||||||
|
|
||||||
constructor(key) {
|
constructor(key) {
|
||||||
this.a = 0;
|
|
||||||
this.b = 0;
|
|
||||||
const s = new Uint8Array(256);
|
const s = new Uint8Array(256);
|
||||||
const keyLength = key.length;
|
const keyLength = key.length;
|
||||||
|
|
||||||
|
|||||||
@ -74,33 +74,52 @@ class XRefWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PDFEditor {
|
class PDFEditor {
|
||||||
|
hasSingleFile = false;
|
||||||
|
|
||||||
|
currentDocument = null;
|
||||||
|
|
||||||
|
oldPages = [];
|
||||||
|
|
||||||
|
newPages = [];
|
||||||
|
|
||||||
|
xref = [null];
|
||||||
|
|
||||||
|
xrefWrapper = new XRefWrapper(this.xref);
|
||||||
|
|
||||||
|
newRefCount = 1;
|
||||||
|
|
||||||
|
namesDict = null;
|
||||||
|
|
||||||
|
version = "1.7";
|
||||||
|
|
||||||
|
pageLabels = null;
|
||||||
|
|
||||||
|
namedDestinations = new Map();
|
||||||
|
|
||||||
|
parentTree = new Map();
|
||||||
|
|
||||||
|
structTreeKids = [];
|
||||||
|
|
||||||
|
idTree = new Map();
|
||||||
|
|
||||||
|
classMap = new Dict();
|
||||||
|
|
||||||
|
roleMap = new Dict();
|
||||||
|
|
||||||
|
namespaces = new Map();
|
||||||
|
|
||||||
|
structTreeAF = [];
|
||||||
|
|
||||||
|
structTreePronunciationLexicon = [];
|
||||||
|
|
||||||
constructor({ useObjectStreams = true, title = "", author = "" } = {}) {
|
constructor({ useObjectStreams = true, title = "", author = "" } = {}) {
|
||||||
this.hasSingleFile = false;
|
|
||||||
this.currentDocument = null;
|
|
||||||
this.oldPages = [];
|
|
||||||
this.newPages = [];
|
|
||||||
this.xref = [null];
|
|
||||||
this.xrefWrapper = new XRefWrapper(this.xref);
|
|
||||||
this.newRefCount = 1;
|
|
||||||
[this.rootRef, this.rootDict] = this.newDict;
|
[this.rootRef, this.rootDict] = this.newDict;
|
||||||
[this.infoRef, this.infoDict] = this.newDict;
|
[this.infoRef, this.infoDict] = this.newDict;
|
||||||
[this.pagesRef, this.pagesDict] = this.newDict;
|
[this.pagesRef, this.pagesDict] = this.newDict;
|
||||||
this.namesDict = null;
|
|
||||||
this.useObjectStreams = useObjectStreams;
|
this.useObjectStreams = useObjectStreams;
|
||||||
this.objStreamRefs = useObjectStreams ? new Set() : null;
|
this.objStreamRefs = useObjectStreams ? new Set() : null;
|
||||||
this.version = "1.7";
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.pageLabels = null;
|
|
||||||
this.namedDestinations = new Map();
|
|
||||||
this.parentTree = new Map();
|
|
||||||
this.structTreeKids = [];
|
|
||||||
this.idTree = new Map();
|
|
||||||
this.classMap = new Dict();
|
|
||||||
this.roleMap = new Dict();
|
|
||||||
this.namespaces = new Map();
|
|
||||||
this.structTreeAF = [];
|
|
||||||
this.structTreePronunciationLexicon = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -79,13 +79,15 @@ const COMMAND_MAP = {
|
|||||||
* the charStrings.
|
* the charStrings.
|
||||||
*/
|
*/
|
||||||
class Type1CharString {
|
class Type1CharString {
|
||||||
constructor() {
|
width = 0;
|
||||||
this.width = 0;
|
|
||||||
this.lsb = 0;
|
lsb = 0;
|
||||||
this.flexing = false;
|
|
||||||
this.output = [];
|
flexing = false;
|
||||||
this.stack = [];
|
|
||||||
}
|
output = [];
|
||||||
|
|
||||||
|
stack = [];
|
||||||
|
|
||||||
convert(encoded, subrs, seacAnalysisEnabled) {
|
convert(encoded, subrs, seacAnalysisEnabled) {
|
||||||
const count = encoded.length;
|
const count = encoded.length;
|
||||||
|
|||||||
@ -35,15 +35,17 @@ class AnnotationStorage {
|
|||||||
|
|
||||||
#storage = new Map();
|
#storage = new Map();
|
||||||
|
|
||||||
constructor() {
|
// Callbacks to signal when the modification state is set or reset.
|
||||||
// Callbacks to signal when the modification state is set or reset.
|
// This is used by the viewer to only bind on `beforeunload` if forms
|
||||||
// This is used by the viewer to only bind on `beforeunload` if forms
|
// are actually edited to prevent doing so unconditionally since that
|
||||||
// are actually edited to prevent doing so unconditionally since that
|
// can have undesirable effects.
|
||||||
// can have undesirable effects.
|
onSetModified = null;
|
||||||
this.onSetModified = null;
|
|
||||||
this.onResetModified = null;
|
|
||||||
this.onAnnotationEditor = null;
|
|
||||||
|
|
||||||
|
onResetModified = null;
|
||||||
|
|
||||||
|
onAnnotationEditor = null;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
// For testing purposes.
|
// For testing purposes.
|
||||||
Object.defineProperty(this, "_setValues", {
|
Object.defineProperty(this, "_setValues", {
|
||||||
|
|||||||
@ -14,132 +14,165 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class PrintParams {
|
class PrintParams {
|
||||||
|
binaryOk = true;
|
||||||
|
|
||||||
|
bitmapDPI = 150;
|
||||||
|
|
||||||
|
booklet = {
|
||||||
|
binding: 0,
|
||||||
|
duplexMode: 0,
|
||||||
|
subsetFrom: 0,
|
||||||
|
subsetTo: -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
colorOverride = 0;
|
||||||
|
|
||||||
|
colorProfile = "";
|
||||||
|
|
||||||
|
constants = Object.freeze({
|
||||||
|
bookletBindings: Object.freeze({
|
||||||
|
Left: 0,
|
||||||
|
Right: 1,
|
||||||
|
LeftTall: 2,
|
||||||
|
RightTall: 3,
|
||||||
|
}),
|
||||||
|
bookletDuplexMode: Object.freeze({
|
||||||
|
BothSides: 0,
|
||||||
|
FrontSideOnly: 1,
|
||||||
|
BasicSideOnly: 2,
|
||||||
|
}),
|
||||||
|
colorOverrides: Object.freeze({
|
||||||
|
auto: 0,
|
||||||
|
gray: 1,
|
||||||
|
mono: 2,
|
||||||
|
}),
|
||||||
|
fontPolicies: Object.freeze({
|
||||||
|
everyPage: 0,
|
||||||
|
jobStart: 1,
|
||||||
|
pageRange: 2,
|
||||||
|
}),
|
||||||
|
handling: Object.freeze({
|
||||||
|
none: 0,
|
||||||
|
fit: 1,
|
||||||
|
shrink: 2,
|
||||||
|
tileAll: 3,
|
||||||
|
tileLarge: 4,
|
||||||
|
nUp: 5,
|
||||||
|
booklet: 6,
|
||||||
|
}),
|
||||||
|
interactionLevel: Object.freeze({
|
||||||
|
automatic: 0,
|
||||||
|
full: 1,
|
||||||
|
silent: 2,
|
||||||
|
}),
|
||||||
|
nUpPageOrders: Object.freeze({
|
||||||
|
Horizontal: 0,
|
||||||
|
HorizontalReversed: 1,
|
||||||
|
Vertical: 2,
|
||||||
|
}),
|
||||||
|
printContents: Object.freeze({
|
||||||
|
doc: 0,
|
||||||
|
docAndComments: 1,
|
||||||
|
formFieldsOnly: 2,
|
||||||
|
}),
|
||||||
|
flagValues: Object.freeze({
|
||||||
|
applyOverPrint: 1,
|
||||||
|
applySoftProofSettings: 1 << 1,
|
||||||
|
applyWorkingColorSpaces: 1 << 2,
|
||||||
|
emitHalftones: 1 << 3,
|
||||||
|
emitPostScriptXObjects: 1 << 4,
|
||||||
|
emitFormsAsPSForms: 1 << 5,
|
||||||
|
maxJP2KRes: 1 << 6,
|
||||||
|
setPageSize: 1 << 7,
|
||||||
|
suppressBG: 1 << 8,
|
||||||
|
suppressCenter: 1 << 9,
|
||||||
|
suppressCJKFontSubst: 1 << 10,
|
||||||
|
suppressCropClip: 1 << 1,
|
||||||
|
suppressRotate: 1 << 12,
|
||||||
|
suppressTransfer: 1 << 13,
|
||||||
|
suppressUCR: 1 << 14,
|
||||||
|
useTrapAnnots: 1 << 15,
|
||||||
|
usePrintersMarks: 1 << 16,
|
||||||
|
}),
|
||||||
|
rasterFlagValues: Object.freeze({
|
||||||
|
textToOutline: 1,
|
||||||
|
strokesToOutline: 1 << 1,
|
||||||
|
allowComplexClip: 1 << 2,
|
||||||
|
preserveOverprint: 1 << 3,
|
||||||
|
}),
|
||||||
|
subsets: Object.freeze({
|
||||||
|
all: 0,
|
||||||
|
even: 1,
|
||||||
|
odd: 2,
|
||||||
|
}),
|
||||||
|
tileMarks: Object.freeze({
|
||||||
|
none: 0,
|
||||||
|
west: 1,
|
||||||
|
east: 2,
|
||||||
|
}),
|
||||||
|
usages: Object.freeze({
|
||||||
|
auto: 0,
|
||||||
|
use: 1,
|
||||||
|
noUse: 2,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
downloadFarEastFonts = false;
|
||||||
|
|
||||||
|
fileName = "";
|
||||||
|
|
||||||
|
firstPage = 0;
|
||||||
|
|
||||||
|
flags = 0;
|
||||||
|
|
||||||
|
fontPolicy = 0;
|
||||||
|
|
||||||
|
gradientDPI = 150;
|
||||||
|
|
||||||
|
interactive = 1;
|
||||||
|
|
||||||
|
npUpAutoRotate = false;
|
||||||
|
|
||||||
|
npUpNumPagesH = 2;
|
||||||
|
|
||||||
|
npUpNumPagesV = 2;
|
||||||
|
|
||||||
|
npUpPageBorder = false;
|
||||||
|
|
||||||
|
npUpPageOrder = 0;
|
||||||
|
|
||||||
|
pageHandling = 0;
|
||||||
|
|
||||||
|
pageSubset = 0;
|
||||||
|
|
||||||
|
printAsImage = false;
|
||||||
|
|
||||||
|
printContent = 0;
|
||||||
|
|
||||||
|
printerName = "";
|
||||||
|
|
||||||
|
psLevel = 0;
|
||||||
|
|
||||||
|
rasterFlags = 0;
|
||||||
|
|
||||||
|
reversePages = false;
|
||||||
|
|
||||||
|
tileLabel = false;
|
||||||
|
|
||||||
|
tileMark = 0;
|
||||||
|
|
||||||
|
tileOverlap = 0;
|
||||||
|
|
||||||
|
tileScale = 1.0;
|
||||||
|
|
||||||
|
transparencyLevel = 75;
|
||||||
|
|
||||||
|
usePrinterCRD = 0;
|
||||||
|
|
||||||
|
useT1Conversion = 0;
|
||||||
|
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
this.binaryOk = true;
|
|
||||||
this.bitmapDPI = 150;
|
|
||||||
this.booklet = {
|
|
||||||
binding: 0,
|
|
||||||
duplexMode: 0,
|
|
||||||
subsetFrom: 0,
|
|
||||||
subsetTo: -1,
|
|
||||||
};
|
|
||||||
this.colorOverride = 0;
|
|
||||||
this.colorProfile = "";
|
|
||||||
this.constants = Object.freeze({
|
|
||||||
bookletBindings: Object.freeze({
|
|
||||||
Left: 0,
|
|
||||||
Right: 1,
|
|
||||||
LeftTall: 2,
|
|
||||||
RightTall: 3,
|
|
||||||
}),
|
|
||||||
bookletDuplexMode: Object.freeze({
|
|
||||||
BothSides: 0,
|
|
||||||
FrontSideOnly: 1,
|
|
||||||
BasicSideOnly: 2,
|
|
||||||
}),
|
|
||||||
colorOverrides: Object.freeze({
|
|
||||||
auto: 0,
|
|
||||||
gray: 1,
|
|
||||||
mono: 2,
|
|
||||||
}),
|
|
||||||
fontPolicies: Object.freeze({
|
|
||||||
everyPage: 0,
|
|
||||||
jobStart: 1,
|
|
||||||
pageRange: 2,
|
|
||||||
}),
|
|
||||||
handling: Object.freeze({
|
|
||||||
none: 0,
|
|
||||||
fit: 1,
|
|
||||||
shrink: 2,
|
|
||||||
tileAll: 3,
|
|
||||||
tileLarge: 4,
|
|
||||||
nUp: 5,
|
|
||||||
booklet: 6,
|
|
||||||
}),
|
|
||||||
interactionLevel: Object.freeze({
|
|
||||||
automatic: 0,
|
|
||||||
full: 1,
|
|
||||||
silent: 2,
|
|
||||||
}),
|
|
||||||
nUpPageOrders: Object.freeze({
|
|
||||||
Horizontal: 0,
|
|
||||||
HorizontalReversed: 1,
|
|
||||||
Vertical: 2,
|
|
||||||
}),
|
|
||||||
printContents: Object.freeze({
|
|
||||||
doc: 0,
|
|
||||||
docAndComments: 1,
|
|
||||||
formFieldsOnly: 2,
|
|
||||||
}),
|
|
||||||
flagValues: Object.freeze({
|
|
||||||
applyOverPrint: 1,
|
|
||||||
applySoftProofSettings: 1 << 1,
|
|
||||||
applyWorkingColorSpaces: 1 << 2,
|
|
||||||
emitHalftones: 1 << 3,
|
|
||||||
emitPostScriptXObjects: 1 << 4,
|
|
||||||
emitFormsAsPSForms: 1 << 5,
|
|
||||||
maxJP2KRes: 1 << 6,
|
|
||||||
setPageSize: 1 << 7,
|
|
||||||
suppressBG: 1 << 8,
|
|
||||||
suppressCenter: 1 << 9,
|
|
||||||
suppressCJKFontSubst: 1 << 10,
|
|
||||||
suppressCropClip: 1 << 1,
|
|
||||||
suppressRotate: 1 << 12,
|
|
||||||
suppressTransfer: 1 << 13,
|
|
||||||
suppressUCR: 1 << 14,
|
|
||||||
useTrapAnnots: 1 << 15,
|
|
||||||
usePrintersMarks: 1 << 16,
|
|
||||||
}),
|
|
||||||
rasterFlagValues: Object.freeze({
|
|
||||||
textToOutline: 1,
|
|
||||||
strokesToOutline: 1 << 1,
|
|
||||||
allowComplexClip: 1 << 2,
|
|
||||||
preserveOverprint: 1 << 3,
|
|
||||||
}),
|
|
||||||
subsets: Object.freeze({
|
|
||||||
all: 0,
|
|
||||||
even: 1,
|
|
||||||
odd: 2,
|
|
||||||
}),
|
|
||||||
tileMarks: Object.freeze({
|
|
||||||
none: 0,
|
|
||||||
west: 1,
|
|
||||||
east: 2,
|
|
||||||
}),
|
|
||||||
usages: Object.freeze({
|
|
||||||
auto: 0,
|
|
||||||
use: 1,
|
|
||||||
noUse: 2,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
this.downloadFarEastFonts = false;
|
|
||||||
this.fileName = "";
|
|
||||||
this.firstPage = 0;
|
|
||||||
this.flags = 0;
|
|
||||||
this.fontPolicy = 0;
|
|
||||||
this.gradientDPI = 150;
|
|
||||||
this.interactive = 1;
|
|
||||||
this.lastPage = data.lastPage;
|
this.lastPage = data.lastPage;
|
||||||
this.npUpAutoRotate = false;
|
|
||||||
this.npUpNumPagesH = 2;
|
|
||||||
this.npUpNumPagesV = 2;
|
|
||||||
this.npUpPageBorder = false;
|
|
||||||
this.npUpPageOrder = 0;
|
|
||||||
this.pageHandling = 0;
|
|
||||||
this.pageSubset = 0;
|
|
||||||
this.printAsImage = false;
|
|
||||||
this.printContent = 0;
|
|
||||||
this.printerName = "";
|
|
||||||
this.psLevel = 0;
|
|
||||||
this.rasterFlags = 0;
|
|
||||||
this.reversePages = false;
|
|
||||||
this.tileLabel = false;
|
|
||||||
this.tileMark = 0;
|
|
||||||
this.tileOverlap = 0;
|
|
||||||
this.tileScale = 1.0;
|
|
||||||
this.transparencyLevel = 75;
|
|
||||||
this.usePrinterCRD = 0;
|
|
||||||
this.useT1Conversion = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,9 @@ class PDFFindBar {
|
|||||||
|
|
||||||
#resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
|
#resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
|
||||||
|
|
||||||
constructor(options, mainContainer, eventBus) {
|
opened = false;
|
||||||
this.opened = false;
|
|
||||||
|
|
||||||
|
constructor(options, mainContainer, eventBus) {
|
||||||
this.bar = options.bar;
|
this.bar = options.bar;
|
||||||
this.toggleButton = options.toggleButton;
|
this.toggleButton = options.toggleButton;
|
||||||
this.findField = options.findField;
|
this.findField = options.findField;
|
||||||
|
|||||||
@ -172,8 +172,7 @@ class PDFPageView extends BasePDFPageView {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
const container = options.container;
|
const { container, defaultViewport } = options;
|
||||||
const defaultViewport = options.defaultViewport;
|
|
||||||
|
|
||||||
this.renderingId = "page" + this.id;
|
this.renderingId = "page" + this.id;
|
||||||
this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
|
this.#layerProperties = options.layerProperties || DEFAULT_LAYER_PROPERTIES;
|
||||||
|
|||||||
@ -27,19 +27,24 @@ const CLEANUP_TIMEOUT = 30000;
|
|||||||
* Controls rendering of the views for pages and thumbnails.
|
* Controls rendering of the views for pages and thumbnails.
|
||||||
*/
|
*/
|
||||||
class PDFRenderingQueue {
|
class PDFRenderingQueue {
|
||||||
constructor() {
|
#highestPriorityPage = null;
|
||||||
this.pdfViewer = null;
|
|
||||||
this.pdfThumbnailViewer = null;
|
|
||||||
this.onIdle = null;
|
|
||||||
this.highestPriorityPage = null;
|
|
||||||
/** @type {number} */
|
|
||||||
this.idleTimeout = null;
|
|
||||||
this.printing = false;
|
|
||||||
this.isThumbnailViewEnabled = false;
|
|
||||||
|
|
||||||
|
#idleTimeout = null;
|
||||||
|
|
||||||
|
#pdfThumbnailViewer = null;
|
||||||
|
|
||||||
|
#pdfViewer = null;
|
||||||
|
|
||||||
|
isThumbnailViewEnabled = false;
|
||||||
|
|
||||||
|
onIdle = null;
|
||||||
|
|
||||||
|
printing = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
Object.defineProperty(this, "hasViewer", {
|
Object.defineProperty(this, "hasViewer", {
|
||||||
value: () => !!this.pdfViewer,
|
value: () => !!this.#pdfViewer,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,14 +53,14 @@ class PDFRenderingQueue {
|
|||||||
* @param {PDFViewer} pdfViewer
|
* @param {PDFViewer} pdfViewer
|
||||||
*/
|
*/
|
||||||
setViewer(pdfViewer) {
|
setViewer(pdfViewer) {
|
||||||
this.pdfViewer = pdfViewer;
|
this.#pdfViewer = pdfViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {PDFThumbnailViewer} pdfThumbnailViewer
|
* @param {PDFThumbnailViewer} pdfThumbnailViewer
|
||||||
*/
|
*/
|
||||||
setThumbnailViewer(pdfThumbnailViewer) {
|
setThumbnailViewer(pdfThumbnailViewer) {
|
||||||
this.pdfThumbnailViewer = pdfThumbnailViewer;
|
this.#pdfThumbnailViewer = pdfThumbnailViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,26 +68,26 @@ class PDFRenderingQueue {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isHighestPriority(view) {
|
isHighestPriority(view) {
|
||||||
return this.highestPriorityPage === view.renderingId;
|
return this.#highestPriorityPage === view.renderingId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} currentlyVisiblePages
|
* @param {Object} currentlyVisiblePages
|
||||||
*/
|
*/
|
||||||
renderHighestPriority(currentlyVisiblePages) {
|
renderHighestPriority(currentlyVisiblePages) {
|
||||||
if (this.idleTimeout) {
|
if (this.#idleTimeout) {
|
||||||
clearTimeout(this.idleTimeout);
|
clearTimeout(this.#idleTimeout);
|
||||||
this.idleTimeout = null;
|
this.#idleTimeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pages have a higher priority than thumbnails, so check them first.
|
// Pages have a higher priority than thumbnails, so check them first.
|
||||||
if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
|
if (this.#pdfViewer.forceRendering(currentlyVisiblePages)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// No pages needed rendering, so check thumbnails.
|
// No pages needed rendering, so check thumbnails.
|
||||||
if (
|
if (
|
||||||
this.isThumbnailViewEnabled &&
|
this.isThumbnailViewEnabled &&
|
||||||
this.pdfThumbnailViewer?.forceRendering()
|
this.#pdfThumbnailViewer?.forceRendering()
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,7 +98,7 @@ class PDFRenderingQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.onIdle) {
|
if (this.onIdle) {
|
||||||
this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
this.#idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,14 +207,14 @@ class PDFRenderingQueue {
|
|||||||
case RenderingStates.FINISHED:
|
case RenderingStates.FINISHED:
|
||||||
return false;
|
return false;
|
||||||
case RenderingStates.PAUSED:
|
case RenderingStates.PAUSED:
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.#highestPriorityPage = view.renderingId;
|
||||||
view.resume();
|
view.resume();
|
||||||
break;
|
break;
|
||||||
case RenderingStates.RUNNING:
|
case RenderingStates.RUNNING:
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.#highestPriorityPage = view.renderingId;
|
||||||
break;
|
break;
|
||||||
case RenderingStates.INITIAL:
|
case RenderingStates.INITIAL:
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.#highestPriorityPage = view.renderingId;
|
||||||
view
|
view
|
||||||
.draw()
|
.draw()
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user