1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use Blob constructor when available instead of deprecated MozBlobBuilder.

This commit is contained in:
Brendan Dahl 2012-09-22 09:44:49 -07:00
parent 130447755e
commit 739ee47865
3 changed files with 15 additions and 8 deletions

View file

@ -460,9 +460,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
//#else
// // 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.
// var bb = new MozBlobBuilder();
// bb.append(document.querySelector('#PDFJS_SCRIPT_TAG').textContent);
// var blobUrl = window.URL.createObjectURL(bb.getBlob());
// var script = document.querySelector('#PDFJS_SCRIPT_TAG');
// var blob = PDFJS.createBlob(script.textContent, script.type);
// var blobUrl = window.URL.createObjectURL(blob);
// worker = new Worker(blobUrl);
//#endif
var messageHandler = new MessageHandler('main', worker);
@ -503,6 +503,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
this.pagePromises = [];
},
setupFakeWorker: function WorkerTransport_setupFakeWorker() {
warn('Setting up fake worker.');
// If we don't use a worker, just post/sendMessage to the main thread.
var fakeWorker = {
postMessage: function WorkerTransport_postMessage(obj) {

View file

@ -662,3 +662,12 @@ var StatTimer = (function StatTimerClosure() {
};
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);
};