Move the hasEqualPageSizes getter from PDFViewerApplication and into PDFViewer instead

Since the method needs to access properties that are directly available inside of `PDFViewer`, it seems simpler to just have it live there.
This commit is contained in:
Jonas Jenwald 2017-07-09 12:43:57 +02:00
parent afb1cd7377
commit 49333ddd44
2 changed files with 17 additions and 14 deletions

View File

@ -977,7 +977,7 @@ let PDFViewerApplication = {
!initialParams.hash) {
return;
}
if (this.hasEqualPageSizes) {
if (pdfViewer.hasEqualPageSizes) {
return;
}
this.initialDestination = initialParams.destination;
@ -1217,19 +1217,6 @@ let PDFViewerApplication = {
}
},
// Whether all pages of the PDF have the same width and height.
get hasEqualPageSizes() {
let firstPage = this.pdfViewer.getPageView(0);
for (let i = 1, ii = this.pagesCount; i < ii; ++i) {
let pageView = this.pdfViewer.getPageView(i);
if (pageView.width !== firstPage.width ||
pageView.height !== firstPage.height) {
return false;
}
}
return true;
},
afterPrint: function pdfViewSetupAfterPrint() {
if (this.printService) {
this.printService.destroy();

View File

@ -914,6 +914,22 @@ var PDFViewer = (function pdfViewer() {
this.findController = findController;
},
/**
* @returns {boolean} Whether all pages of the PDF document have identical
* widths and heights.
*/
get hasEqualPageSizes() {
let firstPageView = this._pages[0];
for (let i = 1, ii = this._pages.length; i < ii; ++i) {
let pageView = this._pages[i];
if (pageView.width !== firstPageView.width ||
pageView.height !== firstPageView.height) {
return false;
}
}
return true;
},
/**
* Returns sizes of the pages.
* @returns {Array} Array of objects with width/height/rotation fields.