mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Merge pull request #9868 from Snuffleupagus/url-polyfill
Stop exposing the `URL` polyfill in the global scope
This commit is contained in:
commit
31012570ea
17 changed files with 736 additions and 671 deletions
|
@ -4,6 +4,13 @@
|
|||
],
|
||||
|
||||
"rules": {
|
||||
// Variables
|
||||
"no-restricted-globals": ["error",
|
||||
"ReadableStream",
|
||||
"URL",
|
||||
"WritableStream",
|
||||
],
|
||||
|
||||
// ECMAScript 6
|
||||
"no-var": "error",
|
||||
},
|
||||
|
|
|
@ -21,9 +21,10 @@ import {
|
|||
TextLayerMode
|
||||
} from './ui_utils';
|
||||
import {
|
||||
build, createBlob, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
|
||||
InvalidPDFException, LinkTarget, loadScript, MissingPDFException, OPS,
|
||||
PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, version
|
||||
build, createBlob, createObjectURL, getDocument, getFilenameFromUrl,
|
||||
GlobalWorkerOptions, InvalidPDFException, LinkTarget, loadScript,
|
||||
MissingPDFException, OPS, PDFWorker, shadow, UnexpectedResponseException,
|
||||
UNSUPPORTED_FEATURES, URL, version
|
||||
} from 'pdfjs-lib';
|
||||
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
||||
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
||||
|
@ -1583,6 +1584,7 @@ function loadAndEnablePDFBug(enabledTabs) {
|
|||
PDFBug.enable(enabledTabs);
|
||||
PDFBug.init({
|
||||
OPS,
|
||||
createObjectURL,
|
||||
}, appConfig.mainContainer);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import { AppOptions } from './app_options';
|
|||
import { BasePreferences } from './preferences';
|
||||
import { DownloadManager } from './download_manager';
|
||||
import { GenericL10n } from './genericl10n';
|
||||
import { URL } from 'pdfjs-lib';
|
||||
|
||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('CHROME')) {
|
||||
throw new Error('Module "pdfjs-web/chromecom" shall not be used outside ' +
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
'use strict';
|
||||
|
||||
var FontInspector = (function FontInspectorClosure() {
|
||||
var fonts;
|
||||
var fonts, createObjectURL;
|
||||
var active = false;
|
||||
var fontAttribute = 'data-font-name';
|
||||
function removeSelection() {
|
||||
|
@ -75,6 +75,8 @@ var FontInspector = (function FontInspectorClosure() {
|
|||
|
||||
fonts = document.createElement('div');
|
||||
panel.appendChild(fonts);
|
||||
|
||||
createObjectURL = pdfjsLib.createObjectURL;
|
||||
},
|
||||
cleanup: function cleanup() {
|
||||
fonts.textContent = '';
|
||||
|
@ -119,10 +121,7 @@ var FontInspector = (function FontInspectorClosure() {
|
|||
url = /url\(['"]?([^\)"']+)/.exec(url);
|
||||
download.href = url[1];
|
||||
} else if (fontObj.data) {
|
||||
url = URL.createObjectURL(new Blob([fontObj.data], {
|
||||
type: fontObj.mimeType,
|
||||
}));
|
||||
download.href = url;
|
||||
download.href = createObjectURL(fontObj.data, fontObj.mimeType);
|
||||
}
|
||||
download.textContent = 'Download';
|
||||
var logIt = document.createElement('a');
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
apiCompatibilityParams, createObjectURL, createValidAbsoluteUrl
|
||||
apiCompatibilityParams, createObjectURL, createValidAbsoluteUrl, URL
|
||||
} from 'pdfjs-lib';
|
||||
|
||||
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import '../extensions/firefox/tools/l10n';
|
||||
import { createObjectURL, PDFDataRangeTransport, shadow } from 'pdfjs-lib';
|
||||
import { createObjectURL, PDFDataRangeTransport, shadow, URL } from 'pdfjs-lib';
|
||||
import { BasePreferences } from './preferences';
|
||||
import { PDFViewerApplication } from './app';
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import { CSS_UNITS, NullL10n } from './ui_utils';
|
||||
import { PDFPrintServiceFactory, PDFViewerApplication } from './app';
|
||||
import { URL } from 'pdfjs-lib';
|
||||
|
||||
let activeService = null;
|
||||
let overlayManager = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue