Merge pull request #11489 from Snuffleupagus/rm-FIREFOX-define
Remove the `FIREFOX` build flag, since it's completely unused and simplify a couple of `PDFJSDev` checks
This commit is contained in:
commit
d2d9441373
@ -88,7 +88,6 @@ var DEFINES = {
|
||||
TESTING: false,
|
||||
// The main build targets:
|
||||
GENERIC: false,
|
||||
FIREFOX: false,
|
||||
MOZCENTRAL: false,
|
||||
CHROME: false,
|
||||
MINIFIED: false,
|
||||
@ -173,7 +172,6 @@ function createWebpackConfig(defines, output) {
|
||||
.readFileSync("./src/license_header_libre.js")
|
||||
.toString();
|
||||
var enableSourceMaps =
|
||||
!bundleDefines.FIREFOX &&
|
||||
!bundleDefines.MOZCENTRAL &&
|
||||
!bundleDefines.CHROME &&
|
||||
!bundleDefines.TESTING;
|
||||
|
@ -1345,7 +1345,10 @@ var JpegImage = (function JpegImageClosure() {
|
||||
},
|
||||
|
||||
getData({ width, height, forceRGB = false, isSourcePDF = false }) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING && !LIB")) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||
) {
|
||||
assert(
|
||||
isSourcePDF === true,
|
||||
'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.'
|
||||
|
@ -1639,7 +1639,6 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
return worker.WorkerMessageHandler;
|
||||
}
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("GENERIC") &&
|
||||
isNodeJS &&
|
||||
// eslint-disable-next-line no-undef
|
||||
|
@ -25,10 +25,9 @@ import {
|
||||
validateRangeRequestCapabilities,
|
||||
} from "./network_utils.js";
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("FIREFOX || MOZCENTRAL")) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error(
|
||||
'Module "./network" shall not ' +
|
||||
"be used with FIREFOX or MOZCENTRAL build."
|
||||
'Module "./network.js" shall not be used with MOZCENTRAL builds.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
||||
let canvas = document.createElement("canvas");
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("FIREFOX || MOZCENTRAL || GENERIC")
|
||||
PDFJSDev.test("MOZCENTRAL || GENERIC")
|
||||
) {
|
||||
canvas.mozOpaque = true;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
return new PDFNetworkStream(params);
|
||||
});
|
||||
}
|
||||
} else if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
let PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
|
||||
let PDFFetchStream;
|
||||
let isChromeWithFetchCredentials = function() {
|
||||
|
@ -51,9 +51,10 @@ function wrapReason(reason) {
|
||||
(typeof reason === "object" && reason !== null),
|
||||
'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
|
||||
);
|
||||
}
|
||||
if (typeof reason !== "object" || reason === null) {
|
||||
return reason;
|
||||
} else {
|
||||
if (typeof reason !== "object" || reason === null) {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
switch (reason.name) {
|
||||
case "AbortException":
|
||||
|
23
web/app.js
23
web/app.js
@ -577,7 +577,7 @@ const PDFViewerApplication = {
|
||||
initPassiveLoading() {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")
|
||||
!PDFJSDev.test("MOZCENTRAL || CHROME")
|
||||
) {
|
||||
throw new Error("Not implemented: initPassiveLoading");
|
||||
}
|
||||
@ -730,10 +730,7 @@ const PDFViewerApplication = {
|
||||
if (key === "docBaseUrl" && !value) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
value = document.URL.split("#")[0];
|
||||
} else if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")
|
||||
) {
|
||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||
value = this.baseUrl;
|
||||
}
|
||||
}
|
||||
@ -926,10 +923,7 @@ const PDFViewerApplication = {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
const errorWrapperConfig = this.appConfig.errorWrapper;
|
||||
const errorWrapper = errorWrapperConfig.container;
|
||||
errorWrapper.removeAttribute("hidden");
|
||||
@ -1044,7 +1038,7 @@ const PDFViewerApplication = {
|
||||
let baseDocumentUrl;
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
baseDocumentUrl = null;
|
||||
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL")) {
|
||||
} else if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
baseDocumentUrl = this.baseUrl;
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
baseDocumentUrl = location.href.split("#")[0];
|
||||
@ -1808,7 +1802,7 @@ function webViewerInitialized() {
|
||||
const params = parseQueryString(queryString);
|
||||
file = "file" in params ? params.file : AppOptions.get("defaultUrl");
|
||||
validateFileURL(file);
|
||||
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL")) {
|
||||
} else if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
file = window.location.href.split("#")[0];
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
file = AppOptions.get("defaultUrl");
|
||||
@ -1942,7 +1936,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
PDFViewerApplication.open(file);
|
||||
}
|
||||
};
|
||||
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")) {
|
||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
|
||||
PDFViewerApplication.setTitleUsingUrl(file);
|
||||
PDFViewerApplication.initPassiveLoading();
|
||||
@ -2520,10 +2514,7 @@ function webViewerKeyDown(evt) {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
// CTRL or META without shift
|
||||
if (cmd === 1 || cmd === 8) {
|
||||
switch (evt.keyCode) {
|
||||
|
@ -19,13 +19,9 @@ import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
|
||||
import { BasePreferences } from "./preferences.js";
|
||||
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error(
|
||||
'Module "pdfjs-web/firefoxcom" shall not be used outside ' +
|
||||
"FIREFOX and MOZCENTRAL builds."
|
||||
'Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class PDFAttachmentViewer {
|
||||
chrome.runtime.getURL("/content/web/viewer.html") +
|
||||
"?file=" +
|
||||
encodeURIComponent(blobUrl + "#" + filename);
|
||||
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL")) {
|
||||
} else if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
// Let Firefox's content handler catch the URL and display the PDF.
|
||||
viewerUrl = blobUrl + "?" + encodeURIComponent(filename);
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ class PDFPageView {
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC")
|
||||
PDFJSDev.test("MOZCENTRAL || GENERIC")
|
||||
) {
|
||||
canvas.mozOpaque = true;
|
||||
}
|
||||
@ -658,7 +658,7 @@ class PDFPageView {
|
||||
paintOnSvg(wrapper) {
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")
|
||||
PDFJSDev.test("MOZCENTRAL || CHROME")
|
||||
) {
|
||||
// Return a mock object, to prevent errors such as e.g.
|
||||
// "TypeError: paintTask.promise is undefined".
|
||||
|
@ -471,10 +471,7 @@ class PDFPresentationMode {
|
||||
|
||||
window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
|
||||
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
window.addEventListener(
|
||||
"webkitfullscreenchange",
|
||||
this.fullscreenChangeBind
|
||||
@ -492,10 +489,7 @@ class PDFPresentationMode {
|
||||
"mozfullscreenchange",
|
||||
this.fullscreenChangeBind
|
||||
);
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
window.removeEventListener(
|
||||
"webkitfullscreenchange",
|
||||
this.fullscreenChangeBind
|
||||
|
@ -54,7 +54,7 @@ const TempImageFactory = (function TempImageFactoryClosure() {
|
||||
// background ourselves. `_getPageDrawContext` uses CSS rules for this.
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC")
|
||||
PDFJSDev.test("MOZCENTRAL || GENERIC")
|
||||
) {
|
||||
tempCanvas.mozOpaque = true;
|
||||
}
|
||||
@ -228,7 +228,7 @@ class PDFThumbnailView {
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC")
|
||||
PDFJSDev.test("MOZCENTRAL || GENERIC")
|
||||
) {
|
||||
canvas.mozOpaque = true;
|
||||
}
|
||||
|
@ -373,8 +373,7 @@ class TextLayerBuilder {
|
||||
if (this.enhanceTextSelection && this.textLayerRenderTask) {
|
||||
this.textLayerRenderTask.expandTextDivs(true);
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")) &&
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
|
||||
expandDivsTimer
|
||||
) {
|
||||
clearTimeout(expandDivsTimer);
|
||||
@ -387,10 +386,7 @@ class TextLayerBuilder {
|
||||
if (!end) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
// On non-Firefox browsers, the selection will feel better if the height
|
||||
// of the `endOfContent` div is adjusted to start at mouse click
|
||||
// location. This avoids flickering when the selection moves up.
|
||||
@ -414,10 +410,7 @@ class TextLayerBuilder {
|
||||
|
||||
div.addEventListener("mouseup", () => {
|
||||
if (this.enhanceTextSelection && this.textLayerRenderTask) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
expandDivsTimer = setTimeout(() => {
|
||||
if (this.textLayerRenderTask) {
|
||||
this.textLayerRenderTask.expandTextDivs(false);
|
||||
@ -434,10 +427,7 @@ class TextLayerBuilder {
|
||||
if (!end) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
end.style.top = "";
|
||||
}
|
||||
end.classList.remove("active");
|
||||
|
@ -745,7 +745,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
|
||||
const animationStarted = new Promise(function(resolve) {
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("LIB") &&
|
||||
PDFJSDev.test("LIB && TESTING") &&
|
||||
typeof window === "undefined"
|
||||
) {
|
||||
// Prevent "ReferenceError: window is not defined" errors when running the
|
||||
|
@ -21,8 +21,8 @@ const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
|
||||
*
|
||||
* The way that the view parameters are stored depends on how PDF.js is built,
|
||||
* for 'gulp <flag>' the following cases exist:
|
||||
* - FIREFOX or MOZCENTRAL - uses sessionStorage.
|
||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||
* - MOZCENTRAL - uses sessionStorage.
|
||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||
*/
|
||||
class ViewHistory {
|
||||
constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
|
||||
@ -57,10 +57,7 @@ class ViewHistory {
|
||||
async _writeToStorage() {
|
||||
const databaseStr = JSON.stringify(this.database);
|
||||
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
sessionStorage.setItem("pdfjs.history", databaseStr);
|
||||
return;
|
||||
}
|
||||
@ -68,10 +65,7 @@ class ViewHistory {
|
||||
}
|
||||
|
||||
async _readFromStorage() {
|
||||
if (
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
PDFJSDev.test("FIREFOX || MOZCENTRAL")
|
||||
) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
return sessionStorage.getItem("pdfjs.history");
|
||||
}
|
||||
return localStorage.getItem("pdfjs.history");
|
||||
|
@ -32,7 +32,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
<!--#endif-->
|
||||
<title>PDF.js viewer</title>
|
||||
|
||||
<!--#if FIREFOX || MOZCENTRAL-->
|
||||
<!--#if MOZCENTRAL-->
|
||||
<!--#include viewer-snippet-firefox-extension.html-->
|
||||
<!--#endif-->
|
||||
<!--#if CHROME-->
|
||||
@ -391,7 +391,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--#if !(FIREFOX || MOZCENTRAL)-->
|
||||
<!--#if !MOZCENTRAL-->
|
||||
<div id="printServiceOverlay" class="container hidden">
|
||||
<div class="dialog">
|
||||
<div class="row">
|
||||
|
@ -41,7 +41,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("PRODUCTION")) {
|
||||
pdfjsWebAppOptions = require("./app_options.js");
|
||||
}
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("FIREFOX || MOZCENTRAL")) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
require("./firefoxcom.js");
|
||||
require("./firefox_print_service.js");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user