mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Enable the dot-notation
ESLint rule
*Please note:* These changes were done automatically, using the `gulp lint --fix` command. This rule is already enabled in mozilla-central, see https://searchfox.org/mozilla-central/rev/567b68b8ff4b6d607ba34a6f1926873d21a7b4d7/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#103-104 The main advantage, besides improved consistency, of this rule is that it reduces the size of the code (by 3 bytes for each case). In the PDF.js code-base there's close to 8000 instances being fixed by the `dot-notation` ESLint rule, which end up reducing the size of even the *built* files significantly; the total size of the `gulp mozcentral` build target changes from `3 247 456` to `3 224 278` bytes, which is a *reduction* of `23 178` bytes (or ~0.7%) for a completely mechanical change. A large number of these changes affect the (large) lookup tables used on the worker-thread, but given that they are still initialized lazily I don't *think* that the new formatting this patch introduces should undo any of the improvements from PR 6915. Please find additional details about the ESLint rule at https://eslint.org/docs/rules/dot-notation
This commit is contained in:
parent
c218e94f66
commit
1cc3dbb694
26 changed files with 7773 additions and 7785 deletions
34
web/app.js
34
web/app.js
|
@ -263,41 +263,35 @@ const PDFViewerApplication = {
|
|||
const hashParams = parseQueryString(hash),
|
||||
waitOn = [];
|
||||
|
||||
if (
|
||||
"disableworker" in hashParams &&
|
||||
hashParams["disableworker"] === "true"
|
||||
) {
|
||||
if ("disableworker" in hashParams && hashParams.disableworker === "true") {
|
||||
waitOn.push(loadFakeWorker());
|
||||
}
|
||||
if ("disablerange" in hashParams) {
|
||||
AppOptions.set("disableRange", hashParams["disablerange"] === "true");
|
||||
AppOptions.set("disableRange", hashParams.disablerange === "true");
|
||||
}
|
||||
if ("disablestream" in hashParams) {
|
||||
AppOptions.set("disableStream", hashParams["disablestream"] === "true");
|
||||
AppOptions.set("disableStream", hashParams.disablestream === "true");
|
||||
}
|
||||
if ("disableautofetch" in hashParams) {
|
||||
AppOptions.set(
|
||||
"disableAutoFetch",
|
||||
hashParams["disableautofetch"] === "true"
|
||||
hashParams.disableautofetch === "true"
|
||||
);
|
||||
}
|
||||
if ("disablefontface" in hashParams) {
|
||||
AppOptions.set(
|
||||
"disableFontFace",
|
||||
hashParams["disablefontface"] === "true"
|
||||
);
|
||||
AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
|
||||
}
|
||||
if ("disablehistory" in hashParams) {
|
||||
AppOptions.set("disableHistory", hashParams["disablehistory"] === "true");
|
||||
AppOptions.set("disableHistory", hashParams.disablehistory === "true");
|
||||
}
|
||||
if ("webgl" in hashParams) {
|
||||
AppOptions.set("enableWebGL", hashParams["webgl"] === "true");
|
||||
AppOptions.set("enableWebGL", hashParams.webgl === "true");
|
||||
}
|
||||
if ("verbosity" in hashParams) {
|
||||
AppOptions.set("verbosity", hashParams["verbosity"] | 0);
|
||||
AppOptions.set("verbosity", hashParams.verbosity | 0);
|
||||
}
|
||||
if ("textlayer" in hashParams) {
|
||||
switch (hashParams["textlayer"]) {
|
||||
switch (hashParams.textlayer) {
|
||||
case "off":
|
||||
AppOptions.set("textLayerMode", TextLayerMode.DISABLE);
|
||||
break;
|
||||
|
@ -305,7 +299,7 @@ const PDFViewerApplication = {
|
|||
case "shadow":
|
||||
case "hover":
|
||||
const viewer = this.appConfig.viewerContainer;
|
||||
viewer.classList.add("textLayer-" + hashParams["textlayer"]);
|
||||
viewer.classList.add("textLayer-" + hashParams.textlayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +307,7 @@ const PDFViewerApplication = {
|
|||
AppOptions.set("pdfBug", true);
|
||||
AppOptions.set("fontExtraProperties", true);
|
||||
|
||||
const enabled = hashParams["pdfbug"].split(",");
|
||||
const enabled = hashParams.pdfbug.split(",");
|
||||
waitOn.push(loadAndEnablePDFBug(enabled));
|
||||
}
|
||||
// It is not possible to change locale for the (various) extension builds.
|
||||
|
@ -322,7 +316,7 @@ const PDFViewerApplication = {
|
|||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
"locale" in hashParams
|
||||
) {
|
||||
AppOptions.set("locale", hashParams["locale"]);
|
||||
AppOptions.set("locale", hashParams.locale);
|
||||
}
|
||||
|
||||
return Promise.all(waitOn).catch(reason => {
|
||||
|
@ -1004,7 +998,7 @@ const PDFViewerApplication = {
|
|||
// To prevent displaying a partially filled loading bar permanently, we
|
||||
// hide it when no data has been loaded during a certain amount of time.
|
||||
const disableAutoFetch = this.pdfDocument
|
||||
? this.pdfDocument.loadingParams["disableAutoFetch"]
|
||||
? this.pdfDocument.loadingParams.disableAutoFetch
|
||||
: AppOptions.get("disableAutoFetch");
|
||||
|
||||
if (disableAutoFetch && percent) {
|
||||
|
@ -1287,7 +1281,7 @@ const PDFViewerApplication = {
|
|||
|
||||
let pdfTitle;
|
||||
|
||||
const infoTitle = info && info["Title"];
|
||||
const infoTitle = info && info.Title;
|
||||
if (infoTitle) {
|
||||
pdfTitle = infoTitle;
|
||||
}
|
||||
|
|
|
@ -519,10 +519,7 @@ class BaseViewer {
|
|||
|
||||
// In addition to 'disableAutoFetch' being set, also attempt to reduce
|
||||
// resource usage when loading *very* long/large documents.
|
||||
if (
|
||||
pdfDocument.loadingParams["disableAutoFetch"] ||
|
||||
pagesCount > 7500
|
||||
) {
|
||||
if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
|
||||
// XXX: Printing is semi-broken with auto fetch disabled.
|
||||
this._pagesCapability.resolve();
|
||||
return;
|
||||
|
|
|
@ -118,8 +118,8 @@ class PDFDocumentProperties {
|
|||
// just update the dialog immediately to avoid redundant lookups.
|
||||
if (
|
||||
this.fieldData &&
|
||||
currentPageNumber === this.fieldData["_currentPageNumber"] &&
|
||||
pagesRotation === this.fieldData["_pagesRotation"]
|
||||
currentPageNumber === this.fieldData._currentPageNumber &&
|
||||
pagesRotation === this.fieldData._pagesRotation
|
||||
) {
|
||||
this._updateUI();
|
||||
return;
|
||||
|
@ -186,11 +186,11 @@ class PDFDocumentProperties {
|
|||
return this._parseFileSize(length);
|
||||
})
|
||||
.then(fileSize => {
|
||||
if (fileSize === this.fieldData["fileSize"]) {
|
||||
if (fileSize === this.fieldData.fileSize) {
|
||||
return; // The fileSize has already been correctly set.
|
||||
}
|
||||
const data = Object.assign(Object.create(null), this.fieldData);
|
||||
data["fileSize"] = fileSize;
|
||||
data.fileSize = fileSize;
|
||||
|
||||
freezeFieldData(data);
|
||||
this._updateUI();
|
||||
|
|
|
@ -228,8 +228,8 @@ class PDFLinkService {
|
|||
if ("search" in params) {
|
||||
this.eventBus.dispatch("findfromurlhash", {
|
||||
source: this,
|
||||
query: params["search"].replace(/"/g, ""),
|
||||
phraseSearch: params["phrase"] === "true",
|
||||
query: params.search.replace(/"/g, ""),
|
||||
phraseSearch: params.phrase === "true",
|
||||
});
|
||||
}
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
|
|
|
@ -66,7 +66,7 @@ function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
|
|||
this.printContainer = printContainer;
|
||||
this.l10n = l10n || NullL10n;
|
||||
this.disableCreateObjectURL =
|
||||
pdfDocument.loadingParams["disableCreateObjectURL"];
|
||||
pdfDocument.loadingParams.disableCreateObjectURL;
|
||||
this.currentPage = -1;
|
||||
// The temporary canvas where renderPage paints one page at a time.
|
||||
this.scratchCanvas = document.createElement("canvas");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue