Skip to content

Commit

Permalink
Merge pull request mozilla#7466 from Snuffleupagus/PDFViewerApplicati…
Browse files Browse the repository at this point in the history
…on-open-remove-fallback-args

Remove handling of fallback arguments from `PDFViewerApplication.open`
  • Loading branch information
timvandermeij authored Jul 9, 2016
2 parents d728651 + cb6a7e5 commit 43613f1
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,25 +562,12 @@ var PDFViewerApplication = {
* is opened.
*/
open: function pdfViewOpen(file, args) {
var scale = 0;
//#if GENERIC
if (arguments.length > 2 || typeof args === 'number') {
console.warn('Call of open() with obsolete signature.');
if (typeof args === 'number') {
scale = args; // scale argument was found
}
args = arguments[4] || null;
if (arguments[3] && typeof arguments[3] === 'object') {
// The pdfDataRangeTransport argument is present.
args = Object.create(args);
args.range = arguments[3];
}
if (typeof arguments[2] === 'string') {
// The password argument is present.
args = Object.create(args);
args.password = arguments[2];
}
return Promise.reject(
new Error('Call of open() with obsolete signature.'));
}

//#endif
if (this.pdfLoadingTask) {
// We need to destroy already opened document.
return this.close().then(function () {
Expand All @@ -591,7 +578,7 @@ var PDFViewerApplication = {
}.bind(this));
}

var parameters = Object.create(null);
var parameters = Object.create(null), scale;
if (typeof file === 'string') { // URL
this.setTitleUsingUrl(file);
parameters.url = file;
Expand All @@ -605,6 +592,13 @@ var PDFViewerApplication = {
for (var prop in args) {
parameters[prop] = args[prop];
}

if (args.scale) {
scale = args.scale;
}
if (args.length) {
this.pdfDocumentProperties.setFileSize(args.length);
}
}

var self = this;
Expand All @@ -625,7 +619,7 @@ var PDFViewerApplication = {
// Listen for unsupported features to trigger the fallback UI.
loadingTask.onUnsupportedFeature = this.fallback.bind(this);

var result = loadingTask.promise.then(
return loadingTask.promise.then(
function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
},
Expand Down Expand Up @@ -655,11 +649,6 @@ var PDFViewerApplication = {
throw new Error(loadingErrorMessage);
}
);

if (args && args.length) {
PDFViewerApplication.pdfDocumentProperties.setFileSize(args.length);
}
return result;
},

download: function pdfViewDownload() {
Expand Down

0 comments on commit 43613f1

Please sign in to comment.