[GeckoView] Ignore the pageLayout, from the PDF document, to prevent issues
First of all, given the screen-sizes of most mobile phones using Spread modes is unlikely to be useful. Secondly, and more importantly, since there's (currently) no UI available for the user to override a PDF document-specified Spread mode this would result in a bad UX otherwise. Also, removes an outdated comment from the `apiPageLayoutToViewerModes` helper function.
This commit is contained in:
		
							parent
							
								
									b518d93b45
								
							
						
					
					
						commit
						0289038961
					
				@ -1236,7 +1236,10 @@ const PDFViewerApplication = {
 | 
				
			|||||||
          if (pageMode && sidebarView === SidebarView.UNKNOWN) {
 | 
					          if (pageMode && sidebarView === SidebarView.UNKNOWN) {
 | 
				
			||||||
            sidebarView = apiPageModeToSidebarView(pageMode);
 | 
					            sidebarView = apiPageModeToSidebarView(pageMode);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					          // NOTE: Always ignore the pageLayout in GeckoView since there's
 | 
				
			||||||
 | 
					          // no UI available to change Scroll/Spread modes for the user.
 | 
				
			||||||
          if (
 | 
					          if (
 | 
				
			||||||
 | 
					            (typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW")) &&
 | 
				
			||||||
            pageLayout &&
 | 
					            pageLayout &&
 | 
				
			||||||
            scrollMode === ScrollMode.UNKNOWN &&
 | 
					            scrollMode === ScrollMode.UNKNOWN &&
 | 
				
			||||||
            spreadMode === SpreadMode.UNKNOWN
 | 
					            spreadMode === SpreadMode.UNKNOWN
 | 
				
			||||||
 | 
				
			|||||||
@ -265,13 +265,19 @@ class PDFScriptingManager {
 | 
				
			|||||||
        case "error":
 | 
					        case "error":
 | 
				
			||||||
          console.error(value);
 | 
					          console.error(value);
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case "layout":
 | 
					        case "layout": {
 | 
				
			||||||
          if (isInPresentationMode) {
 | 
					          // NOTE: Always ignore the pageLayout in GeckoView since there's
 | 
				
			||||||
 | 
					          // no UI available to change Scroll/Spread modes for the user.
 | 
				
			||||||
 | 
					          if (
 | 
				
			||||||
 | 
					            (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GECKOVIEW")) ||
 | 
				
			||||||
 | 
					            isInPresentationMode
 | 
				
			||||||
 | 
					          ) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          const modes = apiPageLayoutToViewerModes(value);
 | 
					          const modes = apiPageLayoutToViewerModes(value);
 | 
				
			||||||
          this._pdfViewer.spreadMode = modes.spreadMode;
 | 
					          this._pdfViewer.spreadMode = modes.spreadMode;
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        case "page-num":
 | 
					        case "page-num":
 | 
				
			||||||
          this._pdfViewer.currentPageNumber = value + 1;
 | 
					          this._pdfViewer.currentPageNumber = value + 1;
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
 | 
				
			|||||||
@ -769,9 +769,6 @@ function getActiveOrFocusedElement() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Converts API PageLayout values to the format used by `BaseViewer`.
 | 
					 * Converts API PageLayout values to the format used by `BaseViewer`.
 | 
				
			||||||
 * NOTE: This is supported to the extent that the viewer implements the
 | 
					 | 
				
			||||||
 *       necessary Scroll/Spread modes (since SinglePage, TwoPageLeft,
 | 
					 | 
				
			||||||
 *       and TwoPageRight all suggests using non-continuous scrolling).
 | 
					 | 
				
			||||||
 * @param {string} mode - The API PageLayout value.
 | 
					 * @param {string} mode - The API PageLayout value.
 | 
				
			||||||
 * @returns {Object}
 | 
					 * @returns {Object}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user