Merge pull request #16744 from Snuffleupagus/app-small-simplifications
A few small `web/app.js` simplifications
This commit is contained in:
		
						commit
						aea13b4478
					
				
							
								
								
									
										35
									
								
								web/app.js
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								web/app.js
									
									
									
									
									
								
							@ -694,7 +694,7 @@ const PDFViewerApplication = {
 | 
				
			|||||||
  async run(config) {
 | 
					  async run(config) {
 | 
				
			||||||
    await this.initialize(config);
 | 
					    await this.initialize(config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const { appConfig, eventBus, l10n } = this;
 | 
					    const { appConfig, eventBus } = this;
 | 
				
			||||||
    let file;
 | 
					    let file;
 | 
				
			||||||
    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
					    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
				
			||||||
      const queryString = document.location.search.substring(1);
 | 
					      const queryString = document.location.search.substring(1);
 | 
				
			||||||
@ -745,7 +745,7 @@ const PDFViewerApplication = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (!this.supportsDocumentFonts) {
 | 
					    if (!this.supportsDocumentFonts) {
 | 
				
			||||||
      AppOptions.set("disableFontFace", true);
 | 
					      AppOptions.set("disableFontFace", true);
 | 
				
			||||||
      l10n.get("web_fonts_disabled").then(msg => {
 | 
					      this.l10n.get("web_fonts_disabled").then(msg => {
 | 
				
			||||||
        console.warn(msg);
 | 
					        console.warn(msg);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -775,22 +775,16 @@ const PDFViewerApplication = {
 | 
				
			|||||||
      true
 | 
					      true
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
				
			||||||
      if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
					      if (file) {
 | 
				
			||||||
        if (file) {
 | 
					        this.open({ url: file });
 | 
				
			||||||
          this.open({ url: file });
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          this._hideViewBookmark();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
 | 
					 | 
				
			||||||
        this.initPassiveLoading(file);
 | 
					 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        throw new Error("Not implemented: run");
 | 
					        this._hideViewBookmark();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (reason) {
 | 
					    } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
 | 
				
			||||||
      l10n.get("loading_error").then(msg => {
 | 
					      this.initPassiveLoading(file);
 | 
				
			||||||
        this._documentError(msg, reason);
 | 
					    } else {
 | 
				
			||||||
      });
 | 
					      throw new Error("Not implemented: run");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1289,13 +1283,13 @@ const PDFViewerApplication = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Since the `setInitialView` call below depends on this being resolved,
 | 
					    // Since the `setInitialView` call below depends on this being resolved,
 | 
				
			||||||
    // fetch it early to avoid delaying initial rendering of the PDF document.
 | 
					    // fetch it early to avoid delaying initial rendering of the PDF document.
 | 
				
			||||||
    const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {
 | 
					    const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {
 | 
				
			||||||
      /* Avoid breaking initial rendering; ignoring errors. */
 | 
					      /* Avoid breaking initial rendering; ignoring errors. */
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    const pageModePromise = pdfDocument.getPageMode().catch(function () {
 | 
					    const pageModePromise = pdfDocument.getPageMode().catch(() => {
 | 
				
			||||||
      /* Avoid breaking initial rendering; ignoring errors. */
 | 
					      /* Avoid breaking initial rendering; ignoring errors. */
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    const openActionPromise = pdfDocument.getOpenAction().catch(function () {
 | 
					    const openActionPromise = pdfDocument.getOpenAction().catch(() => {
 | 
				
			||||||
      /* Avoid breaking initial rendering; ignoring errors. */
 | 
					      /* Avoid breaking initial rendering; ignoring errors. */
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1336,7 +1330,6 @@ const PDFViewerApplication = {
 | 
				
			|||||||
      })
 | 
					      })
 | 
				
			||||||
      .catch(() => {
 | 
					      .catch(() => {
 | 
				
			||||||
        /* Unable to read from storage; ignoring errors. */
 | 
					        /* Unable to read from storage; ignoring errors. */
 | 
				
			||||||
        return Object.create(null);
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    firstPagePromise.then(pdfPage => {
 | 
					    firstPagePromise.then(pdfPage => {
 | 
				
			||||||
@ -1369,7 +1362,7 @@ const PDFViewerApplication = {
 | 
				
			|||||||
          let scrollMode = AppOptions.get("scrollModeOnLoad");
 | 
					          let scrollMode = AppOptions.get("scrollModeOnLoad");
 | 
				
			||||||
          let spreadMode = AppOptions.get("spreadModeOnLoad");
 | 
					          let spreadMode = AppOptions.get("spreadModeOnLoad");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
 | 
					          if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
 | 
				
			||||||
            hash =
 | 
					            hash =
 | 
				
			||||||
              `page=${stored.page}&zoom=${zoom || stored.zoom},` +
 | 
					              `page=${stored.page}&zoom=${zoom || stored.zoom},` +
 | 
				
			||||||
              `${stored.scrollLeft},${stored.scrollTop}`;
 | 
					              `${stored.scrollLeft},${stored.scrollTop}`;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user