2012-09-01 07:48:21 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-01-16 13:32:11 +09:00
|
|
|
import "../extensions/firefox/tools/l10n.js";
|
2020-01-15 22:26:47 +09:00
|
|
|
import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
|
2021-02-24 21:02:58 +09:00
|
|
|
import { isPdfFile, PDFDataRangeTransport, shadow } from "pdfjs-lib";
|
2020-01-02 20:00:16 +09:00
|
|
|
import { BasePreferences } from "./preferences.js";
|
2021-02-24 21:02:58 +09:00
|
|
|
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
2021-02-22 20:43:16 +09:00
|
|
|
import { getL10nFallback } from "./l10n_utils.js";
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
2020-01-08 21:57:31 +09:00
|
|
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Error(
|
2020-01-08 21:57:31 +09:00
|
|
|
'Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.'
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
);
|
2016-10-15 00:57:53 +09:00
|
|
|
}
|
|
|
|
|
2021-01-01 22:21:47 +09:00
|
|
|
class FirefoxCom {
|
|
|
|
/**
|
|
|
|
* Creates an event that the extension is listening for and will
|
|
|
|
* synchronously respond to.
|
2021-01-01 22:40:46 +09:00
|
|
|
* NOTE: It is recommended to use requestAsync() instead since one day we may
|
|
|
|
* not be able to synchronously reply.
|
2021-01-01 22:21:47 +09:00
|
|
|
* @param {string} action - The action to trigger.
|
|
|
|
* @param {Object|string} [data] - The data to send.
|
|
|
|
* @returns {*} The response.
|
|
|
|
*/
|
|
|
|
static requestSync(action, data) {
|
|
|
|
const request = document.createTextNode("");
|
2022-06-12 19:20:25 +09:00
|
|
|
document.documentElement.append(request);
|
2012-08-02 07:31:25 +09:00
|
|
|
|
2023-04-23 20:01:35 +09:00
|
|
|
const sender = new CustomEvent("pdf.js.message", {
|
|
|
|
bubbles: true,
|
|
|
|
cancelable: false,
|
|
|
|
detail: {
|
|
|
|
action,
|
|
|
|
data,
|
|
|
|
sync: true,
|
|
|
|
},
|
2021-01-01 22:21:47 +09:00
|
|
|
});
|
|
|
|
request.dispatchEvent(sender);
|
|
|
|
const response = sender.detail.response;
|
|
|
|
request.remove();
|
2020-12-31 21:40:03 +09:00
|
|
|
|
2021-01-01 22:21:47 +09:00
|
|
|
return response;
|
|
|
|
}
|
2017-08-22 20:16:28 +09:00
|
|
|
|
2021-01-01 22:40:46 +09:00
|
|
|
/**
|
|
|
|
* Creates an event that the extension is listening for and will
|
|
|
|
* asynchronously respond to.
|
|
|
|
* @param {string} action - The action to trigger.
|
|
|
|
* @param {Object|string} [data] - The data to send.
|
|
|
|
* @returns {Promise<any>} A promise that is resolved with the response data.
|
|
|
|
*/
|
|
|
|
static requestAsync(action, data) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
this.request(action, data, resolve);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-01-01 22:21:47 +09:00
|
|
|
/**
|
|
|
|
* Creates an event that the extension is listening for and will, optionally,
|
|
|
|
* asynchronously respond to.
|
|
|
|
* @param {string} action - The action to trigger.
|
|
|
|
* @param {Object|string} [data] - The data to send.
|
|
|
|
*/
|
|
|
|
static request(action, data, callback = null) {
|
|
|
|
const request = document.createTextNode("");
|
|
|
|
if (callback) {
|
|
|
|
request.addEventListener(
|
|
|
|
"pdf.js.response",
|
|
|
|
event => {
|
|
|
|
const response = event.detail.response;
|
|
|
|
event.target.remove();
|
2012-08-02 07:31:25 +09:00
|
|
|
|
2021-01-01 22:21:47 +09:00
|
|
|
callback(response);
|
|
|
|
},
|
|
|
|
{ once: true }
|
|
|
|
);
|
|
|
|
}
|
2022-06-12 19:20:25 +09:00
|
|
|
document.documentElement.append(request);
|
2012-08-02 07:31:25 +09:00
|
|
|
|
2023-04-23 20:01:35 +09:00
|
|
|
const sender = new CustomEvent("pdf.js.message", {
|
|
|
|
bubbles: true,
|
|
|
|
cancelable: false,
|
|
|
|
detail: {
|
|
|
|
action,
|
|
|
|
data,
|
|
|
|
sync: false,
|
|
|
|
responseExpected: !!callback,
|
|
|
|
},
|
2021-01-01 22:21:47 +09:00
|
|
|
});
|
|
|
|
request.dispatchEvent(sender);
|
|
|
|
}
|
|
|
|
}
|
2013-07-13 03:14:13 +09:00
|
|
|
|
2017-08-22 20:16:28 +09:00
|
|
|
class DownloadManager {
|
2022-11-04 23:29:45 +09:00
|
|
|
#openBlobUrls = new WeakMap();
|
2021-02-23 20:58:17 +09:00
|
|
|
|
2023-05-05 22:18:01 +09:00
|
|
|
downloadUrl(url, filename, options = {}) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.request("download", {
|
2017-08-22 20:16:28 +09:00
|
|
|
originalUrl: url,
|
|
|
|
filename,
|
2023-05-05 22:18:01 +09:00
|
|
|
options,
|
2017-08-22 20:16:28 +09:00
|
|
|
});
|
|
|
|
}
|
2015-02-03 00:12:52 +09:00
|
|
|
|
2017-08-22 20:16:28 +09:00
|
|
|
downloadData(data, filename, contentType) {
|
2020-04-24 18:29:33 +09:00
|
|
|
const blobUrl = URL.createObjectURL(
|
|
|
|
new Blob([data], { type: contentType })
|
|
|
|
);
|
2021-01-01 22:40:46 +09:00
|
|
|
|
2022-05-10 21:15:57 +09:00
|
|
|
FirefoxCom.request("download", {
|
2021-01-01 22:40:46 +09:00
|
|
|
blobUrl,
|
|
|
|
originalUrl: blobUrl,
|
|
|
|
filename,
|
|
|
|
isAttachment: true,
|
|
|
|
});
|
2017-08-22 20:16:28 +09:00
|
|
|
}
|
2013-07-13 03:14:13 +09:00
|
|
|
|
2021-02-23 20:58:17 +09:00
|
|
|
/**
|
|
|
|
* @returns {boolean} Indicating if the data was opened.
|
|
|
|
*/
|
|
|
|
openOrDownloadData(element, data, filename) {
|
2021-02-24 21:02:58 +09:00
|
|
|
const isPdfData = isPdfFile(filename);
|
|
|
|
const contentType = isPdfData ? "application/pdf" : "";
|
2021-02-23 20:58:17 +09:00
|
|
|
|
2021-02-24 21:02:58 +09:00
|
|
|
if (isPdfData) {
|
2022-11-04 23:29:45 +09:00
|
|
|
let blobUrl = this.#openBlobUrls.get(element);
|
2021-02-23 20:58:17 +09:00
|
|
|
if (!blobUrl) {
|
|
|
|
blobUrl = URL.createObjectURL(new Blob([data], { type: contentType }));
|
2022-11-04 23:29:45 +09:00
|
|
|
this.#openBlobUrls.set(element, blobUrl);
|
2021-02-23 20:58:17 +09:00
|
|
|
}
|
|
|
|
// Let Firefox's content handler catch the URL and display the PDF.
|
|
|
|
const viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename);
|
|
|
|
|
|
|
|
try {
|
|
|
|
window.open(viewerUrl);
|
|
|
|
return true;
|
|
|
|
} catch (ex) {
|
|
|
|
console.error(`openOrDownloadData: ${ex}`);
|
|
|
|
// Release the `blobUrl`, since opening it failed, and fallback to
|
|
|
|
// downloading the PDF file.
|
|
|
|
URL.revokeObjectURL(blobUrl);
|
2022-11-04 23:29:45 +09:00
|
|
|
this.#openBlobUrls.delete(element);
|
2021-02-23 20:58:17 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.downloadData(data, filename, contentType);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-05 22:18:01 +09:00
|
|
|
download(blob, url, filename, options = {}) {
|
2019-12-27 08:22:32 +09:00
|
|
|
const blobUrl = URL.createObjectURL(blob);
|
2021-01-01 22:40:46 +09:00
|
|
|
|
2022-05-10 21:15:57 +09:00
|
|
|
FirefoxCom.request("download", {
|
2021-01-01 22:40:46 +09:00
|
|
|
blobUrl,
|
|
|
|
originalUrl: url,
|
|
|
|
filename,
|
2023-05-05 22:18:01 +09:00
|
|
|
options,
|
2021-01-01 22:40:46 +09:00
|
|
|
});
|
2017-08-22 20:16:28 +09:00
|
|
|
}
|
|
|
|
}
|
2013-11-19 07:51:06 +09:00
|
|
|
|
2017-04-17 20:21:11 +09:00
|
|
|
class FirefoxPreferences extends BasePreferences {
|
2018-07-30 23:48:16 +09:00
|
|
|
async _writeToStorage(prefObj) {
|
2021-01-01 22:40:46 +09:00
|
|
|
return FirefoxCom.requestAsync("setPreferences", prefObj);
|
2017-04-17 20:21:11 +09:00
|
|
|
}
|
2013-11-19 07:51:06 +09:00
|
|
|
|
2018-07-30 23:48:16 +09:00
|
|
|
async _readFromStorage(prefObj) {
|
2021-01-01 22:40:46 +09:00
|
|
|
const prefStr = await FirefoxCom.requestAsync("getPreferences", prefObj);
|
|
|
|
return JSON.parse(prefStr);
|
2017-04-17 20:21:11 +09:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 02:34:27 +09:00
|
|
|
|
2017-05-04 10:05:53 +09:00
|
|
|
class MozL10n {
|
|
|
|
constructor(mozL10n) {
|
|
|
|
this.mozL10n = mozL10n;
|
|
|
|
}
|
|
|
|
|
2018-07-30 23:28:39 +09:00
|
|
|
async getLanguage() {
|
|
|
|
return this.mozL10n.getLanguage();
|
2018-03-20 21:42:45 +09:00
|
|
|
}
|
|
|
|
|
2018-07-30 23:28:39 +09:00
|
|
|
async getDirection() {
|
|
|
|
return this.mozL10n.getDirection();
|
2017-05-04 10:05:53 +09:00
|
|
|
}
|
|
|
|
|
2021-02-22 20:43:16 +09:00
|
|
|
async get(key, args = null, fallback = getL10nFallback(key, args)) {
|
|
|
|
return this.mozL10n.get(key, args, fallback);
|
2017-05-04 10:05:53 +09:00
|
|
|
}
|
|
|
|
|
2018-07-30 23:28:39 +09:00
|
|
|
async translate(element) {
|
2017-05-04 10:05:53 +09:00
|
|
|
this.mozL10n.translate(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 21:11:40 +09:00
|
|
|
(function listenFindEvents() {
|
2017-08-22 20:16:28 +09:00
|
|
|
const events = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"find",
|
|
|
|
"findagain",
|
|
|
|
"findhighlightallchange",
|
|
|
|
"findcasesensitivitychange",
|
|
|
|
"findentirewordchange",
|
|
|
|
"findbarclose",
|
2021-04-19 06:37:22 +09:00
|
|
|
"finddiacriticmatchingchange",
|
2016-04-28 21:11:40 +09:00
|
|
|
];
|
2021-10-03 23:03:51 +09:00
|
|
|
const findLen = "find".length;
|
|
|
|
|
2020-04-14 19:28:14 +09:00
|
|
|
const handleEvent = function ({ type, detail }) {
|
2016-04-28 21:11:40 +09:00
|
|
|
if (!PDFViewerApplication.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (type === "findbarclose") {
|
|
|
|
PDFViewerApplication.eventBus.dispatch(type, { source: window });
|
2018-09-22 22:31:33 +09:00
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
PDFViewerApplication.eventBus.dispatch("find", {
|
2016-04-28 21:11:40 +09:00
|
|
|
source: window,
|
2021-10-03 23:03:51 +09:00
|
|
|
type: type.substring(findLen),
|
2018-09-22 22:31:33 +09:00
|
|
|
query: detail.query,
|
|
|
|
caseSensitive: !!detail.caseSensitive,
|
|
|
|
entireWord: !!detail.entireWord,
|
|
|
|
highlightAll: !!detail.highlightAll,
|
|
|
|
findPrevious: !!detail.findPrevious,
|
2021-04-19 06:37:22 +09:00
|
|
|
matchDiacritics: !!detail.matchDiacritics,
|
2016-04-28 21:11:40 +09:00
|
|
|
});
|
2016-12-10 21:58:06 +09:00
|
|
|
};
|
2016-04-28 21:11:40 +09:00
|
|
|
|
2019-03-19 18:45:27 +09:00
|
|
|
for (const event of events) {
|
|
|
|
window.addEventListener(event, handleEvent);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function listenZoomEvents() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const events = ["zoomin", "zoomout", "zoomreset"];
|
2020-04-14 19:28:14 +09:00
|
|
|
const handleEvent = function ({ type, detail }) {
|
2019-03-19 18:45:27 +09:00
|
|
|
if (!PDFViewerApplication.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-17 18:59:56 +09:00
|
|
|
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
|
|
|
|
// when using the `Ctrl + 0` keyboard shortcut.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
2019-12-26 04:03:46 +09:00
|
|
|
type === "zoomreset" &&
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
PDFViewerApplication.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE
|
|
|
|
) {
|
2019-07-17 18:59:56 +09:00
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
PDFViewerApplication.eventBus.dispatch(type, { source: window });
|
2019-03-19 18:45:27 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
for (const event of events) {
|
2018-09-01 08:28:19 +09:00
|
|
|
window.addEventListener(event, handleEvent);
|
2016-04-28 21:11:40 +09:00
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2020-08-20 04:19:59 +09:00
|
|
|
(function listenSaveEvent() {
|
|
|
|
const handleEvent = function ({ type, detail }) {
|
|
|
|
if (!PDFViewerApplication.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
2022-02-19 19:47:24 +09:00
|
|
|
PDFViewerApplication.eventBus.dispatch("download", { source: window });
|
2020-08-20 04:19:59 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener("save", handleEvent);
|
|
|
|
})();
|
|
|
|
|
2022-07-05 01:04:32 +09:00
|
|
|
(function listenEditingEvent() {
|
|
|
|
const handleEvent = function ({ detail }) {
|
|
|
|
if (!PDFViewerApplication.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
PDFViewerApplication.eventBus.dispatch("editingaction", {
|
|
|
|
source: window,
|
|
|
|
name: detail.name,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener("editingaction", handleEvent);
|
|
|
|
})();
|
|
|
|
|
2018-10-21 00:15:27 +09:00
|
|
|
class FirefoxComDataRangeTransport extends PDFDataRangeTransport {
|
|
|
|
requestDataRange(begin, end) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.request("requestDataRange", { begin, end });
|
2018-10-21 00:15:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
abort() {
|
|
|
|
// Sync call to ensure abort is really started.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.requestSync("abortLoading", null);
|
2018-10-21 00:15:27 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
}
|
|
|
|
|
2020-10-23 19:17:47 +09:00
|
|
|
class FirefoxScripting {
|
Update the events, used with scripting, to use lower-case names and avoid using DOM events internally in the viewer
For DOM events all event names are lower-case, and the newly added PDF.js scripting-events thus "stick out" quite a bit. Even more so, considering that our internal `eventBus`-events follow the same naming convention.
Hence this patch, which changes the "updateFromSandbox"/"dispatchEventInSandbox" events to be lower-case instead.
Furthermore, using DOM events for communication *within* the PDF.js code itself (i.e. between code in `web/app.js` and `src/display/annotation_layer.js/`) feels *really* out of place.
That's exactly the reason that we have the `EventBus` abstraction, since it allowed us to remove prior use of DOM events, and this patch thus re-factors the code to make use of the `EventBus` instead for scripting-related events.
Obviously for events targeting a *specific element* using DOM events is still fine, but the "updatefromsandbox"/"dispatcheventinsandbox" ones should be using the `EventBus` internally.
*Drive-by change:* Use the `BaseViewer.currentScaleValue` setter unconditionally in `PDFViewerApplication._initializeJavaScript`, since it accepts either a string or a number.
2020-12-17 22:10:56 +09:00
|
|
|
static async createSandbox(data) {
|
2021-01-01 22:40:46 +09:00
|
|
|
const success = await FirefoxCom.requestAsync("createSandbox", data);
|
|
|
|
if (!success) {
|
|
|
|
throw new Error("Cannot create sandbox.");
|
|
|
|
}
|
2020-10-23 19:17:47 +09:00
|
|
|
}
|
|
|
|
|
2020-12-04 08:39:50 +09:00
|
|
|
static async dispatchEventInSandbox(event) {
|
|
|
|
FirefoxCom.request("dispatchEventInSandbox", event);
|
2020-10-23 19:17:47 +09:00
|
|
|
}
|
|
|
|
|
2020-12-04 08:39:50 +09:00
|
|
|
static async destroySandbox() {
|
|
|
|
FirefoxCom.request("destroySandbox", null);
|
2020-10-23 19:17:47 +09:00
|
|
|
}
|
|
|
|
}
|
2020-10-01 20:57:23 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
class FirefoxExternalServices extends DefaultExternalServices {
|
|
|
|
static updateFindControlState(data) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.request("updateFindControlState", data);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static updateFindMatchesCount(data) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.request("updateFindMatchesCount", data);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2018-09-08 21:19:34 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static initPassiveLoading(callbacks) {
|
2017-08-22 20:16:28 +09:00
|
|
|
let pdfDataRangeTransport;
|
2016-04-14 06:21:05 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
window.addEventListener("message", function windowMessage(e) {
|
2016-04-14 06:21:05 +09:00
|
|
|
if (e.source !== null) {
|
|
|
|
// The message MUST originate from Chrome code.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
console.warn("Rejected untrusted message from " + e.origin);
|
2016-04-14 06:21:05 +09:00
|
|
|
return;
|
|
|
|
}
|
2019-12-27 08:22:32 +09:00
|
|
|
const args = e.data;
|
2016-04-14 06:21:05 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
|
2016-04-14 06:21:05 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (args.pdfjsLoadAction) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "supportsRangedLoading":
|
2021-11-02 01:50:49 +09:00
|
|
|
if (args.done && !args.data) {
|
|
|
|
callbacks.onError();
|
|
|
|
break;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
pdfDataRangeTransport = new FirefoxComDataRangeTransport(
|
|
|
|
args.length,
|
|
|
|
args.data,
|
2021-02-24 21:02:58 +09:00
|
|
|
args.done,
|
|
|
|
args.filename
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
);
|
|
|
|
|
2023-02-01 05:34:42 +09:00
|
|
|
callbacks.onOpenWithTransport(pdfDataRangeTransport);
|
2016-04-14 06:21:05 +09:00
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "range":
|
2016-04-14 06:21:05 +09:00
|
|
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "rangeProgress":
|
2016-04-14 06:21:05 +09:00
|
|
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "progressiveRead":
|
2016-04-14 06:21:05 +09:00
|
|
|
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
|
2019-04-06 18:04:44 +09:00
|
|
|
|
|
|
|
// Don't forget to report loading progress as well, since otherwise
|
|
|
|
// the loadingBar won't update when `disableRange=true` is set.
|
|
|
|
pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
|
2016-04-14 06:21:05 +09:00
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "progressiveDone":
|
2021-11-02 01:50:49 +09:00
|
|
|
pdfDataRangeTransport?.onDataProgressiveDone();
|
[Firefox regression] Fix `disableRange=true` bug in `PDFDataTransportStream`
Currently if trying to set `disableRange=true` in the built-in PDF Viewer in Firefox, either through `about:config` or via the URL hash, the PDF document will never load. It appears that this has been broken for a couple of years, without anyone noticing.
Obviously it's not a good idea to set `disableRange=true`, however it seems that this bug affects the PDF Viewer in Firefox even with default settings:
- In the case where `initialData` already contains the *entire* file, we're forced to dispatch a range request to re-fetch already available data just so that file loading may complete.
- (In the case where the data arrives, via streaming, before being specifically requested through `requestDataRange`, we're also forced to re-fetch data unnecessarily.) *This part was removed, to reduce the scope/risk of the patch somewhat.*
In the cases outlined above, we're having to re-fetch already available data thus potentially delaying loading/rendering of PDF files in Firefox (and wasting resources in the process).
2019-03-27 00:05:30 +09:00
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "progress":
|
2016-04-14 06:21:05 +09:00
|
|
|
callbacks.onProgress(args.loaded, args.total);
|
|
|
|
break;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "complete":
|
2016-04-14 06:21:05 +09:00
|
|
|
if (!args.data) {
|
|
|
|
callbacks.onError(args.errorCode);
|
|
|
|
break;
|
|
|
|
}
|
2021-02-24 21:02:58 +09:00
|
|
|
callbacks.onOpenWithData(args.data, args.filename);
|
2016-04-14 06:21:05 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.requestSync("initPassiveLoading", null);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static reportTelemetry(data) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
FirefoxCom.request("reportTelemetry", JSON.stringify(data));
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2022-12-03 20:52:36 +09:00
|
|
|
static createDownloadManager() {
|
2020-11-01 19:46:10 +09:00
|
|
|
return new DownloadManager();
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static createPreferences() {
|
2017-04-17 20:21:11 +09:00
|
|
|
return new FirefoxPreferences();
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2017-05-04 10:05:53 +09:00
|
|
|
|
2022-07-05 01:04:32 +09:00
|
|
|
static updateEditorStates(data) {
|
|
|
|
FirefoxCom.request("updateEditorStates", data);
|
|
|
|
}
|
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static createL10n(options) {
|
2019-12-27 08:22:32 +09:00
|
|
|
const mozL10n = document.mozL10n;
|
2017-05-04 10:05:53 +09:00
|
|
|
// TODO refactor mozL10n.setExternalLocalizerServices
|
|
|
|
return new MozL10n(mozL10n);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2017-04-17 20:21:11 +09:00
|
|
|
|
2020-12-20 20:24:26 +09:00
|
|
|
static createScripting(options) {
|
2020-10-01 20:57:23 +09:00
|
|
|
return FirefoxScripting;
|
|
|
|
}
|
|
|
|
|
2023-01-03 02:23:44 +09:00
|
|
|
static get supportsPinchToZoom() {
|
|
|
|
const support = FirefoxCom.requestSync("supportsPinchToZoom");
|
|
|
|
return shadow(this, "supportsPinchToZoom", support);
|
|
|
|
}
|
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static get supportsIntegratedFind() {
|
2019-12-27 08:22:32 +09:00
|
|
|
const support = FirefoxCom.requestSync("supportsIntegratedFind");
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "supportsIntegratedFind", support);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static get supportsDocumentFonts() {
|
2019-12-27 08:22:32 +09:00
|
|
|
const support = FirefoxCom.requestSync("supportsDocumentFonts");
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "supportsDocumentFonts", support);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2020-01-15 22:26:47 +09:00
|
|
|
static get supportedMouseWheelZoomModifierKeys() {
|
2019-12-27 08:22:32 +09:00
|
|
|
const support = FirefoxCom.requestSync(
|
|
|
|
"supportedMouseWheelZoomModifierKeys"
|
|
|
|
);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "supportedMouseWheelZoomModifierKeys", support);
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
2020-02-27 23:25:33 +09:00
|
|
|
|
|
|
|
static get isInAutomation() {
|
|
|
|
// Returns the value of `Cu.isInAutomation`, which is only `true` when e.g.
|
|
|
|
// various test-suites are running in mozilla-central.
|
|
|
|
const isInAutomation = FirefoxCom.requestSync("isInAutomation");
|
|
|
|
return shadow(this, "isInAutomation", isInAutomation);
|
|
|
|
}
|
2023-03-07 01:16:43 +09:00
|
|
|
|
|
|
|
static get canvasMaxAreaInBytes() {
|
|
|
|
const maxArea = FirefoxCom.requestSync("getCanvasMaxArea");
|
|
|
|
return shadow(this, "canvasMaxAreaInBytes", maxArea);
|
|
|
|
}
|
2020-01-15 22:26:47 +09:00
|
|
|
}
|
|
|
|
PDFViewerApplication.externalServices = FirefoxExternalServices;
|
2016-04-14 06:21:05 +09:00
|
|
|
|
2017-01-20 00:26:32 +09:00
|
|
|
// l10n.js for Firefox extension expects services to be set.
|
2016-04-14 06:21:05 +09:00
|
|
|
document.mozL10n.setExternalLocalizerServices({
|
2017-04-28 19:02:42 +09:00
|
|
|
getLocale() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return FirefoxCom.requestSync("getLocale", null);
|
2016-04-14 06:21:05 +09:00
|
|
|
},
|
|
|
|
|
2017-04-28 19:02:42 +09:00
|
|
|
getStrings(key) {
|
2022-03-01 05:24:38 +09:00
|
|
|
return FirefoxCom.requestSync("getStrings", null);
|
Fix inconsistent spacing and trailing commas in objects in `web/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = (typeof label === 'string' ? label : null);
- this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
- then((msg) => {
+ this.l10n.get('thumb_page_title', { page: this.pageId, },
+ 'Page {{page}}').then((msg) => {
this.anchor.title = msg;
});
diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
{ element: options.printButton, eventName: 'print', close: true, },
{ element: options.downloadButton, eventName: 'download', close: true, },
{ element: options.viewBookmarkButton, eventName: null, close: true, },
- { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+ { element: options.firstPageButton, eventName: 'firstpage',
+ close: true, },
{ element: options.lastPageButton, eventName: 'lastpage', close: true, },
{ element: options.pageRotateCwButton, eventName: 'rotatecw',
close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
{ element: options.cursorHandToolButton, eventName: 'switchcursortool',
eventDetails: { tool: CursorTool.HAND, }, close: true, },
{ element: options.documentPropertiesButton,
- eventName: 'documentproperties', close: true, }
+ eventName: 'documentproperties', close: true, },
];
this.items = {
firstPage: options.firstPageButton,
```
2017-06-01 19:46:12 +09:00
|
|
|
},
|
2016-04-14 06:21:05 +09:00
|
|
|
});
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
export { DownloadManager, FirefoxCom };
|