From 2f936f88f493c546d9ae3afd8da1e2c7912a4680 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 12 Nov 2017 17:30:53 +0100 Subject: [PATCH 1/3] Remove the `ignoreCurrentPositionOnZoom` viewer option The only reason for adding this parameter in the first place, all the way back in PR 4074, was that the "maintain document position on zooming" feature was landed and backed out a couple of times before it finally stuck. Hence it seemed, at the time, like a good idea to have a simple way to disable that behaviour. However, that was almost four years ago, and it's just not likely that we'd want/need to ever disable it now. Furthermore I really cannot imagine why anyone would actually *want* to reset the position whenever zooming occurs, since it results in a quite annoying UX. *So, to summarize:* Based on the above, I think that we should try to remove this parameter now. On the off chance that anyone complains, re-adding it shouldn't be difficult. --- web/app.js | 4 ---- web/base_viewer.js | 2 +- web/ui_utils.js | 6 ------ 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/web/app.js b/web/app.js index bf2226b87..0dd5f1f54 100644 --- a/web/app.js +++ b/web/app.js @@ -1525,10 +1525,6 @@ function webViewerInitialized() { if ('verbosity' in hashParams) { PDFJS.verbosity = hashParams['verbosity'] | 0; } - if ('ignorecurrentpositiononzoom' in hashParams) { - PDFJS.ignoreCurrentPositionOnZoom = - (hashParams['ignorecurrentpositiononzoom'] === 'true'); - } if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) { if ('disablebcmaps' in hashParams && hashParams['disablebcmaps']) { PDFJS.cMapUrl = '../external/cmaps/'; diff --git a/web/base_viewer.js b/web/base_viewer.js index bc953977e..521b193a7 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -505,7 +505,7 @@ class BaseViewer { if (!noScroll) { let page = this._currentPageNumber, dest; - if (this._location && !PDFJS.ignoreCurrentPositionOnZoom && + if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) { page = this._location.pageNumber; dest = [null, { name: 'XYZ', }, this._location.left, diff --git a/web/ui_utils.js b/web/ui_utils.js index dc762dfeb..455309b50 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -102,12 +102,6 @@ PDFJS.disableHistory = (PDFJS.disableHistory === undefined ? PDFJS.disableTextLayer = (PDFJS.disableTextLayer === undefined ? false : PDFJS.disableTextLayer); -/** - * Disables maintaining the current position in the document when zooming. - */ -PDFJS.ignoreCurrentPositionOnZoom = (PDFJS.ignoreCurrentPositionOnZoom === - undefined ? false : PDFJS.ignoreCurrentPositionOnZoom); - if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('FIREFOX || MOZCENTRAL')) { /** From eb3a1f24a3546ffa0642239263bd31775c131c8e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 12 Nov 2017 17:32:36 +0100 Subject: [PATCH 2/3] Remove the `PDFJS.disableHistory` code from `src/shared/compatibility.js` This compatibility code is only relevant for browsers that will no longer be supported (with PDF.js version 2.0), hence we ought to be able to remove it. --- src/shared/compatibility.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index 6e3f191e8..117d68345 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -488,20 +488,6 @@ PDFJS.compatibilityChecked = true; } })(); -// Check if the browser supports manipulation of the history. -// Support: IE<10, Android<4.2 -(function checkHistoryManipulation() { - if (!hasDOM) { - return; - } - // Android 2.x has so buggy pushState support that it was removed in - // Android 3.0 and restored as late as in Android 4.2. - // Support: Android 2.x - if (!history.pushState || isAndroidPre3) { - PDFJS.disableHistory = true; - } -})(); - // Support: IE<11, Chrome<21, Android<4.4, Safari<6 (function checkSetPresenceInImageData() { if (!hasDOM) { From 745cb73c65e315e44bf299a09f8d272d46a3b3f3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 12 Nov 2017 17:43:07 +0100 Subject: [PATCH 3/3] Remove `PDFJS.disableRange`/`PDFJS.disableStream` code for now unsupported browsers in `src/shared/compatibility.js` We're currently disabling range requests and streaming for a number of configurations. A couple of those will no longer be supported (with PDF.js version 2.0), hence we ought to be able to clean up the compatibility code slightly. --- src/shared/compatibility.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index 117d68345..4822755cd 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -25,10 +25,8 @@ var globalScope = require('./global_scope'); var userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''; var isAndroid = /Android/.test(userAgent); -var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent); var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent); var isChrome = userAgent.indexOf('Chrom') >= 0; -var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent); var isIOSChrome = userAgent.indexOf('CriOS') >= 0; var isIE = userAgent.indexOf('Trident') >= 0; var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent); @@ -470,19 +468,12 @@ PDFJS.compatibilityChecked = true; PDFJS.locale = navigator.userLanguage || 'en-US'; })(); -// Support: Safari 6.0+, Android<3.0, Chrome 39/40, iOS +// Support: Safari 6.0+, iOS (function checkRangeRequests() { // Safari has issues with cached range requests see: // https://github.com/mozilla/pdf.js/issues/3260 // Last tested with version 6.0.4. - - // Older versions of Android (pre 3.0) has issues with range requests, see: - // https://github.com/mozilla/pdf.js/issues/3381. - // Make sure that we only match webkit-based Android browsers, - // since Firefox/Fennec works as expected. - - // Range requests are broken in Chrome 39 and 40, https://crbug.com/442318 - if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) { + if (isSafari || isIOS) { PDFJS.disableRange = true; PDFJS.disableStream = true; }