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:
Tim van der Meij 2020-01-24 23:59:13 +01:00 committed by GitHub
commit d2d9441373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 40 additions and 75 deletions

View File

@ -88,7 +88,6 @@ var DEFINES = {
TESTING: false, TESTING: false,
// The main build targets: // The main build targets:
GENERIC: false, GENERIC: false,
FIREFOX: false,
MOZCENTRAL: false, MOZCENTRAL: false,
CHROME: false, CHROME: false,
MINIFIED: false, MINIFIED: false,
@ -173,7 +172,6 @@ function createWebpackConfig(defines, output) {
.readFileSync("./src/license_header_libre.js") .readFileSync("./src/license_header_libre.js")
.toString(); .toString();
var enableSourceMaps = var enableSourceMaps =
!bundleDefines.FIREFOX &&
!bundleDefines.MOZCENTRAL && !bundleDefines.MOZCENTRAL &&
!bundleDefines.CHROME && !bundleDefines.CHROME &&
!bundleDefines.TESTING; !bundleDefines.TESTING;

View File

@ -1345,7 +1345,10 @@ var JpegImage = (function JpegImageClosure() {
}, },
getData({ width, height, forceRGB = false, isSourcePDF = false }) { getData({ width, height, forceRGB = false, isSourcePDF = false }) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING && !LIB")) { if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
isSourcePDF === true, isSourcePDF === true,
'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.' 'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.'

View File

@ -1639,7 +1639,6 @@ const PDFWorker = (function PDFWorkerClosure() {
return worker.WorkerMessageHandler; return worker.WorkerMessageHandler;
} }
if ( if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("GENERIC") && PDFJSDev.test("GENERIC") &&
isNodeJS && isNodeJS &&
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef

View File

@ -25,10 +25,9 @@ import {
validateRangeRequestCapabilities, validateRangeRequestCapabilities,
} from "./network_utils.js"; } from "./network_utils.js";
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("FIREFOX || MOZCENTRAL")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error( throw new Error(
'Module "./network" shall not ' + 'Module "./network.js" shall not be used with MOZCENTRAL builds.'
"be used with FIREFOX or MOZCENTRAL build."
); );
} }

View File

@ -601,7 +601,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
let canvas = document.createElement("canvas"); let canvas = document.createElement("canvas");
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("FIREFOX || MOZCENTRAL || GENERIC") PDFJSDev.test("MOZCENTRAL || GENERIC")
) { ) {
canvas.mozOpaque = true; canvas.mozOpaque = true;
} }

View File

