Use Blob constructor when available instead of deprecated MozBlobBuilder.
This commit is contained in:
parent
130447755e
commit
739ee47865
@ -460,9 +460,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
//#else
|
//#else
|
||||||
// // The firefox extension can't load the worker from the resource://
|
// // The firefox extension can't load the worker from the resource://
|
||||||
// // url so we have to inline the script and then use the blob loader.
|
// // url so we have to inline the script and then use the blob loader.
|
||||||
// var bb = new MozBlobBuilder();
|
// var script = document.querySelector('#PDFJS_SCRIPT_TAG');
|
||||||
// bb.append(document.querySelector('#PDFJS_SCRIPT_TAG').textContent);
|
// var blob = PDFJS.createBlob(script.textContent, script.type);
|
||||||
// var blobUrl = window.URL.createObjectURL(bb.getBlob());
|
// var blobUrl = window.URL.createObjectURL(blob);
|
||||||
// worker = new Worker(blobUrl);
|
// worker = new Worker(blobUrl);
|
||||||
//#endif
|
//#endif
|
||||||
var messageHandler = new MessageHandler('main', worker);
|
var messageHandler = new MessageHandler('main', worker);
|
||||||
@ -503,6 +503,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
this.pagePromises = [];
|
this.pagePromises = [];
|
||||||
},
|
},
|
||||||
setupFakeWorker: function WorkerTransport_setupFakeWorker() {
|
setupFakeWorker: function WorkerTransport_setupFakeWorker() {
|
||||||
|
warn('Setting up fake worker.');
|
||||||
// If we don't use a worker, just post/sendMessage to the main thread.
|
// If we don't use a worker, just post/sendMessage to the main thread.
|
||||||
var fakeWorker = {
|
var fakeWorker = {
|
||||||
postMessage: function WorkerTransport_postMessage(obj) {
|
postMessage: function WorkerTransport_postMessage(obj) {
|
||||||
|
@ -662,3 +662,12 @@ var StatTimer = (function StatTimerClosure() {
|
|||||||
};
|
};
|
||||||
return StatTimer;
|
return StatTimer;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
PDFJS.createBlob = function createBlob(data, contentType) {
|
||||||
|
if (typeof Blob === 'function')
|
||||||
|
return new Blob([data], { type: contentType });
|
||||||
|
// Blob builder is deprecated in FF14 and removed in FF18.
|
||||||
|
var bb = new MozBlobBuilder();
|
||||||
|
bb.append(data);
|
||||||
|
return bb.getBlob(contentType);
|
||||||
|
};
|
||||||
|
@ -483,7 +483,6 @@ var PDFView = {
|
|||||||
function noData() {
|
function noData() {
|
||||||
FirefoxCom.request('download', { originalUrl: url });
|
FirefoxCom.request('download', { originalUrl: url });
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = this.url.split('#')[0];
|
var url = this.url.split('#')[0];
|
||||||
//#if !(FIREFOX || MOZCENTRAL)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
url += '#pdfjs.action=download';
|
url += '#pdfjs.action=download';
|
||||||
@ -496,10 +495,8 @@ var PDFView = {
|
|||||||
// }
|
// }
|
||||||
// this.pdfDocument.getData().then(
|
// this.pdfDocument.getData().then(
|
||||||
// function getDataSuccess(data) {
|
// function getDataSuccess(data) {
|
||||||
// var bb = new MozBlobBuilder();
|
// var blob = PDFJS.createBlob(data.buffer, 'application/pdf');
|
||||||
// bb.append(data.buffer);
|
// var blobUrl = window.URL.createObjectURL(blob);
|
||||||
// var blobUrl = window.URL.createObjectURL(
|
|
||||||
// bb.getBlob('application/pdf'));
|
|
||||||
//
|
//
|
||||||
// FirefoxCom.request('download', { blobUrl: blobUrl, originalUrl: url },
|
// FirefoxCom.request('download', { blobUrl: blobUrl, originalUrl: url },
|
||||||
// function response(err) {
|
// function response(err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user