[Pkg-javascript-commits] [pdf.js] 71/157: Remove `PDFViewerApplication.updateScaleControls` (issue 6158)

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:37 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 5cb15874fa27be2d2561b26c7c270739ca73c80a
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri Jul 10 13:34:14 2015 +0200

    Remove `PDFViewerApplication.updateScaleControls` (issue 6158)
    
    *With this patch we're getting very close to fixing 6158.*
    
    The only use-case for `PDFViewerApplication.updateScaleControls` is to try and avoid calling `selectScaleOption` from the `scalechange` event handler in viewer.js.
    This will *only* happen when the user has manually changed the scale by using the `<select>` dropdown, which means that in reality this is just a micro optimization. Furthermore, `selectScaleOption` is only skipped for the "named" scale values (e.g. `auto`, `page-actual`, `page-fit`, `page-width`), thus further reducing the value of this code.
    
    Also, since we're updating the scale `<select>` dropdown from an event handler, we're currently depending on the event being dispatched (and handled) completely before the next `scalechange` event. Relying on the execution order of the code in this way, even though it currently works, seems unfortunate since it *could* potentially cause the internal scale value and the UI from getting out of sync.
---
 web/viewer.js | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/web/viewer.js b/web/viewer.js
index 77bbccf..976c9d3 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -109,7 +109,6 @@ var PDFViewerApplication = {
   /** @type {PDFHistory} */
   pdfHistory: null,
   pageRotation: 0,
-  updateScaleControls: true,
   isInitialViewSet: false,
   animationStartedPromise: null,
   preferenceSidebarViewOnLoad: SidebarView.NONE,
@@ -1175,9 +1174,7 @@ var PDFViewerApplication = {
   },
 
   setScale: function (value, resetAutoSettings) {
-    this.updateScaleControls = !!resetAutoSettings;
     this.pdfViewer.currentScaleValue = value;
-    this.updateScaleControls = true;
   },
 
   rotatePages: function pdfViewRotatePages(delta) {
@@ -1752,18 +1749,6 @@ window.addEventListener('scalechange', function scalechange(evt) {
   document.getElementById('zoomOut').disabled = (evt.scale === MIN_SCALE);
   document.getElementById('zoomIn').disabled = (evt.scale === MAX_SCALE);
 
-  var customScaleOption = document.getElementById('customScaleOption');
-  customScaleOption.selected = false;
-
-  if (!PDFViewerApplication.updateScaleControls &&
-      (document.getElementById('pageAutoOption').selected ||
-       document.getElementById('pageActualOption').selected ||
-       document.getElementById('pageFitOption').selected ||
-       document.getElementById('pageWidthOption').selected)) {
-    updateViewarea();
-    return;
-  }
-
   if (evt.presetValue) {
     selectScaleOption(evt.presetValue);
     updateViewarea();
@@ -1772,6 +1757,7 @@ window.addEventListener('scalechange', function scalechange(evt) {
 
   var predefinedValueFound = selectScaleOption('' + evt.scale);
   if (!predefinedValueFound) {
+    var customScaleOption = document.getElementById('customScaleOption');
     var customScale = Math.round(evt.scale * 10000) / 100;
     customScaleOption.textContent =
       mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');

-- 
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