[Pkg-javascript-commits] [pdf.js] 116/157: Prevent documents from intermittently opening with the zoom level set to 1% (issue 6253)

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 299d05eaa51457bab6ebf46a0310071dae0eabfb
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Wed Jul 22 23:40:38 2015 +0200

    Prevent documents from intermittently opening with the zoom level set to 1% (issue 6253)
    
    *This fixes a regression from PR 6192.*
    
    Under some circumstances, the `resize` event handler in `viewer.js` is fired before the scale has been set. This can lead to PDF documents being rendered at the wrong zoom level when they are opened.
    It seems that a way to reliably trigger this is to, using the Firefox addon, open a PDF file that triggers the `fallback` bar, in a new background tab (i.e. middle clicking on a link, or use the context menu).
    
    Prior to PR 6192, we checked the selected option in the `scaleSelect` dropdown instead. Since `pageAutoOption` is selected by default in `viewer.html`, this should explain why the issue wasn't visible previously.
---
 web/viewer.js | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/web/viewer.js b/web/viewer.js
index fc6e8f3..602750c 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -1639,13 +1639,16 @@ window.addEventListener('updateviewarea', function (evt) {
 window.addEventListener('resize', function webViewerResize(evt) {
   if (PDFViewerApplication.initialized) {
     var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;
-    switch (currentScaleValue) {
-      case 'auto':
-      case 'page-fit':
-      case 'page-width':
-        // Note: the scale is constant for 'page-actual'.
-        PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
-        break;
+    if (currentScaleValue === 'auto' ||
+        currentScaleValue === 'page-fit' ||
+        currentScaleValue === 'page-width') {
+      // Note: the scale is constant for 'page-actual'.
+      PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
+    } else if (!currentScaleValue) {
+      // Normally this shouldn't happen, but if the scale wasn't initialized
+      // we set it to the default value in order to prevent any issues.
+      // (E.g. the document being rendered with the wrong scale on load.)
+      PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
     }
   }
   updateViewarea();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list