Remove handling of fallback arguments from PDFViewerApplication.open
				
					
				
			The method signature was improved in PR 6546, which was included in the `1.2.109` release from last November. Hence I think that we should now be able to remove the fallback code for the old method signature. Note that this patch now throws an `Error` in `GENERIC` builds, to clearly indicate that the `open` callsite must be modified.
This commit is contained in:
		
							parent
							
								
									f082407ab4
								
							
						
					
					
						commit
						cb6a7e5503
					
				
							
								
								
									
										37
									
								
								web/app.js
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								web/app.js
									
									
									
									
									
								
							@ -562,25 +562,12 @@ var PDFViewerApplication = {
 | 
				
			|||||||
   *                      is opened.
 | 
					   *                      is opened.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  open: function pdfViewOpen(file, args) {
 | 
					  open: function pdfViewOpen(file, args) {
 | 
				
			||||||
    var scale = 0;
 | 
					//#if GENERIC
 | 
				
			||||||
    if (arguments.length > 2 || typeof args === 'number') {
 | 
					    if (arguments.length > 2 || typeof args === 'number') {
 | 
				
			||||||
      console.warn('Call of open() with obsolete signature.');
 | 
					      return Promise.reject(
 | 
				
			||||||
      if (typeof args === 'number') {
 | 
					        new Error('Call of open() with obsolete signature.'));
 | 
				
			||||||
        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];
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					//#endif
 | 
				
			||||||
    if (this.pdfLoadingTask) {
 | 
					    if (this.pdfLoadingTask) {
 | 
				
			||||||
      // We need to destroy already opened document.
 | 
					      // We need to destroy already opened document.
 | 
				
			||||||
      return this.close().then(function () {
 | 
					      return this.close().then(function () {
 | 
				
			||||||
@ -591,7 +578,7 @@ var PDFViewerApplication = {
 | 
				
			|||||||
      }.bind(this));
 | 
					      }.bind(this));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var parameters = Object.create(null);
 | 
					    var parameters = Object.create(null), scale;
 | 
				
			||||||
    if (typeof file === 'string') { // URL
 | 
					    if (typeof file === 'string') { // URL
 | 
				
			||||||
      this.setTitleUsingUrl(file);
 | 
					      this.setTitleUsingUrl(file);
 | 
				
			||||||
      parameters.url = file;
 | 
					      parameters.url = file;
 | 
				
			||||||
@ -605,6 +592,13 @@ var PDFViewerApplication = {
 | 
				
			|||||||
      for (var prop in args) {
 | 
					      for (var prop in args) {
 | 
				
			||||||
        parameters[prop] = args[prop];
 | 
					        parameters[prop] = args[prop];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (args.scale) {
 | 
				
			||||||
 | 
					        scale = args.scale;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (args.length) {
 | 
				
			||||||
 | 
					        this.pdfDocumentProperties.setFileSize(args.length);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var self = this;
 | 
					    var self = this;
 | 
				
			||||||
@ -625,7 +619,7 @@ var PDFViewerApplication = {
 | 
				
			|||||||
    // Listen for unsupported features to trigger the fallback UI.
 | 
					    // Listen for unsupported features to trigger the fallback UI.
 | 
				
			||||||
    loadingTask.onUnsupportedFeature = this.fallback.bind(this);
 | 
					    loadingTask.onUnsupportedFeature = this.fallback.bind(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var result = loadingTask.promise.then(
 | 
					    return loadingTask.promise.then(
 | 
				
			||||||
      function getDocumentCallback(pdfDocument) {
 | 
					      function getDocumentCallback(pdfDocument) {
 | 
				
			||||||
        self.load(pdfDocument, scale);
 | 
					        self.load(pdfDocument, scale);
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
@ -655,11 +649,6 @@ var PDFViewerApplication = {
 | 
				
			|||||||
        throw new Error(loadingErrorMessage);
 | 
					        throw new Error(loadingErrorMessage);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (args && args.length) {
 | 
					 | 
				
			||||||
      PDFViewerApplication.pdfDocumentProperties.setFileSize(args.length);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return result;
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  download: function pdfViewDownload() {
 | 
					  download: function pdfViewDownload() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user