[Pkg-javascript-commits] [pdf.js] 112/207: Increases page cache size when needed

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:37 UTC 2014


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

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

commit df87df59b60a38c02d1d5f1c9ac3f0d30b933c6d
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Tue Jun 17 13:41:40 2014 -0500

    Increases page cache size when needed
---
 web/ui_utils.js | 6 ++++++
 web/viewer.js   | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/web/ui_utils.js b/web/ui_utils.js
index 9caa815..29ee01b 100644
--- a/web/ui_utils.js
+++ b/web/ui_utils.js
@@ -255,5 +255,11 @@ var Cache = function cacheCache(size) {
       data.shift().destroy();
     }
   };
+  this.resize = function (newSize) {
+    size = newSize;
+    while (data.length > size) {
+      data.shift().destroy();
+    }
+  };
 };
 
diff --git a/web/viewer.js b/web/viewer.js
index 553765f..30cdf27 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -28,7 +28,7 @@ var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
 var DEFAULT_SCALE = 'auto';
 var DEFAULT_SCALE_DELTA = 1.1;
 var UNKNOWN_SCALE = 0;
-var CACHE_SIZE = 10;
+var DEFAULT_CACHE_SIZE = 10;
 var CSS_UNITS = 96.0 / 72.0;
 var SCROLLBAR_PADDING = 40;
 var VERTICAL_PADDING = 5;
@@ -91,7 +91,7 @@ var mozL10n = document.mozL10n || document.webL10n;
 //#include chromecom.js
 //#endif
 
-var cache = new Cache(CACHE_SIZE);
+var cache = new Cache(DEFAULT_CACHE_SIZE);
 var currentPageNumber = 1;
 
 //#include view_history.js
@@ -1964,6 +1964,10 @@ function updateViewarea() {
     return;
   }
 
+  var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE,
+      2 * visiblePages.length + 1);
+  cache.resize(suggestedCacheSize);
+
   PDFView.renderHighestPriority(visible);
 
   var currentId = PDFView.page;

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