Skip to content

Commit

Permalink
[api-minor] rm disableCreateObjectURL
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffleupagus committed Feb 22, 2020
1 parent 8ae7e6f commit 636991c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 45 deletions.
1 change: 0 additions & 1 deletion src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ import { PDFImage } from "./image.js";

var PartialEvaluator = (function PartialEvaluatorClosure() {
const DefaultPartialEvaluatorOptions = {
forceDataSchema: false,
maxImageSize: -1,
disableFontFace: false,
ignoreErrors: false,
Expand Down
1 change: 0 additions & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ var WorkerMessageHandler = {
ensureNotTerminated();

var evaluatorOptions = {
forceDataSchema: data.disableCreateObjectURL,
maxImageSize: data.maxImageSize,
disableFontFace: data.disableFontFace,
ignoreErrors: data.ignoreErrors,
Expand Down
9 changes: 0 additions & 9 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
* The default value is `false`.
* NOTE: It is also necessary to disable streaming, see above,
* in order for disabling of pre-fetching to work correctly.
* @property {boolean} [disableCreateObjectURL] - Disable the use of
* `URL.createObjectURL`, for compatibility with older browsers.
* The default value is `false`.
* @property {boolean} [pdfBug] - Enables special hooks for debugging
* PDF.js (see `web/debugger.js`). The default value is `false`.
*/
Expand Down Expand Up @@ -257,10 +254,6 @@ function getDocument(src) {
if (typeof params.disableAutoFetch !== "boolean") {
params.disableAutoFetch = false;
}
if (typeof params.disableCreateObjectURL !== "boolean") {
params.disableCreateObjectURL =
apiCompatibilityParams.disableCreateObjectURL || false;
}

// Set the main-thread verbosity level.
setVerbosityLevel(params.verbosity);
Expand Down Expand Up @@ -373,7 +366,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
},
maxImageSize: source.maxImageSize,
disableFontFace: source.disableFontFace,
disableCreateObjectURL: source.disableCreateObjectURL,
postMessageTransfers: worker.postMessageTransfers,
docBaseUrl: source.docBaseUrl,
ignoreErrors: source.ignoreErrors,
Expand Down Expand Up @@ -2478,7 +2470,6 @@ class WorkerTransport {
const params = this._params;
return shadow(this, "loadingParams", {
disableAutoFetch: params.disableAutoFetch,
disableCreateObjectURL: params.disableCreateObjectURL,
disableFontFace: params.disableFontFace,
});
}
Expand Down
15 changes: 0 additions & 15 deletions src/display/api_compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ const compatibilityParams = Object.create(null);
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const { isNodeJS } = require("../shared/is_node.js");

const userAgent =
(typeof navigator !== "undefined" && navigator.userAgent) || "";
const isIE = /Trident/.test(userAgent);
const isIOSChrome = /CriOS/.test(userAgent);

// Checks if possible to use URL.createObjectURL()
// Support: IE, Chrome on iOS
(function checkOnBlobSupport() {
// Sometimes IE and Chrome on iOS losing the data created with
// createObjectURL(), see issues #3977 and #8081.
if (isIE || isIOSChrome) {
compatibilityParams.disableCreateObjectURL = true;
}
})();

// Support: Node.js
(function checkFontFace() {
// Node.js is missing native support for `@font-face`.
Expand Down
2 changes: 1 addition & 1 deletion src/display/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
let shadingCount = 0;

SVGGraphics = class SVGGraphics {
constructor(commonObjs, objs, forceDataSchema) {
constructor(commonObjs, objs, forceDataSchema = false) {
this.svgFactory = new DOMSVGFactory();

this.current = new SVGExtraState();
Expand Down
13 changes: 6 additions & 7 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import { apiCompatibilityParams } from "pdfjs-lib";
import { viewerCompatibilityParams } from "./viewer_compatibility.js";

const OptionKind = {
Expand Down Expand Up @@ -43,6 +42,12 @@ const defaultOptions = {
value: "",
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
disableCreateObjectURL: {
/** @type {boolean} */
value: false,
compatibility: viewerCompatibilityParams.disableCreateObjectURL,
kind: OptionKind.VIEWER,
},
disableHistory: {
/** @type {boolean} */
value: false,
Expand Down Expand Up @@ -167,12 +172,6 @@ const defaultOptions = {
value: false,
kind: OptionKind.API + OptionKind.PREFERENCE,
},
disableCreateObjectURL: {
/** @type {boolean} */
value: false,
compatibility: apiCompatibilityParams.disableCreateObjectURL,
kind: OptionKind.API,
},
disableFontFace: {
/** @type {boolean} */
value: false,
Expand Down
9 changes: 3 additions & 6 deletions web/download_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* limitations under the License.
*/

import {
apiCompatibilityParams,
createObjectURL,
createValidAbsoluteUrl,
} from "pdfjs-lib";
import { createObjectURL, createValidAbsoluteUrl } from "pdfjs-lib";
import { viewerCompatibilityParams } from "./viewer_compatibility.js";

if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
throw new Error(
Expand All @@ -27,7 +24,7 @@ if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
}

const DISABLE_CREATE_OBJECT_URL =
apiCompatibilityParams.disableCreateObjectURL || false;
viewerCompatibilityParams.disableCreateObjectURL || false;

function download(blobUrl, filename) {
const a = document.createElement("a");
Expand Down
6 changes: 3 additions & 3 deletions web/pdf_attachment_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class PDFAttachmentViewer {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// The current URL is the viewer, let's use it and append the file.
viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
} else if (PDFJSDev.test("MOZCENTRAL")) {
// Let Firefox's content handler catch the URL and display the PDF.
viewerUrl = blobUrl + "?" + encodeURIComponent(filename);
} else if (PDFJSDev.test("CHROME")) {
// In the Chrome extension, the URL is rewritten using the history API
// in viewer.js, so an absolute URL must be generated.
Expand All @@ -100,9 +103,6 @@ class PDFAttachmentViewer {
chrome.runtime.getURL("/content/web/viewer.html") +
"?file=" +
encodeURIComponent(blobUrl + "#" + filename);
} else if (PDFJSDev.test("MOZCENTRAL")) {
// Let Firefox's content handler catch the URL and display the PDF.
viewerUrl = blobUrl + "?" + encodeURIComponent(filename);
}
window.open(viewerUrl);
return false;
Expand Down
3 changes: 1 addition & 2 deletions web/pdf_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
this.pagesOverview = pagesOverview;
this.printContainer = printContainer;
this.l10n = l10n || NullL10n;
this.disableCreateObjectURL =
pdfDocument.loadingParams["disableCreateObjectURL"];
this.disableCreateObjectURL = AppOptions.get("disableCreateObjectURL");
this.currentPage = -1;
// The temporary canvas where renderPage paints one page at a time.
this.scratchCanvas = document.createElement("canvas");
Expand Down
12 changes: 12 additions & 0 deletions web/viewer_compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;

const isAndroid = /Android/.test(userAgent);
const isIE = /Trident/.test(userAgent);
const isIOS =
/\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) ||
(platform === "MacIntel" && maxTouchPoints > 1);
const isIOSChrome = /CriOS/.test(userAgent);

// Checks if possible to use URL.createObjectURL()
// Support: IE, Chrome on iOS
(function checkOnBlobSupport() {
// Sometimes IE and Chrome on iOS losing the data created with
// createObjectURL(), see issues #3977 and #8081.
if (isIE || isIOSChrome) {
compatibilityParams.disableCreateObjectURL = true;
}
})();

// Limit canvas size to 5 mega-pixels on mobile.
// Support: Android, iOS
Expand Down

0 comments on commit 636991c

Please sign in to comment.