@ -53,7 +53,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
return new PDFNetworkStream(params); 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 PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
let PDFFetchStream; let PDFFetchStream;
let isChromeWithFetchCredentials = function() { let isChromeWithFetchCredentials = function() {

View File

@ -51,9 +51,10 @@ function wrapReason(reason) {
(typeof reason === "object" && reason !== null), (typeof reason === "object" && reason !== null),
'wrapReason: Expected "reason" to be a (possibly cloned) Error.' 'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
); );
} } else {
if (typeof reason !== "object" || reason === null) { if (typeof reason !== "object" || reason === null) {
return reason; return reason;
}
} }
switch (reason.name) { switch (reason.name) {
case "AbortException": case "AbortException":

View File

@ -577,7 +577,7 @@ const PDFViewerApplication = {
initPassiveLoading() { initPassiveLoading() {
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME") !PDFJSDev.test("MOZCENTRAL || CHROME")
) { ) {
throw new Error("Not implemented: initPassiveLoading"); throw new Error("Not implemented: initPassiveLoading");
} }
@ -730,10 +730,7 @@ const PDFViewerApplication = {
if (key === "docBaseUrl" && !value) { if (key === "docBaseUrl" && !value) {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
value = document.URL.split("#")[0]; value = document.URL.split("#")[0];
} else if ( } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")
) {
value = this.baseUrl; value = this.baseUrl;
} }
} }
@ -926,10 +923,7 @@ const PDFViewerApplication = {
} }
} }
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
const errorWrapperConfig = this.appConfig.errorWrapper; const errorWrapperConfig = this.appConfig.errorWrapper;
const errorWrapper = errorWrapperConfig.container; const errorWrapper = errorWrapperConfig.container;
errorWrapper.removeAttribute("hidden"); errorWrapper.removeAttribute("hidden");
@ -1044,7 +1038,7 @@ const PDFViewerApplication = {
let baseDocumentUrl; let baseDocumentUrl;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
baseDocumentUrl = null; baseDocumentUrl = null;
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL")) { } else if (PDFJSDev.test("MOZCENTRAL")) {
baseDocumentUrl = this.baseUrl; baseDocumentUrl = this.baseUrl;
} else if (PDFJSDev.test("CHROME")) { } else if (PDFJSDev.test("CHROME")) {
baseDocumentUrl = location.href.split("#")[0]; baseDocumentUrl = location.href.split("#")[0];
@ -1808,7 +1802,7 @@ function webViewerInitialized() {
const params = parseQueryString(queryString); const params = parseQueryString(queryString);
file = "file" in params ? params.file : AppOptions.get("defaultUrl"); file = "file" in params ? params.file : AppOptions.get("defaultUrl");
validateFileURL(file); validateFileURL(file);
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL")) { } else if (PDFJSDev.test("MOZCENTRAL")) {
file = window.location.href.split("#")[0]; file = window.location.href.split("#")[0];
} else if (PDFJSDev.test("CHROME")) { } else if (PDFJSDev.test("CHROME")) {
file = AppOptions.get("defaultUrl"); file = AppOptions.get("defaultUrl");
@ -1942,7 +1936,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
PDFViewerApplication.open(file); PDFViewerApplication.open(file);
} }
}; };
} else if (PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME")) { } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
PDFViewerApplication.setTitleUsingUrl(file); PDFViewerApplication.setTitleUsingUrl(file);
PDFViewerApplication.initPassiveLoading(); PDFViewerApplication.initPassiveLoading();
@ -2520,10 +2514,7 @@ function webViewerKeyDown(evt) {
} }
} }
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
// CTRL or META without shift // CTRL or META without shift
if (cmd === 1 || cmd === 8) { if (cmd === 1 || cmd === 8) {
switch (evt.keyCode) { switch (evt.keyCode) {

View File

@ -19,13 +19,9 @@ import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
import { BasePreferences } from "./preferences.js"; import { BasePreferences } from "./preferences.js";
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js"; import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
throw new Error( throw new Error(
'Module "pdfjs-web/firefoxcom" shall not be used outside ' + 'Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.'
"FIREFOX and MOZCENTRAL builds."
); );
} }

View File

@ -100,7 +100,7 @@ class PDFAttachmentViewer {
chrome.runtime.getURL("/content/web/viewer.html") + chrome.runtime.getURL("/content/web/viewer.html") +
"?file=" + "?file=" +
encodeURIComponent(blobUrl + "#" + filename); 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. // Let Firefox's content handler catch the URL and display the PDF.
viewerUrl = blobUrl + "?" + encodeURIComponent(filename); viewerUrl = blobUrl + "?" + encodeURIComponent(filename);
} }

View File

@ -581,7 +581,7 @@ class PDFPageView {
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC") PDFJSDev.test("MOZCENTRAL || GENERIC")
) { ) {
canvas.mozOpaque = true; canvas.mozOpaque = true;
} }
@ -658,7 +658,7 @@ class PDFPageView {
paintOnSvg(wrapper) { paintOnSvg(wrapper) {
if ( if (
typeof PDFJSDev !== "undefined" && typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("FIREFOX || MOZCENTRAL || CHROME") PDFJSDev.test("MOZCENTRAL || CHROME")
) { ) {
// Return a mock object, to prevent errors such as e.g. // Return a mock object, to prevent errors such as e.g.
// "TypeError: paintTask.promise is undefined". // "TypeError: paintTask.promise is undefined".

View File

@ -471,10 +471,7 @@ class PDFPresentationMode {
window.addEventListener("fullscreenchange", this.fullscreenChangeBind); window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind); window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
window.addEventListener( window.addEventListener(
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind
@ -492,10 +489,7 @@ class PDFPresentationMode {
"mozfullscreenchange", "mozfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind
); );
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
window.removeEventListener( window.removeEventListener(
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind

View File

@ -54,7 +54,7 @@ const TempImageFactory = (function TempImageFactoryClosure() {
// background ourselves. `_getPageDrawContext` uses CSS rules for this. // background ourselves. `_getPageDrawContext` uses CSS rules for this.
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC") PDFJSDev.test("MOZCENTRAL || GENERIC")
) { ) {
tempCanvas.mozOpaque = true; tempCanvas.mozOpaque = true;
} }
@ -228,7 +228,7 @@ class PDFThumbnailView {
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("MOZCENTRAL || FIREFOX || GENERIC") PDFJSDev.test("MOZCENTRAL || GENERIC")
) { ) {
canvas.mozOpaque = true; canvas.mozOpaque = true;
} }

View File

@ -373,8 +373,7 @@ class TextLayerBuilder {
if (this.enhanceTextSelection && this.textLayerRenderTask) { if (this.enhanceTextSelection && this.textLayerRenderTask) {
this.textLayerRenderTask.expandTextDivs(true); this.textLayerRenderTask.expandTextDivs(true);
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
!PDFJSDev.test("FIREFOX || MOZCENTRAL")) &&
expandDivsTimer expandDivsTimer
) { ) {
clearTimeout(expandDivsTimer); clearTimeout(expandDivsTimer);
@ -387,10 +386,7 @@ class TextLayerBuilder {
if (!end) { if (!end) {
return; return;
} }
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
// On non-Firefox browsers, the selection will feel better if the height // On non-Firefox browsers, the selection will feel better if the height
// of the `endOfContent` div is adjusted to start at mouse click // of the `endOfContent` div is adjusted to start at mouse click
// location. This avoids flickering when the selection moves up. // location. This avoids flickering when the selection moves up.
@ -414,10 +410,7 @@ class TextLayerBuilder {
div.addEventListener("mouseup", () => { div.addEventListener("mouseup", () => {
if (this.enhanceTextSelection && this.textLayerRenderTask) { if (this.enhanceTextSelection && this.textLayerRenderTask) {
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
expandDivsTimer = setTimeout(() => { expandDivsTimer = setTimeout(() => {
if (this.textLayerRenderTask) { if (this.textLayerRenderTask) {
this.textLayerRenderTask.expandTextDivs(false); this.textLayerRenderTask.expandTextDivs(false);
@ -434,10 +427,7 @@ class TextLayerBuilder {
if (!end) { if (!end) {
return; return;
} }
if ( if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev === "undefined" ||
!PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
end.style.top = ""; end.style.top = "";
} }
end.classList.remove("active"); end.classList.remove("active");

View File

@ -745,7 +745,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
const animationStarted = new Promise(function(resolve) { const animationStarted = new Promise(function(resolve) {
if ( if (
typeof PDFJSDev !== "undefined" && typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("LIB") && PDFJSDev.test("LIB && TESTING") &&
typeof window === "undefined" typeof window === "undefined"
) { ) {
// Prevent "ReferenceError: window is not defined" errors when running the // Prevent "ReferenceError: window is not defined" errors when running the

View File

@ -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, * The way that the view parameters are stored depends on how PDF.js is built,
* for 'gulp <flag>' the following cases exist: * for 'gulp <flag>' the following cases exist:
* - FIREFOX or MOZCENTRAL - uses sessionStorage. * - MOZCENTRAL - uses sessionStorage.
* - GENERIC or CHROME - uses localStorage, if it is available. * - GENERIC or CHROME - uses localStorage, if it is available.
*/ */
class ViewHistory { class ViewHistory {
constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) { constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
@ -57,10 +57,7 @@ class ViewHistory {
async _writeToStorage() { async _writeToStorage() {
const databaseStr = JSON.stringify(this.database); const databaseStr = JSON.stringify(this.database);
if ( if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
sessionStorage.setItem("pdfjs.history", databaseStr); sessionStorage.setItem("pdfjs.history", databaseStr);
return; return;
} }
@ -68,10 +65,7 @@ class ViewHistory {
} }
async _readFromStorage() { async _readFromStorage() {
if ( if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("FIREFOX || MOZCENTRAL")
) {
return sessionStorage.getItem("pdfjs.history"); return sessionStorage.getItem("pdfjs.history");
} }
return localStorage.getItem("pdfjs.history"); return localStorage.getItem("pdfjs.history");

View File

@ -32,7 +32,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<!--#endif--> <!--#endif-->
<title>PDF.js viewer</title> <title>PDF.js viewer</title>
<!--#if FIREFOX || MOZCENTRAL--> <!--#if MOZCENTRAL-->
<!--#include viewer-snippet-firefox-extension.html--> <!--#include viewer-snippet-firefox-extension.html-->
<!--#endif--> <!--#endif-->
<!--#if CHROME--> <!--#if CHROME-->
@ -391,7 +391,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div> </div>
</div> </div>
</div> </div>
<!--#if !(FIREFOX || MOZCENTRAL)--> <!--#if !MOZCENTRAL-->
<div id="printServiceOverlay" class="container hidden"> <div id="printServiceOverlay" class="container hidden">
<div class="dialog"> <div class="dialog">
<div class="row"> <div class="row">

View File

@ -41,7 +41,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("PRODUCTION")) {
pdfjsWebAppOptions = require("./app_options.js"); pdfjsWebAppOptions = require("./app_options.js");
} }
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("FIREFOX || MOZCENTRAL")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
require("./firefoxcom.js"); require("./firefoxcom.js");
require("./firefox_print_service.js"); require("./firefox_print_service.js");
} }