[Pkg-javascript-commits] [pdf.js] 07/116: Removes Stats dependency from PDFPageView.

David Prévot taffit at moszumanska.debian.org
Fri Mar 6 16:19:55 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 22c62685b0f7e6d2009f3a6d0419b51817851c99
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Mon Sep 29 11:15:06 2014 -0500

    Removes Stats dependency from PDFPageView.
---
 web/pdf_page_view.js | 15 +--------------
 web/pdf_viewer.js    |  1 -
 web/viewer.js        | 19 ++++++++++++++++---
 3 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js
index 87228c3..3ebe414 100644
--- a/web/pdf_page_view.js
+++ b/web/pdf_page_view.js
@@ -14,8 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/* globals RenderingStates, PDFJS, CustomStyle, CSS_UNITS, getOutputScale,
-           Stats */
+/* globals RenderingStates, PDFJS, CustomStyle, CSS_UNITS, getOutputScale  */
 
 'use strict';
 
@@ -392,7 +391,6 @@ var PDFPageView = (function PDFPageViewClosure() {
 
         self.error = error;
         self.stats = pdfPage.stats;
-        self.updateStats();
         if (self.onAfterDraw) {
           self.onAfterDraw();
         }
@@ -508,17 +506,6 @@ var PDFPageView = (function PDFPageViewClosure() {
         });
       };
     },
-
-    updateStats: function PDFPageView_updateStats() {
-      if (!this.stats) {
-        return;
-      }
-
-      if (PDFJS.pdfBug && Stats.enabled) {
-        var stats = this.stats;
-        Stats.add(this.id, stats);
-      }
-    },
   };
 
   return PDFPageView;
diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js
index 8448322..42e9efa 100644
--- a/web/pdf_viewer.js
+++ b/web/pdf_viewer.js
@@ -107,7 +107,6 @@ var PDFViewer = (function pdfViewer() {
         return;
       }
 
-      this.pages[val - 1].updateStats();
       event.previousPageNumber = this._currentPageNumber;
       this._currentPageNumber = val;
       event.pageNumber = val;
diff --git a/web/viewer.js b/web/viewer.js
index 802d554..c00a43b 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -16,7 +16,7 @@
  */
 /* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, ProgressBar,
            DownloadManager, getFileName, scrollIntoView, getPDFFileNameFromURL,
-           PDFHistory, Preferences, SidebarView, ViewHistory,
+           PDFHistory, Preferences, SidebarView, ViewHistory, Stats,
            PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
            PasswordPrompt, PresentationMode, HandTool, Promise,
            DocumentProperties, DocumentOutlineView, DocumentAttachmentsView,
@@ -1730,12 +1730,17 @@ function webViewerInitialized() {
 document.addEventListener('DOMContentLoaded', webViewerLoad, true);
 
 document.addEventListener('pagerendered', function (e) {
-  var pageIndex = e.detail.pageNumber - 1;
+  var pageNumber = e.detail.pageNumber;
+  var pageIndex = pageNumber - 1;
   var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
   var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.
                       getThumbnail(pageIndex);
   thumbnailView.setImage(pageView);
 
+  if (PDFJS.pdfBug && Stats.enabled && pageView.stats) {
+    Stats.add(pageNumber, pageView.stats);
+  }
+
 //#if (FIREFOX || MOZCENTRAL)
 //if (pageView.textLayer && pageView.textLayer.textDivs &&
 //    pageView.textLayer.textDivs.length > 0 &&
@@ -1768,7 +1773,7 @@ document.addEventListener('pagerendered', function (e) {
 
   // If the page is still visible when it has finished rendering,
   // ensure that the page number input loading indicator is hidden.
-  if ((pageIndex + 1) === PDFViewerApplication.page) {
+  if (pageNumber === PDFViewerApplication.page) {
     var pageNumberInput = document.getElementById('pageNumber');
     pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
   }
@@ -1965,6 +1970,14 @@ window.addEventListener('pagechange', function pagechange(evt) {
   document.getElementById('firstPage').disabled = (page <= 1);
   document.getElementById('lastPage').disabled = (page >= numPages);
 
+  // we need to update stats
+  if (PDFJS.pdfBug && Stats.enabled) {
+    var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
+    if (pageView.stats) {
+      Stats.add(page, pageView.stats);
+    }
+  }
+
   // checking if the this.page was called from the updateViewarea function
   if (evt.updateInProgress) {
     return;

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