[api-minor] Add a pdfjsNext parameter, and PDFJS_NEXT build flag, to allow backwards incompatible API changes

This commit is contained in:
Jonas Jenwald 2017-03-13 17:35:33 +01:00
parent 2b17188998
commit 6d672c4ba6
7 changed files with 20 additions and 5 deletions

View File

@ -67,7 +67,8 @@ var DEFINES = {
CHROME: false, CHROME: false,
MINIFIED: false, MINIFIED: false,
SINGLE_FILE: false, SINGLE_FILE: false,
COMPONENTS: false COMPONENTS: false,
PDFJS_NEXT: false,
}; };
function createStringSource(filename, content) { function createStringSource(filename, content) {
@ -669,7 +670,7 @@ gulp.task('minified', ['minified-pre'], function (done) {
gulp.task('firefox-pre', ['buildnumber', 'locale'], function () { gulp.task('firefox-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building Firefox extension'); console.log('### Building Firefox extension');
var defines = builder.merge(DEFINES, {FIREFOX: true}); var defines = builder.merge(DEFINES, { FIREFOX: true, PDFJS_NEXT: true, });
var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/', var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
FIREFOX_EXTENSION_DIR = 'extensions/firefox/', FIREFOX_EXTENSION_DIR = 'extensions/firefox/',
@ -780,7 +781,7 @@ gulp.task('firefox', ['firefox-pre'], function (done) {
gulp.task('mozcentral-pre', ['buildnumber', 'locale'], function () { gulp.task('mozcentral-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building mozilla-central extension'); console.log('### Building mozilla-central extension');
var defines = builder.merge(DEFINES, {MOZCENTRAL: true}); var defines = builder.merge(DEFINES, { MOZCENTRAL: true, PDFJS_NEXT: true, });
var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/', var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/',
MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/', MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/',
@ -851,7 +852,7 @@ gulp.task('mozcentral', ['mozcentral-pre']);
gulp.task('chromium-pre', ['buildnumber', 'locale'], function () { gulp.task('chromium-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building Chromium extension'); console.log('### Building Chromium extension');
var defines = builder.merge(DEFINES, {CHROME: true}); var defines = builder.merge(DEFINES, { CHROME: true, PDFJS_NEXT: true, });
var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/', var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/'; CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/';

View File

@ -2065,7 +2065,7 @@ var RenderTask = (function RenderTaskClosure() {
/** /**
* Cancels the rendering task. If the task is currently rendering it will * Cancels the rendering task. If the task is currently rendering it will
* not be cancelled until graphics pauses with a timeout. The promise that * not be cancelled until graphics pauses with a timeout. The promise that
* this object extends will resolved when cancelled. * this object extends will be rejected when cancelled.
*/ */
cancel: function RenderTask_cancel() { cancel: function RenderTask_cancel() {
this._internalRenderTask.cancel(); this._internalRenderTask.cancel();

View File

@ -305,6 +305,8 @@ function getDefaultSetting(id) {
return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL; return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
case 'enableStats': case 'enableStats':
return !!(globalSettings && globalSettings.enableStats); return !!(globalSettings && globalSettings.enableStats);
case 'pdfjsNext':
return !!(globalSettings && globalSettings.pdfjsNext);
default: default:
throw new Error('Unknown default setting: ' + id); throw new Error('Unknown default setting: ' + id);
} }

View File

@ -251,6 +251,13 @@
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
true : PDFJS.isEvalSupported); true : PDFJS.isEvalSupported);
/**
* Opt-in to backwards incompatible API changes. NOTE:
* If the `PDFJS_NEXT` build flag is set, it will override this setting.
* @var {boolean}
*/
PDFJS.pdfjsNext = (PDFJS.pdfjsNext === undefined) ? false : PDFJS.pdfjsNext;
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) { if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow; var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow; delete PDFJS.openExternalLinksInNewWindow;

View File

@ -263,6 +263,8 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
PDFJS.cMapUrl = '../external/bcmaps/'; PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.enableStats = true; PDFJS.enableStats = true;
PDFJS.imageResourcesPath = '/web/images/'; PDFJS.imageResourcesPath = '/web/images/';
// Opt-in to using the latest API.
PDFJS.pdfjsNext = true;
// Set the passed options // Set the passed options
this.inflight = options.inflight; this.inflight = options.inflight;

View File

@ -60,6 +60,8 @@ function initializePDFJS(callback) {
// Configure the worker. // Configure the worker.
displayGlobal.PDFJS.workerSrc = '../../src/worker_loader.js'; displayGlobal.PDFJS.workerSrc = '../../src/worker_loader.js';
// Opt-in to using the latest API.
displayGlobal.PDFJS.pdfjsNext = true;
callback(); callback();
}); });

View File

@ -117,6 +117,7 @@ function configure(PDFJS) {
PDFJS.cMapUrl = '../external/bcmaps/'; PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.cMapPacked = true; PDFJS.cMapPacked = true;
PDFJS.workerSrc = '../src/worker_loader.js'; PDFJS.workerSrc = '../src/worker_loader.js';
PDFJS.pdfjsNext = true;
} else { } else {
PDFJS.cMapUrl = '../web/cmaps/'; PDFJS.cMapUrl = '../web/cmaps/';
PDFJS.cMapPacked = true; PDFJS.cMapPacked = true;