Merge pull request #7640 from timvandermeij/interactive-forms-rm-global
Interactive forms: remove global PDFJS usage
This commit is contained in:
commit
ab1b4cec5d
@ -243,13 +243,6 @@
|
|||||||
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
||||||
true : PDFJS.isEvalSupported);
|
true : PDFJS.isEvalSupported);
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders interactive form elements.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.renderInteractiveForms = (PDFJS.renderInteractiveForms === undefined ?
|
|
||||||
false : PDFJS.renderInteractiveForms);
|
|
||||||
|
|
||||||
//#if !MOZCENTRAL
|
//#if !MOZCENTRAL
|
||||||
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
|
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
|
||||||
delete PDFJS.openExternalLinksInNewWindow;
|
delete PDFJS.openExternalLinksInNewWindow;
|
||||||
|
@ -36,6 +36,7 @@ var SimpleLinkService = pdfLinkService.SimpleLinkService;
|
|||||||
* @typedef {Object} AnnotationLayerBuilderOptions
|
* @typedef {Object} AnnotationLayerBuilderOptions
|
||||||
* @property {HTMLDivElement} pageDiv
|
* @property {HTMLDivElement} pageDiv
|
||||||
* @property {PDFPage} pdfPage
|
* @property {PDFPage} pdfPage
|
||||||
|
* @property {boolean} renderInteractiveForms
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
* @property {DownloadManager} downloadManager
|
* @property {DownloadManager} downloadManager
|
||||||
*/
|
*/
|
||||||
@ -51,6 +52,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
|||||||
function AnnotationLayerBuilder(options) {
|
function AnnotationLayerBuilder(options) {
|
||||||
this.pageDiv = options.pageDiv;
|
this.pageDiv = options.pageDiv;
|
||||||
this.pdfPage = options.pdfPage;
|
this.pdfPage = options.pdfPage;
|
||||||
|
this.renderInteractiveForms = options.renderInteractiveForms;
|
||||||
this.linkService = options.linkService;
|
this.linkService = options.linkService;
|
||||||
this.downloadManager = options.downloadManager;
|
this.downloadManager = options.downloadManager;
|
||||||
|
|
||||||
@ -77,9 +79,9 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
|||||||
div: self.div,
|
div: self.div,
|
||||||
annotations: annotations,
|
annotations: annotations,
|
||||||
page: self.pdfPage,
|
page: self.pdfPage,
|
||||||
|
renderInteractiveForms: self.renderInteractiveForms,
|
||||||
linkService: self.linkService,
|
linkService: self.linkService,
|
||||||
downloadManager: self.downloadManager,
|
downloadManager: self.downloadManager,
|
||||||
renderInteractiveForms: pdfjsLib.PDFJS.renderInteractiveForms,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (self.div) {
|
if (self.div) {
|
||||||
@ -126,12 +128,15 @@ DefaultAnnotationLayerFactory.prototype = {
|
|||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPage} pdfPage
|
||||||
|
* @param {boolean} renderInteractiveForms
|
||||||
* @returns {AnnotationLayerBuilder}
|
* @returns {AnnotationLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createAnnotationLayerBuilder: function (pageDiv, pdfPage) {
|
createAnnotationLayerBuilder: function (pageDiv, pdfPage,
|
||||||
|
renderInteractiveForms) {
|
||||||
return new AnnotationLayerBuilder({
|
return new AnnotationLayerBuilder({
|
||||||
pageDiv: pageDiv,
|
pageDiv: pageDiv,
|
||||||
pdfPage: pdfPage,
|
pdfPage: pdfPage,
|
||||||
|
renderInteractiveForms: renderInteractiveForms,
|
||||||
linkService: new SimpleLinkService(),
|
linkService: new SimpleLinkService(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,7 @@ var PDFViewerApplication = {
|
|||||||
linkService: pdfLinkService,
|
linkService: pdfLinkService,
|
||||||
downloadManager: downloadManager,
|
downloadManager: downloadManager,
|
||||||
enhanceTextSelection: false,
|
enhanceTextSelection: false,
|
||||||
|
renderInteractiveForms: false,
|
||||||
});
|
});
|
||||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||||
pdfLinkService.setViewer(this.pdfViewer);
|
pdfLinkService.setViewer(this.pdfViewer);
|
||||||
@ -371,7 +372,10 @@ var PDFViewerApplication = {
|
|||||||
PDFJS.externalLinkTarget = value;
|
PDFJS.externalLinkTarget = value;
|
||||||
}),
|
}),
|
||||||
Preferences.get('renderInteractiveForms').then(function resolved(value) {
|
Preferences.get('renderInteractiveForms').then(function resolved(value) {
|
||||||
PDFJS.renderInteractiveForms = value;
|
// TODO: Like the `enhanceTextSelection` preference, move the
|
||||||
|
// initialization and fetching of `Preferences` to occur
|
||||||
|
// before the various viewer components are initialized.
|
||||||
|
self.pdfViewer.renderInteractiveForms = value;
|
||||||
}),
|
}),
|
||||||
// TODO move more preferences and other async stuff here
|
// TODO move more preferences and other async stuff here
|
||||||
]).catch(function (reason) { });
|
]).catch(function (reason) { });
|
||||||
|
@ -113,7 +113,9 @@ IPDFAnnotationLayerFactory.prototype = {
|
|||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPage} pdfPage
|
||||||
|
* @param {boolean} renderInteractiveForms
|
||||||
* @returns {AnnotationLayerBuilder}
|
* @returns {AnnotationLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createAnnotationLayerBuilder: function (pageDiv, pdfPage) {}
|
createAnnotationLayerBuilder: function (pageDiv, pdfPage,
|
||||||
|
renderInteractiveForms) {}
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
|
|||||||
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
|
||||||
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
* @property {boolean} enhanceTextSelection - Turns on the text selection
|
||||||
* enhancement. The default is `false`.
|
* enhancement. The default is `false`.
|
||||||
|
* @property {boolean} renderInteractiveForms - Turns on rendering of
|
||||||
|
* interactive form elements. The default is `false`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,6 +74,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
var textLayerFactory = options.textLayerFactory;
|
var textLayerFactory = options.textLayerFactory;
|
||||||
var annotationLayerFactory = options.annotationLayerFactory;
|
var annotationLayerFactory = options.annotationLayerFactory;
|
||||||
var enhanceTextSelection = options.enhanceTextSelection || false;
|
var enhanceTextSelection = options.enhanceTextSelection || false;
|
||||||
|
var renderInteractiveForms = options.renderInteractiveForms || false;
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.renderingId = 'page' + id;
|
this.renderingId = 'page' + id;
|
||||||
@ -82,6 +85,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
this.pdfPageRotate = defaultViewport.rotation;
|
this.pdfPageRotate = defaultViewport.rotation;
|
||||||
this.hasRestrictedScaling = false;
|
this.hasRestrictedScaling = false;
|
||||||
this.enhanceTextSelection = enhanceTextSelection;
|
this.enhanceTextSelection = enhanceTextSelection;
|
||||||
|
this.renderInteractiveForms = renderInteractiveForms;
|
||||||
|
|
||||||
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
|
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
|
||||||
this.renderingQueue = renderingQueue;
|
this.renderingQueue = renderingQueue;
|
||||||
@ -498,7 +502,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
canvasContext: ctx,
|
canvasContext: ctx,
|
||||||
transform: transform,
|
transform: transform,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
renderInteractiveForms: pdfjsLib.PDFJS.renderInteractiveForms,
|
renderInteractiveForms: this.renderInteractiveForms,
|
||||||
// intent: 'default', // === 'display'
|
// intent: 'default', // === 'display'
|
||||||
};
|
};
|
||||||
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
||||||
@ -524,7 +528,8 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||||||
if (this.annotationLayerFactory) {
|
if (this.annotationLayerFactory) {
|
||||||
if (!this.annotationLayer) {
|
if (!this.annotationLayer) {
|
||||||
this.annotationLayer = this.annotationLayerFactory.
|
this.annotationLayer = this.annotationLayerFactory.
|
||||||
createAnnotationLayerBuilder(div, this.pdfPage);
|
createAnnotationLayerBuilder(div, this.pdfPage,
|
||||||
|
this.renderInteractiveForms);
|
||||||
}
|
}
|
||||||
this.annotationLayer.render(this.viewport, 'display');
|
this.annotationLayer.render(this.viewport, 'display');
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,8 @@ var DEFAULT_CACHE_SIZE = 10;
|
|||||||
* around the pages. The default is false.
|
* around the pages. The default is false.
|
||||||
* @property {boolean} enhanceTextSelection - (optional) Enables the improved
|
* @property {boolean} enhanceTextSelection - (optional) Enables the improved
|
||||||
* text selection behaviour. The default is `false`.
|
* text selection behaviour. The default is `false`.
|
||||||
|
* @property {boolean} renderInteractiveForms - (optional) Enables rendering of
|
||||||
|
* interactive form elements. The default is `false`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,6 +132,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
this.downloadManager = options.downloadManager || null;
|
this.downloadManager = options.downloadManager || null;
|
||||||
this.removePageBorders = options.removePageBorders || false;
|
this.removePageBorders = options.removePageBorders || false;
|
||||||
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
||||||
|
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||||
|
|
||||||
this.defaultRenderingQueue = !options.renderingQueue;
|
this.defaultRenderingQueue = !options.renderingQueue;
|
||||||
if (this.defaultRenderingQueue) {
|
if (this.defaultRenderingQueue) {
|
||||||
@ -357,6 +360,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
textLayerFactory: textLayerFactory,
|
textLayerFactory: textLayerFactory,
|
||||||
annotationLayerFactory: this,
|
annotationLayerFactory: this,
|
||||||
enhanceTextSelection: this.enhanceTextSelection,
|
enhanceTextSelection: this.enhanceTextSelection,
|
||||||
|
renderInteractiveForms: this.renderInteractiveForms,
|
||||||
});
|
});
|
||||||
bindOnAfterAndBeforeDraw(pageView);
|
bindOnAfterAndBeforeDraw(pageView);
|
||||||
this._pages.push(pageView);
|
this._pages.push(pageView);
|
||||||
@ -856,12 +860,15 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} pageDiv
|
* @param {HTMLDivElement} pageDiv
|
||||||
* @param {PDFPage} pdfPage
|
* @param {PDFPage} pdfPage
|
||||||
|
* @param {boolean} renderInteractiveForms
|
||||||
* @returns {AnnotationLayerBuilder}
|
* @returns {AnnotationLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createAnnotationLayerBuilder: function (pageDiv, pdfPage) {
|
createAnnotationLayerBuilder: function (pageDiv, pdfPage,
|
||||||
|
renderInteractiveForms) {
|
||||||
return new AnnotationLayerBuilder({
|
return new AnnotationLayerBuilder({
|
||||||
pageDiv: pageDiv,
|
pageDiv: pageDiv,
|
||||||
pdfPage: pdfPage,
|
pdfPage: pdfPage,
|
||||||
|
renderInteractiveForms: renderInteractiveForms,
|
||||||
linkService: this.linkService,
|
linkService: this.linkService,
|
||||||
downloadManager: this.downloadManager
|
downloadManager: this.downloadManager
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user